From 8d1bfe6f3b862f6ee1fb4e464d434160e923078e Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Tue, 25 Nov 2003 19:20:20 +0000 Subject: [PATCH] Reverted some obfuscated RegExes. Nijel, as you where working on that: I removed the bugfixes you threw in for my faulty code because there where some issue left (for me): The lines $re0 = '@(^|(\\\\\\\\)+|[^\\\\])'; // non-escaped wildcards $re1 = '@(^|[^\])(\\\)+'; // escaped wildcards as they currently where made no sense to me, because the single [^\] should be replaced to [^\\\\] as well, doesn't it? To not seriously break more stuff I decided to revert to the previous mechanism here. I will do more serious tests the next days and will actually work with my PMA again and I pay close attention to see if there are any issues left. I also searched through the code to see if the setting of the array points from former while() constructs was in any way used [current(), next(), prev(), key(), end(), each()] but did find none. --- ChangeLog | 11 +++++++++++ db_details_qbe.php | 1 - left.php | 1 - libraries/common.lib.php | 8 ++++---- libraries/db_config.lib.php | 2 +- libraries/display_tbl.lib.php | 5 +---- libraries/grab_globals.lib.php | 1 - libraries/mysql_charsets.lib.php | 4 +--- libraries/select_lang.lib.php | 4 ++-- main.php | 22 +++++++++++----------- pdf_pages.php | 2 -- server_collations.php | 2 -- tbl_change.php | 3 ++- tbl_indexes.php | 3 +-- tbl_move_copy.php | 1 - tbl_relation.php | 1 - tbl_replace.php | 1 - 17 files changed, 34 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 022310e99..b59bef8ad 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,17 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-11-24 Garvin Hicking + * db_details_qbe.php, left.php, main.php, pdf_pages.php, server_collations.php, + tbl_change.php, tbl_indexes.php, tbl_move_copy.php, tbl_relation.php, + tbl_replace.php, libraries/common.lib.php, libraries/db_config.lib.php, + libraries/display_tbl.lib.php, libraries/grab_globals.lib.php, + libraries/mysql_charsets.lib.php, libraries/select_lang.lib.php: + + Reverted some obfuscated regular expressions to their working eregi-versions + to not break stuff. Removed unneccessary reset() calls, replaced some more + while(list()) constructs. + 2003-11-24 Alexander M. Turek * lang/german-*.inc.php: Updates. * lang/english-*.inc.php: Sortation. diff --git a/db_details_qbe.php b/db_details_qbe.php index c2d52e0ff..baee2ca79 100644 --- a/db_details_qbe.php +++ b/db_details_qbe.php @@ -862,7 +862,6 @@ if (isset($Field) && count($Field) > 0) { } else { reset($col_cand); $master = current($col_cand); // Only one single candidate - // } } // end if (exactly one where clause) diff --git a/left.php b/left.php index 703c3e98d..5e72ede31 100644 --- a/left.php +++ b/left.php @@ -484,7 +484,6 @@ if ($num_dbs > 1) { if (!empty($cfg['LeftFrameTableSeparator'])) { $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'',$table)); if (is_array($_table)) { - reset($_table); foreach($_table AS $key => $val) { if ($val == '') { $_table[$key] = '__protected__'; diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 3051f4c89..9f0c61d9b 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -651,11 +651,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} // loic1: fixed bad regexp // TODO: db names may contain characters // that are regexp instructions - $re = '@(^|(\\\\\\\\)+|[^\])'; - $uva_regex = preg_replace($re . '%@', '\\1.*', preg_replace($re . '_@', '\\1.{1}', $uva_matchpattern)); + $re = '(^|(\\\\\\\\)+|[^\])'; + $uva_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $uva_matchpattern)); // Fixed db name matching // 2000-08-28 -- Benjamin Gandon - if (preg_match('@^' . $uva_regex . '$@', $uva_db)) { + if (ereg('^' . $uva_regex . '$', $uva_db)) { $dblist[] = $uva_db; break; } @@ -1104,7 +1104,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} // We don't want more than one asterisk inside our 'only_db'. continue; } - if ($is_show_dbs && preg_match('@(^|[^\\\\])(_|%)@', $dblist[$i])) { + if ($is_show_dbs && ereg('(^|[^\])(_|%)', $dblist[$i])) { $local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\''; $rs = PMA_mysql_query($local_query, $dbh); // "SHOW DATABASES" statement is disabled diff --git a/libraries/db_config.lib.php b/libraries/db_config.lib.php index 2b4935f31..813619e36 100644 --- a/libraries/db_config.lib.php +++ b/libraries/db_config.lib.php @@ -25,7 +25,7 @@ if (!defined('PMA_DB_CONFIG_LIB_INCLUDED')) { */ function obj2xml($v, $indent = '') { $attr = ''; - while (list($key, $val) = each($v)) { + foreach($v AS $key => $val) { if (is_string($key) && ($key == '__attr')) { continue; } diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 9133402ff..20b57868d 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -985,8 +985,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { echo '  ' . "\n"; } - reset($vertical_display['desc']); - while (list($key, $val) = each($vertical_display['desc'])) { + foreach($vertical_display['desc'] AS $key => $val) { echo $val; } @@ -1544,8 +1543,6 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { { global $vertical_display, $repeat_cells; - reset($vertical_display); - // Displays "multi row delete" link at top if required if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) { echo '' . "\n"; diff --git a/libraries/grab_globals.lib.php b/libraries/grab_globals.lib.php index 9ce9984d0..dc40e910d 100644 --- a/libraries/grab_globals.lib.php +++ b/libraries/grab_globals.lib.php @@ -31,7 +31,6 @@ if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) { $target[$key] = $value; } } - reset($array); return TRUE; } diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php index f1fc9b466..eb9a34fe9 100644 --- a/libraries/mysql_charsets.lib.php +++ b/libraries/mysql_charsets.lib.php @@ -36,14 +36,12 @@ if (!defined('PMA_MYSQL_CHARSETS_LIB_INCLUDED')){ } } - reset($mysql_collations); $mysql_collations_count = 0; - while (list($key, $value) = each($mysql_collations)) { + foreach($mysql_collations AS $key => $value) { $mysql_collations_count += count($mysql_collations[$key]); sort($mysql_collations[$key], SORT_STRING); reset($mysql_collations[$key]); } - reset($mysql_collations); @mysql_free_result($res); unset($res); diff --git a/libraries/select_lang.lib.php b/libraries/select_lang.lib.php index 2dda69831..0c706c403 100644 --- a/libraries/select_lang.lib.php +++ b/libraries/select_lang.lib.php @@ -174,8 +174,8 @@ if (!defined('PMA_SELECT_LANG_LIB_INCLUDED')) { foreach($available_languages AS $key => $value) { // $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable, // 2 for the 'HTTP_USER_AGENT' one - if (($envType == 1 && preg_match('@^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$@i', $str)) - || ($envType == 2 && preg_match('@(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))@i', $str))) { + if (($envType == 1 && eregi('^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$', $str)) + || ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))', $str))) { $lang = $key; break; } diff --git a/main.php b/main.php index 6ed1c735a..1c6379a06 100644 --- a/main.php +++ b/main.php @@ -209,13 +209,13 @@ if ($server > 0) { $local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\''; $rs_usr = PMA_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE); if ($rs_usr) { - $re0 = '@(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards - $re1 = '@(^|[^\])(\\\)+'; // escaped wildcards + $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards + $re1 = '(^|[^\])(\\\)+'; // escaped wildcards while ($row = PMA_mysql_fetch_array($rs_usr)) { - if (preg_match($re0 . '(%|_)@', $row['Db']) - || (!PMA_mysql_select_db(preg_replace($re1 . '(%|_)@', '\\1\\3', $row['Db']), $userlink) && @mysql_errno() != 1044)) { - $db_to_create = preg_replace($re0 . '%@', '\\1...', preg_replace($re0 . '_@', '\\1?', $row['Db'])); - $db_to_create = preg_replace($re1 . '(%|_)@', '\\1\\3', $db_to_create); + if (ereg($re0 . '(%|_)', $row['Db']) + || (!PMA_mysql_select_db(ereg_replace($re1 . '(%|_)', '\\1\\3', $row['Db']), $userlink) && @mysql_errno() != 1044)) { + $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $row['Db'])); + $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create); $is_create_priv = TRUE; break; } // end if @@ -235,8 +235,8 @@ if ($server > 0) { $rs_usr = PMA_mysql_query($local_query, $dbh); } if ($rs_usr) { - $re0 = '@(^|(\\\\\\\\)+|[^\\\\])'; // non-escaped wildcards - $re1 = '@(^|[^\])(\\\)+'; // escaped wildcards + $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards + $re1 = '(^|[^\])(\\\)+'; // escaped wildcards while ($row = PMA_mysql_fetch_row($rs_usr)) { $show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') + 4,(strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4)); $show_grants_str = substr($row[0],6,(strpos($row[0],' ON ')-6)); @@ -246,9 +246,9 @@ if ($server > 0) { $db_to_create = ''; break; } // end if - else if (preg_match($re0 . '%|_@', $show_grants_dbname) || !PMA_mysql_select_db($show_grants_dbname, $userlink) && @mysql_errno() != 1044) { - $db_to_create = preg_replace($re0 . '%@', '\\1...', preg_replace($re0 . '_@', '\\1?', $show_grants_dbname)); - $db_to_create = preg_replace($re1 . '(%|_)@', '\\1\\3', $db_to_create); + else if (preg_match($re0 . '%|_', $show_grants_dbname) || !PMA_mysql_select_db($show_grants_dbname, $userlink) && @mysql_errno() != 1044) { + $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname)); + $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create); $is_create_priv = TRUE; break; } // end elseif diff --git a/pdf_pages.php b/pdf_pages.php index 57bb8face..faa9fa9ad 100644 --- a/pdf_pages.php +++ b/pdf_pages.php @@ -295,7 +295,6 @@ $i = 0; while ($temp_sh_page = @PMA_mysql_fetch_array($page_rs)) { $array_sh_page[] = $temp_sh_page; } -reset($array_sh_page); // garvin: Display WYSIWYG-PDF parts? if ($cfg['WYSIWYG-PDF']) { @@ -384,7 +383,6 @@ function resetDrag() { echo '>'; echo "\n" . ' ' . "\n" . '