diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 87d9953ad..5d63ca166 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -81,26 +81,26 @@ function PMA_securePath($path) */ function PMA_getDbList() { - if ( empty( $GLOBALS['dblist'] ) ) { + if (empty($GLOBALS['dblist'])) { PMA_availableDatabases(); } $dblist = $GLOBALS['dblist']; $dbgroups = array(); $parts = array(); - foreach ( $dblist as $key => $db ) { + foreach ($dblist as $key => $db) { // garvin: Get comments from PMA comments table $db_tooltip = ''; - if ( $GLOBALS['cfg']['ShowTooltip'] - && $GLOBALS['cfgRelation']['commwork'] ) { + if ($GLOBALS['cfg']['ShowTooltip'] + && $GLOBALS['cfgRelation']['commwork']) { $_db_tooltip = PMA_getComments($db); - if ( is_array($_db_tooltip) ) { + if (is_array($_db_tooltip)) { $db_tooltip = implode(' ', $_db_tooltip); } } - if ( $GLOBALS['cfg']['LeftFrameDBTree'] + if ($GLOBALS['cfg']['LeftFrameDBTree'] && $GLOBALS['cfg']['LeftFrameDBSeparator'] - && strstr($db, $GLOBALS['cfg']['LeftFrameDBSeparator']) ) + && strstr($db, $GLOBALS['cfg']['LeftFrameDBSeparator'])) { $pos = strrpos($db, $GLOBALS['cfg']['LeftFrameDBSeparator']); $group = substr($db, 0, $pos); @@ -111,7 +111,7 @@ function PMA_getDbList() } $disp_name = $db; - if ( $db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB'] ) { + if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) { $disp_name = $db_tooltip; $disp_name_cut = $db_tooltip; $db_tooltip = $db; @@ -123,8 +123,8 @@ function PMA_getDbList() 'disp_name' => $disp_name, 'comment' => $db_tooltip, 'num_tables' => PMA_getTableCount($db), - ); - } // end foreach ( $dblist as $db ) + ); + } // end foreach ($dblist as $db) return $dbgroups; } @@ -143,8 +143,8 @@ function PMA_getHtmlSelectDb($selected = '') .' onchange="window.parent.openDb(this.value);">' . "\n" .'' ."\n"; - foreach ( $dblist as $group => $dbs ) { - if ( count($dbs) > 1 ) { + foreach ($dblist as $group => $dbs) { + if (count($dbs) > 1) { $return .= '' . "\n"; // wether display db_name cuted by the group part @@ -153,16 +153,16 @@ function PMA_getHtmlSelectDb($selected = '') // .. or full $cut = false; } - foreach ( $dbs as $db ) { + foreach ($dbs as $db) { $return .= '' . "\n"; } } @@ -182,7 +182,7 @@ function PMA_getTableCount($db) $tables = PMA_DBI_try_query( 'SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE); - if ( $tables ) { + if ($tables) { $num_tables = PMA_DBI_num_rows($tables); PMA_DBI_free_result($tables); } else { @@ -232,7 +232,7 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink, // Access to "mysql" db allowed and dblist still empty -> gets the // usable db list - if ( ! $dblist_cnt && ($rs && @PMA_DBI_num_rows($rs)) ) { + if (!$dblist_cnt && ($rs && @PMA_DBI_num_rows($rs))) { $row = PMA_DBI_fetch_assoc($rs); PMA_DBI_free_result($rs); // Correction uva 19991215 @@ -313,7 +313,7 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink, $rs = PMA_DBI_try_query($local_query, $controllink); if ($rs && @PMA_DBI_num_rows($rs)) { while ($row = PMA_DBI_fetch_assoc($rs)) { - if ( ! in_array($row['Db'], $dblist) ) { + if (!in_array($row['Db'], $dblist)) { $dblist[] = $row['Db']; } } // end while @@ -333,7 +333,7 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink, */ function get_real_size($size = 0) { - if ( ! $size ) { + if (!$size) { return 0; } $scan['MB'] = 1048576; @@ -345,9 +345,9 @@ function get_real_size($size = 0) $scan['K'] = 1024; $scan['k'] = 1024; - while ( list( $key ) = each($scan) ) { - if ( ( strlen($size) > strlen($key) ) - && ( substr($size, strlen($size) - strlen($key)) == $key ) ) { + while (list($key) = each($scan)) { + if ((strlen($size) > strlen($key)) + && (substr($size, strlen($size) - strlen($key)) == $key)) { $size = substr($size, 0, strlen($size) - strlen($key)) * $scan[$key]; break; } @@ -378,14 +378,14 @@ function PMA_dl($module) { static $dl_allowed = null; - if ( extension_loaded($module) ) { + if (extension_loaded($module)) { return true; } - if ( null === $dl_allowed ) { - if ( ! @ini_get('safe_mode') + if (null === $dl_allowed) { + if (!@ini_get('safe_mode') && @ini_get('enable_dl') - && @function_exists('dl') ) { + && @function_exists('dl')) { ob_start(); phpinfo(INFO_GENERAL); /* Only general info */ $a = strip_tags(ob_get_contents()); @@ -404,11 +404,11 @@ function PMA_dl($module) } } - if ( ! $dl_allowed ) { + if (!$dl_allowed) { return false; } - if ( strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ) { + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $module_file = 'php_' . $module . '.dll'; } else { $module_file = $module . '.so'; @@ -436,7 +436,7 @@ function PMA_dl($module) */ function PMA_array_merge_recursive() { - switch( func_num_args() ) { + switch(func_num_args()) { case 0 : return false; break; @@ -445,11 +445,11 @@ function PMA_array_merge_recursive() break; case 2 : $args = func_get_args(); - if ( ! is_array($args[0]) || ! is_array($args[1]) ) { + if (!is_array($args[0]) || !is_array($args[1])) { return $args[1]; } - foreach ( $args[1] AS $key2 => $value2 ) { - if ( isset( $args[0][$key2] ) ) { + foreach ($args[1] AS $key2 => $value2) { + if (isset($args[0][$key2])) { $args[0][$key2] = PMA_array_merge_recursive($args[0][$key2], $value2); } else { @@ -479,7 +479,7 @@ require_once './libraries/Config.class.php'; -if ( ! defined('PMA_MINIMUM_COMMON') ) { +if (!defined('PMA_MINIMUM_COMMON')) { /** * Displays the maximum size for an upload * @@ -682,7 +682,7 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { default: if (empty($link)) $link = 'index'; $mysql = '5.0'; - if ( defined('PMA_MYSQL_INT_VERSION')) { + if (defined('PMA_MYSQL_INT_VERSION')) { if (PMA_MYSQL_INT_VERSION < 50000) { $mysql = '4.1'; } elseif (PMA_MYSQL_INT_VERSION >= 50100) { @@ -695,7 +695,7 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { break; } - if ( $big_icon ) { + if ($big_icon) { return '' . $GLOBALS['strDocu'] . ''; } elseif ($GLOBALS['cfg']['ReplaceHelpImg']) { return '' . $GLOBALS['strDocu'] . ''; @@ -846,17 +846,17 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { $sql = ' SELECT * FROM ' . PMA_backquote($error_table) . ' - WHERE CONCAT_WS( "-", ' . implode(', ', $error_fields) . ' ) + WHERE CONCAT_WS("-", ' . implode(', ', $error_fields) . ') = "' . PMA_sqlAddslashes($duplicate_value) . '" ORDER BY ' . implode(', ', $error_fields); - unset( $error_table, $error_fields, $duplicate_value ); + unset($error_table, $error_fields, $duplicate_value); echo '
' ."\n" .' ' . "\n" .' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n" .' ' . "\n" .'
' . "\n"; - unset( $sql ); + unset($sql); } // end of show duplicate entry echo ''; @@ -901,7 +901,7 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { } // end function /** - * Send HTTP header, taking IIS limits into account ( 600 seems ok) + * Send HTTP header, taking IIS limits into account (600 seems ok) * * @param string $uri the header to send * @return boolean always true @@ -928,16 +928,16 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { echo '' . "\n"; } else { - if ( SID ) { - if ( strpos($uri, '?') === false ) { + if (SID) { + if (strpos($uri, '?') === false) { header('Location: ' . $uri . '?' . SID); } else { // use seperators defined by php, but prefer ';' // as recommended by W3C $php_arg_separator_input = ini_get('arg_separator.input'); - if ( strpos($php_arg_separator_input, ';') !== false ) { + if (strpos($php_arg_separator_input, ';') !== false) { $separator = ';'; - } elseif ( strlen($php_arg_separator_input) > 0 ) { + } elseif (strlen($php_arg_separator_input) > 0) { $separator = $php_arg_separator_input{0}; } else { $separator = '&'; @@ -969,16 +969,16 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { // 1. A list of allowed databases has already been defined by the // authentification process -> gets the available databases list - if ( count($dblist) ) { - foreach ( $dblist as $key => $db ) { - if ( ! @PMA_DBI_select_db($db) ) { - unset( $dblist[$key] ); + if (count($dblist)) { + foreach ($dblist as $key => $db) { + if (!@PMA_DBI_select_db($db)) { + unset($dblist[$key]); } // end if } // end for } // end if // 2. Allowed database list is empty -> gets the list of all databases // on the server - elseif ( empty( $cfg['Server']['only_db'] ) ) { + elseif (empty($cfg['Server']['only_db'])) { $dblist = PMA_DBI_get_dblist(); // needed? or PMA_mysqlDie('', 'SHOW DATABASES;', false, $error_url); } // end else @@ -986,8 +986,8 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { // natural order for db list; but do not sort if user asked // for a specific order with the 'only_db' mechanism - if ( ! is_array($GLOBALS['cfg']['Server']['only_db']) - && $GLOBALS['cfg']['NaturalOrder'] ) { + if (!is_array($GLOBALS['cfg']['Server']['only_db']) + && $GLOBALS['cfg']['NaturalOrder']) { natsort($dblist); } @@ -1016,11 +1016,11 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { $sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; $tables = PMA_DBI_get_tables_full($db); - if ( count($tables) < 1 ) { + if (count($tables) < 1) { return $tables; } - if ( $GLOBALS['cfg']['NaturalOrder'] ) { + if ($GLOBALS['cfg']['NaturalOrder']) { uksort($tables, 'strnatcasecmp'); } @@ -1029,43 +1029,43 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { 'Rows' => 0, 'Comment' => '', 'disp_name' => '', - ); + ); $table_groups = array(); - foreach ( $tables as $table_name => $table ) { + foreach ($tables as $table_name => $table) { // check for correct row count - if ( null === $table['Rows'] ) { + if (null === $table['Rows']) { $table['Rows'] = PMA_countRecords($db, $table['Name'], $return = true, $force_exact = true); } // in $group we save the reference to the place in $table_groups // where to store the table info - if ( $GLOBALS['cfg']['LeftFrameDBTree'] - && $sep && strstr($table_name, $sep) ) + if ($GLOBALS['cfg']['LeftFrameDBTree'] + && $sep && strstr($table_name, $sep)) { $parts = explode($sep, $table_name); $group =& $table_groups; $i = 0; $group_name_full = ''; - while ( $i < count($parts) - 1 - && $i < $GLOBALS['cfg']['LeftFrameTableLevel'] ) { + while ($i < count($parts) - 1 + && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) { $group_name = $parts[$i] . $sep; $group_name_full .= $group_name; - if ( ! isset( $group[$group_name] ) ) { + if (!isset($group[$group_name])) { $group[$group_name] = array(); $group[$group_name]['is' . $sep . 'group'] = true; $group[$group_name]['tab' . $sep . 'count'] = 1; $group[$group_name]['tab' . $sep . 'group'] = $group_name_full; - } elseif ( ! isset( $group[$group_name]['is' . $sep . 'group'] ) ) { + } elseif (!isset($group[$group_name]['is' . $sep . 'group'])) { $table = $group[$group_name]; $group[$group_name] = array(); $group[$group_name][$group_name] = $table; - unset( $table ); + unset($table); $group[$group_name]['is' . $sep . 'group'] = true; $group[$group_name]['tab' . $sep . 'count'] = 1; $group[$group_name]['tab' . $sep . 'group'] = $group_name_full; @@ -1076,15 +1076,15 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { $i++; } } else { - if ( ! isset( $table_groups[$table_name] ) ) { + if (!isset($table_groups[$table_name])) { $table_groups[$table_name] = array(); } $group =& $table_groups; } - if ( $GLOBALS['cfg']['ShowTooltipAliasTB'] - && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested' ) { + if ($GLOBALS['cfg']['ShowTooltipAliasTB'] + && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested') { // switch tooltip and name $table['Comment'] = $table['Name']; $table['disp_name'] = $table['Comment']; @@ -1125,7 +1125,7 @@ if ( ! defined('PMA_MINIMUM_COMMON') ) { if (is_array($a_name)) { $result = array(); - foreach ( $a_name AS $key => $val ) { + foreach ($a_name AS $key => $val) { $result[$key] = '`' . $val . '`'; } return $result; @@ -1322,7 +1322,7 @@ window.parent.updateTableTitle('', '

@@ -1335,12 +1335,12 @@ window.parent.updateTableTitle('', ''; } - if ( $cfg['ShowSQL'] == true - && ( !empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']) ) ) { + if ($cfg['ShowSQL'] == true + && (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) { $local_query = !empty($GLOBALS['display_query']) ? $GLOBALS['display_query'] : (($cfg['SQP']['fmtType'] == 'none' && isset($GLOBALS['unparsed_sql']) && $GLOBALS['unparsed_sql'] != '') ? $GLOBALS['unparsed_sql'] : $GLOBALS['sql_query']); // Basic url query part $url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : ''); @@ -1413,7 +1413,7 @@ window.parent.updateTableTitle('', '', ' $onclick )) . ']'; + $edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']'; } else { $edit_link = ''; } @@ -1545,7 +1545,7 @@ window.parent.updateTableTitle('', '' . "\n"; - if ( ! empty( $edit_target ) ) { + if (!empty($edit_target)) { echo '
'; echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link; echo '
'; @@ -1578,9 +1578,9 @@ window.parent.updateTableTitle('', '= 1; $d--, $ex-=3 ) { + for ($d = 6, $ex = 15; $d >= 1; $d--, $ex-=3) { if (isset($GLOBALS['byteUnits'][$d]) && $value >= $li * pow(10, $ex)) { - $value = round($value / ( pow(1024, $d) / $dh)) /$dh; + $value = round($value / (pow(1024, $d) / $dh)) /$dh; $unit = $GLOBALS['byteUnits'][$d]; break 1; } // end if @@ -1622,7 +1622,7 @@ window.parent.updateTableTitle('', '', ' 'E', 7 => 'Z', 8 => 'Y' - ); + ); // we need at least 3 digits to be displayed - if ( 3 > $length + $comma ) { + if (3 > $length + $comma) { $length = 3 - $comma; } // check for negativ value to retain sign - if ( $value < 0 ) { + if ($value < 0) { $sign = '-'; $value = abs($value); } else { @@ -1667,23 +1667,23 @@ window.parent.updateTableTitle('', '= 1 ) { - for ( $d = 8; $d >= 0; $d-- ) { + if ($value >= 1) { + for ($d = 8; $d >= 0; $d--) { if (isset($units[$d]) && $value >= $li * pow(1000, $d-1)) { - $value = round($value / ( pow(1000, $d) / $dh)) /$dh; + $value = round($value / (pow(1000, $d) / $dh)) /$dh; $unit = $units[$d]; break 1; } // end if } // end for - } elseif ( ! $only_down && (float) $value !== 0.0 ) { - for ( $d = -8; $d <= 8; $d++ ) { + } elseif (!$only_down && (float) $value !== 0.0) { + for ($d = -8; $d <= 8; $d++) { if (isset($units[$d]) && $value <= $li * pow(1000, $d-1)) { - $value = round($value / ( pow(1000, $d) / $dh)) /$dh; + $value = round($value / (pow(1000, $d) / $dh)) /$dh; $unit = $units[$d]; break 1; } // end if } // end for - } // end if ( $value >= 1 ) elseif ( ! $only_down && (float) $value !== 0.0 ) + } // end if ($value >= 1) elseif (!$only_down && (float) $value !== 0.0) $value = number_format($value, $comma, @@ -1777,33 +1777,33 @@ window.parent.updateTableTitle('', ' '?', 'attr' => '', 'args' => '', - ); + ); $tab = array_merge($defaults, $tab); // determine aditional style-class - if ( empty( $tab['class'] ) ) { - if ( $tab['text'] == $GLOBALS['strEmpty'] - || $tab['text'] == $GLOBALS['strDrop'] ) { + if (empty($tab['class'])) { + if ($tab['text'] == $GLOBALS['strEmpty'] + || $tab['text'] == $GLOBALS['strDrop']) { $tab['class'] = 'caution'; } - elseif ( ! empty( $tab['active'] ) - || ( isset( $GLOBALS['active_page'] ) - && $GLOBALS['active_page'] == $tab['link'] ) - || basename($_SERVER['PHP_SELF']) == $tab['link'] ) + elseif (!empty($tab['active']) + || (isset($GLOBALS['active_page']) + && $GLOBALS['active_page'] == $tab['link']) + || basename($_SERVER['PHP_SELF']) == $tab['link']) { $tab['class'] = 'active'; } } // build the link - if ( ! empty( $tab['link'] ) ) { + if (!empty($tab['link'])) { $tab['link'] = htmlentities($tab['link']); $tab['link'] = $tab['link'] . $tab['sep'] - .( empty( $GLOBALS['url_query'] ) ? - PMA_generate_common_url() : $GLOBALS['url_query'] ); - if ( ! empty( $tab['args'] ) ) { - foreach ( $tab['args'] as $param => $value ) { + .(empty($GLOBALS['url_query']) ? + PMA_generate_common_url() : $GLOBALS['url_query']); + if (!empty($tab['args'])) { + foreach ($tab['args'] as $param => $value) { $tab['link'] .= '&' . urlencode($param) . '=' . urlencode($value); } @@ -1811,20 +1811,20 @@ window.parent.updateTableTitle('', '%2$s'; $tab['text'] = sprintf($image, htmlentities($tab['icon']), $tab['text']); } // check to not display an empty link-text - elseif ( empty( $tab['text'] ) ) { + elseif (empty($tab['text'])) { $tab['text'] = '?'; trigger_error('empty linktext in function ' . __FUNCTION__ . '()', E_USER_NOTICE); } - if ( ! empty( $tab['link'] ) ) { + if (!empty($tab['link'])) { $out = '' . $tab['text'] . ''; @@ -1851,7 +1851,7 @@ window.parent.updateTableTitle('', '' . "\n" .'