diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index 5e467ebd31..80559a7c65 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -55,8 +55,10 @@ class Advisor /** * Stores current error in run results. * - * @param $description string Description of an error. - * @param $exception object Exception raised + * @param string $description description of an error. + * @param object $exception exception raised + * + * @return void */ function storeError($description, $exception) { @@ -83,7 +85,10 @@ class Advisor $precond = $this->ruleExprEvaluate($rule['precondition']); } catch (Exception $e) { $this->storeError( - sprintf(__('Failed evaluating precondition for rule \'%s\''), $rule['name']), + sprintf( + __('Failed evaluating precondition for rule \'%s\''), + $rule['name'] + ), $e ); continue; @@ -97,7 +102,10 @@ class Advisor $value = $this->ruleExprEvaluate($rule['formula']); } catch(Exception $e) { $this->storeError( - sprintf(__('Failed calculating value for rule \'%s\''), $rule['name']), + sprintf( + __('Failed calculating value for rule \'%s\''), + $rule['name'] + ), $e ); continue; @@ -113,7 +121,10 @@ class Advisor } } catch(Exception $e) { $this->storeError( - sprintf(__('Failed running test for rule \'%s\''), $rule['name']), + sprintf( + __('Failed running test for rule \'%s\''), + $rule['name'] + ), $e ); } @@ -138,8 +149,8 @@ class Advisor /** * Wrapper function for translating. * - * @param string $str - * @param mixed $param + * @param string $str the string + * @param mixed $param the parameters * * @return string */ @@ -159,7 +170,7 @@ class Advisor /** * Splits justification to text and formula. * - * @param string $rule + * @param string $rule the rule * * @return array */ @@ -175,8 +186,10 @@ class Advisor /** * Adds a rule to the result list * - * @param $type string type of rule - * @param $rule array rule itslef + * @param string $type type of rule + * @param array $rule rule itslef + * + * @return void */ function addRule($type, $rule) { @@ -190,7 +203,10 @@ class Advisor $str = $this->translate($jst[0], $jst[1]); } catch (Exception $e) { $this->storeError( - sprintf(__('Failed formatting string for rule \'%s\'.'), $rule['name']), + sprintf( + __('Failed formatting string for rule \'%s\'.'), + $rule['name'] + ), $e ); return; @@ -243,8 +259,8 @@ class Advisor * Runs a code expression, replacing variable names with their respective * values * - * @param $expr string expressoin to evaluate - * @param $ignoreUntil int if > 0, it doesn't replace any variables until that string + * @param string $expr expressoin to evaluate + * @param int $ignoreUntil if > 0, it doesn't replace any variables until that string * position, but still evaluates the whole expr * * @return result of evaluated expression @@ -293,7 +309,9 @@ class Advisor $errors = array(); $rules = array(); $lines = array(); - $ruleSyntax = array('name', 'formula', 'test', 'issue', 'recommendation', 'justification'); + $ruleSyntax = array( + 'name', 'formula', 'test', 'issue', 'recommendation', 'justification' + ); $numRules = count($ruleSyntax); $numLines = count($file); $j = -1; diff --git a/libraries/Config.class.php b/libraries/Config.class.php index d4dc004e09..a1f8efeff2 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -219,9 +219,7 @@ class PMA_Config } elseif (preg_match('@rv:1.9(.*)Gecko@', $HTTP_USER_AGENT)) { $this->set('PMA_USR_BROWSER_VER', '1.9'); $this->set('PMA_USR_BROWSER_AGENT', 'GECKO'); - } elseif ( - preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version) - ) { + } elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) { $this->set('PMA_USR_BROWSER_VER', $log_version[1]); $this->set('PMA_USR_BROWSER_AGENT', 'MOZILLA'); } else { @@ -411,10 +409,13 @@ class PMA_Config // check if commit exists in Github $is_remote_commit = false; - if ($commit !== false && isset($_SESSION['PMA_VERSION_REMOTECOMMIT_' . $hash])) { + if ($commit !== false + && isset($_SESSION['PMA_VERSION_REMOTECOMMIT_' . $hash]) + ) { $is_remote_commit = $_SESSION['PMA_VERSION_REMOTECOMMIT_' . $hash]; } else { - $link = 'https://api.github.com/repos/phpmyadmin/phpmyadmin/git/commits/' . $hash; + $link = 'https://api.github.com/repos/phpmyadmin/phpmyadmin/git/commits/' + . $hash; $is_found = $this->checkHTTP($link, !$commit); switch($is_found) { case false: @@ -820,8 +821,9 @@ class PMA_Config * * @return void */ - function setUserValue($cookie_name, $cfg_path, $new_cfg_value, $default_value = null) - { + function setUserValue($cookie_name, $cfg_path, $new_cfg_value, + $default_value = null + ) { // use permanent user preferences if possible $prefs_type = $this->get('user_preferences'); if ($prefs_type) { @@ -1349,11 +1351,15 @@ class PMA_Config // Scheme if (PMA_getenv('HTTP_SCHEME')) { $url['scheme'] = PMA_getenv('HTTP_SCHEME'); - } elseif (PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) == 'on') { + } elseif (PMA_getenv('HTTPS') + && strtolower(PMA_getenv('HTTPS')) == 'on' + ) { $url['scheme'] = 'https'; } elseif (PMA_getenv('HTTP_X_FORWARDED_PROTO')) { $url['scheme'] = strtolower(PMA_getenv('HTTP_X_FORWARDED_PROTO')); - } elseif (PMA_getenv('HTTP_FRONT_END_HTTPS') && strtolower(PMA_getenv('HTTP_FRONT_END_HTTPS')) == 'on') { + } elseif (PMA_getenv('HTTP_FRONT_END_HTTPS') + && strtolower(PMA_getenv('HTTP_FRONT_END_HTTPS')) == 'on' + ) { $url['scheme'] = 'https'; } else { $url['scheme'] = 'http'; @@ -1597,8 +1603,9 @@ class PMA_Config * * @return boolean result of setcookie() */ - function setCookie($cookie, $value, $default = null, $validity = null, $httponly = true) - { + function setCookie($cookie, $value, $default = null, $validity = null, + $httponly = true + ) { if ($validity == null) { $validity = 2592000; } diff --git a/libraries/bookmark.lib.php b/libraries/bookmark.lib.php index bc92a13251..5ae108bb74 100644 --- a/libraries/bookmark.lib.php +++ b/libraries/bookmark.lib.php @@ -60,17 +60,23 @@ function PMA_Bookmark_getList($db) return array(); } - $query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) - . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND user = \'' . PMA_sqlAddSlashes($cfgBookmark['user']) . '\'' - . ' ORDER BY label'; - $per_user = PMA_DBI_fetch_result($query, 'id', 'label', $controllink, PMA_DBI_QUERY_STORE); + $query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) + . '.' . PMA_backquote($cfgBookmark['table']) + . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\'' + . ' AND user = \'' . PMA_sqlAddSlashes($cfgBookmark['user']) . '\'' + . ' ORDER BY label'; + $per_user = PMA_DBI_fetch_result( + $query, 'id', 'label', $controllink, PMA_DBI_QUERY_STORE + ); - $query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) - . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND user = \'\'' - . ' ORDER BY label'; - $global = PMA_DBI_fetch_result($query, 'id', 'label', $controllink, PMA_DBI_QUERY_STORE); + $query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) + . '.' . PMA_backquote($cfgBookmark['table']) + . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\'' + . ' AND user = \'\'' + . ' ORDER BY label'; + $global = PMA_DBI_fetch_result( + $query, 'id', 'label', $controllink, PMA_DBI_QUERY_STORE + ); foreach ($global as $key => $val) { $global[$key] = $val . ' (' . __('shared') . ')'; @@ -90,7 +96,8 @@ function PMA_Bookmark_getList($db) * @param string $db the current database name * @param mixed $id the id of the bookmark to get * @param string $id_field which field to look up the $id - * @param boolean $action_bookmark_all true: get all bookmarks regardless of the owning user + * @param boolean $action_bookmark_all true: get all bookmarks regardless + * of the owning user * @param boolean $exact_user_match whether to ignore bookmarks with no user * * @return string the sql query @@ -100,8 +107,9 @@ function PMA_Bookmark_getList($db) * @global resource the controluser db connection handle * */ -function PMA_Bookmark_get($db, $id, $id_field = 'id', $action_bookmark_all = false, $exact_user_match = false) -{ +function PMA_Bookmark_get($db, $id, $id_field = 'id', $action_bookmark_all = false, + $exact_user_match = false +) { global $controllink; $cfgBookmark = PMA_Bookmark_getParams(); @@ -110,7 +118,8 @@ function PMA_Bookmark_get($db, $id, $id_field = 'id', $action_bookmark_all = fal return ''; } - $query = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) + $query = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) + . '.' . PMA_backquote($cfgBookmark['table']) . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\''; if (!$action_bookmark_all) { @@ -149,8 +158,13 @@ function PMA_Bookmark_save($fields, $all_users = false) return false; } - $query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) - . ' (id, dbase, user, query, label) VALUES (NULL, \'' . PMA_sqlAddSlashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddSlashes($fields['user'])) . '\', \'' . PMA_sqlAddSlashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddSlashes($fields['label']) . '\')'; + $query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) + . '.' . PMA_backquote($cfgBookmark['table']) + . ' (id, dbase, user, query, label)' + . ' VALUES (NULL, \'' . PMA_sqlAddSlashes($fields['dbase']) . '\', ' + . '\'' . ($all_users ? '' : PMA_sqlAddSlashes($fields['user'])) . '\', ' + . '\'' . PMA_sqlAddSlashes(urldecode($fields['query'])) . '\', ' + . '\'' . PMA_sqlAddSlashes($fields['label']) . '\')'; return PMA_DBI_query($query, $controllink); } // end of the 'PMA_Bookmark_save()' function @@ -177,10 +191,11 @@ function PMA_Bookmark_delete($db, $id) return false; } - $query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) - . ' WHERE (user = \'' . PMA_sqlAddSlashes($cfgBookmark['user']) . '\'' - . ' OR user = \'\')' - . ' AND id = ' . $id; + $query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) + . '.' . PMA_backquote($cfgBookmark['table']) + . ' WHERE (user = \'' . PMA_sqlAddSlashes($cfgBookmark['user']) . '\'' + . ' OR user = \'\')' + . ' AND id = ' . $id; return PMA_DBI_try_query($query, $controllink); } // end of the 'PMA_Bookmark_delete()' function diff --git a/libraries/build_html_for_db.lib.php b/libraries/build_html_for_db.lib.php index e4d6d21fc9..12aa55d07f 100644 --- a/libraries/build_html_for_db.lib.php +++ b/libraries/build_html_for_db.lib.php @@ -79,7 +79,9 @@ function PMA_buildHtmlForDb( $out = ''; if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) { $out .= ''; - $out .= ''; @@ -90,10 +92,14 @@ function PMA_buildHtmlForDb( } $out .= '' . ' ' . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . '' @@ -113,7 +119,8 @@ function PMA_buildHtmlForDb( } $out .= ''; if (isset($stat['description_function'])) { - $out .= ''; + $out .= ''; } $out .= $value; if (isset($stat['description_function'])) { @@ -129,12 +136,21 @@ function PMA_buildHtmlForDb( if ($replication_info[$type]['status']) { $out .= ''; - if (strlen(array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB'])) > 0) { + $key = array_search( + $current["SCHEMA_NAME"], + $replication_info[$type]['Ignore_DB'] + ); + if (strlen($key) > 0) { $out .= PMA_getIcon('s_cancel.png', __('Not replicated')); } else { - $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']); + $key = array_search( + $current["SCHEMA_NAME"], $replication_info[$type]['Do_DB'] + ); - if (strlen($key) > 0 || ($replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1)) { + if (strlen($key) > 0 + || ($replication_info[$type]['Do_DB'][0] == "" + && count($replication_info[$type]['Do_DB']) == 1) + ) { // if ($key != null) did not work for index "0" $out .= PMA_getIcon('s_success.png', __('Replicated')); } @@ -147,10 +163,15 @@ function PMA_buildHtmlForDb( if ($is_superuser && !PMA_DRIZZLE) { $out .= '' . '' . ' ' . PMA_getIcon('s_rights.png', __('Check Privileges')) diff --git a/libraries/charset_conversion.lib.php b/libraries/charset_conversion.lib.php index 78637a08c7..eccb320f09 100644 --- a/libraries/charset_conversion.lib.php +++ b/libraries/charset_conversion.lib.php @@ -17,7 +17,10 @@ define('PMA_CHARSET_ICONV_AIX', 3); // Finally detect which function we will use: if ($cfg['RecodingEngine'] == 'iconv') { if (@function_exists('iconv')) { - if ((@stristr(PHP_OS, 'AIX')) && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) { + if ((@stristr(PHP_OS, 'AIX')) + && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) + && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) + ) { $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX; } else { $PMA_recoding_engine = PMA_CHARSET_ICONV; @@ -35,7 +38,10 @@ if ($cfg['RecodingEngine'] == 'iconv') { } } elseif ($cfg['RecodingEngine'] == 'auto') { if (@function_exists('iconv')) { - if ((@stristr(PHP_OS, 'AIX')) && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) { + if ((@stristr(PHP_OS, 'AIX')) + && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) + && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) + ) { $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX; } else { $PMA_recoding_engine = PMA_CHARSET_ICONV; @@ -76,9 +82,13 @@ function PMA_convert_string($src_charset, $dest_charset, $what) case PMA_CHARSET_RECODE: return recode_string($src_charset . '..' . $dest_charset, $what); case PMA_CHARSET_ICONV: - return iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what); + return iconv( + $src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what + ); case PMA_CHARSET_ICONV_AIX: - return PMA_aix_iconv_wrapper($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what); + return PMA_aix_iconv_wrapper( + $src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what + ); default: return $what; } diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php index a9009ec19a..402bb4674a 100644 --- a/libraries/check_user_privileges.lib.php +++ b/libraries/check_user_privileges.lib.php @@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) { /** * */ -$GLOBALS['is_superuser'] = PMA_isSuperuser(); +$GLOBALS['is_superuser'] = PMA_isSuperuser(); /** * sets privilege information extracted from SHOW GRANTS result @@ -113,13 +113,19 @@ function PMA_analyseShowGrant() * Do not handle the underscore wildcard * (this case must be rare anyway) */ - $GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '%/', '\\1...', $show_grants_dbname); - $GLOBALS['db_to_create'] = preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $GLOBALS['db_to_create']); + $GLOBALS['db_to_create'] = preg_replace( + '/' . $re0 . '%/', '\\1...', + $show_grants_dbname + ); + $GLOBALS['db_to_create'] = preg_replace( + '/' . $re1 . '(%|_)/', '\\1\\3', + $GLOBALS['db_to_create'] + ); $GLOBALS['is_create_db_priv'] = true; /** - * @todo collect $GLOBALS['db_to_create'] into an array, to display a - * drop-down in the "Create database" dialog + * @todo collect $GLOBALS['db_to_create'] into an array, + * to display a drop-down in the "Create database" dialog */ // we don't break, we want all possible databases //break; @@ -135,13 +141,18 @@ function PMA_analyseShowGrant() PMA_cacheSet('is_process_priv', $GLOBALS['is_process_priv'], true); PMA_cacheSet('is_reload_priv', $GLOBALS['is_reload_priv'], true); PMA_cacheSet('db_to_create', $GLOBALS['db_to_create'], true); - PMA_cacheSet('dbs_where_create_table_allowed', $GLOBALS['dbs_where_create_table_allowed'], true); + PMA_cacheSet( + 'dbs_where_create_table_allowed', + $GLOBALS['dbs_where_create_table_allowed'], + true + ); } // end function if (!PMA_DRIZZLE) { PMA_analyseShowGrant(); } else { - // todo: for simple_user_policy only database with user's login can be created (unless logged in as root) + // todo: for simple_user_policy only database with user's login can be created + // (unless logged in as root) $GLOBALS['is_create_db_priv'] = $GLOBALS['is_superuser']; $GLOBALS['is_process_priv'] = false; $GLOBALS['is_reload_priv'] = false; diff --git a/libraries/cleanup.lib.php b/libraries/cleanup.lib.php index 6cbc416e85..1fdfe35c50 100644 --- a/libraries/cleanup.lib.php +++ b/libraries/cleanup.lib.php @@ -22,7 +22,9 @@ function PMA_remove_request_vars(&$whitelist) // do not check only $_REQUEST because it could have been overwritten // and use type casting because the variables could have become // strings - $keys = array_keys(array_merge((array)$_REQUEST, (array)$_GET, (array)$_POST, (array)$_COOKIE)); + $keys = array_keys( + array_merge((array)$_REQUEST, (array)$_GET, (array)$_POST, (array)$_COOKIE) + ); foreach ($keys as $key) { if (! in_array($key, $whitelist)) { diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 12d38bc85b..f99e04a544 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -288,7 +288,7 @@ if (version_compare(phpversion(), '5.4', 'lt')) { date_default_timezone_set(@date_default_timezone_get()); /******************************************************************************/ -/* parsing configuration file LABEL_parsing_config_file */ +/* parsing configuration file LABEL_parsing_config_file */ /** * We really need this one! @@ -320,7 +320,8 @@ $GLOBALS['PMA_Config']->enableBc(); */ $pma_cookie_version = 4; if (isset($_COOKIE) - && (isset($_COOKIE['pmaCookieVer']) && $_COOKIE['pmaCookieVer'] < $pma_cookie_version) + && (isset($_COOKIE['pmaCookieVer']) + && $_COOKIE['pmaCookieVer'] < $pma_cookie_version) ) { // delete all cookies foreach ($_COOKIE as $cookie_name => $tmp) { @@ -472,7 +473,9 @@ if (PMA_checkPageValidity($_REQUEST['back'], $goto_whitelist)) { * @todo variables should be handled by their respective owners (objects) * f.e. lang, server, collation_connection in PMA_Config */ -if (! PMA_isValid($_REQUEST['token']) || $_SESSION[' PMA_token '] != $_REQUEST['token']) { +if (! PMA_isValid($_REQUEST['token']) + || $_SESSION[' PMA_token '] != $_REQUEST['token'] +) { /** * List of parameters which are allowed from unsafe source */ @@ -608,10 +611,10 @@ require './libraries/select_lang.lib.php'; * this check is done here after loading language files to present errors in locale */ if ($GLOBALS['PMA_Config']->error_config_file) { - $error = '[strong]' . __('Failed to read configuration file') . '[/strong][br][br]' + $error = '[strong]' . __('Failed to read configuration file') . '[/strong]' + . '[br][br]' . _('This usually means there is a syntax error in it, please check any errors shown below.') - . '[br]' - . '[br]' + . '[br][br]' . '[conferr]'; trigger_error($error, E_USER_ERROR); } @@ -623,7 +626,10 @@ if ($GLOBALS['PMA_Config']->error_config_default_file) { trigger_error($error, E_USER_ERROR); } if ($GLOBALS['PMA_Config']->error_pma_uri) { - trigger_error(__('The [code]$cfg[\'PmaAbsoluteUri\'][/code] directive MUST be set in your configuration file!'), E_USER_ERROR); + trigger_error( + __('The [code]$cfg[\'PmaAbsoluteUri\'][/code] directive MUST be set in your configuration file!'), + E_USER_ERROR + ); } @@ -653,14 +659,23 @@ if (! isset($cfg['Servers']) || count($cfg['Servers']) == 0) { // Detect wrong configuration if (!is_int($server_index) || $server_index < 1) { - trigger_error(sprintf(__('Invalid server index: %s'), $server_index), E_USER_ERROR); + trigger_error( + sprintf(__('Invalid server index: %s'), $server_index), + E_USER_ERROR + ); } $each_server = array_merge($default_server, $each_server); // Don't use servers with no hostname if ($each_server['connect_type'] == 'tcp' && empty($each_server['host'])) { - trigger_error(sprintf(__('Invalid hostname for server %1$s. Please review your configuration.'), $server_index), E_USER_ERROR); + trigger_error( + sprintf( + __('Invalid hostname for server %1$s. Please review your configuration.'), + $server_index + ), + E_USER_ERROR + ); } // Final solution to bug #582890 @@ -668,7 +683,10 @@ if (! isset($cfg['Servers']) || count($cfg['Servers']) == 0) { // and there is nothing in the verbose server name // or the host field, then generate a name for the server // in the form of "Server 2", localized of course! - if ($each_server['connect_type'] == 'socket' && empty($each_server['host']) && empty($each_server['verbose'])) { + if ($each_server['connect_type'] == 'socket' + && empty($each_server['host']) + && empty($each_server['verbose']) + ) { $each_server['verbose'] = __('Server') . $server_index; } @@ -793,7 +811,11 @@ if (! defined('PMA_MINIMUM_COMMON')) { * and '$cfg['ServerDefault'] = 0' is set. */ - if (isset($_REQUEST['server']) && (is_string($_REQUEST['server']) || is_numeric($_REQUEST['server'])) && ! empty($_REQUEST['server']) && ! empty($cfg['Servers'][$_REQUEST['server']])) { + if (isset($_REQUEST['server']) + && (is_string($_REQUEST['server']) || is_numeric($_REQUEST['server'])) + && ! empty($_REQUEST['server']) + && ! empty($cfg['Servers'][$_REQUEST['server']]) + ) { $GLOBALS['server'] = $_REQUEST['server']; $cfg['Server'] = $cfg['Servers'][$GLOBALS['server']]; } else { @@ -840,8 +862,8 @@ if (! defined('PMA_MINIMUM_COMMON')) { include_once './libraries/logging.lib.php'; // get LoginCookieValidity from preferences cache - // no generic solution for loading preferences from cache as some settings need to be kept - // for processing in PMA_Config::loadUserPreferences() + // no generic solution for loading preferences from cache as some settings + // need to be kept for processing in PMA_Config::loadUserPreferences() $cache_key = 'server_' . $GLOBALS['server']; if (isset($_SESSION['cache'][$cache_key]['userprefs']['LoginCookieValidity'])) { $value = $_SESSION['cache'][$cache_key]['userprefs']['LoginCookieValidity']; @@ -857,7 +879,9 @@ if (! defined('PMA_MINIMUM_COMMON')) { // to allow HTTP or http $cfg['Server']['auth_type'] = strtolower($cfg['Server']['auth_type']); if (! file_exists('./libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php')) { - PMA_fatalError(__('Invalid authentication method set in configuration:') . ' ' . $cfg['Server']['auth_type']); + PMA_fatalError( + __('Invalid authentication method set in configuration:') . ' ' . $cfg['Server']['auth_type'] + ); } /** * the required auth type plugin @@ -947,12 +971,15 @@ if (! defined('PMA_MINIMUM_COMMON')) { if (! empty($cfg['Server']['controlhost'])) { $controllink = PMA_DBI_connect( $cfg['Server']['controluser'], - $cfg['Server']['controlpass'], true, + $cfg['Server']['controlpass'], + true, array('host' => $cfg['Server']['controlhost']) ); } else { $controllink = PMA_DBI_connect( - $cfg['Server']['controluser'], $cfg['Server']['controlpass'], true + $cfg['Server']['controluser'], + $cfg['Server']['controlpass'], + true ); } } @@ -975,7 +1002,10 @@ if (! defined('PMA_MINIMUM_COMMON')) { * - > 5.0.15 */ if (PMA_MYSQL_INT_VERSION < 50015) { - PMA_fatalError(__('You should upgrade to %s %s or later.'), array('MySQL', '5.0.15')); + PMA_fatalError( + __('You should upgrade to %s %s or later.'), + array('MySQL', '5.0.15') + ); } /** @@ -1016,7 +1046,9 @@ if (! defined('PMA_MINIMUM_COMMON')) { /** * some resetting has to be done when switching servers */ - if (isset($_SESSION['tmp_user_values']['previous_server']) && $_SESSION['tmp_user_values']['previous_server'] != $GLOBALS['server']) { + if (isset($_SESSION['tmp_user_values']['previous_server']) + && $_SESSION['tmp_user_values']['previous_server'] != $GLOBALS['server'] + ) { unset($_SESSION['tmp_user_values']['navi_limit_offset']); } $_SESSION['tmp_user_values']['previous_server'] = $GLOBALS['server']; diff --git a/libraries/common.lib.php b/libraries/common.lib.php index cbe01ad5e8..ec5d4f4e78 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -226,8 +226,9 @@ function PMA_generateHiddenMaxFileSize($max_size) * * @access public */ -function PMA_sqlAddSlashes($a_string = '', $is_like = false, $crlf = false, $php_code = false) -{ +function PMA_sqlAddSlashes($a_string = '', $is_like = false, $crlf = false, + $php_code = false +) { if ($is_like) { $a_string = str_replace('\\', '\\\\\\\\', $a_string); } else { @@ -416,8 +417,9 @@ function PMA_showDocLink($link, $target = 'documentation') * * @access public */ -function PMA_showMySQLDocu($chapter, $link, $big_icon = false, $anchor = '', $just_open = false) -{ +function PMA_showMySQLDocu($chapter, $link, $big_icon = false, $anchor = '', + $just_open = false +) { global $cfg; if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) { @@ -564,8 +566,11 @@ function PMA_showHint($message, $bbcode = false, $type = 'notice') } // footnotemarker used in js/tooltip.js - return '' . $nr . '' . - PMA_getImage('b_help.png', '', array('class' => 'footnotemarker footnote_' . $nr)); + return '' . $nr . '' + . PMA_getImage( + 'b_help.png', '', + array('class' => 'footnotemarker footnote_' . $nr) + ); } /** @@ -577,6 +582,8 @@ function PMA_showHint($message, $bbcode = false, $type = 'notice') * @param string $back_url the "back" link url (full path is not required) * @param bool $exit EXIT the page? * + * @return void + * * @global string the curent table * @global string the current db * @@ -609,14 +616,18 @@ function PMA_mysqlDie( $formatted_sql = ''; } else { if (strlen($the_query) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { - $formatted_sql = htmlspecialchars(substr($the_query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]'; + $formatted_sql = htmlspecialchars( + substr($the_query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) + ) + . '[...]'; } else { $formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query); } } // --- $error_msg_output .= "\n" . '' . "\n"; - $error_msg_output .= '

' . __('Error') . '

' . "\n"; + $error_msg_output .= '

' . __('Error') + . '

' . "\n"; // if the config password is wrong, or the MySQL server does not // respond, do not show the query that would reveal the // username/password @@ -641,12 +652,15 @@ function PMA_mysqlDie( if (strlen($table)) { $_url_params['db'] = $db; $_url_params['table'] = $table; - $doedit_goto = '
'; + $doedit_goto = ''; } elseif (strlen($db)) { $_url_params['db'] = $db; - $doedit_goto = ''; + $doedit_goto = ''; } else { - $doedit_goto = ''; + $doedit_goto = ''; } $error_msg_output .= $doedit_goto @@ -735,12 +749,15 @@ function PMA_mysqlDie( * * @return array (recursive) grouped table list */ -function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count = false) -{ +function PMA_getTableList($db, $tables = null, $limit_offset = 0, + $limit_count = false +) { $sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; if (null === $tables) { - $tables = PMA_DBI_get_tables_full($db, false, false, null, $limit_offset, $limit_count); + $tables = PMA_DBI_get_tables_full( + $db, false, false, null, $limit_offset, $limit_count + ); if ($GLOBALS['cfg']['NaturalOrder']) { uksort($tables, 'strnatcasecmp'); } @@ -1000,15 +1017,16 @@ if (typeof(window.parent) != 'undefined' * * @access public */ -function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view = false) -{ +function PMA_showMessage($message, $sql_query = null, $type = 'notice', + $is_view = false +) { /* * PMA_ajaxResponse uses this function to collect the string of HTML generated * for showing the message. Use output buffering to collect it and return it * in a string. In some special cases on sql.php, buffering has to be disabled * and hence we check with $GLOBALS['buffer_message'] */ - if ( $GLOBALS['is_ajax_request'] == true && ! isset($GLOBALS['buffer_message']) ) { + if ($GLOBALS['is_ajax_request'] == true && ! isset($GLOBALS['buffer_message'])) { ob_start(); } global $cfg; @@ -1016,7 +1034,9 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view if (null === $sql_query) { if (! empty($GLOBALS['display_query'])) { $sql_query = $GLOBALS['display_query']; - } elseif ($cfg['SQP']['fmtType'] == 'none' && ! empty($GLOBALS['unparsed_sql'])) { + } elseif ($cfg['SQP']['fmtType'] == 'none' + && ! empty($GLOBALS['unparsed_sql']) + ) { $sql_query = $GLOBALS['unparsed_sql']; } elseif (! empty($GLOBALS['sql_query'])) { $sql_query = $GLOBALS['sql_query']; @@ -1050,7 +1070,9 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view if (strlen($GLOBALS['table']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']) ) { - if (PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Index_length') > 1024 && ! PMA_DRIZZLE) { + if (PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Index_length') > 1024 + && ! PMA_DRIZZLE + ) { PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])); } } @@ -1059,7 +1081,9 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view // In an Ajax request, $GLOBALS['cell_align_left'] may not be defined. Hence, // check for it's presence before using it echo '
' . "\n"; if ($message instanceof PMA_Message) { @@ -1088,7 +1112,9 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view $new_line = '\\n"
' . "\n" . '    . "'; $query_base = htmlspecialchars(addslashes($sql_query)); - $query_base = preg_replace('/((\015\012)|(\015)|(\012))/', $new_line, $query_base); + $query_base = preg_replace( + '/((\015\012)|(\015)|(\012))/', $new_line, $query_base + ); } else { $query_base = $sql_query; } @@ -1231,7 +1257,11 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view } $edit_link .= PMA_generate_common_url($url_params) . '#querybox'; - $edit_link = ' [' . PMA_linkOrButton($edit_link, __('Edit'), array('onclick' => $onclick)) . ']'; + $edit_link = ' [' + . PMA_linkOrButton( + $edit_link, __('Edit'), array('onclick' => $onclick) + ) + . ']'; } else { $edit_link = ''; } @@ -1398,6 +1428,8 @@ function PMA_profilingSupported() * * @param string $sql_query sql query * + * @return void + * * @access public */ function PMA_profilingCheckbox($sql_query) @@ -1821,9 +1853,11 @@ function PMA_generate_html_tab($tab, $url_params = array(), $base_dir = '') * * @return string html-code for tab-navigation */ -function PMA_generate_html_tabs($tabs, $url_params, $base_dir = '', $menu_id = 'topmenu') -{ - $tab_navigation = '