123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- <?php
- namespace PhpMyAdmin\Dbi;
- use PhpMyAdmin\Core;
- use PhpMyAdmin\DatabaseInterface;
- if (! defined('PHPMYADMIN')) {
- exit;
- }
- if (! extension_loaded('mysql')) {
-
-
-
- return;
- }
- class DbiMysql implements DbiExtension
- {
-
- private function _realConnect($server, $user, $password, $client_flags,
- $persistent = false
- ) {
- global $cfg;
- if (ini_get('mysql.allow_local_infile')) {
- Core::fatalError(__('Please disable mysql.allow_local_infile in your PHP configuration or install the mysqli extension.'));
- }
- if (empty($client_flags)) {
- if ($cfg['PersistentConnections'] || $persistent) {
- $link = @mysql_pconnect($server, $user, $password);
- } else {
- $link = @mysql_connect($server, $user, $password);
- }
- } else {
- if ($cfg['PersistentConnections'] || $persistent) {
- $link = @mysql_pconnect($server, $user, $password, $client_flags);
- } else {
- $link = @mysql_connect(
- $server, $user, $password, false, $client_flags
- );
- }
- }
- return $link;
- }
-
- public function realMultiQuery($link, $query)
- {
-
-
-
-
- return false;
- }
-
- public function connect(
- $user, $password, array $server
- ) {
- if ($server['port'] === 0) {
- $server_port = '';
- } else {
- $server_port = ':' . $server['port'];
- }
- if (is_null($server['socket'])) {
- $server_socket = '';
- } else {
- $server_socket = ':' . $server['socket'];
- }
- $client_flags = 0;
- if (defined('PMA_ENABLE_LDI')) {
-
-
-
- $client_flags |= 128;
- }
-
- if (defined('MYSQL_CLIENT_COMPRESS') && $server['compress']) {
- $client_flags |= MYSQL_CLIENT_COMPRESS;
- }
-
- if (defined('MYSQL_CLIENT_SSL') && $server['ssl']) {
- $client_flags |= MYSQL_CLIENT_SSL;
- }
- if (!isset($server['host'])) {
- $link = $this->_realConnect($server_socket, $user, $password, null);
- } else {
- $link = $this->_realConnect(
- $server['host'] . $server_port . $server_socket,
- $user, $password, null
- );
- }
- return $link;
- }
-
- public function selectDb($dbname, $link)
- {
- return mysql_select_db($dbname, $link);
- }
-
- public function realQuery($query, $link, $options)
- {
- if ($options == ($options | DatabaseInterface::QUERY_STORE)) {
- return mysql_query($query, $link);
- } elseif ($options == ($options | DatabaseInterface::QUERY_UNBUFFERED)) {
- return mysql_unbuffered_query($query, $link);
- }
- return mysql_query($query, $link);
- }
-
- public function fetchArray($result)
- {
- return mysql_fetch_array($result, MYSQL_BOTH);
- }
-
- public function fetchAssoc($result)
- {
- return mysql_fetch_array($result, MYSQL_ASSOC);
- }
-
- public function fetchRow($result)
- {
- return mysql_fetch_array($result, MYSQL_NUM);
- }
-
- public function dataSeek($result, $offset)
- {
- return mysql_data_seek($result, $offset);
- }
-
- public function freeResult($result)
- {
- if (is_resource($result) && get_resource_type($result) === 'mysql result') {
- mysql_free_result($result);
- }
- }
-
- public function moreResults($link)
- {
-
-
-
-
- return false;
- }
-
- public function nextResult($link)
- {
-
-
-
-
- return false;
- }
-
- public function getHostInfo($link)
- {
- return mysql_get_host_info($link);
- }
-
- public function getProtoInfo($link)
- {
- return mysql_get_proto_info($link);
- }
-
- public function getClientInfo()
- {
- return mysql_get_client_info();
- }
-
- public function getError($link)
- {
- $GLOBALS['errno'] = 0;
- if (null !== $link && false !== $link) {
- $error_number = mysql_errno($link);
- $error_message = mysql_error($link);
- } else {
- $error_number = mysql_errno();
- $error_message = mysql_error();
- }
- if (0 == $error_number) {
- return false;
- }
-
-
- $GLOBALS['errno'] = $error_number;
- return $GLOBALS['dbi']->formatError($error_number, $error_message);
- }
-
- public function numRows($result)
- {
- if (is_bool($result)) {
- return 0;
- }
- return mysql_num_rows($result);
- }
-
- public function affectedRows($link)
- {
- return mysql_affected_rows($link);
- }
-
- public function getFieldsMeta($result)
- {
- $fields = array();
- $num_fields = mysql_num_fields($result);
- for ($i = 0; $i < $num_fields; $i++) {
- $field = mysql_fetch_field($result, $i);
- $field->flags = mysql_field_flags($result, $i);
- $field->orgtable = mysql_field_table($result, $i);
- $field->orgname = mysql_field_name($result, $i);
- $fields[] = $field;
- }
- return $fields;
- }
-
- public function numFields($result)
- {
- return mysql_num_fields($result);
- }
-
- public function fieldLen($result, $i)
- {
- return mysql_field_len($result, $i);
- }
-
- public function fieldName($result, $i)
- {
- return mysql_field_name($result, $i);
- }
-
- public function fieldFlags($result, $i)
- {
- return mysql_field_flags($result, $i);
- }
-
- public function storeResult($result)
- {
- return false;
- }
-
- public function escapeString($link, $str)
- {
- return mysql_real_escape_string($str, $link);
- }
- }
|