diff --git a/ChangeLog b/ChangeLog index 137f1d868..ed922997e 100755 --- a/ChangeLog +++ b/ChangeLog @@ -21,7 +21,8 @@ $Source$ * lang/indonesian: Updated, thanks to Rachim Tamsjadi (tamsy). 2003-11-20 Garvin Hicking - * libraries/auth/*, libraries/dbg/*, libraries/export/* + * libraries/auth/*, libraries/dbg/*, libraries/export/*, libraries/fpdf/*, + libraries/transformations/overview.php, libraries/*.php (work in progress) Lots of PHP < 4.1.0 / MySQL < 3.23.32 compatibility/performance changes: @@ -30,9 +31,14 @@ $Source$ - Removed calls to $HTTP_*_VARS (using $_* now). - Replaced some TAB-characters with whitespace - Removed PHP4 < 4.1.0 compatibility code + - Removed MySQL < 3.23.32 compatibility code - Replaced "for ($i=0; $i <= count(); $i++)" loops to "$cnt = count(); for ($i=0; $i <= $cnt; $i++)" structures for better performance + - Replace calls to eregi*/split functions to their preg* counterparts for + faster and binary-safe operation + - Replace regex-Calls to simple string functions where possible (speedup) + - Replace calls to substr($string, X, 1) to $string{X} 2003-11-19 Marc Delisle * libraries/display_tbl.lib.php: first group of headers was offset by diff --git a/db_create.php b/db_create.php index 26de2f08f..b01c88eb6 100644 --- a/db_create.php +++ b/db_create.php @@ -21,14 +21,6 @@ PMA_checkParameters(array('db')); */ $err_url = 'main.php?' . PMA_generate_common_url(); -/** - * Ensures the db name is valid - */ -if (PMA_MYSQL_INT_VERSION < 32306) { - PMA_checkReservedWords($db, $err_url); -} - - /** * Executes the db creation sql query */ diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index 3e1e97b73..c75aac921 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -125,4 +125,4 @@ h1 {font-family: ; font-size: +?> \ No newline at end of file diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 7fb715fb7..7507f745f 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -610,4 +610,4 @@ if (uname.value == '') { } // end of the 'PMA_auth_fails()' function } // $__PMA_COOKIE_AUTH_LIB__ -?> +?> \ No newline at end of file diff --git a/libraries/auth/http.auth.lib.php b/libraries/auth/http.auth.lib.php index da4bb20be..3f39b0fba 100644 --- a/libraries/auth/http.auth.lib.php +++ b/libraries/auth/http.auth.lib.php @@ -150,16 +150,16 @@ h1 {font-family: ; font-size: ; font-size: +?> \ No newline at end of file diff --git a/libraries/blowfish.php b/libraries/blowfish.php index d7867ba35..e69aa57ee 100644 --- a/libraries/blowfish.php +++ b/libraries/blowfish.php @@ -467,4 +467,4 @@ class Horde_Cipher_blowfish { return array_values(unpack('C*', $key)); } -} +} \ No newline at end of file diff --git a/libraries/bookmark.lib.php b/libraries/bookmark.lib.php index d5a19173c..7fa311ac7 100644 --- a/libraries/bookmark.lib.php +++ b/libraries/bookmark.lib.php @@ -177,4 +177,4 @@ if (!defined('PMA_BOOKMARK_LIB_INCLUDED')) { } // $__PMA_BOOKMARK_LIB__ -?> +?> \ No newline at end of file diff --git a/libraries/charset_conversion.lib.php b/libraries/charset_conversion.lib.php index 5003ce132..3e2e8b393 100644 --- a/libraries/charset_conversion.lib.php +++ b/libraries/charset_conversion.lib.php @@ -155,8 +155,7 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){ } else if (is_array($what)) { $result = array(); - reset($what); - while (list($key, $val) = each($what)) { + foreach($what AS $key => $val) { if (is_string($val) || is_array($val)) { if (is_string($key)) { $result[PMA_convert_display_charset($key)] = PMA_convert_display_charset($val); @@ -321,4 +320,4 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){ } // end of the "PMA_convert_file()" function } // $__PMA_CHARSET_CONVERSION_LIB__ -?> +?> \ No newline at end of file diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 9755973f2..38451d0e4 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -63,7 +63,7 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')) { } /** - * Avoids undefined variables in PHP3 + * Avoids undefined variables */ if (!isset($use_backquotes)) { $use_backquotes = 0; @@ -173,30 +173,12 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} /** * Define $is_upload */ - //$is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get')) - // ? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize'))) - // loic1: php 3.0.15 and lower bug -> always enabled - // : (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize'))); - - // Note: PHP <40300 returns TRUE for function_exists, even - // if the function is disabled; - // PHP < 30016 had problems with get_cfg_var; - // so if we cannot detect that uploads - // are disabled, we assume they are enabled $is_upload = TRUE; - if (PMA_PHP_INT_VERSION >= 40000 - && function_exists('ini_get') - && (strtolower(@ini_get('file_uploads')) == 'off' - || @ini_get('file_uploads') == 0)) { + if (strtolower(@ini_get('file_uploads')) == 'off' + || @ini_get('file_uploads') == 0) { $is_upload = FALSE; } - if (PMA_PHP_INT_VERSION >= 30016 - && PMA_PHP_INT_VERSION < 40000 - && !intval(@get_cfg_var('upload_max_filesize'))) { - $is_upload = FALSE; - } - /** * Charset conversion. @@ -242,8 +224,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} // If zlib output compression is set in the php configuration file, no // output buffering should be run - if (PMA_PHP_INT_VERSION < 40000 - || (PMA_PHP_INT_VERSION >= 40005 && @ini_get('zlib.output_compression'))) { + if (@ini_get('zlib.output_compression')) { $cfg['OBGzip'] = FALSE; } @@ -262,17 +243,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} */ include('./libraries/url_generating.lib.php'); - /** * Loads the mysql extensions if it is not loaded yet */ if (!@function_exists('mysql_connect')) { - if (PMA_PHP_INT_VERSION < 40000) { - $extension = 'MySQL'; - } else { - $extension = 'mysql'; - } - PMA_dl($extension); + PMA_dl('mysql'); } // check whether mysql is available @@ -320,26 +295,6 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} } // end of the 'PMA_sqlAddslashes()' function - if (!function_exists('in_array')) { - /** - * Searches $haystack for $needle and returns TRUE if it is found in - * the array, FALSE otherwise. - * - * @param mixed the 'needle' - * @param array the 'haystack' - * - * @return boolean has $needle been found or not? - */ - function in_array($needle, $haystack) { - while (list(, $value) = each($haystack)) { - if ($value == $haystack) { - return TRUE; - } - } - return FALSE; - } - } - /** * Add slashes before "_" and "%" characters for using them in MySQL * database, table and field names. @@ -527,7 +482,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} } // end if if (!empty($error_message)) { $error_message = htmlspecialchars($error_message); - $error_message = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $error_message); + $error_message = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $error_message); } echo '

' . "\n" . ' ' . $GLOBALS['strMySQLSaid'] . '
' . "\n" @@ -603,28 +558,26 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} if ($only_db_check == FALSE) { // ... first checks whether the "safe_show_database" is on or not // (if MYSQL supports this) - if (PMA_MYSQL_INT_VERSION >= 32330) { - $is_safe_show_dbs = FALSE; - if (PMA_MYSQL_INT_VERSION >= 40002) { - $is_safe_show_dbs = 'ON'; - } - else { - $local_query = 'SHOW VARIABLES LIKE \'safe\\_show\\_database\''; - $rs = PMA_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE); - $is_safe_show_dbs = ($rs) ? @PMA_mysql_result($rs, 0, 'Value') : FALSE; - mysql_free_result($rs); - } + $is_safe_show_dbs = FALSE; + if (PMA_MYSQL_INT_VERSION >= 40002) { + $is_safe_show_dbs = 'ON'; + } + else { + $local_query = 'SHOW VARIABLES LIKE \'safe\\_show\\_database\''; + $rs = PMA_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE); + $is_safe_show_dbs = ($rs) ? @PMA_mysql_result($rs, 0, 'Value') : FALSE; + mysql_free_result($rs); + } - // ... and if on, try to get the available dbs list - if ($is_safe_show_dbs && strtoupper($is_safe_show_dbs) != 'OFF') { - $uva_alldbs = mysql_list_dbs($userlink); - while ($uva_row = PMA_mysql_fetch_array($uva_alldbs)) { - $dblist[] = $uva_row[0]; - } // end while - $dblist_cnt = count($dblist); - unset($uva_alldbs); - } // end if ($is_safe_show_dbs) - } //end if (PMA_MYSQL_INT_VERSION) + // ... and if on, try to get the available dbs list + if ($is_safe_show_dbs && strtoupper($is_safe_show_dbs) != 'OFF') { + $uva_alldbs = mysql_list_dbs($userlink); + while ($uva_row = PMA_mysql_fetch_array($uva_alldbs)) { + $dblist[] = $uva_row[0]; + } // end while + $dblist_cnt = count($dblist); + unset($uva_alldbs); + } // end if ($is_safe_show_dbs) // ... else checks for available databases in the "mysql" db if (!$dblist_cnt) { @@ -694,16 +647,15 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} $dblist[] = $uva_db; $uva_mydbs[$uva_db] = 0; } else if (!isset($dblist[$uva_db])) { - reset($uva_mydbs); - while (list($uva_matchpattern, $uva_value) = each($uva_mydbs)) { + foreach($uva_mydbs AS $uva_matchpattern => $uva_value) { // loic1: fixed bad regexp // TODO: db names may contain characters // that are regexp instructions - $re = '(^|(\\\\\\\\)+|[^\])'; - $uva_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $uva_matchpattern)); + $re = '@(^|(\\\\\\\\)+|[^\])'; + $uva_regex = preg_replace($re . '%@', '\\1.*', preg_replace($re . '_@', '\\1.{1}', $uva_matchpattern)); // Fixed db name matching // 2000-08-28 -- Benjamin Gandon - if (ereg('^' . $uva_regex . '$', $uva_db)) { + if (preg_match('@^' . $uva_regex . '$@', $uva_db)) { $dblist[] = $uva_db; break; } @@ -834,8 +786,6 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} if (empty($cfg['PmaAbsoluteUri'])) { if (!empty($_SERVER)) { $SERVER_ARRAY = '_SERVER'; - } else if (!empty($HTTP_SERVER_VARS)) { - $SERVER_ARRAY = 'HTTP_SERVER_VARS'; } else { $SERVER_ARRAY = 'GLOBALS'; } // end if @@ -906,8 +856,6 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} if (substr($cfg['PmaAbsoluteUri'], 0, 7) != 'http://' && substr($cfg['PmaAbsoluteUri'], 0, 8) != 'https://') { if (!empty($_SERVER)) { $SERVER_ARRAY = '_SERVER'; - } else if (!empty($HTTP_SERVER_VARS)) { - $SERVER_ARRAY = 'HTTP_SERVER_VARS'; } else { $SERVER_ARRAY = 'GLOBALS'; } // end if @@ -932,8 +880,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} /** * Gets the valid servers list and parameters */ - reset($cfg['Servers']); - while (list($key, $val) = each($cfg['Servers'])) { + foreach($cfg['Servers'] AS $key => $val) { // Don't use servers with no hostname if ( ($val['connect_type'] == 'tcp') && empty($val['host'])) { unset($cfg['Servers'][$key]); @@ -980,10 +927,10 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} if (strtolower($cfg['Server']['connect_type']) == 'tcp') { $cfg['Server']['socket'] = ''; } - $server_socket = (empty($cfg['Server']['socket']) || PMA_PHP_INT_VERSION < 30010) + $server_socket = (empty($cfg['Server']['socket'])) ? '' : ':' . $cfg['Server']['socket']; - if (PMA_PHP_INT_VERSION >= 40300 && PMA_MYSQL_CLIENT_API >= 32349) { + if (PMA_MYSQL_CLIENT_API >= 32349) { $client_flags = $cfg['Server']['compress'] && defined('MYSQL_CLIENT_COMPRESS') ? MYSQL_CLIENT_COMPRESS : 0; } @@ -1050,9 +997,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} } } // end if - if (PMA_PHP_INT_VERSION >= 40000) { - $bkp_track_err = @ini_set('track_errors', 1); - } + $bkp_track_err = @ini_set('track_errors', 1); // Try to connect MySQL with the control user profile (will be used to // get the privileges list for the current user but the true user link @@ -1122,9 +1067,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} // Pass #2 of DB-Config to read in user level DB-Config will go here // Robbat2 - May 11, 2002 - if (PMA_PHP_INT_VERSION >= 40000) { - @ini_set('track_errors', $bkp_track_err); - } + @ini_set('track_errors', $bkp_track_err); // If controluser isn't defined, use the current user settings to get // his rights @@ -1150,7 +1093,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} if ($dblist[$i] == '*' && $dblist_asterisk_bool == FALSE) { $dblist_asterisk_bool = TRUE; $dblist_full = PMA_safe_db_list(FALSE, $dbh, FALSE, $rs, $userlink, $cfg, $dblist); - while(list($dbl_key, $dbl_val) = each($dblist_full)) { + foreach($dblist_full AS $dbl_key => $dbl_val) { if (!in_array($dbl_val, $dblist)) { $true_dblist[] = $dbl_val; } @@ -1162,7 +1105,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} continue; } - if ($is_show_dbs && ereg('(^|[^\])(_|%)', $dblist[$i])) { + if ($is_show_dbs && preg_match('@(^|[^\])(_|%)@', $dblist[$i])) { $local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\''; $rs = PMA_mysql_query($local_query, $dbh); // "SHOW DATABASES" statement is disabled @@ -1286,13 +1229,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} function PMA_backquote($a_name, $do_it = TRUE) { if ($do_it - && PMA_MYSQL_INT_VERSION >= 32306 && !empty($a_name) && $a_name != '*') { if (is_array($a_name)) { $result = array(); - reset($a_name); - while(list($key, $val) = each($a_name)) { + foreach($a_name AS $key => $val) { $result[$key] = '`' . $val . '`'; } return $result; @@ -1378,14 +1319,13 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} function PMA_countRecords($db, $table, $ret = FALSE) { global $err_url, $cfg; - if (PMA_MYSQL_INT_VERSION >= 32303) { - $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''; - $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); - $showtable = PMA_mysql_fetch_array($result); - $num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); - if ($num < $cfg['MaxExactCount']) unset($num); - mysql_free_result($result); - } + $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''; + $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); + $showtable = PMA_mysql_fetch_array($result); + $num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); + if ($num < $cfg['MaxExactCount']) unset($num); + mysql_free_result($result); + if (!isset($num)) { $result = PMA_mysql_query('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)) or PMA_mysqlDie('', $local_query, '', $err_url); $num = ($result) ? PMA_mysql_result($result, 0, 'num') : 0; @@ -1431,7 +1371,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} } // Corrects the tooltip text via JS if required - else if (!empty($GLOBALS['table']) && $cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303) { + else if (!empty($GLOBALS['table']) && $cfg['ShowTooltip']) { $result = @PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\''); if ($result) { $tbl_status = PMA_mysql_fetch_array($result, MYSQL_ASSOC); @@ -1460,8 +1400,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} } // end if... else if // Checks if the table needs to be repaired after a TRUNCATE query. - if (PMA_MYSQL_INT_VERSION >= 40000 - && isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) + if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) { if (!isset($tbl_status)) { $result = @PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\''); @@ -1509,7 +1448,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} /* SQL-Parser-Analyzer */ $query_base = PMA_sqlAddslashes(htmlspecialchars($local_query)); /* SQL-Parser-Analyzer */ - $query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base); + $query_base = preg_replace("@((\015\012)|(\015)|(\012))+@", $new_line, $query_base); } else { $query_base = $local_query; } @@ -1572,9 +1511,9 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} . $explain_link_validate . '&sql_query='; - if (eregi('^SELECT[[:space:]]+', $local_query)) { + if (preg_match('@^SELECT[[:space:]]+@i', $local_query)) { $explain_link .= urlencode('EXPLAIN ' . $local_query) . '">' . $GLOBALS['strExplain']; - } else if (eregi('^EXPLAIN[[:space:]]+SELECT[[:space:]]+', $local_query)) { + } else if (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $local_query)) { $explain_link .= urlencode(substr($local_query, 8)) . '">' . $GLOBALS['strNoExplain']; } else { $explain_link = ''; @@ -1732,48 +1671,6 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} return $options; } // end of the 'PMA_getEnumSetOptions' function - - /** - * Ensures a database/table/field's name is not a reserved word (for MySQL - * releases < 3.23.6) - * - * @param string the name to check - * @param string the url to go back in case of error - * - * @return boolean true if the name is valid (no return else) - * - * @access public - * - * @author Dell'Aiera Pol; Olivier Blin - */ - function PMA_checkReservedWords($the_name, $error_url) - { - // The name contains caracters <> a-z, A-Z and "_" -> not a reserved - // word - if (!ereg('^[a-zA-Z_]+$', $the_name)) { - return TRUE; - } - - // Else do the work - $filename = 'badwords.txt'; - if (file_exists($filename)) { - // Builds the reserved words array - $fd = fopen($filename, 'r'); - $contents = fread($fd, filesize($filename) - 1); - fclose ($fd); - $word_list = explode("\n", $contents); - - // Do the checking - $word_cnt = count($word_list); - for ($i = 0; $i < $word_cnt; $i++) { - if (strtolower($the_name) == $word_list[$i]) { - PMA_mysqlDie(sprintf($GLOBALS['strInvalidName'], $the_name), '', FALSE, $error_url); - } // end if - } // end for - } // end if - } // end of the 'PMA_checkReservedWords' function - - /** * Writes localised date * @@ -1795,8 +1692,8 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} $timestamp = time(); } - $date = ereg_replace('%[aA]', $day_of_week[(int)strftime('%w', $timestamp)], $format); - $date = ereg_replace('%[bB]', $month[(int)strftime('%m', $timestamp)-1], $date); + $date = preg_replace('@%[aA]@', $day_of_week[(int)strftime('%w', $timestamp)], $format); + $date = preg_replace('@%[bB]@', $month[(int)strftime('%m', $timestamp)-1], $date); return strftime($date, $timestamp); } // end of the 'PMA_localisedDate()' function @@ -1897,15 +1794,14 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} $link_or_button = '

