diff --git a/ChangeLog b/ChangeLog index 9322509cee..82f820fca2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,9 @@ phpMyAdmin - ChangeLog - issue #5555 Better report query errors while generating SQL exports - issue #12307 Produce valid JSON on export - issue #12325 Setup script icons broken +- issue #12378 Support IPv6 proxies +- issue Removed MySQL connection retry without password +- issue #12218 Allow to specify further parameters for control connection 4.6.4 (not yet released) - issue Include X-Robots-Tag header in responses @@ -27,6 +30,11 @@ phpMyAdmin - ChangeLog - issue #12394 Create view should require a view name - issue #12391 Message with 'Change password successfully' displayed, but does not take effect - issue Tighten control on PHP sessions and session cookies +- issue #12409 Re-enable overhead on server databases view +- issue #12414 Fixed rendering of Original theme +- issue #12413 Fixed deleting users in non English locales +- issue #12416 Fixed replication status output in Databases listing +- issue #12303 Avoid typecasting to float when not needed 4.6.3 (2016-06-23) - issue #12249 Fixed cookie path on Windows diff --git a/doc/config.rst b/doc/config.rst index 62d97c9dba..6c069cc190 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -442,6 +442,10 @@ Server connection settings Permits to use an alternate host to hold the configuration storage data. + .. seealso:: + + :config:option:`$cfg['Servers'][$i]['control_*']` + .. _controlport: .. config:option:: $cfg['Servers'][$i]['controlport'] @@ -451,6 +455,10 @@ Server connection settings Permits to use an alternate port to connect to the host that holds the configuration storage. + .. seealso:: + + :config:option:`$cfg['Servers'][$i]['control_*']` + .. _controluser: .. config:option:: $cfg['Servers'][$i]['controluser'] @@ -462,15 +470,11 @@ Server connection settings :type: string :default: ``''`` - This special account is used to access :ref:`linked-tables`. - You don't need it in single user case, but if phpMyAdmin is shared it - is recommended to give access to :ref:`linked-tables` only to this user - and configure phpMyAdmin to use it. All users will then be able to use - the features without need to have direct access to :ref:`linked-tables`. - - (see - - You can use + This special account is used to access :ref:`linked-tables`. + You don't need it in single user case, but if phpMyAdmin is shared it + is recommended to give access to :ref:`linked-tables` only to this user + and configure phpMyAdmin to use it. All users will then be able to use + the features without need to have direct access to :ref:`linked-tables`. .. versionchanged:: 2.2.5 those were called ``stduser`` and ``stdpass`` @@ -480,7 +484,45 @@ Server connection settings :ref:`setup`, :ref:`authentication_modes`, :ref:`linked-tables`, - :config:option:`$cfg['Servers'][$i]['pmadb']` + :config:option:`$cfg['Servers'][$i]['pmadb']`, + :config:option:`$cfg['Servers'][$i]['controlhost']`, + :config:option:`$cfg['Servers'][$i]['controlport']`, + :config:option:`$cfg['Servers'][$i]['control_*']` + +.. config:option:: $cfg['Servers'][$i]['control_*'] + + :type: mixed + + .. versionadded:: 4.7.0 + + You can change any MySQL connection setting for control link (used to + access :ref:`linked-tables`) using configuration prefixed with ``control_``. + + This can be used to change any aspect of the control connection, which by + default uses same parameters as the user one. + + For example you can configure SSL for the control connection: + + .. code-block:: php + + // Enable SSL + $cfg['Servers'][$i]['control_ssl'] = true; + // Client secret key + $cfg['Servers'][$i]['control_ssl_key'] = '../client-key.pem'; + // Client certificate + $cfg['Servers'][$i]['control_ssl_cert'] = '../client-cert.pem'; + // Server certification authority + $cfg['Servers'][$i]['control_ssl_ca'] = '../server-ca.pem'; + + .. seealso:: + + :config:option:`$cfg['Servers'][$i]['ssl']`, + :config:option:`$cfg['Servers'][$i]['ssl_key']`, + :config:option:`$cfg['Servers'][$i]['ssl_cert']`, + :config:option:`$cfg['Servers'][$i]['ssl_ca']`, + :config:option:`$cfg['Servers'][$i]['ssl_ca_path']`, + :config:option:`$cfg['Servers'][$i]['ssl_ciphers']`, + :config:option:`$cfg['Servers'][$i]['ssl_verify']` .. config:option:: $cfg['Servers'][$i]['auth_type'] diff --git a/examples/openid.php b/examples/openid.php index 0db0a466b8..a87c1b19a8 100644 --- a/examples/openid.php +++ b/examples/openid.php @@ -89,7 +89,7 @@ $base .= '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']; $realm = $base . '/'; $returnTo = $base . dirname($_SERVER['PHP_SELF']); -if ($returnTo[mb_strlen($returnTo) - 1] != '/') { +if ($returnTo[strlen($returnTo) - 1] != '/') { $returnTo .= '/'; } $returnTo .= 'openid.php'; diff --git a/libraries/DatabaseInterface.php b/libraries/DatabaseInterface.php index aca8215c65..7e5302976d 100644 --- a/libraries/DatabaseInterface.php +++ b/libraries/DatabaseInterface.php @@ -38,6 +38,21 @@ class DatabaseInterface */ const GETVAR_GLOBAL = 2; + /** + * User connection. + */ + const CONNECT_USER = 0x100; + /** + * Control user connection. + */ + const CONNECT_CONTROL = 0x101; + /** + * Auxiliary connection. + * + * Used for example for replication setup. + */ + const CONNECT_AUXILIARY = 0x102; + /** * @var DBIExtension */ @@ -787,7 +802,8 @@ class DatabaseInterface SUM(t.INDEX_LENGTH) AS SCHEMA_INDEX_LENGTH, SUM(t.DATA_LENGTH + t.INDEX_LENGTH) AS SCHEMA_LENGTH, - SUM(t.DATA_FREE) AS SCHEMA_DATA_FREE'; + SUM(IF(t.ENGINE <> \'InnoDB\', t.DATA_FREE, 0)) + AS SCHEMA_DATA_FREE'; } $sql .= ' FROM `information_schema`.SCHEMATA s'; @@ -2203,25 +2219,118 @@ class DatabaseInterface || $schema_name == 'sys'; } + /** + * Return connection parameters for the database server + * + * @param integer $mode Connection mode on of CONNECT_USER, CONNECT_CONTROL + * or CONNECT_AUXILIARY. + * @param array $server Server information like host/port/socket/persistent + * + * @return array user, host and server settings array + */ + public function getConnectionParams($mode, $server = null) + { + global $cfg; + + $user = null; + $password = null; + + if ($mode == DatabaseInterface::CONNECT_USER) { + $user = $cfg['Server']['user']; + $password = $cfg['Server']['password']; + $server = $cfg['Server']; + } elseif ($mode == DatabaseInterface::CONNECT_CONTROL) { + $user = $cfg['Server']['controluser']; + $password = $cfg['Server']['controlpass']; + + $server = array(); + + if (! empty($cfg['Server']['controlhost'])) { + $server['host'] = $cfg['Server']['controlhost']; + } else { + $server['host'] = $cfg['Server']['host']; + } + // Share the settings if the host is same + if ($server['host'] == $cfg['Server']['host']) { + $shared = array( + 'port', 'socket', 'connect_type', 'compress', + 'ssl', 'ssl_key', 'ssl_cert', 'ssl_ca', + 'ssl_ca_path', 'ssl_ciphers', 'ssl_verify', + ); + foreach ($shared as $item) { + if (isset($cfg['Server'][$item])) { + $server[$item] = $cfg['Server'][$item]; + } + } + } + // Set configured port + if (! empty($cfg['Server']['controlport'])) { + $server['port'] = $cfg['Server']['controlport']; + } + // Set any configuration with control_ prefix + foreach ($cfg['Server'] as $key => $val) { + if (substr($key, 0, 8) === 'control_') { + $server[substr($key, 8)] = $val; + } + } + } else { + if (is_null($server)) { + return array(null, null, null); + } + if (isset($server['user'])) { + $user = $server['user']; + } + if (isset($server['password'])) { + $password = $server['password']; + } + } + + // Perform sanity checks on some variables + if (empty($server['port'])) { + $server['port'] = 0; + } else { + $server['port'] = intval($server['port']); + } + if (empty($server['socket'])) { + $server['socket'] = null; + } + if (empty($server['host'])) { + $server['host'] = 'localhost'; + } + if (!isset($server['ssl'])) { + $server['ssl'] = false; + } + if (!isset($server['compress'])) { + $server['compress'] = false; + } + + return array($user, $password, $server); + } + /** * connects to the database server * - * @param string $user user name - * @param string $password user password - * @param bool $is_controluser whether this is a control user connection - * @param array $server host/port/socket/persistent - * @param bool $auxiliary_connection (when true, don't go back to login if - * connection fails) + * @param integer $mode Connection mode on of CONNECT_USER, CONNECT_CONTROL + * or CONNECT_AUXILIARY. + * @param array $server Server information like host/port/socket/persistent * * @return mixed false on error or a connection object on success */ - public function connect( - $user, $password, $is_controluser = false, $server = null, - $auxiliary_connection = false - ) { + public function connect($mode, $server = null) + { + list($user, $password, $server) = $this->getConnectionParams($mode, $server); + + if (is_null($user) || is_null($password)) { + trigger_error( + __('Missing connection parameters!'), + E_USER_WARNING + ); + return false; + } + $error_count = $GLOBALS['error_handler']->countErrors(); $result = $this->_extension->connect( - $user, $password, $is_controluser, $server, $auxiliary_connection + $user, $password, $server ); /* Any errors from connection? */ @@ -2236,13 +2345,14 @@ class DatabaseInterface } if ($result) { - if (! $auxiliary_connection && ! $is_controluser) { + /* Run post connect for user connections */ + if ($mode == DatabaseInterface::CONNECT_USER) { $this->postConnect($result); } return $result; } - if ($is_controluser) { + if ($mode == DatabaseInterface::CONNECT_CONTROL) { trigger_error( __( 'Connection for controluser as defined in your ' @@ -2251,11 +2361,9 @@ class DatabaseInterface E_USER_WARNING ); return false; - } - - // Do not go back to main login if connection failed - // (currently used only in unit testing) - if ($auxiliary_connection) { + } else if ($mode == DatabaseInterface::CONNECT_AUXILIARY) { + // Do not go back to main login if connection failed + // (currently used only in unit testing) return false; } @@ -2568,42 +2676,6 @@ class DatabaseInterface return $this->_extension->fieldFlags($result, $i); } - /** - * Gets server connection port - * - * @param array|null $server host/port/socket/persistent - * - * @return int - */ - public function getServerPort($server = null) - { - if (is_null($server)) { - $server = &$GLOBALS['cfg']['Server']; - } - - return intval($server['port']); - } - - /** - * Gets server connection socket - * - * @param array|null $server host/port/socket/persistent - * - * @return null|string - */ - public function getServerSocket($server = null) - { - if (is_null($server)) { - $server = &$GLOBALS['cfg']['Server']; - } - - if (empty($server['socket'])) { - return null; - } else { - return $server['socket']; - } - } - /** * Gets correct link object. * diff --git a/libraries/Util.php b/libraries/Util.php index f52ecfc9d6..aa8cc94a87 100644 --- a/libraries/Util.php +++ b/libraries/Util.php @@ -88,7 +88,7 @@ class Util $pow = gmp_strval(gmp_pow($base, $exp)); break; case 'pow' : - $base = (float) $base; + $base = $base; $exp = (int) $exp; $pow = pow($base, $exp); break; @@ -1453,8 +1453,7 @@ class Util $unit = $byteUnits[0]; for ($d = 6, $ex = 15; $d >= 1; $d--, $ex-=3) { - // cast to float to avoid overflow - $unitSize = (float) $li * self::pow(10, $ex); + $unitSize = $li * self::pow(10, $ex); if (isset($byteUnits[$d]) && $value >= $unitSize) { // use 1024.0 to avoid integer overflow on 64-bit machines $value = round($value / (self::pow(1024, $d) / $dh)) /$dh; diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 17d2b84af5..2ad08641b8 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -753,46 +753,14 @@ if (! defined('PMA_MINIMUM_COMMON')) { // scripts) $controllink = false; if ($cfg['Server']['controluser'] != '') { - if (! empty($cfg['Server']['controlhost']) - || ! empty($cfg['Server']['controlport']) - ) { - $server_details = array(); - if (! empty($cfg['Server']['controlhost'])) { - $server_details['host'] = $cfg['Server']['controlhost']; - } else { - $server_details['host'] = $cfg['Server']['host']; - } - if (! empty($cfg['Server']['controlport'])) { - $server_details['port'] = $cfg['Server']['controlport']; - } elseif ($server_details['host'] == $cfg['Server']['host']) { - // Evaluates to true when controlhost == host - // or controlhost is not defined (hence it defaults to host) - // In such case we can use the value of port. - $server_details['port'] = $cfg['Server']['port']; - } - // otherwise we leave the $server_details['port'] unset, - // allowing it to take default mysql port - - $controllink = $GLOBALS['dbi']->connect( - $cfg['Server']['controluser'], - $cfg['Server']['controlpass'], - true, - $server_details - ); - } else { - $controllink = $GLOBALS['dbi']->connect( - $cfg['Server']['controluser'], - $cfg['Server']['controlpass'], - true - ); - } + $controllink = $GLOBALS['dbi']->connect( + DatabaseInterface::CONNECT_CONTROL + ); } // Connects to the server (validates user's login) /** @var DatabaseInterface $userlink */ - $userlink = $GLOBALS['dbi']->connect( - $cfg['Server']['user'], $cfg['Server']['password'], false - ); + $userlink = $GLOBALS['dbi']->connect(DatabaseInterface::CONNECT_USER); // Set timestamp for the session, if required. if ($cfg['Server']['SessionTimeZone'] != '') { @@ -832,9 +800,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { * and phpMyAdmin issuing queries to configuration storage, which * is not locked by that time. */ - $controllink = $GLOBALS['dbi']->connect( - $cfg['Server']['user'], $cfg['Server']['password'], false - ); + $controllink = $GLOBALS['dbi']->connect(DatabaseInterface::CONNECT_USER); } $auth_plugin->storeUserCredentials(); diff --git a/libraries/controllers/server/ServerDatabasesController.php b/libraries/controllers/server/ServerDatabasesController.php index 5a6f5a65e3..2685a8ad8b 100644 --- a/libraries/controllers/server/ServerDatabasesController.php +++ b/libraries/controllers/server/ServerDatabasesController.php @@ -362,9 +362,11 @@ class ServerDatabasesController extends Controller 'format' => 'byte', 'footer' => 0, ); - // At this point we were preparing the display of Overhead using DATA_FREE - // but its content does not represent the real overhead in the case - // of InnoDB + $column_order['SCHEMA_DATA_FREE'] = array( + 'disp_name' => __('Overhead'), + 'format' => 'byte', + 'footer' => 0, + ); return $column_order; } @@ -493,9 +495,7 @@ class ServerDatabasesController extends Controller ); if (mb_strlen($key) > 0 - || (isset($replication_info[$type]['Do_DB'][0]) - && $replication_info[$type]['Do_DB'][0] == "" - && count($replication_info[$type]['Do_DB']) == 1) + || count($replication_info[$type]['Do_DB']) == 0 ) { // if ($key != null) did not work for index "0" $out = Util::getIcon( diff --git a/libraries/core.lib.php b/libraries/core.lib.php index 1bbff685b5..a6a41d68ac 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -983,18 +983,12 @@ function PMA_getIp() $value = PMA_getenv($GLOBALS['cfg']['TrustedProxies'][$direct_ip]); // Grab first element what is client adddress $value = explode(',', $value)[0]; - // Extract IP address - // the $ checks that the header contains only one IP address, - // ?: makes sure the () don't capture - $matches = array(); - $is_ip = preg_match( - '|^(?:[0-9]{1,3}\.){3,3}[0-9]{1,3}$|', - $value, $matches - ); + // checks that the header contains only one IP address, + $is_ip = filter_var($value, FILTER_VALIDATE_IP); - if ($is_ip && (count($matches) == 1)) { + if ($is_ip !== false) { // True IP behind a proxy - return $matches[0]; + return $value; } // We could not parse header diff --git a/libraries/dbi/DBIDummy.php b/libraries/dbi/DBIDummy.php index e5f0db96f5..1f1a60b6a2 100644 --- a/libraries/dbi/DBIDummy.php +++ b/libraries/dbi/DBIDummy.php @@ -897,19 +897,14 @@ class DBIDummy implements DBIExtension * * @param string $user mysql user name * @param string $password mysql user password - * @param bool $is_controluser whether this is a control user connection * @param array $server host/port/socket/persistent - * @param bool $auxiliary_connection (when true, don't go back to login if - * connection fails) * * @return mixed false on error or a mysqli object on success */ public function connect( $user, $password, - $is_controluser = false, - $server = null, - $auxiliary_connection = false + $server = null ) { return true; } diff --git a/libraries/dbi/DBIExtension.php b/libraries/dbi/DBIExtension.php index eaa93caa64..f871c65b67 100644 --- a/libraries/dbi/DBIExtension.php +++ b/libraries/dbi/DBIExtension.php @@ -20,16 +20,12 @@ interface DBIExtension * * @param string $user user name * @param string $password user password - * @param bool $is_controluser whether this is a control user connection * @param array $server host/port/socket/persistent - * @param bool $auxiliary_connection (when true, don't go back to login if - * connection fails) * * @return mixed false on error or a connection object on success */ public function connect( - $user, $password, $is_controluser = false, $server = null, - $auxiliary_connection = false + $user, $password, $server ); /** diff --git a/libraries/dbi/DBIMysql.php b/libraries/dbi/DBIMysql.php index b5763df63a..ebeb9c5e2b 100644 --- a/libraries/dbi/DBIMysql.php +++ b/libraries/dbi/DBIMysql.php @@ -94,32 +94,23 @@ class DBIMysql implements DBIExtension * * @param string $user mysql user name * @param string $password mysql user password - * @param bool $is_controluser whether this is a control user connection * @param array $server host/port/socket/persistent - * @param bool $auxiliary_connection (when true, don't go back to login if - * connection fails) * * @return mixed false on error or a mysqli object on success */ public function connect( - $user, $password, $is_controluser = false, $server = null, - $auxiliary_connection = false + $user, $password, $server ) { - global $cfg; - - $server_port = $GLOBALS['dbi']->getServerPort($server); - $server_socket = $GLOBALS['dbi']->getServerSocket($server); - - if ($server_port === 0) { + if ($server['port'] === 0) { $server_port = ''; } else { - $server_port = ':' . $server_port; + $server_port = ':' . $server['port']; } - if (is_null($server_socket)) { + if (is_null($server['socket'])) { $server_socket = ''; } else { - $server_socket = ':' . $server_socket; + $server_socket = ':' . $server['socket']; } $client_flags = 0; @@ -132,37 +123,22 @@ class DBIMysql implements DBIExtension } /* Optionally compress connection */ - if (defined('MYSQL_CLIENT_COMPRESS') && $cfg['Server']['compress']) { + if (defined('MYSQL_CLIENT_COMPRESS') && $server['compress']) { $client_flags |= MYSQL_CLIENT_COMPRESS; } /* Optionally enable SSL */ - if (defined('MYSQL_CLIENT_SSL') && $cfg['Server']['ssl']) { + if (defined('MYSQL_CLIENT_SSL') && $server['ssl']) { $client_flags |= MYSQL_CLIENT_SSL; } - if (! $server) { - $link = $this->_realConnect( - $cfg['Server']['host'] . $server_port . $server_socket, - $user, $password, empty($client_flags) ? null : $client_flags - ); - - // Retry with empty password if we're allowed to - if (empty($link) && $cfg['Server']['nopassword'] && ! $is_controluser) { - $link = $this->_realConnect( - $cfg['Server']['host'] . $server_port . $server_socket, - $user, '', empty($client_flags) ? null : $client_flags - ); - } + if (!isset($server['host'])) { + $link = $this->_realConnect($server_socket, $user, $password, null); } else { - 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 - ); - } + $link = $this->_realConnect( + $server['host'] . $server_port . $server_socket, + $user, $password, null + ); } return $link; } diff --git a/libraries/dbi/DBIMysqli.php b/libraries/dbi/DBIMysqli.php index 0b98c85218..8ff31ba228 100644 --- a/libraries/dbi/DBIMysqli.php +++ b/libraries/dbi/DBIMysqli.php @@ -112,22 +112,13 @@ class DBIMysqli implements DBIExtension * * @param string $user mysql user name * @param string $password mysql user password - * @param bool $is_controluser whether this is a control user connection * @param array $server host/port/socket/persistent - * @param bool $auxiliary_connection (when true, don't go back to login if - * connection fails) * * @return mixed false on error or a mysqli object on success */ public function connect( - $user, $password, $is_controluser = false, $server = null, - $auxiliary_connection = false + $user, $password, $server ) { - global $cfg; - - $server_port = $GLOBALS['dbi']->getServerPort($server); - $server_socket = $GLOBALS['dbi']->getServerSocket($server); - if ($server) { $server['host'] = (empty($server['host'])) ? 'localhost' @@ -147,21 +138,21 @@ class DBIMysqli implements DBIExtension $client_flags = 0; /* Optionally compress connection */ - if ($cfg['Server']['compress'] && defined('MYSQLI_CLIENT_COMPRESS')) { + if ($server['compress'] && defined('MYSQLI_CLIENT_COMPRESS')) { $client_flags |= MYSQLI_CLIENT_COMPRESS; } /* Optionally enable SSL */ - if ($cfg['Server']['ssl']) { + if ($server['ssl']) { $client_flags |= MYSQLI_CLIENT_SSL; - if (!empty($cfg['Server']['ssl_key'])) { + if (!empty($server['ssl_key'])) { mysqli_ssl_set( $link, - $cfg['Server']['ssl_key'], - $cfg['Server']['ssl_cert'], - $cfg['Server']['ssl_ca'], - $cfg['Server']['ssl_ca_path'], - $cfg['Server']['ssl_ciphers'] + $server['ssl_key'], + $server['ssl_cert'], + $server['ssl_ca'], + $server['ssl_ca_path'], + $server['ssl_ciphers'] ); } /* @@ -169,55 +160,25 @@ class DBIMysqli implements DBIExtension * @link https://bugs.php.net/bug.php?id=68344 * @link https://github.com/phpmyadmin/phpmyadmin/pull/11838 */ - if (! $cfg['Server']['ssl_verify']) { + if (! $server['ssl_verify']) { mysqli_options( $link, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, - $cfg['Server']['ssl_verify'] + $server['ssl_verify'] ); $client_flags |= MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT; } } - if (! $server) { - $return_value = $this->_realConnect( - $link, - $cfg['Server']['host'], - $user, - $password, - false, - $server_port, - $server_socket, - $client_flags - ); - // Retry with empty password if we're allowed to - if ($return_value == false - && isset($cfg['Server']['nopassword']) - && $cfg['Server']['nopassword'] - && ! $is_controluser - ) { - $return_value = $this->_realConnect( - $link, - $cfg['Server']['host'], - $user, - '', - false, - $server_port, - $server_socket, - $client_flags - ); - } - } else { - $return_value = $this->_realConnect( - $link, - $server['host'], - $user, - $password, - false, - $server_port, - $server_socket - ); - } + $return_value = $this->_realConnect( + $link, + $server['host'], + $user, + $password, + false, + $server['port'], + $server['socket'] + ); if ($return_value === false || is_null($return_value)) { return false; diff --git a/libraries/replication.inc.php b/libraries/replication.inc.php index 9f2179ba14..663388560d 100644 --- a/libraries/replication.inc.php +++ b/libraries/replication.inc.php @@ -293,13 +293,15 @@ function PMA_Replication_connectToMaster( $user, $password, $host = null, $port = null, $socket = null ) { $server = array(); - $server["host"] = $host; + $server['user'] = $user; + $server['password'] = $password; + $server["host"] = PMA_sanitizeMySQLHost($host); $server["port"] = $port; $server["socket"] = $socket; // 5th parameter set to true means that it's an auxiliary connection // and we must not go back to login page if it fails - return PMA_DBI_connect($user, $password, false, PMA_sanitizeMySQLHost($server), true); + return $GLOBALS['dbi']->connect(DatabaseInterface::CONNECT_AUXILIARY, $server); } /** * Fetches position and file of current binary log on master diff --git a/libraries/server_status_monitor.lib.php b/libraries/server_status_monitor.lib.php index f0b6d90df9..ea79aee3b0 100644 --- a/libraries/server_status_monitor.lib.php +++ b/libraries/server_status_monitor.lib.php @@ -675,7 +675,7 @@ function PMA_getJsonForLogDataTypeGeneral($start, $end) $temp = $return['rows'][$insertTablesFirst]['argument']; $return['rows'][$insertTablesFirst]['argument'] .= PMA_getSuspensionPoints( - $temp[mb_strlen($temp) - 1] + $temp[strlen($temp) - 1] ); // Group this value, thus do not add to the result list diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php index 2526024bce..812bd13279 100644 --- a/libraries/transformations.lib.php +++ b/libraries/transformations.lib.php @@ -51,7 +51,7 @@ function PMA_Transformation_getOptions($option_string) $trimmed = trim($option); if (mb_strlen($trimmed) > 1 && $trimmed[0] == "'" - && $trimmed[mb_strlen($trimmed) - 1] == "'" + && $trimmed[strlen($trimmed) - 1] == "'" ) { // '...' $option = mb_substr($trimmed, 1, -1); @@ -62,7 +62,7 @@ function PMA_Transformation_getOptions($option_string) // ..., $trimmed .= ',' . $option; $rtrimmed = rtrim($trimmed); - if ($rtrimmed[mb_strlen($rtrimmed) - 1] == "'") { + if ($rtrimmed[strlen($rtrimmed) - 1] == "'") { // ,...' break; } diff --git a/po/fi.po b/po/fi.po index df01e295ce..29899adcf8 100644 --- a/po/fi.po +++ b/po/fi.po @@ -4,16 +4,16 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.7.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2016-05-23 14:29+0200\n" -"PO-Revision-Date: 2016-05-19 19:28+0000\n" -"Last-Translator: Daniel Linjama \n" -"Language-Team: Finnish \n" +"PO-Revision-Date: 2016-07-29 11:47+0000\n" +"Last-Translator: Juha \n" +"Language-Team: Finnish " +"\n" "Language: fi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 2.7-dev\n" +"X-Generator: Weblate 2.8-dev\n" #: changelog.php:37 license.php:33 #, php-format @@ -3043,7 +3043,7 @@ msgstr "Korealainen" #: libraries/Charsets.php:313 msgid "Burmese" -msgstr "" +msgstr "Burma" #: libraries/Charsets.php:316 msgid "Persian" @@ -3063,7 +3063,7 @@ msgstr "Romanialainen" #: libraries/Charsets.php:328 msgid "Sinhalese" -msgstr "" +msgstr "Sinhali" #: libraries/Charsets.php:331 msgid "Slovak" @@ -3108,10 +3108,9 @@ msgid "multilingual" msgstr "monikielinen" #: libraries/Charsets.php:358 -#, fuzzy #| msgid "Table name" msgid "Vietnamese" -msgstr "Taulun nimi" +msgstr "Vietnam" #: libraries/Charsets.php:390 msgid "Central European" @@ -3159,22 +3158,19 @@ msgid "unknown" msgstr "tuntematon" #: libraries/Charsets.php:460 -#, fuzzy #| msgid "Collation" msgid "binary collation" -msgstr "Aakkosjärjestys" +msgstr "Binaarinen kollaatio" #: libraries/Charsets.php:467 -#, fuzzy #| msgid "case-insensitive" msgid "case-insensitive collation" -msgstr "kirjainkoolla ei väliä" +msgstr "kirjainkoosta riippumaton kollaatio" #: libraries/Charsets.php:469 -#, fuzzy #| msgid "case-sensitive" msgid "case-sensitive collation" -msgstr "tarkka kirjainkoko" +msgstr "täsmällinen kirjainkoko" #: libraries/Config.php:1155 #, php-format @@ -3212,8 +3208,8 @@ msgstr "Fonttikoko" #, php-format msgid "Showing %1$d bookmark (both private and shared)" msgid_plural "Showing %1$d bookmarks (both private and shared)" -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Näytetään %1$d kirjanmerkki (sekä yksityinen että jaettu)" +msgstr[1] "Näytetään %1$d kirjanmerkkiä (sekä yksityiset että jaetut)" #: libraries/Console.php:95 msgid "No bookmarks" @@ -3664,7 +3660,6 @@ msgstr "Linkkiä ei löydy!" #. l10n: This is currently used only in Japanese locales #: libraries/Encoding.php:312 -#, fuzzy #| msgid "None" msgctxt "None encoding conversion" msgid "None" @@ -3673,7 +3668,7 @@ msgstr "Ei mitään" #. l10n: This is currently used only in Japanese locales #: libraries/Encoding.php:323 msgid "Convert to Kana" -msgstr "" +msgstr "Käännä Kana-merkeiksi" #: libraries/ErrorHandler.php:65 msgid "Too many error messages, some are not displayed." @@ -5482,14 +5477,11 @@ msgid "Highlight pointer" msgstr "Korosta osoitin" #: libraries/config/messages.inc.php:47 -#, fuzzy #| msgid "" #| "Enable [a@http://en.wikipedia.org/wiki/Bzip2]bzip2[/a] compression for " #| "import operations." msgid "Enable bzip2 compression for import operations." -msgstr "" -"Käytä tuontitoiminnoissa [a@http://en.wikipedia.org/wiki/Bzip2]bzip2[/a]-" -"pakkausta." +msgstr "Käytä tuontitoiminnoissa bzip2-pakkausta." #: libraries/config/messages.inc.php:50 msgid "Bzip2" @@ -5510,7 +5502,6 @@ msgid "CHAR columns editing" msgstr "CHAR-sarakkeiden muokkaus" #: libraries/config/messages.inc.php:58 -#, fuzzy #| msgid "" #| "Use user-friendly editor for editing SQL queries ([a@http://codemirror." #| "net/]CodeMirror[/a]) with syntax highlighting and line numbers." @@ -5518,8 +5509,8 @@ msgid "" "Use user-friendly editor for editing SQL queries (CodeMirror) with syntax " "highlighting and line numbers." msgstr "" -"Käytä käyttäjäystävällistä editoria SQL-kyselyiden muokkaamiseen ([a@http://" -"codemirror.net/]CodeMirror[/a]) syntaksin korostuksella ja rivinumeroilla." +"Käytä käyttäjäystävällistä editoria SQL-kyselyiden (CodeMirror) " +"muokkaamiseen syntaksin korostuksella ja rivinumeroilla." #: libraries/config/messages.inc.php:62 msgid "Enable CodeMirror" @@ -6274,14 +6265,11 @@ msgid "Disable some of the warnings shown by phpMyAdmin." msgstr "Kytke osa phpMyAdminin näyttämistä varoituksista pois päältä." #: libraries/config/messages.inc.php:353 -#, fuzzy #| msgid "" #| "Enable [a@http://en.wikipedia.org/wiki/Gzip]gzip[/a] compression for " #| "import and export operations." msgid "Enable gzip compression for import and export operations." -msgstr "" -"Käytä tuonti- ja vientitoiminnoissa [a@http://en.wikipedia.org/wiki/" -"Gzip]gzip[/a]-pakkausta." +msgstr "Käytä tuonti- ja vientitoiminnoissa gzip-pakkausta." #: libraries/config/messages.inc.php:356 msgid "GZip" @@ -6733,10 +6721,9 @@ msgid "Show row links anyway" msgstr "Näytä rivilinkit jopa tapauksessa" #: libraries/config/messages.inc.php:552 libraries/config/messages.inc.php:553 -#, fuzzy #| msgid "Disable foreign key checks" msgid "Disable shortcut keys" -msgstr "Älä tarkista viiteavaimia" +msgstr "Poista oikotieavaimet käytöstä" #: libraries/config/messages.inc.php:555 msgid "Use natural order for sorting table and database names." @@ -6970,7 +6957,6 @@ msgid "Authentication type" msgstr "Todennustyyppi" #: libraries/config/messages.inc.php:640 -#, fuzzy #| msgid "" #| "Leave blank for no [a@https://wiki.phpmyadmin.net/pma/bookmark]bookmark[/" #| "a] support, suggested: [kbd]pma__bookmark[/kbd]" @@ -6978,8 +6964,8 @@ msgid "" "Leave blank for no [doc@bookmarks@]bookmark[/doc] support, suggested: " "[kbd]pma__bookmark[/kbd]" msgstr "" -"Jätä tyhjäksi, jos et halua [a@https://wiki.phpmyadmin.net/pma/" -"bookmark]kirjanmerkki[/a]tukea, oletusarvo: [kbd]pma__bookmark[/kbd]" +"Jätä tyhjäksi, jos et halua [doc@bookmarks@]kirjanmerkki[/doc]tukea, " +"oletusarvo: [kbd]pma__bookmark[/kbd]" #: libraries/config/messages.inc.php:643 msgid "Bookmark table" diff --git a/server_privileges.php b/server_privileges.php index c095f42a91..34dd8933b8 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -301,7 +301,7 @@ if ($GLOBALS['is_ajax_request'] && (! isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export') && ((! isset($_REQUEST['initial']) || $_REQUEST['initial'] === null || $_REQUEST['initial'] === '') - || (isset($_REQUEST['delete']) && $_REQUEST['delete'] === 'Go')) + || (isset($_REQUEST['delete']) && $_REQUEST['delete'] === __('Go'))) && ! isset($_REQUEST['showall']) && ! isset($_REQUEST['edit_user_group_dialog']) && ! isset($_REQUEST['db_specific']) diff --git a/test/classes/DatabaseInterfaceTest.php b/test/classes/DatabaseInterfaceTest.php index c7d701fe76..3339ad15ce 100644 --- a/test/classes/DatabaseInterfaceTest.php +++ b/test/classes/DatabaseInterfaceTest.php @@ -6,6 +6,8 @@ * @package PhpMyAdmin-test */ +use PMA\libraries\DatabaseInterface; + require_once 'test/PMATestCase.php'; /** @@ -140,6 +142,170 @@ class DatabaseInterfaceTest extends PMATestCase $GLOBALS['cfg']['DBG']['sql'] = true; $this->assertEquals('utf8_general_ci', $this->_dbi->getServerCollation()); } + + /** + * Test for getConnectionParams + * + * @param array $server_cfg Server configuration + * @param integer $mode Mode to test + * @param array|null $server Server array to test + * @param array $expected Expected result + * + * @return void + * + * @dataProvider connectionParams + */ + public function testGetConnectionParams($server_cfg, $mode, $server, $expected) + { + $GLOBALS['cfg']['Server'] = $server_cfg; + $result = $this->_dbi->getConnectionParams($mode, $server); + $this->assertEquals($expected, $result); + } + + /** + * Data provider for getConnectionParams test + * + * @return array + */ + public function connectionParams() + { + $cfg_basic = array( + 'user' => 'u', + 'password' => 'pass', + 'host' => '', + 'controluser' => 'u2', + 'controlpass' => 'p2', + ); + $cfg_ssl = array( + 'user' => 'u', + 'password' => 'pass', + 'host' => '', + 'ssl' => true, + 'controluser' => 'u2', + 'controlpass' => 'p2', + ); + $cfg_control_ssl = array( + 'user' => 'u', + 'password' => 'pass', + 'host' => '', + 'control_ssl' => true, + 'controluser' => 'u2', + 'controlpass' => 'p2', + ); + return array( + array( + $cfg_basic, + DatabaseInterface::CONNECT_USER, + null, + array( + 'u', + 'pass', + array( + 'user' => 'u', + 'password' => 'pass', + 'host' => 'localhost', + 'socket' => null, + 'port' => 0, + 'ssl' => false, + 'compress' => false, + 'controluser' => 'u2', + 'controlpass' => 'p2', + ) + ), + ), + array( + $cfg_basic, + DatabaseInterface::CONNECT_CONTROL, + null, + array( + 'u2', + 'p2', + array( + 'host' => 'localhost', + 'socket' => null, + 'port' => 0, + 'ssl' => false, + 'compress' => false, + ) + ), + ), + array( + $cfg_ssl, + DatabaseInterface::CONNECT_USER, + null, + array( + 'u', + 'pass', + array( + 'user' => 'u', + 'password' => 'pass', + 'host' => 'localhost', + 'socket' => null, + 'port' => 0, + 'ssl' => true, + 'compress' => false, + 'controluser' => 'u2', + 'controlpass' => 'p2', + ) + ), + ), + array( + $cfg_ssl, + DatabaseInterface::CONNECT_CONTROL, + null, + array( + 'u2', + 'p2', + array( + 'host' => 'localhost', + 'socket' => null, + 'port' => 0, + 'ssl' => true, + 'compress' => false, + ) + ), + ), + array( + $cfg_control_ssl, + DatabaseInterface::CONNECT_USER, + null, + array( + 'u', + 'pass', + array( + 'user' => 'u', + 'password' => 'pass', + 'host' => 'localhost', + 'socket' => null, + 'port' => 0, + 'ssl' => false, + 'compress' => false, + 'controluser' => 'u2', + 'controlpass' => 'p2', + 'control_ssl' => true, + ) + ), + ), + array( + $cfg_control_ssl, + DatabaseInterface::CONNECT_CONTROL, + null, + array( + 'u2', + 'p2', + array( + 'host' => 'localhost', + 'socket' => null, + 'port' => 0, + 'ssl' => true, + 'compress' => false, + ) + ), + ), + ); + } + + } /** diff --git a/test/classes/controllers/ServerDatabasesControllerTest.php b/test/classes/controllers/ServerDatabasesControllerTest.php index e737883466..b5f86a8c46 100644 --- a/test/classes/controllers/ServerDatabasesControllerTest.php +++ b/test/classes/controllers/ServerDatabasesControllerTest.php @@ -307,6 +307,11 @@ class ServerDatabasesControllerTest extends PMATestCase 'disp_name' => __('Total'), 'format' => 'byte', 'footer' => 0 + ), + 'SCHEMA_DATA_FREE' => array( + 'disp_name' => __('Overhead'), + 'format' => 'byte', + 'footer' => 0 ) ), $method->invoke($ctrl) diff --git a/test/classes/dbi/DBIMysqlTest.php b/test/classes/dbi/DBIMysqlTest.php index 2a296e5b70..595b99842a 100644 --- a/test/classes/dbi/DBIMysqlTest.php +++ b/test/classes/dbi/DBIMysqlTest.php @@ -153,18 +153,17 @@ class DBIMysqlTest extends PMATestCase //test for connect $user = 'PMA_user'; $password = 'PMA_password'; - $is_controluser = false; $server = array( 'port' => 8080, 'socket' => 123, 'host' => 'locahost', + 'compress' => false, + 'ssl' => false, ); - $auxiliary_connection = true; //test for connect $ret = $this->object->connect( - $user, $password, $is_controluser, - $server, $auxiliary_connection + $user, $password, $server ); $this->assertEquals( 'mysql_connect', @@ -173,8 +172,7 @@ class DBIMysqlTest extends PMATestCase $GLOBALS['cfg']['PersistentConnections'] = true; $ret = $this->object->connect( - $user, $password, $is_controluser, - $server, $auxiliary_connection + $user, $password, $server ); $this->assertEquals( 'mysql_pconnect', diff --git a/test/classes/dbi/DBIMysqliTest.php b/test/classes/dbi/DBIMysqliTest.php index 45f0152515..b23db1e980 100644 --- a/test/classes/dbi/DBIMysqliTest.php +++ b/test/classes/dbi/DBIMysqliTest.php @@ -102,18 +102,17 @@ class DBIMysqliTest extends PMATestCase $user = 'PMA_user'; $password = 'PMA_password'; - $is_controluser = false; $server = array( 'port' => 8080, 'socket' => 123, 'host' => 'locahost', + 'compress' => false, + 'ssl' => false, ); - $auxiliary_connection = true; //test for connect $ret = $this->object->connect( - $user, $password, $is_controluser, - $server, $auxiliary_connection + $user, $password, $server ); $this->assertEquals( 'mysqli_init', diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php index f5adf00de9..eaf220b7ac 100644 --- a/themes/original/css/common.css.php +++ b/themes/original/css/common.css.php @@ -418,6 +418,7 @@ div.error { margin: 0.3em 0 0 0; border: 2px solid; background-repeat: no-repeat; + clear: both; background-position: 10px 50%; @@ -878,7 +879,7 @@ div#tablestatistics table { #fieldset_add_user_login label { float: ; display: block; - width: 10em; + width: 15em; max-width: 100%; text-align: ; padding-: 0.5em;