' . "\n"; - reset ($query_parts); - while (list(, $query_pair) = each($query_parts)) { + foreach($query_parts AS $query_pair) { list($eachvar, $eachval) = explode('=', $query_pair); $link_or_button .= ' ' . "\n"; } // end while if (stristr($message, '' . "\n" . '' . "\n"; + $link_or_button .= ' ' . "\n" . '' . "\n"; } else { $link_or_button .= ' ' . "\n" . '' . "\n"; @@ -1958,7 +1854,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} $charbuff = false; for ($i = 0; $i <= strlen($string); $i++) { - $char = substr($string, $i, 1); + $char = $string{$i}; $append = false; if ($char == '&') { @@ -1971,9 +1867,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} $format_string .= $charbuff; $charbuff = false; $append = true; - } - else - { + } else { $format_string .= $char; $append = true; } @@ -2008,7 +1902,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} $found_error = FALSE; $error_message = ''; - while (list(, $param) = each($params)) { + foreach($params AS $param) { if (!isset($GLOBALS[$param])) { $error_message .= $reported_script_name . ': Missing ' . $param . '
'; $found_error = TRUE; @@ -2025,40 +1919,13 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} // Kanji encoding convert feature appended by Y.Kawada (2002/2/20) - if (PMA_PHP_INT_VERSION >= 40006 - && @function_exists('mb_convert_encoding') + if (@function_exists('mb_convert_encoding') && strpos(' ' . $lang, 'ja-') && file_exists('./libraries/kanji-encoding.lib.php')) { include('./libraries/kanji-encoding.lib.php'); define('PMA_MULTIBYTE_ENCODING', 1); } // end if - // garvin: moved from read_dump.php because this should be used in tbl_replace_fields.php as well. - if (!function_exists('is_uploaded_file')) { - /** - * Emulates the 'is_uploaded_file()' function for old php versions. - * Grabbed at the php manual: - * http://www.php.net/manual/en/features.file-upload.php - * - * @param string the name of the file to check - * - * @return boolean wether the file has been uploaded or not - * - * @access public - */ - function is_uploaded_file($filename) { - if (!$tmp_file = @get_cfg_var('upload_tmp_dir')) { - $tmp_file = tempnam('',''); - $deleted = @unlink($tmp_file); - $tmp_file = dirname($tmp_file); - } - $tmp_file .= '/' . basename($filename); - - // User might have trailing slash in php.ini... - return (ereg_replace('/+', '/', $tmp_file) == $filename); - } // end of the 'is_uploaded_file()' emulated function - } // end if - /** * Function to check valid extension of file. It accepts entered * extensions and bz2 and gz if supported. @@ -2082,4 +1949,4 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} } // end if: minimal common.lib needed? } // $__PMA_COMMON_LIB__ -?> +?> \ No newline at end of file diff --git a/libraries/config_import.lib.php b/libraries/config_import.lib.php index 753bf3c70..94462c6b7 100644 --- a/libraries/config_import.lib.php +++ b/libraries/config_import.lib.php @@ -1272,4 +1272,4 @@ if (!defined('PMA_CONFIG_IMPORT_LIB_INCLUDED')) { } // $__PMA_CONFIG_IMPORT_LIB__ -?> +?> \ No newline at end of file diff --git a/libraries/db_config.lib.php b/libraries/db_config.lib.php index 1af860920..2b4935f31 100644 --- a/libraries/db_config.lib.php +++ b/libraries/db_config.lib.php @@ -32,7 +32,7 @@ if (!defined('PMA_DB_CONFIG_LIB_INCLUDED')) { // Check for __attr if (is_object($val->__attr)) { - while (list($key2, $val2) = each($val->__attr)) { + foreach($val->__attr AS $key2 => $val2) { $attr .= " $key2=\"$val2\""; } } else { diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php index 6331dd752..ce5800d10 100644 --- a/libraries/db_table_exists.lib.php +++ b/libraries/db_table_exists.lib.php @@ -34,4 +34,4 @@ if (!isset($is_table) || !$is_table) { mysql_free_result($is_table); } } // end if (ensures table exists) -?> +?> \ No newline at end of file diff --git a/libraries/dbg/profiling.php b/libraries/dbg/profiling.php index d10c82aa3..ec596fe41 100644 --- a/libraries/dbg/profiling.php +++ b/libraries/dbg/profiling.php @@ -86,4 +86,4 @@ if (!defined('PMA_DBG_PROFILING_INCLUDED')) { } } -?> +?> \ No newline at end of file diff --git a/libraries/dbg/setup.php b/libraries/dbg/setup.php index 04682506b..f0d7aa93d 100644 --- a/libraries/dbg/setup.php +++ b/libraries/dbg/setup.php @@ -21,4 +21,4 @@ if (!defined('PMA_DBG_SETUP_INCLUDED')) { } } -?> +?> \ No newline at end of file diff --git a/libraries/defines.lib.php b/libraries/defines.lib.php index a79766dbc..ced1560a9 100644 --- a/libraries/defines.lib.php +++ b/libraries/defines.lib.php @@ -55,8 +55,6 @@ if (!defined('PMA_USR_OS')) { // php 4.1+ if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; - } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { - $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; } else if (!isset($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ''; } @@ -79,26 +77,26 @@ if (!defined('PMA_USR_OS')) { // 2. browser and version // (must check everything else before Mozilla) - if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) { define('PMA_USR_BROWSER_VER', $log_version[2]); define('PMA_USR_BROWSER_AGENT', 'OPERA'); - } else if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + } else if (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) { define('PMA_USR_BROWSER_VER', $log_version[1]); define('PMA_USR_BROWSER_AGENT', 'IE'); - } else if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + } else if (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) { define('PMA_USR_BROWSER_VER', $log_version[1]); define('PMA_USR_BROWSER_AGENT', 'OMNIWEB'); //} else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { // Konqueror 2.2.2 says Konqueror/2.2.2 // Konqueror 3.0.3 says Konqueror/3 - } else if (ereg('(Konqueror/)(.*)(;)', $HTTP_USER_AGENT, $log_version)) { + } else if (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) { define('PMA_USR_BROWSER_VER', $log_version[2]); define('PMA_USR_BROWSER_AGENT', 'KONQUEROR'); - } else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version) - && ereg('Safari/([0-9]*)', $HTTP_USER_AGENT, $log_version2)) { + } else if (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version) + && preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version2)) { define('PMA_USR_BROWSER_VER', $log_version[1] . '.' . $log_version2[1]); define('PMA_USR_BROWSER_AGENT', 'SAFARI'); - } else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + } else if (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) { define('PMA_USR_BROWSER_VER', $log_version[1]); define('PMA_USR_BROWSER_AGENT', 'MOZILLA'); } else { @@ -106,4 +104,4 @@ if (!defined('PMA_USR_OS')) { define('PMA_USR_BROWSER_AGENT', 'OTHER'); } } // $__PMA_DEFINES_LIB__ -?> +?> \ No newline at end of file diff --git a/libraries/defines_php.lib.php b/libraries/defines_php.lib.php index c2eacb08e..00bf87d14 100644 --- a/libraries/defines_php.lib.php +++ b/libraries/defines_php.lib.php @@ -21,8 +21,8 @@ if (!defined('PMA_VERSION')) { // php version if (!defined('PMA_PHP_INT_VERSION')) { - if (!ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})', phpversion(), $match)) { - $result = ereg('([0-9]{1,2}).([0-9]{1,2})', phpversion(), $match); + if (!preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match)) { + $result = preg_match('@([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match); } if (isset($match) && !empty($match[1])) { if (!isset($match[2])) { @@ -41,21 +41,14 @@ if (!defined('PMA_PHP_INT_VERSION')) { // MySQL client API if (!defined('PMA_MYSQL_CLIENT_API')) { - if (function_exists('mysql_get_client_info')) { - $client_api = mysql_get_client_info(); - } else { - // for compatibility with php <= 4.0.5 - // expect the worst! - $client_api = '3.21.0'; - } - $client_api = explode('.', $client_api); + $client_api = explode('.', mysql_get_client_info()); define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2]))); unset($client_api); } // Whether the os php is running on is windows or not if (!defined('PMA_IS_WINDOWS')) { - if (defined('PHP_OS') && eregi('win', PHP_OS)) { + if (defined('PHP_OS') && stristr(PHP_OS, 'win')) { define('PMA_IS_WINDOWS', 1); } else { define('PMA_IS_WINDOWS', 0); @@ -64,27 +57,20 @@ if (!defined('PMA_IS_WINDOWS')) { function PMA_dl($module) { if (!isset($GLOBALS['PMA_dl_allowed'])) { - if (((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) - || (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode'))) - && @function_exists('dl')) { - - if (PMA_PHP_INT_VERSION < 40000) { - $GLOBALS['PMA_dl_allowed'] = TRUE; - } else { - ob_start(); - phpinfo(INFO_GENERAL); /* Only general info */ - $a = strip_tags(ob_get_contents()); - ob_end_clean(); - /* Get GD version string from phpinfo output */ - if (ereg('Thread Safety[[:space:]]*enabled', $a)) { - if (ereg('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { - $GLOBALS['PMA_dl_allowed'] = TRUE; - } else { - $GLOBALS['PMA_dl_allowed'] = FALSE; - } - } else { + if (!@ini_get('safe_mode') && @ini_get('enable_dl') && @function_exists('dl')) { + ob_start(); + phpinfo(INFO_GENERAL); /* Only general info */ + $a = strip_tags(ob_get_contents()); + ob_end_clean(); + /* Get GD version string from phpinfo output */ + if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) { + if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) { $GLOBALS['PMA_dl_allowed'] = TRUE; + } else { + $GLOBALS['PMA_dl_allowed'] = FALSE; } + } else { + $GLOBALS['PMA_dl_allowed'] = TRUE; } } else { $GLOBALS['PMA_dl_allowed'] = FALSE; @@ -100,7 +86,6 @@ function PMA_dl($module) { } else { return FALSE; } - } // Whether GD2 is present @@ -123,14 +108,14 @@ if (!defined('PMA_IS_GD2')) { } else { define('PMA_IS_GD2', 0); } - } elseif (PMA_PHP_INT_VERSION >= 40000) { + } else { /* We must do hard way... */ ob_start(); phpinfo(INFO_MODULES); /* Only modules */ $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) { + if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) { if (strstr($v, '2.')) { define('PMA_IS_GD2', 1); } else { @@ -139,12 +124,9 @@ if (!defined('PMA_IS_GD2')) { } else { define('PMA_IS_GD2', 0); } - } else { - // This is PHP 3 version, it probably doesn't have GD2 - define('PMA_IS_GD2', 0); } } } } // $__PMA_DEFINES_PHP_LIB__ -?> +?> \ No newline at end of file diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index 1cd970ffa..76a79f897 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -162,25 +162,13 @@ if ($export_type == 'server') {
/>
-= 32306) { - ?> />
-
-= 32321) { -?> />
= 3.23.21 - if (!empty($cfgRelation['relation'])) { ?> /> @@ -477,24 +465,18 @@ if (isset($table) && !empty($table) && !isset($num_tables)) { if ($export_type == 'database') { if (isset($_COOKIE) && !empty($_COOKIE['pma_db_filename_template'])) { echo $_COOKIE['pma_db_filename_template']; - } elseif (isset($HTTP_COOKIE_VARS) && !empty($HTTP_COOKIE_VARS['pma_db_filename_template'])) { - echo $HTTP_COOKIE_VARS['pma_db_filename_template']; } else { echo '__DB__'; } } elseif ($export_type == 'table') { if (isset($_COOKIE) && !empty($_COOKIE['pma_table_filename_template'])) { echo $_COOKIE['pma_table_filename_template']; - } elseif (isset($HTTP_COOKIE_VARS) && !empty($HTTP_COOKIE_VARS['pma_table_filename_template'])) { - echo $HTTP_COOKIE_VARS['pma_table_filename_template']; } else { echo '__TABLE__'; } } else { if (isset($_COOKIE) && !empty($_COOKIE['pma_server_filename_template'])) { echo $_COOKIE['pma_server_filename_template']; - } elseif (isset($HTTP_COOKIE_VARS) && !empty($HTTP_COOKIE_VARS['pma_server_filename_template'])) { - echo $HTTP_COOKIE_VARS['pma_server_filename_template']; } else { echo '__SERVER__'; } @@ -541,31 +523,29 @@ if (isset($table) && !empty($table) && !isset($num_tables)) { = 40004) { - $is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress')); - $is_gzip = (isset($cfg['GZipDump']) && $cfg['GZipDump'] && @function_exists('gzencode')); - $is_bzip = (isset($cfg['BZipDump']) && $cfg['BZipDump'] && @function_exists('bzcompress')); - if ($is_zip || $is_gzip || $is_bzip) { - if ($is_zip) { - ?> - /> - - - /> - - - /> - - + /> + + + /> + + + /> + + 0) { $do_display['edit_lnk'] = 'nn'; // no edit link $do_display['del_lnk'] = 'kp'; // "kill process" type edit link @@ -460,22 +460,22 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { // Defines the url used to append/modify a sorting order // Nijel: This was originally done inside loop below, but I see // no reason to do this for each column. - if (eregi('(.*)([[:space:]]ORDER[[:space:]]*BY[[:space:]](.*))', $sql_query, $regs1)) { - if (eregi('((.*)([[:space:]]ASC|[[:space:]]DESC)([[:space:]]|$))(.*)', $regs1[2], $regs2)) { + if (preg_match('@(.*)([[:space:]]ORDER[[:space:]]*BY[[:space:]](.*))@i', $sql_query, $regs1)) { + if (preg_match('@((.*)([[:space:]]ASC|[[:space:]]DESC)([[:space:]]|$))(.*)@i', $regs1[2], $regs2)) { $unsorted_sql_query = trim($regs1[1] . ' ' . $regs2[5]); $sql_order = trim($regs2[1]); - eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order); + preg_match('@(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)@i',$sql_order,$after_order); $sort_expression = trim($after_order[2]); } - else if (eregi('((.*))[[:space:]]+(LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE)', $regs1[2], $regs3)) { + else if (preg_match('@((.*))[[:space:]]+(LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE)@i', $regs1[2], $regs3)) { $unsorted_sql_query = trim($regs1[1] . ' ' . $regs3[3]); $sql_order = trim($regs3[1]) . ' ASC'; - eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order); + preg_match('@(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)@i',$sql_order,$after_order); $sort_expression = trim($after_order[2]); } else { $unsorted_sql_query = trim($regs1[1]); $sql_order = trim($regs1[2]) . ' ASC'; - eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order); + preg_match('@(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)@i',$sql_order,$after_order); $sort_expression = trim($after_order[2]); } } else { @@ -545,10 +545,10 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { echo $GLOBALS['strSortByKey'] . ':