diff options
author | Garvin Hicking <me@supergarv.de> | 2003-11-22 23:57:48 +0300 |
---|---|---|
committer | Garvin Hicking <me@supergarv.de> | 2003-11-22 23:57:48 +0300 |
commit | c2b46ac9452b997ff61664e3f15a0f4e1367b1b2 (patch) | |
tree | 26f88dfa49345ad56261a93bf756941f99ddafe7 | |
parent | 096094b74d73ae02aef352b8daafac0706b69078 (diff) |
Final batch of PHP3-Compatibility fixes. Please test. :-)
66 files changed, 567 insertions, 986 deletions
@@ -5,6 +5,9 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-11-22 Garvin Hicking <me@supergarv.de> + * ./*: More PHP3-compatibility removal, see 2003-11-20. + 2003-11-22 Marc Delisle <lem9@users.sourceforge.net> * tbl_properties_operations.php: display "Add constraints" only if there are foreign keys in current table diff --git a/Documentation.html b/Documentation.html index bf42f267fa..e78482888a 100755 --- a/Documentation.html +++ b/Documentation.html @@ -3443,7 +3443,6 @@ To create a new, empty mimetype please see libraries/transformations/template_ge Your initial query which is going to be stored as a bookmark has to yield at least one result row so you can store the bookmark. You may have that to work around using well positioned "/**/" comments.<br /> - <b>Variable expansion with PHP-Versions prior to 4.0.3 may not work as expected due to a necessary extra-space after any [VARIABLE] usage</b> </p> <h4> diff --git a/browse_foreigners.php b/browse_foreigners.php index addd13d80a..b702384c4e 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -109,7 +109,7 @@ if ($the_total > $per_page) { if ($i == $pageNow) { $selected = 'selected="selected"'; } else { - $selected = ""; + $selected = ''; } $gotopage .= ' <option ' . $selected . ' value="' . (($i - 1) * $session_max_rows) . '">' . $i . '</option>' . "\n"; } diff --git a/chk_rel.php b/chk_rel.php index 5e0058beab..206af9d7f4 100644 --- a/chk_rel.php +++ b/chk_rel.php @@ -23,4 +23,4 @@ $cfgRelation = PMA_getRelationsParam(TRUE); */ echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/db_create.php b/db_create.php index b01c88eb6a..a15ca13d97 100644 --- a/db_create.php +++ b/db_create.php @@ -34,4 +34,4 @@ $result = PMA_mysql_query('CREATE DATABASE ' . PMA_backquote($db)) or PMA_m $message = $strDatabase . ' ' . htmlspecialchars($db) . ' ' . $strHasBeenCreated; require('./' . $cfg['DefaultTabDatabase']); -?> +?>
\ No newline at end of file diff --git a/db_datadict.php b/db_datadict.php index 5601a99db4..8e1024df2c 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -61,12 +61,7 @@ if (!$rowset) { } $count = 0; while ($row = mysql_fetch_array($rowset)) { - if (PMA_MYSQL_INT_VERSION >= 32303) { - $myfieldname = 'Tables_in_' . htmlspecialchars($db); - } - else { - $myfieldname = 'Tables in ' . htmlspecialchars($db); - } + $myfieldname = 'Tables_in_' . htmlspecialchars($db); $table = $row[$myfieldname]; if ($cfgRelation['commwork']) { $comments = PMA_getComments($db, $table); @@ -81,19 +76,11 @@ while ($row = mysql_fetch_array($rowset)) { * Gets table informations */ // The 'show table' statement works correct since 3.23.03 - if (PMA_MYSQL_INT_VERSION >= 32303) { - $local_query = 'SHOW TABLE STATUS 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_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); - $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); - } else { - $local_query = 'SELECT COUNT(*) AS count FROM ' . PMA_backquote($table); - $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); - $showtable = array(); - $num_rows = PMA_mysql_result($result, 0, 'count'); - $show_comment = ''; - } // end display comments + $local_query = 'SHOW TABLE STATUS 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_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); + $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); if ($result) { mysql_free_result($result); } @@ -130,10 +117,7 @@ while ($row = mysql_fetch_array($rowset)) { // I don't know what does following column mean.... // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; - if (PMA_MYSQL_INT_VERSION >= 32300) { - // rabus: The 'Comment' field was added in MySQL 3.23.0. - $indexes_info[$row['Key_name']]['Comment'] = $row['Comment']; - } + $indexes_info[$row['Key_name']]['Comment'] = $row['Comment']; $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name']; if (isset($row['Sub_part'])) { @@ -214,8 +198,8 @@ while ($row = mysql_fetch_array($rowset)) { $type = $row['Type']; // reformat mysql query output - staybyte - 9. June 2001 // loic1: set or enum types: slashes single quotes inside options - if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) { - $tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1); + if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { + $tmp[2] = substr(preg_replace('@([^,])\'\'', '\\1\\\'@', ',' . $tmp[2]), 1); $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type_nowrap = ''; @@ -223,13 +207,13 @@ while ($row = mysql_fetch_array($rowset)) { $unsigned = 0; $zerofill = 0; } else { - $binary = eregi('BINARY', $row['Type'], $test); - $unsigned = eregi('UNSIGNED', $row['Type'], $test); - $zerofill = eregi('ZEROFILL', $row['Type'], $test); + $binary = stristr($row['Type'], 'binary'); + $unsigned = stristr($row['Type'], 'unsigned'); + $zerofill = stristr($row['Type'], 'zerofill'); $type_nowrap = ' nowrap="nowrap"'; - $type = eregi_replace('BINARY', '', $type); - $type = eregi_replace('ZEROFILL', '', $type); - $type = eregi_replace('UNSIGNED', '', $type); + $type = preg_replace('@BINARY@i', '', $type); + $type = preg_replace('@ZEROFILL@i', '', $type); + $type = preg_replace('@UNSIGNED@i', '', $type); if (empty($type)) { $type = ' '; } @@ -334,4 +318,4 @@ function printPage() echo '<br /><br /> <input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/db_details.php b/db_details.php index 884f306535..532ae93da9 100644 --- a/db_details.php +++ b/db_details.php @@ -173,7 +173,7 @@ if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) { echo ' <div style="margin-bottom: 5px">' . "\n"; echo ' <select name="id_bookmark">' . "\n"; echo ' <option value=""></option>' . "\n"; - while (list($key, $value) = each($bookmark_list)) { + foreach($bookmark_list AS $key => $value) { echo ' <option value="' . htmlspecialchars($value) . '">' . htmlspecialchars($key) . '</option>' . "\n"; } echo ' </select>' . "<br />\n"; @@ -201,4 +201,4 @@ if (function_exists('PMA_set_enc_form')) { */ echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/db_details_common.php b/db_details_common.php index 824a7528e8..f96e3d6e20 100644 --- a/db_details_common.php +++ b/db_details_common.php @@ -63,4 +63,4 @@ window.parent.frames['nav'].location.replace('./left.php?<?php echo PMA_generate */ $url_query = PMA_generate_common_url($db); -?> +?>
\ No newline at end of file diff --git a/db_details_db_info.php b/db_details_db_info.php index c9403c60ba..39579ac7ff 100644 --- a/db_details_db_info.php +++ b/db_details_db_info.php @@ -18,62 +18,51 @@ PMA_checkParameters(array('db')); */ // staybyte: speedup view on locked tables - 11 June 2001 $tables = array(); -if (PMA_MYSQL_INT_VERSION >= 32303) { - // Special speedup for newer MySQL Versions (in 4.0 format changed) - if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) { - $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db); - $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - // Blending out tables in use - if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) { - while ($tmp = PMA_mysql_fetch_row($db_info_result)) { - // if in use memorize tablename - if (eregi('in_use=[1-9]+', $tmp[1])) { - $sot_cache[$tmp[0]] = TRUE; - } +// Special speedup for newer MySQL Versions (in 4.0 format changed) +if ($cfg['SkipLockedTables'] == TRUE) { + $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db); + $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + // Blending out tables in use + if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) { + while ($tmp = PMA_mysql_fetch_row($db_info_result)) { + // if in use memorize tablename + if (preg_match('@in_use=[1-9]+@i', $tmp[1])) { + $sot_cache[$tmp[0]] = TRUE; } - mysql_free_result($db_info_result); + } + mysql_free_result($db_info_result); - if (isset($sot_cache)) { - $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db); - $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) { - while ($tmp = PMA_mysql_fetch_row($db_info_result)) { - if (!isset($sot_cache[$tmp[0]])) { - $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\''; - $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - $sts_tmp = PMA_mysql_fetch_array($sts_result); - $tables[] = $sts_tmp; - } else { // table in use - $tables[] = array('Name' => $tmp[0]); - } + if (isset($sot_cache)) { + $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db); + $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) { + while ($tmp = PMA_mysql_fetch_row($db_info_result)) { + if (!isset($sot_cache[$tmp[0]])) { + $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\''; + $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + $sts_tmp = PMA_mysql_fetch_array($sts_result); + $tables[] = $sts_tmp; + } else { // table in use + $tables[] = array('Name' => $tmp[0]); } - mysql_free_result($db_info_result); - $sot_ready = TRUE; } + mysql_free_result($db_info_result); + $sot_ready = TRUE; } } } - if (!isset($sot_ready)) { - $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); - $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) { - while ($sts_tmp = PMA_mysql_fetch_array($db_info_result)) { - $tables[] = $sts_tmp; - } - mysql_free_result($db_info_result); +} +if (!isset($sot_ready)) { + $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); + $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) { + while ($sts_tmp = PMA_mysql_fetch_array($db_info_result)) { + $tables[] = $sts_tmp; } + mysql_free_result($db_info_result); } - $num_tables = (isset($tables) ? count($tables) : 0); -} // end if (PMA_MYSQL_INT_VERSION >= 32303) -else { - $db_info_result = PMA_mysql_list_tables($db); - $num_tables = ($db_info_result) ? @mysql_numrows($db_info_result) : 0; - for ($i = 0; $i < $num_tables; $i++) { - $tables[] = PMA_mysql_tablename($db_info_result, $i); - } - mysql_free_result($db_info_result); } - +$num_tables = (isset($tables) ? count($tables) : 0); /** * Displays top menu links @@ -81,4 +70,4 @@ else { echo '<!-- Top menu links -->' . "\n"; require('./db_details_links.php'); -?> +?>
\ No newline at end of file diff --git a/db_details_export.php b/db_details_export.php index 38920d0247..d8afd7eacd 100644 --- a/db_details_export.php +++ b/db_details_export.php @@ -28,7 +28,7 @@ if ($num_tables > 1) { $i = 0; while ($i < $num_tables) { - $table = (PMA_MYSQL_INT_VERSION >= 32303) ? $tables[$i]['Name'] : $tables[$i]; + $table = $tables[$i]['Name']; if (!empty($selectall) || (isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $table . '|'))) { $is_selected = ' selected="selected"'; } else { @@ -63,4 +63,4 @@ require('./libraries/display_export.lib.php'); * Displays the footer */ require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/db_details_importdocsql.php b/db_details_importdocsql.php index 6d8ed2922b..bc54ad1d25 100644 --- a/db_details_importdocsql.php +++ b/db_details_importdocsql.php @@ -46,8 +46,8 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) { function docsql_check($docpath = '', $file = '', $filename = '', $content = 'none') { global $GLOBALS; - if (eregi('^(.*)_field_comment\.(txt|zip|bz2|bzip).*$', $filename)) { - $tab = eregi_replace('^(.*)_field_comment\.(txt|zip|bz2|bzip).*', '\1', $filename); + if (preg_match('@^(.*)_field_comment\.(txt|zip|bz2|bzip).*$@i', $filename)) { + $tab = preg_replace('@^(.*)_field_comment\.(txt|zip|bz2|bzip).*@i', '\1', $filename); //echo '<h1>Working on Table ' . $_tab . '</h1>'; if ($content == 'none') { $lines = array(); @@ -64,8 +64,7 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) { } if (isset($lines) && is_array($lines) && count($lines) > 0) { - @reset($lines); - while(list($lkey, $line) = each($lines)) { + foreach($lines AS $lkey => $line) { //echo '<p>' . $line . '</p>'; $inf = explode('|',$line); if (!empty($inf[1]) && strlen(trim($inf[1])) > 0) { @@ -127,15 +126,9 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) { if (!empty($_SERVER) && isset($_SERVER['DOCUMENT_ROOT'])) { $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; } - else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['DOCUMENT_ROOT'])) { - $DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT']; - } else if (!empty($_ENV) && isset($_ENV['DOCUMENT_ROOT'])) { $DOCUMENT_ROOT = $_ENV['DOCUMENT_ROOT']; } - else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['DOCUMENT_ROOT'])) { - $DOCUMENT_ROOT = $HTTP_ENV_VARS['DOCUMENT_ROOT']; - } else if (@getenv('DOCUMENT_ROOT')) { $DOCUMENT_ROOT = getenv('DOCUMENT_ROOT'); } @@ -163,13 +156,7 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) { if (file_exists($sql_file) && is_uploaded_file($sql_file)) { - $open_basedir = ''; - if (PMA_PHP_INT_VERSION >= 40000) { - $open_basedir = @ini_get('open_basedir'); - } - if (empty($open_basedir)) { - $open_basedir = @get_cfg_var('open_basedir'); - } + $open_basedir = @ini_get('open_basedir'); // If we are on a server with open_basedir, we must move the file // before opening it. The doc explains how to create the "./tmp" @@ -189,11 +176,7 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) { } else { $sql_file_new = $tmp_subdir . basename($sql_file); - if (PMA_PHP_INT_VERSION < 40003) { - copy($sql_file, $sql_file_new); - } else { - move_uploaded_file($sql_file, $sql_file_new); - } + move_uploaded_file($sql_file, $sql_file_new); $docsql_text = PMA_readFile($sql_file_new, $sql_file_compression); unlink($sql_file_new); } @@ -218,7 +201,7 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) { } else { // echo '<h1>Starting Import</h1>'; - $docpath = $cfg['docSQLDir'] . eregi_replace('\.\.*', '.', $docpath); + $docpath = $cfg['docSQLDir'] . preg_replace('@\.\.*@', '.', $docpath); if (substr($docpath, -1) != '/') { $docpath .= '/'; } @@ -318,4 +301,4 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) { echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/db_details_links.php b/db_details_links.php index 889dab7bf9..61257662e7 100644 --- a/db_details_links.php +++ b/db_details_links.php @@ -86,4 +86,3 @@ if (!$cfg['LightTabs']) { } ?> <br /> - diff --git a/db_details_qbe.php b/db_details_qbe.php index 2fd942fc70..c2d52e0ff8 100644 --- a/db_details_qbe.php +++ b/db_details_qbe.php @@ -21,7 +21,7 @@ $cfgRelation = PMA_getRelationsParam(); /** * A query has been submitted -> execute it, else display the headers */ -if (isset($submit_sql) && eregi('^SELECT', $encoded_sql_query)) { +if (isset($submit_sql) && preg_match('@^SELECT@i', $encoded_sql_query)) { $goto = 'db_details.php'; $zero_rows = htmlspecialchars($strSuccess); $sql_query = urldecode($encoded_sql_query); @@ -34,7 +34,7 @@ if (isset($submit_sql) && eregi('^SELECT', $encoded_sql_query)) { include('./db_details_db_info.php'); } -if (isset($submit_sql) && !eregi('^SELECT', $encoded_sql_query)) { +if (isset($submit_sql) && !preg_match('@^SELECT@i', $encoded_sql_query)) { echo '<p class="warning">' . $strHaveToShow . '</p>'; } @@ -121,7 +121,8 @@ $k = 0; // The tables list sent by a previously submitted form if (!empty($TableList)) { - for ($x = 0; $x < count($TableList); $x++) { + $cnt_table_list = count($TableList); + for ($x = 0; $x < $cnt_table_list; $x++) { $tbl_names[urldecode($TableList[$x])] = ' selected="selected"'; } } // end if @@ -627,7 +628,7 @@ for ($x = 0; $x < $col; $x++) { <br /> <select name="TableList[]" size="7" multiple="multiple"> <?php -while (list($key, $val) = each($tbl_names)) { +foreach($tbl_names AS $key => $val) { echo ' '; echo '<option value="' . htmlspecialchars($key) . '"' . $val . '>' . htmlspecialchars($key) . '</option>' . "\n"; } @@ -714,8 +715,6 @@ if (!empty($qry_select)) { // If we can use Relations we could make some left joins. // First find out if relations are available in this database. -// Debugging: -//echo '</textarea><pre style="background-color: white;">'; // First we need the really needed Tables - those in TableList might still be // all Tables. if (isset($Field) && count($Field) > 0) { @@ -730,21 +729,19 @@ if (isset($Field) && count($Field) > 0) { $fromclause = ''; // We only start this if we have fields, otherwise it would be dumb -// echo "get everything\n"; - while (list(, $value) = each($Field)) { + foreach($Field AS $value) { $parts = explode('.', $value); if (!empty($parts[0]) && !empty($parts[1])) { $tab_raw = urldecode($parts[0]); $tab = str_replace('`', '', $tab_raw); -// echo 'new Tab: ' . $tab . "\n"; $tab_all[$tab] = $tab; + $col_raw = urldecode($parts[1]); $col_all[] = $tab . '.' . str_replace('`', '', $col_raw); -// echo 'new col: ' . $tab . '.' . str_replace('`', '', $col_raw) . "\n"; } } // end while -// echo "check where clauses\n"; + // Check 'where' clauses if ($cfgRelation['relwork'] && count($tab_all) > 0) { // Now we need all tables that we have in the where clause $crit_cnt = count($Criteria); @@ -760,10 +757,9 @@ if (isset($Field) && count($Field) > 0) { // Now we know that our array has the same numbers as $Criteria // we can check which of our columns has a where clause if (!empty($Criteria[$x])) { - if (substr($Criteria[$x], 0, 1) == '=' || eregi('is', $Criteria[$x])) { + if (substr($Criteria[$x], 0, 1) == '=' || stristr($Criteria[$x], 'is')) { $col_where[$col] = $col1; $tab_wher[$tab] = $tab; -// echo 'new where clause: ' . $tab_wher[$tab] . "||\n"; } } // end if } // end if @@ -778,11 +774,9 @@ if (isset($Field) && count($Field) > 0) { // If there is exactly one column that has a decent where-clause // we will just use this $master = key($tab_wher); -// echo 'nur ein where: master = ' .$master . "||\n"; } else { // Now let's find out which of the tables has an index -// echo "prüfe indexe:\n"; - while (list(, $tab) = each($tab_all)) { + foreach($tab_all AS $tab) { $ind_qry = 'SHOW INDEX FROM ' . PMA_backquote($tab); $ind_rs = PMA_mysql_query($ind_qry); while ($ind = PMA_mysql_fetch_array($ind_rs)) { @@ -794,14 +788,12 @@ if (isset($Field) && count($Field) > 0) { } else { $col_unique[$col1] = 'N'; } -//echo 'neuen unique index gefunden: ' . $col . "\n"; } else { if (isset($col_where[$col1])) { $col_index[$col1] = 'Y'; } else { $col_index[$col1] = 'N'; } -//echo 'neuen index gefunden: ' . $col . "\n"; } } } // end while (each col of tab) @@ -809,20 +801,16 @@ if (isset($Field) && count($Field) > 0) { // now we want to find the best. if (isset($col_unique) && count($col_unique) > 0) { $col_cand = $col_unique; -//echo "Kandidaten sind jetzt alle mit unique index\n"; $needsort = 1; } else if (isset($col_index) && count($col_index) > 0) { $col_cand = $col_index; $needsort = 1; -//echo "Kandidaten sind jetzt alle mit index\n"; } else if (isset($col_where) && count($col_where) > 0) { $col_cand = $tab_wher; -//echo "Kandidaten sind jetzt alle im whereclause\n"; $needsort = 0; } else { $col_cand = $tab_all; $needsort = 0; -//echo "Kandidaten sind jetzt alle \n"; } // If we came up with $col_unique (very good) or $col_index (still @@ -830,7 +818,7 @@ if (isset($Field) && count($Field) > 0) { // (that would mean that they were also found in the whereclauses // which would be great). if yes, we take only those if ($needsort == 1) { - while (list($col, $is_where) = each($col_cand)) { + foreach($col_cand AS $col => $is_where) { $tab = explode('.', $col); $tab = $tab[0]; if ($is_where == 'Y') { @@ -841,10 +829,10 @@ if (isset($Field) && count($Field) > 0) { } if (isset($vg)) { $col_cand = $vg; -//echo "Kandidaten konnten auf index+where beschränkt werden\n"; + // Candidates restricted in index+where } else { $col_cand = $sg; -//echo "keiner der Kandidaten mit Index ist im wherclause\n"; + // None of the candidates where in a where-clause } } @@ -854,38 +842,29 @@ if (isset($Field) && count($Field) > 0) { // the Criteria which gives the smallest result set in its table, // but it would take too much time to check this if (count($col_cand) > 1) { -//echo "wir haben immer noch mehr als einen Kandidaten. Prüfe Größe\n"; // Of course we only want to check each table once $checked_tables = $col_cand; - while (list(, $tab) = each($col_cand)) { + foreach($col_cand AS $tab) { if ($checked_tables[$tab] != 1 ) { -//echo 'prüfe jetzt: Tabelle ' . $tab . "\n"; $rows_qry = 'SELECT COUNT(1) AS anz ' . 'FROM ' . PMA_backquote($tab); $rows_rs = PMA_mysql_query($rows_qry); while ($res = PMA_mysql_fetch_array($rows_rs)) { $tsize[$tab] = $res['anz']; -//echo "$tab hat: " . $tsize[$tab] . "\n"; } $checked_tables[$tab] = 1; } $csize[$tab] = $tsize[$tab]; -//echo 'erster csize: ' . $csize[$tab] . "\n"; } asort($csize); reset($csize); - $master = key($csize); -//echo 'kleinste Datei: ' . $master . "\n"; + $master = key($csize); // Smallest } else { - //$master = $col_cand[0]; reset($col_cand); - $master = current($col_cand); -//echo 'master ist der einzige Kandidat: ' . $master . "\n"; + $master = current($col_cand); // Only one single candidate + // } } // end if (exactly one where clause) -//echo 'ich habe mich entschieden: ' . $master; -//die; - /** * Removes unwanted entries from an array (PHP3 compliant) @@ -899,7 +878,7 @@ if (isset($Field) && count($Field) > 0) { */ function PMA_arrayShort($array, $key) { - while (list($k, $v) = each($array)) { + foreach($array AS $k => $v) { if ($k != $key) { $reta[$k] = $v; } @@ -986,7 +965,7 @@ if (isset($Field) && count($Field) > 0) { $run++; if ($run > 5) { - while (list(, $tab) = each($tab_left)) { + foreach($tab_left AS $tab) { $emerg .= ', ' . $tab; $tab_left = PMA_arrayShort($tab_left, $tab); } @@ -1099,4 +1078,4 @@ if (!empty($qry_orderby)) { * Displays the footer */ require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/db_details_structure.php b/db_details_structure.php index 3580b4dfeb..3986c48065 100644 --- a/db_details_structure.php +++ b/db_details_structure.php @@ -148,8 +148,8 @@ if ($cfg['PropertiesIconic'] == true) { if ($num_tables == 0) { echo $strNoTablesFound . "\n"; } -// 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001 -else if (PMA_MYSQL_INT_VERSION >= 32303) { +// 2. Shows table informations - staybyte - 11 June 2001 +else { // Get additional information about tables for tooltip if ($cfg['ShowTooltip']) { $tooltip_truename = array(); @@ -211,7 +211,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) { $checked = (!empty($checkall) ? ' checked="checked"' : ''); $num_columns = ($cfg['PropertiesNumColumns'] > 1 ? (ceil($num_tables / $cfg['PropertiesNumColumns']) + 1) : 0); $row_count = 0; - while (list($keyname, $sts_data) = each($tables)) { + foreach($tables AS $keyname => $sts_data) { $table = $sts_data['Name']; $table_encoded = urlencode($table); $table_name = htmlspecialchars($table); @@ -316,7 +316,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) { if (isset($sts_data['Rows'])) { // MyISAM, ISAM or Heap table: Row count, data size and index size // is accurate. - if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) { + if (isset($sts_data['Type']) && preg_match('@^(MyISAM|ISAM|HEAP)$@', $sts_data['Type'])) { if ($cfg['ShowStats']) { $tblsize = doubleval($sts_data['Data_length']) + doubleval($sts_data['Index_length']); $sum_size += $tblsize; @@ -356,7 +356,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) { } // Merge or BerkleyDB table: Only row count is accurate. - else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) { + else if (isset($sts_data['Type']) && preg_match('@^(MRG_MyISAM|BerkeleyDB)$@', $sts_data['Type'])) { if ($cfg['ShowStats']) { $formated_size = ' - '; $unit = ''; @@ -530,145 +530,12 @@ if ($cfg['PropertiesNumColumns'] > 1) { ?> </form> <?php -} // end case mysql >= 3.23.03 - -// 3. Shows tables list mysql < 3.23.03 -else { - if ($cfgRelation['commwork']) { - $comment = PMA_getComments($db); - - /** - * Displays table comment - */ - if (is_array($comment)) { - ?> - <!-- DB comment --> - <p><i> - <?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?> - </i></p> - <?php - } // end if - } - - $i = 0; - echo "\n"; - ?> -<form action="db_details_structure.php"> - <?php PMA_generate_common_hidden_inputs($db); ?> - -<?php - if ($cfg['PropertiesNumColumns'] > 1) { -?> -<table cellspacing="0" cellpadding="0" border="0"> - <tr> - <td valign="top"> -<?php - } - - pma_TableHeader(true); - - $checked = (!empty($checkall) ? ' checked="checked"' : ''); - $num_columns = ($cfg['PropertiesNumColumns'] > 1 ? (ceil($num_tables / $cfg['PropertiesNumColumns']) + 1) : 0); - $row_count = 0; - while ($i < $num_tables) { - $table = $tables[$i]; - $table_encoded = urlencode($table); - $table_name = htmlspecialchars($table); - - // Sets parameters for links - $tbl_url_query = $url_query . '&table=' . $table_encoded; - $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; - echo "\n"; - $row_count++; - if($num_columns > 0 && $num_tables > $num_columns && (($row_count % ($num_columns)) == 0)) { - $bgcolor = $cfg['BgcolorTwo']; - $row_count = 1; - ?> - </tr> - </table> - </td> - <td><img src="./images/spacer.gif" border="0" width="10" height="1" alt="" /></td> - <td valign="top"> - <?php - pma_TableHeader(true); - } - ?> - <tr> - <td align="center" bgcolor="<?php echo $bgcolor; ?>"> - <input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> /> - </td> - <td bgcolor="<?php echo $bgcolor; ?>" class="data"> - <b> <label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label> </b> - </td> - <td bgcolor="<?php echo $bgcolor; ?>"> - <a href="sql.php?<?php echo $tbl_url_query; ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0"><?php echo $strBrowse; ?></a> - </td> - <td align="center" bgcolor="<?php echo $bgcolor; ?>"> - <a href="tbl_select.php?<?php echo $tbl_url_query; ?>"><?php echo $titles['Search']; ?></a> - </td> - <td bgcolor="<?php echo $bgcolor; ?>"> - <a href="tbl_change.php?<?php echo $tbl_url_query; ?>"><?php echo $titles['Insert']; ?></a> - </td> - <td bgcolor="<?php echo $bgcolor; ?>"> - <a href="tbl_properties.php?<?php echo $tbl_url_query; ?>"><?php echo $titles['Properties']; ?></a> - </td> - <td bgcolor="<?php echo $bgcolor; ?>"> - <a href="sql.php?<?php echo $tbl_url_query; ?>&reload=1&purge=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, $table_name)); ?>"><?php echo $titles['Drop']; ?></a> - </td> - <td bgcolor="<?php echo $bgcolor; ?>"> - <a href="sql.php?<?php echo $tbl_url_query; ?>&sql_query=<?php echo urlencode('DELETE FROM ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenEmptied, $table_name)); ?>"><?php echo $titles['Empty']; ?></a> - </td> - <td align="right" bgcolor="<?php echo $bgcolor; ?>"> - <?php PMA_countRecords($db, $table); echo "\n"; ?> - </td> - </tr> - <?php - $i++; - } // end while - echo "\n"; - - // Check all tables url - $checkall_url = 'db_details_structure.php?' . PMA_generate_common_url($db); - ?> - <tr> - <td colspan="9"> - <img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" /> - <a href="<?php echo $checkall_url; ?>&checkall=1" onclick="setCheckboxes('tablesForm', true); return false;"> - <?php echo $strCheckAll; ?></a> - / - <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;"> - <?php echo $strUncheckAll; ?></a> - </td> - </tr> - - <tr> - <td colspan="9"> - <img src="./images/spacer.gif" border="0" width="38" height="1" alt="" /> - <i><?php echo $strWithChecked; ?></i> - <input type="submit" name="submit_mult" value="<?php echo $strDrop; ?>" /> - <?php $strOr . "\n"; ?> - <input type="submit" name="submit_mult" value="<?php echo $strEmpty; ?>" /> - </td> - </tr> - </table> -<?php - if ($cfg['PropertiesNumColumns'] > 1) { -?> - </td> - </tr> -</table> -<?php - } -?> -</form> - <?php -} // end case mysql < 3.23.03 +} // end if more than one table echo "\n"; ?> <hr /> - <?php /** * Work on the database @@ -791,7 +658,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { <?php echo $strPaperSize; ?> <select name="paper"> <?php - while (list($key,$val) = each($cfg['PDFPageSizes'])) { + foreach($cfg['PDFPageSizes'] AS $key => $val) { echo '<option value="' . $val . '"'; if ($val == $cfg['PDFDefaultPageSize']) { echo ' selected="selected"'; diff --git a/db_printview.php b/db_printview.php index 7bea47214a..3a52c585f8 100644 --- a/db_printview.php +++ b/db_printview.php @@ -33,61 +33,51 @@ $cfgRelation = PMA_getRelationsParam(); * tables if possible */ // staybyte: speedup view on locked tables - 11 June 2001 -if (PMA_MYSQL_INT_VERSION >= 32303) { - // Special speedup for newer MySQL Versions (in 4.0 format changed) - if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) { - $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db); - $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); - // Blending out tables in use - if ($result != FALSE && mysql_num_rows($result) > 0) { - while ($tmp = PMA_mysql_fetch_array($result)) { - // if in use memorize tablename - if (eregi('in_use=[1-9]+', $tmp[0])) { - $sot_cache[$tmp[0]] = TRUE; - } +// Special speedup for newer MySQL Versions (in 4.0 format changed) +if ($cfg['SkipLockedTables'] == TRUE) { + $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db); + $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); + // Blending out tables in use + if ($result != FALSE && mysql_num_rows($result) > 0) { + while ($tmp = PMA_mysql_fetch_array($result)) { + // if in use memorize tablename + if (preg_match('@in_use=[1-9]+@i', $tmp[0])) { + $sot_cache[$tmp[0]] = TRUE; } - mysql_free_result($result); + } + mysql_free_result($result); - if (isset($sot_cache)) { - $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db); - $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); - if ($result != FALSE && mysql_num_rows($result) > 0) { - while ($tmp = PMA_mysql_fetch_array($result)) { - if (!isset($sot_cache[$tmp[0]])) { - $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\''; - $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); - $sts_tmp = PMA_mysql_fetch_array($sts_result); - $tables[] = $sts_tmp; - } else { // table in use - $tables[] = array('Name' => $tmp[0]); - } + if (isset($sot_cache)) { + $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db); + $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); + if ($result != FALSE && mysql_num_rows($result) > 0) { + while ($tmp = PMA_mysql_fetch_array($result)) { + if (!isset($sot_cache[$tmp[0]])) { + $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\''; + $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); + $sts_tmp = PMA_mysql_fetch_array($sts_result); + $tables[] = $sts_tmp; + } else { // table in use + $tables[] = array('Name' => $tmp[0]); } - mysql_free_result($result); - $sot_ready = TRUE; } + mysql_free_result($result); + $sot_ready = TRUE; } } } - if (!isset($sot_ready)) { - $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); - $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); - if ($result != FALSE && mysql_num_rows($result) > 0) { - while ($sts_tmp = PMA_mysql_fetch_array($result)) { - $tables[] = $sts_tmp; - } - mysql_free_result($result); +} +if (!isset($sot_ready)) { + $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); + $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); + if ($result != FALSE && mysql_num_rows($result) > 0) { + while ($sts_tmp = PMA_mysql_fetch_array($result)) { + $tables[] = $sts_tmp; } + mysql_free_result($result); } - $num_tables = (isset($tables) ? count($tables) : 0); -} // end if (PMA_MYSQL_INT_VERSION >= 32303) -else { - $result = PMA_mysql_list_tables($db); - $num_tables = ($result) ? @mysql_numrows($result) : 0; - for ($i = 0; $i < $num_tables; $i++) { - $tables[] = PMA_mysql_tablename($result, $i); - } - mysql_free_result($result); } +$num_tables = (isset($tables) ? count($tables) : 0); if ($cfgRelation['commwork']) { $comment = PMA_getComments($db); @@ -114,7 +104,7 @@ if ($num_tables == 0) { echo $strNoTablesFound; } // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001 -else if (PMA_MYSQL_INT_VERSION >= 32303) { +else { ?> <!-- The tables list --> @@ -133,7 +123,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) { </tr> <?php $i = $sum_entries = $sum_size = 0; - while (list($keyname, $sts_data) = each($tables)) { + foreach($tables AS $keyname => $sts_data) { $table = $sts_data['Name']; $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; echo "\n"; @@ -149,7 +139,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) { if (isset($sts_data['Type'])) { if ($sts_data['Type'] == 'MRG_MyISAM') { $mergetable = TRUE; - } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) { + } else if (!preg_match('@ISAM|HEAP@i', $sts_data['Type'])) { $nonisam = TRUE; } } @@ -295,42 +285,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) { </tr> </table> <?php -} // end case mysql >= 3.23.03 - -// 3. Shows tables list mysql < 3.23.03 -else { - $i = 0; - echo "\n"; - ?> - -<!-- The tables list --> -<table border="<?php echo $cfg['Border']; ?>"> -<tr> - <th> <?php echo $strTable; ?> </th> - <th><?php echo $strRecords; ?></th> -</tr> - <?php - while ($i < $num_tables) { - $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo']; - echo "\n"; - ?> -<tr> - <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"> - <b><?php echo htmlspecialchars($tables[$i]); ?> </b> - </td> - <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"> - <?php PMA_countRecords($db, $tables[$i]); ?> - </td> -</tr> - <?php - $i++; - } // end while - echo "\n"; - ?> -</table> - <?php -} // end if - +} /** * Displays the footer @@ -354,4 +309,4 @@ function printPage() echo '<br /><br /> <input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/db_search.php b/db_search.php index 4dfc439372..ad78f46e8e 100644 --- a/db_search.php +++ b/db_search.php @@ -380,4 +380,4 @@ echo"\n"; */ echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/export.php b/export.php index 9d947c6170..017587acb6 100644 --- a/export.php +++ b/export.php @@ -157,7 +157,7 @@ $output_charset_conversion = $asfile && $buffer_needed = isset($compression) && ($compression == 'zip' | $compression == 'gzip' | $compression == 'bzip'); // Use on fly compression? -$onfly_compression = $GLOBALS['cfg']['CompressOnFly'] && PMA_PHP_INT_VERSION >= 40004 && isset($compression) && ($compression == 'gzip' | $compression == 'bzip'); +$onfly_compression = $GLOBALS['cfg']['CompressOnFly'] && isset($compression) && ($compression == 'gzip' | $compression == 'bzip'); if ($onfly_compression) { $memory_limit = trim(@ini_get('memory_limit')); // 2 MB as default @@ -248,7 +248,7 @@ if ($save_on_server) { if (substr($cfg['SaveDir'], -1) != '/') { $cfg['SaveDir'] .= '/'; } - $save_filename = $cfg['SaveDir'] . ereg_replace('[/\\]','_',$filename); + $save_filename = $cfg['SaveDir'] . preg_replace('@[/\\]@','_',$filename); unset($message); if (file_exists($save_filename) && empty($onserverover)) { $message = sprintf($strFileAlreadyExists, htmlspecialchars($save_filename)); @@ -364,8 +364,7 @@ if ($export_type == 'server') { $tmp_select = '|' . $tmp_select . '|'; } // Walk over databases - reset($dblist); - while (list(, $current_db) = each($dblist)) { + foreach($dblist AS $current_db) { if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|')) || !isset($tmp_select)) { PMA_exportDBHeader($current_db); @@ -438,7 +437,7 @@ if (!empty($asfile)) { // Do the compression // 1. as a gzipped file if (isset($compression) && $compression == 'zip') { - if (PMA_PHP_INT_VERSION >= 40000 && @function_exists('gzcompress')) { + if (@function_exists('gzcompress')) { if ($type == 'csv' ) { $extbis = '.csv'; } else if ($type == 'xml') { @@ -453,10 +452,9 @@ if (!empty($asfile)) { } // 2. as a bzipped file else if (isset($compression) && $compression == 'bzip') { - if (PMA_PHP_INT_VERSION >= 40004 && @function_exists('bzcompress')) { + if (@function_exists('bzcompress')) { $dump_buffer = bzcompress($dump_buffer); - // nijel: eval in next line is because otherwise === causes syntax error on php3 - if (eval('return($dump_buffer === -8);')) { + if ($dump_buffer === -8) { include('./header.inc.php'); echo sprintf($strBzError, '<a href="http://bugs.php.net/bug.php?id=17300" target="_blank">17300</a>'); include('./footer.inc.php'); @@ -466,7 +464,7 @@ if (!empty($asfile)) { } // 3. as a gzipped file else if (isset($compression) && $compression == 'gzip') { - if (PMA_PHP_INT_VERSION >= 40004 && @function_exists('gzencode')) { + if (@function_exists('gzencode')) { // without the optional parameter level because it bug $dump_buffer = gzencode($dump_buffer); } @@ -511,4 +509,4 @@ else { echo "\n"; include('./footer.inc.php'); } // end if -?> +?>
\ No newline at end of file diff --git a/footer.inc.php b/footer.inc.php index 701dc03f33..31beba6fd9 100644 --- a/footer.inc.php +++ b/footer.inc.php @@ -153,4 +153,4 @@ if (isset($GLOBALS['cfg']['OBGzip']) && $GLOBALS['cfg']['OBGzip'] PMA_outBufferPost($GLOBALS['ob_mode']); } -?> +?>
\ No newline at end of file diff --git a/header.inc.php b/header.inc.php index fb99613897..86202f0c9b 100644 --- a/header.inc.php +++ b/header.inc.php @@ -159,4 +159,4 @@ if (!defined('PMA_HEADER_INC_INCLUDED')) { */ $GLOBALS['is_header_sent'] = TRUE; } // PMA_HEADER_INC_INCLUDED -?> +?>
\ No newline at end of file diff --git a/header_printview.inc.php b/header_printview.inc.php index 044afb05e2..3d86ba7eaa 100644 --- a/header_printview.inc.php +++ b/header_printview.inc.php @@ -68,4 +68,4 @@ if ($text_dir == 'ltr') { * Sets a variable to remember headers have been sent */ $is_header_sent = TRUE; -?> +?>
\ No newline at end of file @@ -18,9 +18,6 @@ if (empty($HTTP_HOST)) { if (!empty($_ENV) && isset($_ENV['HTTP_HOST'])) { $HTTP_HOST = $_ENV['HTTP_HOST']; } - else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['HTTP_HOST'])) { - $HTTP_HOST = $HTTP_ENV_VARS['HTTP_HOST']; - } else if (@getenv('HTTP_HOST')) { $HTTP_HOST = getenv('HTTP_HOST'); } @@ -115,4 +112,4 @@ if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) { } ?> -</html> +</html>
\ No newline at end of file diff --git a/ldi_check.php b/ldi_check.php index 107f3200dd..70d4c5cccf 100644 --- a/ldi_check.php +++ b/ldi_check.php @@ -34,15 +34,9 @@ if (isset($btnLDI) && isset($local_textfile) && $local_textfile != '') { if (!empty($_SERVER) && isset($_SERVER['DOCUMENT_ROOT'])) { $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; } - else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['DOCUMENT_ROOT'])) { - $DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT']; - } else if (!empty($_ENV) && isset($_ENV['DOCUMENT_ROOT'])) { $DOCUMENT_ROOT = $_ENV['DOCUMENT_ROOT']; } - else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['DOCUMENT_ROOT'])) { - $DOCUMENT_ROOT = $HTTP_ENV_VARS['DOCUMENT_ROOT']; - } else if (@getenv('DOCUMENT_ROOT')) { $DOCUMENT_ROOT = getenv('DOCUMENT_ROOT'); } @@ -54,15 +48,9 @@ if (isset($btnLDI) && isset($local_textfile) && $local_textfile != '') { if (substr($cfg['UploadDir'], -1) != '/') { $cfg['UploadDir'] .= '/'; } - $textfile = $DOCUMENT_ROOT . dirname($PHP_SELF) . '/' . eregi_replace('^./', '', $cfg['UploadDir']) . eregi_replace('\.\.*', '.', $local_textfile); + $textfile = $DOCUMENT_ROOT . dirname($PHP_SELF) . '/' . preg_replace('@^./@', '', $cfg['UploadDir']) . preg_replace('@\.\.*@', '.', $local_textfile); if (file_exists($textfile)) { - $open_basedir = ''; - if (PMA_PHP_INT_VERSION >= 40000) { - $open_basedir = @ini_get('open_basedir'); - } - if (empty($open_basedir)) { - $open_basedir = @get_cfg_var('open_basedir'); - } + $open_basedir = @ini_get('open_basedir'); // If we are on a server with open_basedir, we must move the file // before opening it. The doc explains how to create the "./tmp" @@ -79,11 +67,7 @@ if (isset($btnLDI) && isset($local_textfile) && $local_textfile != '') { exit(); } else { $textfile_new = $tmp_subdir . basename($textfile); - if (PMA_PHP_INT_VERSION < 40003) { - copy($textfile, $textfile_new); - } else { - move_uploaded_file($textfile, $textfile_new); - } + move_uploaded_file($textfile, $textfile_new); $textfile = $textfile_new; $unlink_local_textfile = true; } @@ -158,19 +142,16 @@ if (isset($btnLDI) && empty($textfile)) { $sql_query .= ' LINES TERMINATED BY \'' . $line_terminator . '\''; } if (strlen($column_name) > 0) { - if (PMA_MYSQL_INT_VERSION >= 32306) { - $sql_query .= ' ('; - $tmp = split(',( ?)', $column_name); - for ($i = 0; $i < count($tmp); $i++) { - if ($i > 0) { - $sql_query .= ', '; - } - $sql_query .= PMA_backquote(trim($tmp[$i])); - } // end for - $sql_query .= ')'; - } else { - $sql_query .= ' (' . $column_name . ')'; - } + $sql_query .= ' ('; + $tmp = split(',( ?)', $column_name); + $cnt_tmp = count($tmp); + for ($i = 0; $i < $cnt_tmp; $i++) { + if ($i > 0) { + $sql_query .= ', '; + } + $sql_query .= PMA_backquote(trim($tmp[$i])); + } // end for + $sql_query .= ')'; } // We could rename the ldi* scripts to tbl_properties_ldi* to improve @@ -191,4 +172,4 @@ if (isset($btnLDI) && empty($textfile)) { else { include('./ldi_table.php'); } -?> +?>
\ No newline at end of file diff --git a/ldi_table.php b/ldi_table.php index f6bb484929..11a8a40a57 100644 --- a/ldi_table.php +++ b/ldi_table.php @@ -195,4 +195,4 @@ if (PMA_MYSQL_INT_VERSION > 40003) { * Displays the footer */ require('./footer.inc.php'); -?> +?>
\ No newline at end of file @@ -69,7 +69,7 @@ function PMA_indent($spaces) { function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) { $name = $key; - $id = eregi_replace('[^a-z0-9]*', '', $baseid . $keyhistory . $key) . $indent; + $id = preg_replace('@[^a-z0-9]*@i', '', $baseid . $keyhistory . $key) . $indent; $on_mouse = (($GLOBALS['cfg']['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"'); @@ -103,7 +103,7 @@ function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent $indent++; } - while(list($key, $val) = each($tablestack)) { + foreach($tablestack AS $key => $val) { if ($key != 'pma_name' && $key != 'pma_list_item') { if ($headerOut) { PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val); @@ -153,11 +153,11 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory $on_mouse = (($GLOBALS['cfg']['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"'); $loops = 0; - while(list($tkey, $tval) = each($tablestack['pma_name'])) { + foreach($tablestack['pma_name'] AS $tkey => $tval) { echo PMA_indent($indent * 5) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent+$extra_indent) * $indent_level) . '" height="9" alt="" />'; $items = explode("\n", $tablestack['pma_list_item'][$tkey]); - while(list($ikey, $ival) = each($items)) { + foreach($items AS $ikey => $ival) { echo "\n"; echo PMA_indent(($indent * 5)) . $ival; } @@ -307,8 +307,7 @@ if ($cfg['LeftDisplayServers']) { <select name="server" onchange="this.form.submit();"> <?php echo "\n"; - reset($cfg['Servers']); - while (list($key, $val) = each($cfg['Servers'])) { + foreach($cfg['Servers'] AS $key => $val) { if (!empty($val['host'])) { echo ' <option value="' . $key . '"'; if (!empty($server) && ($server == $key)) { @@ -486,7 +485,7 @@ if ($num_dbs > 1) { $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'',$table)); if (is_array($_table)) { reset($_table); - while(list($key, $val) = each($_table)) { + foreach($_table AS $key => $val) { if ($val == '') { $_table[$key] = '__protected__'; } @@ -715,8 +714,7 @@ else if ($num_dbs == 1) { if (!empty($cfg['LeftFrameTableSeparator'])) { $_table = explode($cfg['LeftFrameTableSeparator'], $table); if (is_array($_table)) { - reset($_table); - while(list($key, $val) = each($_table)) { + foreach($_table AS $key => $val) { if ($val == '') { $_table[$key] = '__protected__'; } @@ -793,4 +791,4 @@ if (isset($cfg['OBGzip']) && $cfg['OBGzip'] && isset($ob_mode) && $ob_mode) { PMA_outBufferPost($ob_mode); } -?> +?>
\ No newline at end of file @@ -119,8 +119,7 @@ if ($server == 0 || count($cfg['Servers']) > 1) { <select name="server"> <?php echo "\n"; - reset($cfg['Servers']); - while (list($key, $val) = each($cfg['Servers'])) { + foreach($cfg['Servers'] AS $key => $val) { if (!empty($val['host'])) { echo ' <option value="' . $key . '"'; if (!empty($server) && ($server == $key)) { @@ -134,11 +133,6 @@ if ($server == 0 || count($cfg['Servers']) > 1) { if (!empty($val['port'])) { echo ':' . $val['port']; } - // loic1: skip this because it's not a so good idea to display - // sockets used to everybody - // if (!empty($val['socket']) && PMA_PHP_INT_VERSION >= 30010) { - // echo ':' . $val['socket']; - // } } // loic1: if 'only_db' is an array and there is more than one // value, displaying such informations may not be a so good @@ -215,20 +209,20 @@ 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 (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); + 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); $is_create_priv = TRUE; break; } // end if } // end while mysql_free_result($rs_usr); } // end if - else if (PMA_MYSQL_INT_VERSION >= 32304) { + else { // Finally, let's try to get the user's privileges by using SHOW // GRANTS... // Maybe we'll find a little CREATE priv there :) @@ -241,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)); @@ -252,9 +246,9 @@ if ($server > 0) { $db_to_create = ''; break; } // end if - else if (ereg($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); + 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); $is_create_priv = TRUE; break; } // end elseif @@ -516,8 +510,7 @@ if (empty($cfg['Lang'])) { } // end of the 'PMA_cmp()' function uasort($available_languages, 'PMA_cmp'); - reset($available_languages); - while (list($id, $tmplang) = each($available_languages)) { + foreach($available_languages AS $id => $tmplang) { $lang_name = ucfirst(substr(strstr($tmplang[0], '|'), 1)); if ($lang == $id) { $selected = ' selected="selected"'; @@ -551,8 +544,7 @@ if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] <select name="convcharset" dir="ltr" onchange="this.form.submit();"> <?php echo "\n"; - reset($cfg['AvailableCharsets']); - while (list($id, $tmpcharset) = each($cfg['AvailableCharsets'])) { + foreach($cfg['AvailableCharsets'] AS $id => $tmpcharset) { if ($convcharset == $tmpcharset) { $selected = ' selected="selected"'; } else { @@ -658,4 +650,4 @@ if (PMA_MYSQL_INT_VERSION < 32336) { */ echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/mult_submits.inc.php b/mult_submits.inc.php index 28e35d5375..462681f7cc 100644 --- a/mult_submits.inc.php +++ b/mult_submits.inc.php @@ -129,7 +129,7 @@ if (!empty($submit_mult) && !empty($what)) { . ','; } if ($i == $selected_cnt-1) { - $full_query = ereg_replace(',$', ';<br />', $full_query); + $full_query = preg_replace('@,$@', ';<br />', $full_query); } break; } // end switch @@ -274,4 +274,4 @@ else if ($mult_btn == $strYes) { } -?> +?>
\ No newline at end of file diff --git a/pdf_pages.php b/pdf_pages.php index 21c3a64238..57bb8facee 100644 --- a/pdf_pages.php +++ b/pdf_pages.php @@ -105,9 +105,9 @@ if ($cfgRelation['pdfwork']) { // one table, and might be a master itself) $foreign_tables = array(); - while (list(,$master_table) = each($all_tables)) { + foreach($all_tables AS $master_table) { $foreigners = PMA_getForeigners($db, $master_table); - while (list(, $foreigner) = each($foreigners)) { + foreach($foreigners AS $foreigner) { if (!in_array($foreigner['foreign_table'], $foreign_tables)) { $foreign_tables[] = $foreigner['foreign_table']; } @@ -115,8 +115,7 @@ if ($cfgRelation['pdfwork']) { } // then merge the arrays - - while (list(,$foreign_table) = each($foreign_tables)) { + foreach($foreign_tables AS $foreign_table) { if (!in_array($foreign_table, $all_tables)) { $all_tables[] = $foreign_table; } @@ -130,9 +129,7 @@ if ($cfgRelation['pdfwork']) { $delta = 50; $delta_mult = 1.34; $direction = "right"; - reset($all_tables); - - while (list(,$current_table) = each($all_tables)) { + foreach($all_tables AS $current_table) { // save current table's coordinates $insert_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['table_coords']) . ' ' @@ -211,7 +208,7 @@ if ($cfgRelation['pdfwork']) { } // end for break; case 'deleteCrap': - while (list(,$current_row) = each($delrow)) { + foreach($delrow AS $current_row) { $d_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n" . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . "\n" . ' AND table_name = \'' . PMA_sqlAddslashes($current_row) . '\'' . "\n" @@ -310,7 +307,7 @@ if ($cfg['WYSIWYG-PDF']) { </form> <div id="pdflayout" class="pdflayout" style="visibility: hidden;"> <?php -while (list($key, $temp_sh_page) = each($array_sh_page)) { +foreach($array_sh_page AS $key => $temp_sh_page) { $drag_x = $temp_sh_page['x']; $drag_y = $temp_sh_page['y']; @@ -338,7 +335,6 @@ while (list($key, $temp_sh_page) = each($array_sh_page)) { $i++; } -reset($array_sh_page); ?> </div> <script type="text/javascript"> @@ -376,7 +372,7 @@ function resetDrag() { $i = 0; - while (list($dummy_sh_page, $sh_page) = each($array_sh_page)) { + foreach($array_sh_page AS $dummy_sh_page => $sh_page) { $_mtab = $sh_page['table_name']; $tabExist[$_mtab] = FALSE; echo "\n" . ' <tr '; @@ -389,7 +385,7 @@ function resetDrag() { echo "\n" . ' <td>' . "\n" . ' <select name="c_table_' . $i . '[name]">'; reset($selectboxall); - while (list($key, $value) = each($selectboxall)) { + foreach($selectboxall AS $key => $value) { echo "\n" . ' <option value="' . $value . '"'; if ($value == $sh_page['table_name']) { echo ' selected="selected"'; @@ -421,8 +417,7 @@ function resetDrag() { echo '>'; echo "\n" . ' <td>' . "\n" . ' <select name="c_table_' . $i . '[name]">'; - reset($selectboxall); - while (list($key, $value) = each($selectboxall)) { + foreach($selectboxall AS $key => $value) { echo "\n" . ' <option value="' . $value . '">' . $value . '</option>'; } echo "\n" . ' </select>' @@ -451,7 +446,7 @@ function resetDrag() { $_strname = ''; $shoot = FALSE; if (!empty($tabExist) && is_array($tabExist)) { - while (list($key, $value) = each($tabExist)) { + foreach($tabExist AS $key => $value) { if (!$value) { $_strtrans .= '<input type="hidden" name="delrow[]" value="' . $key . '">' . "\n"; $_strname .= '<li>' . $key . '</li>' . "\n"; @@ -503,7 +498,7 @@ function resetDrag() { <?php echo $strPaperSize; ?> <select name="paper" <?php echo ($cfg['WYSIWYG-PDF'] ? 'onchange="refreshDragOption(\'pdflayout\');"' : ''); ?>> <?php - while (list($key,$val) = each($cfg['PDFPageSizes'])) { + foreach($cfg['PDFPageSizes'] AS $key => $val) { echo '<option value="' . $val . '"'; if ($val == $cfg['PDFDefaultPageSize']) { echo ' selected="selected"'; @@ -533,4 +528,4 @@ ToggleDragDrop('pdflayout'); */ echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/pdf_schema.php b/pdf_schema.php index fc97f0f33b..05dd2e7563 100644 --- a/pdf_schema.php +++ b/pdf_schema.php @@ -43,32 +43,10 @@ if (!$cfgRelation['pdfwork']) { * Gets the "fpdf" libraries and defines the pdf font path */ require('./libraries/fpdf/fpdf.php'); -// loic1: PHP3 compatibility -// define('FPDF_FONTPATH', './libraries/fpdf/font/'); $FPDF_font_path = './libraries/fpdf/font/'; /** - * Emulates the "array_search" function with PHP < 4.0.5 - */ -if (PMA_PHP_INT_VERSION < 40005) { - function array_search($needle, $haystack) { - $match = FALSE; - - reset($haystack); - while (list($key, $value) = each($haystack)) { - if ($value == $needle) { - $match = $key; - } - } // end while - - return $match; - } // end of the "array_search" function -} // end if - - - -/** * Extends the "FPDF" class and prepares the work * * @access public @@ -121,8 +99,7 @@ class PMA_PDF extends FPDF if(count($this->Alias) > 0) { $nb=$this->page; - @reset($this->Alias); - while(list($alias, $value) = each($this->Alias)) { + foreach($this->Alias AS $alias => $value) { for($n=1;$n<=$nb;$n++) $this->pages[$n]=str_replace($alias,$value,$this->pages[$n]); } @@ -472,14 +449,16 @@ function Row($data,$links) { // line height $nb=0; - for($i=0;$i<count($data);$i++) + $data_cnt = count($data); + for($i=0;$i<$data_cnt;$i++) $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i])); $il = $this->FontSize; $h=($il+1)*$nb; // page break if necessary $this->CheckPageBreak($h); // draw the cells - for($i=0;$i<count($data);$i++) + $data_cnt = count($data); + for($i=0;$i<$data_cnt;$i++) { $w=$this->widths[$i]; // save current position @@ -598,8 +577,7 @@ class PMA_RT_Table // there are fields that require wider cells than the name of the table? global $pdf; - reset($this->fields); - while (list(, $field) = each($this->fields)) { + foreach($this->fields AS $field) { $this->width = max($this->width, $pdf->GetStringWidth($field)); } $this->width += $pdf->GetStringWidth(' '); @@ -656,17 +634,16 @@ class PMA_RT_Table $pdf->SetTextColor(0); $pdf->SetFillColor(255); - reset($this->fields); - while (list(, $field) = each($this->fields)) { + foreach($this->fields AS $field) { // loic1 : PHP3 fix // if (in_array($field, $this->primary)) { if ($setcolor) { if (PMA_isInto($field, $this->primary) != -1) { - $pdf->SetFillColor(215, 121, 123); - } - if ($field == $this->displayfield) { - $pdf->SetFillColor(142, 159, 224); - } + $pdf->SetFillColor(215, 121, 123); + } + if ($field == $this->displayfield) { + $pdf->SetFillColor(142, 159, 224); + } } if ($with_doc) $pdf->SetLink($pdf->PMA_links['RT'][$this->table_name][$field],-1); else $pdf->PMA_links['doc'][$this->table_name][$field] = ''; @@ -1019,8 +996,7 @@ class PMA_RT function PMA_RT_drawRelations($change_color) { $i = 0; - reset($this->relations); - while (list(, $relation) = each($this->relations)) { + foreach($this->relations AS $relation) { $relation->PMA_RT_Relation_draw($change_color, $i); $i++; } // end while @@ -1038,8 +1014,7 @@ class PMA_RT */ function PMA_RT_drawTables($show_info,$draw_color=0) { - reset($this->tables); - while (list(, $table) = each($this->tables)) { + foreach($this->tables AS $table) { $table->PMA_RT_Table_draw($show_info, $this->ff,$draw_color); } } // end of the "PMA_RT_drawTables()" method @@ -1165,14 +1140,11 @@ class PMA_RT /* snip */ - reset ($alltables); - while (list(, $table) = each ($alltables)) { + foreach($alltables AS $table) { if (!isset($this->tables[$table])) { $this->tables[$table] = new PMA_RT_Table($table, $this->ff, $this->tablewidth); } - } // while - reset($alltables); - while (list(, $table) = each ($alltables)) { + if($this->same_wide){ $this->tables[$table]->width = $this->tablewidth; } @@ -1206,13 +1178,12 @@ class PMA_RT // and finding its foreigns is OK (then we can support innodb) $seen_a_relation = FALSE; - reset($alltables); - while (list(,$one_table) = each($alltables)) { + foreach($alltables AS $one_table) { $exist_rel = PMA_getForeigners($db, $one_table, '', 'both'); if ($exist_rel) { $seen_a_relation = TRUE; - while (list($master_field,$rel) = each($exist_rel)) { + foreach($exist_rel AS $master_field => $rel) { // put the foreign table on the schema only if selected // by the user // (do not use array_search() because we would have to @@ -1254,8 +1225,7 @@ function PMA_RT_DOC($alltables ){ $pdf->Cell(0,9, $GLOBALS['strTableOfContents'],1,0,'C'); $pdf->Ln(15); $i = 1; - @reset($alltables); - while(list(, $table) = each($alltables)) { + foreach($alltables AS $table) { $pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink(); $pdf->SetX(10); //$pdf->Ln(1); @@ -1281,8 +1251,7 @@ function PMA_RT_DOC($alltables ){ $pdf->SetX(10); $pdf->Cell(0,6,$i.' '. $GLOBALS['strRelationalSchema'],0,1,'L',0,$pdf->PMA_links['RT']['-']); $z = 0; - @reset($alltables); - while(list(, $table) = each($alltables)) { + foreach($alltables AS $table) { $z++; $pdf->addpage($GLOBALS['orientation']); $pdf->Bookmark($table); @@ -1305,24 +1274,15 @@ function PMA_RT_DOC($alltables ){ /** * Gets table informations */ - // The 'show table' statement works correct since 3.23.03 - if (PMA_MYSQL_INT_VERSION >= 32303) { - $local_query = "SHOW TABLE STATUS 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_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); - $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); - $create_time = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : ''); - $update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : ''); - $check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : ''); - } else { - $showtable = array(); - $num_rows = PMA_countRecords($db, $table, TRUE); - $show_comment = ''; - $create_time = ''; - $update_time = ''; - $check_time = ''; - } // end display comments + $local_query = "SHOW TABLE STATUS 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_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); + $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); + $create_time = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : ''); + $update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : ''); + $check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : ''); + if ($result) { mysql_free_result($result); } @@ -1460,8 +1420,8 @@ function PMA_RT_DOC($alltables ){ $type = $row['Type']; // reformat mysql query output - staybyte - 9. June 2001 // loic1: set or enum types: slashes single quotes inside options - if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) { - $tmp[2] = substr(ereg_replace("([^,])''", "\\1\\'", ',' . $tmp[2]), 1); + if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { + $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1); $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type_nowrap = ''; @@ -1470,16 +1430,16 @@ function PMA_RT_DOC($alltables ){ $zerofill = 0; } else { $type_nowrap = ' nowrap="nowrap"'; - $type = eregi_replace('BINARY', '', $type); - $type = eregi_replace('ZEROFILL', '', $type); - $type = eregi_replace('UNSIGNED', '', $type); + $type = preg_replace('@BINARY@i', '', $type); + $type = preg_replace('@ZEROFILL@i', '', $type); + $type = preg_replace('@UNSIGNED@i', '', $type); if (empty($type)) { $type = ' '; } - $binary = eregi('BINARY', $row['Type'], $test); - $unsigned = eregi('UNSIGNED', $row['Type'], $test); - $zerofill = eregi('ZEROFILL', $row['Type'], $test); + $binary = stristr($row['Type'], 'BINARY'); + $unsigned = stristr($row['Type'], 'UNSIGNED'); + $zerofill = stristr($row['Type'], 'ZEROFILL'); } $strAttribute = ' '; if ($binary) { @@ -1562,4 +1522,4 @@ $paper = isset($paper) ? $paper : 'A4'; PMA_mysql_select_db($db); $rt = new PMA_RT($pdf_page_number, $show_table_dimension, $show_color, $show_grid, $all_tab_same_wide, $orientation, $paper); -?> +?>
\ No newline at end of file diff --git a/phpinfo.php b/phpinfo.php index 29f0ea690a..726b67c54a 100644 --- a/phpinfo.php +++ b/phpinfo.php @@ -17,4 +17,4 @@ $is_superuser = @PMA_mysql_query('USE mysql', $userlink); if ($is_superuser || $cfg['ShowPhpInfo']) { phpinfo(); } -?> +?>
\ No newline at end of file diff --git a/queryframe.php b/queryframe.php index 293b42ae19..d24c7f77fe 100644 --- a/queryframe.php +++ b/queryframe.php @@ -129,4 +129,4 @@ if (isset($cfg['OBGzip']) && $cfg['OBGzip'] && isset($ob_mode) && $ob_mode) { PMA_outBufferPost($ob_mode); } -?> +?>
\ No newline at end of file diff --git a/querywindow.php b/querywindow.php index 2fa872eeff..81990ad32b 100644 --- a/querywindow.php +++ b/querywindow.php @@ -180,8 +180,7 @@ if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) { $temp_history = PMA_getHistory($cfg['Server']['user']); if (is_array($temp_history) && count($temp_history) > 0) { - @reset($temp_history); - while(@list($history_nr, $history_array) = @each($temp_history)) { + foreach($temp_history AS $history_nr => $history_array) { if (!isset($dup_sql[$history_array['sqlquery']])) { $sql_history[] = '<li>' . '<a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . preg_replace('/(\n)/i', ' ', addslashes(htmlspecialchars($history_array['sqlquery']))) . '\'; document.querywindow.auto_commit.value = \'false\'; document.querywindow.db.value = \'' . htmlspecialchars($history_array['db']) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($history_array['db']) . '\'; document.querywindow.table.value = \'' . (isset($history_array['table']) ? htmlspecialchars($history_array['table']) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($history_array['table']) ? htmlspecialchars($history_array['table']) : '') . '\'; document.querywindow.submit(); return false;">' . $titles['Change'] . '</a>' @@ -196,8 +195,7 @@ if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) { if (isset($query_history) && is_array($query_history)) { $current_index = count($query_history); - @reset($query_history); - while(list($query_no, $query_sql) = each($query_history)) { + foreach($query_history AS $query_no => $query_sql) { if (!isset($dup_sql[$query_sql])) { $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_sql . '" />'; @@ -299,4 +297,4 @@ if (isset($cfg['OBGzip']) && $cfg['OBGzip'] && isset($ob_mode) && $ob_mode) { PMA_outBufferPost($ob_mode); } -?> +?>
\ No newline at end of file diff --git a/read_dump.php b/read_dump.php index bb12b9fdb9..41f981cc43 100644 --- a/read_dump.php +++ b/read_dump.php @@ -22,12 +22,12 @@ if (!isset($db)) { /** * Defines the url to return to in case of error in a sql statement */ -if (!isset($goto) || !eregi('^(db_details|tbl_properties)(_[a-z]*)?\.php$', $goto)) { +if (!isset($goto) || !preg_match('@^(db_details|tbl_properties)(_[a-z]*)?\.php$@i', $goto)) { $goto = 'db_details.php'; } $err_url = $goto . '?' . PMA_generate_common_url($db) - . (eregi('^tbl_properties(_[a-z]*)?\.php$', $goto) ? '&table=' . urlencode($table) : ''); + . (preg_match('@^tbl_properties(_[a-z]*)?\.php$@', $goto) ? '&table=' . urlencode($table) : ''); /** @@ -54,11 +54,7 @@ if (!empty($id_bookmark)) { case 0: // bookmarked query that have to be run $sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark); if (isset($bookmark_variable) && !empty($bookmark_variable)) { - if (PMA_PHP_INT_VERSION >= 40300) { - $sql_query = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddslashes($bookmark_variable) . '${2}', $sql_query); - } else { - $sql_query = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '\1 ' . PMA_sqlAddslashes($bookmark_variable) . '\2', $sql_query); - } + $sql_query = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddslashes($bookmark_variable) . '${2}', $sql_query); } break; case 1: // bookmarked query that have to be displayed @@ -148,7 +144,7 @@ if (!empty($prev_sql_query)) { // Drop database is not allowed -> ensure the query can be run if (!$cfg['AllowUserDropDatabase'] - && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE ', $sql_query)) { + && preg_match('@DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE @i', $sql_query)) { // Checks if the user is a Superuser // TODO: set a global variable with this information // loic1: optimized query @@ -240,7 +236,7 @@ if ($sql_query != '') { // Only one query to run if ($pieces_count == 1 && !empty($pieces[0])) { $sql_query = $pieces[0]; - if (eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $sql_query)) { + if (preg_match('@^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@i', $sql_query)) { $reload = 1; } include('./sql.php'); @@ -255,7 +251,7 @@ if ($sql_query != '') { for ($i = 0; $i < $pieces_count; $i++) { $a_sql_query = $pieces[$i]; - if ($i == $pieces_count - 1 && eregi('^(SELECT|SHOW)', $a_sql_query)) { + if ($i == $pieces_count - 1 && preg_match('@^(SELECT|SHOW)@i', $a_sql_query)) { $complete_query = $sql_query; $display_query = $sql_query; $sql_query = $a_sql_query; @@ -300,7 +296,7 @@ if ($sql_query != '') { $info_count++; } - if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) { + if (!isset($reload) && preg_match('@^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@i', $a_sql_query)) { $reload = 1; } } // end for @@ -326,7 +322,7 @@ if (isset($my_die)) { $js_to_run = 'functions.js'; include('./header.inc.php'); if (is_array($my_die)) { - while(list($key, $die_string) = each($my_die)) { + foreach($my_die AS $key => $die_string) { PMA_mysqlDie('', $die_string, '', $err_url, FALSE); echo '<hr />'; } diff --git a/scripts/decode_bug.php b/scripts/decode_bug.php index 8c818faa33..75838c7562 100644 --- a/scripts/decode_bug.php +++ b/scripts/decode_bug.php @@ -77,9 +77,6 @@ function PMA_printDecodedBug($textdata) if (!empty($_POST) && isset($_POST['bug_encoded'])) { $bug_encoded = $_POST['bug_encoded']; } -else if (!empty($HTTP_POST_VARS) && isset($HTTP_POST_VARS['bug_encoded'])) { - $bug_encoded = $HTTP_POST_VARS['bug_encoded']; -} if (!empty($bug_encoded)) { if (get_magic_quotes_gpc()) { diff --git a/server_collations.php b/server_collations.php index 1084c28dd6..4ac56a716a 100644 --- a/server_collations.php +++ b/server_collations.php @@ -60,7 +60,6 @@ reset($mysql_collations); $i = 0; $table_row_count = count($mysql_charsets) + $mysql_collations_count; -//while (list(, $current_charset) = each($mysql_charsets)) { foreach ($mysql_charsets as $current_charset) { if ($i > $table_row_count / 2) { $i = 0; @@ -85,8 +84,6 @@ foreach ($mysql_charsets as $current_charset) { . ' </td>' . "\n" . ' </tr>' . "\n"; $useBgcolorOne = TRUE; -// reset($mysql_collations[$current_charset]); -// while (list(, $current_collation) = each($mysql_collations[$current_charset])) { foreach ($mysql_collations[$current_charset] as $current_collation) { $i++; echo ' <tr>' . "\n" @@ -108,4 +105,4 @@ echo ' </table>' . "\n" require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/server_common.inc.php b/server_common.inc.php index 2113db5983..ffb57f00ee 100644 --- a/server_common.inc.php +++ b/server_common.inc.php @@ -50,4 +50,4 @@ $is_superuser = @PMA_mysql_query('SELECT COUNT(*) FROM mysql.user', $userlink); if ($is_superuser) { @PMA_mysql_query('USE mysql', $userlink); } -?> +?>
\ No newline at end of file diff --git a/server_databases.php b/server_databases.php index a643fd399e..87f2eddd02 100644 --- a/server_databases.php +++ b/server_databases.php @@ -111,7 +111,7 @@ if (!empty($dbstats) && !$is_superuser) { * Prepares the statistics */ $statistics = array(); -while (list(, $current_db) = each($dblist)) { +foreach($dblist AS $current_db) { $tmp_array = array( 'db_name' => $current_db, 'tbl_cnt' => 0, diff --git a/server_export.php b/server_export.php index 345a83db85..dacd387477 100644 --- a/server_export.php +++ b/server_export.php @@ -39,8 +39,7 @@ if ($server > 0 && empty($dblist)) { $multi_values = '<div align="center"><select name="db_select[]" size="6" multiple="multiple">'; $multi_values .= "\n"; -reset($dblist); -while (list(, $current_db) = each($dblist)) { +foreach($dblist AS $current_db) { if (!empty($selectall) || (isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))) { $is_selected = ' selected="selected"'; } else { @@ -70,5 +69,4 @@ require('./libraries/display_export.lib.php'); * Displays the footer */ require('./footer.inc.php'); -?> - +?>
\ No newline at end of file diff --git a/server_links.inc.php b/server_links.inc.php index 39de062ced..fc53dd8dbb 100644 --- a/server_links.inc.php +++ b/server_links.inc.php @@ -66,4 +66,4 @@ echo PMA_printTab($strExport, 'server_export.php', $url_query); ?> </tr> </table> -<br /> +<br />
\ No newline at end of file diff --git a/server_privileges.php b/server_privileges.php index 9b66cd3501..c90130aafe 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -82,7 +82,6 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) $av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7)); unset($row1); $users_grants = explode(',', $row['Table_priv']); -// while (list(, $current_grant) = each($av_grants)) { foreach ($av_grants as $current_grant) { $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N'; } @@ -92,7 +91,6 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) } $privs = array(); $allPrivileges = TRUE; -// while (list(, $current_grant) = each($grants)) { foreach ($grants as $current_grant) { if ((!empty($row) && isset($row[$current_grant[0]])) || (empty($row) && isset($GLOBALS[$current_grant[0]]))) { if ((!empty($row) && $row[$current_grant[0]] == 'Y') || (empty($row) && ($GLOBALS[$current_grant[0]] == 'Y' || (is_array($GLOBALS[$current_grant[0]]) && count($GLOBALS[$current_grant[0]]) == $GLOBALS['column_count'] && empty($GLOBALS[$current_grant[0] . '_none']))))) { @@ -199,7 +197,6 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = $av_grants = explode ('\',\'' , substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3)); unset($row1); $users_grants = explode(',', $row['Table_priv']); -// while (list(, $current_grant) = each($av_grants)) { foreach ($av_grants as $current_grant) { $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N'; } @@ -227,7 +224,6 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query); while ($row1 = PMA_mysql_fetch_row($res)) { $row1[1] = explode(',', $row1[1]); -// while (list(, $current) = each($row1[1])) { foreach ($row1[1] as $current) { $columns[$row1[0]][$current] = TRUE; } @@ -261,7 +257,6 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = $rowspan = count($row) - 5; echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n" . $spaces . ' <select name="Select_priv[]" multiple="multiple">' . "\n"; -// while (list($current_column, $current_column_privileges) = each($columns)) { foreach ($columns as $current_column => $current_column_privileges) { echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"'; if ($row['Select_priv'] == 'Y' || $current_column_privileges['Select']) { @@ -276,8 +271,6 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = . $spaces . ' </td>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n" . $spaces . ' <select name="Insert_priv[]" multiple="multiple">' . "\n"; -// reset($columns); -// while (list($current_column, $current_column_privileges) = each($columns)) { foreach ($columns as $current_column => $current_column_privileges) { echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"'; if ($row['Insert_priv'] == 'Y' || $current_column_privileges['Insert']) { @@ -292,8 +285,6 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = . $spaces . ' </td>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n" . $spaces . ' <select name="Update_priv[]" multiple="multiple">' . "\n"; -// reset($columns); -// while (list($current_column, $current_column_privileges) = each($columns)) { foreach ($columns as $current_column => $current_column_privileges) { echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"'; if ($row['Update_priv'] == 'Y' || $current_column_privileges['Update']) { @@ -308,8 +299,6 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = . $spaces . ' </td>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n" . $spaces . ' <select name="References_priv[]" multiple="multiple">' . "\n"; -// reset($columns); -// while (list($current_column, $current_column_privileges) = each($columns)) { foreach ($columns as $current_column => $current_column_privileges) { echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"'; if ($row['References_priv'] == 'Y' || $current_column_privileges['References']) { @@ -330,7 +319,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="checkbox" name="' . $current_grant . '" id="checkbox_' . $current_grant . '" value="Y" ' . ($current_grant_value == 'Y' ? 'checked="checked" ' : '') . 'title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5)) . 'Tbl']) . '"/></td>' . "\n" . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="checkbox_' . $current_grant . '"><tt><dfn title="' . (isset($GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($current_grant, 0, (strlen($current_grant) - 5)) . 'Tbl']) . '">' . strtoupper(substr($current_grant, 0, strlen($current_grant) - 5)) . '</dfn></tt></label></td>' . "\n" . $spaces . ' </tr>' . "\n"; - while (list($current_grant, $current_grant_value) = each($row)) { + foreach($row AS $current_grant => $current_grant_value) { if (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) { continue; } @@ -855,9 +844,8 @@ if (!empty($delete) || (!empty($change_copy) && $mode < 4)) { $queries[] = '# ' . $strReloadingThePrivileges . ' ...'; $queries[] = 'FLUSH PRIVILEGES;'; } -// while (list(, $sql_query) = each($queries)) { foreach ($queries as $sql_query) { - if (substr($sql_query, 0, 1) != '#') { + if ($sql_query{0} != '#') { PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink)); } } @@ -873,9 +861,8 @@ if (!empty($delete) || (!empty($change_copy) && $mode < 4)) { * Changes / copies a user, part V */ if (!empty($change_copy)) { -// while (list(, $sql_query) = each($queries)) { foreach ($queries as $sql_query) { - if (substr($sql_query, 0, 1) != '#') { + if ($sql_query{0} != '#') { PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink)); } } @@ -1174,7 +1161,6 @@ if (empty($adduser) && empty($checkprivs)) { if (!empty($pred_db_array)) { echo ' <select name="pred_dbname" onchange="this.form.submit();">' . "\n" . ' <option value="" selected="selected">' . $strUseTextField . ':</option>' . "\n"; -// while (list(, $current_db) = each($pred_db_array)) { foreach ($pred_db_array as $current_db) { echo ' <option value="' . htmlspecialchars($current_db) . '">' . htmlspecialchars($current_db) . '</option>' . "\n"; } @@ -1197,7 +1183,6 @@ if (empty($adduser) && empty($checkprivs)) { if (!empty($pred_tbl_array)) { echo ' <select name="pred_tablename" onchange="this.form.submit();">' . "\n" . ' <option value="" selected="selected">' . $strUseTextField . ':</option>' . "\n"; -// while (list(, $current_table) = each($pred_tbl_array)) { foreach ($pred_tbl_array as $current_table) { echo ' <option value="' . htmlspecialchars($current_table) . '">' . htmlspecialchars($current_table) . '</option>' . "\n"; } @@ -1395,7 +1380,6 @@ if (empty($adduser) && empty($checkprivs)) { echo ' bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' ' . htmlspecialchars($current_host) . "\n" . ' </td>' . "\n"; -// while (list(, $current) = each($current_privileges)) { foreach ($current_privileges as $current) { echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' '; @@ -1445,4 +1429,4 @@ if (empty($adduser) && empty($checkprivs)) { echo "\n\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/server_processlist.php b/server_processlist.php index 3b50a25e19..c3b3bb36a6 100644 --- a/server_processlist.php +++ b/server_processlist.php @@ -68,7 +68,7 @@ unset($row); </tr> <?php $useBgcolorOne = TRUE; -while (list($name, $value) = each($serverProcesses)) { +foreach($serverProcesses AS $name => $value) { ?> <tr> <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <a href="./server_processlist.php?<?php echo $url_query . '&kill=' . $value['Id']; ?>"><?php echo $strKill; ?></a> </td> diff --git a/server_status.php b/server_status.php index caeedc2f97..0b18e7b0ff 100644 --- a/server_status.php +++ b/server_status.php @@ -76,7 +76,7 @@ unset($row); //Get query statistics $queryStats = array(); $tmp_array = $serverStatus; -while (list($name, $value) = each($tmp_array)) { +foreach($tmp_array AS $name => $value) { if (substr($name, 0, 4) == 'Com_') { $queryStats[str_replace('_', ' ', substr($name, 4))] = $value; unset($serverStatus[$name]); @@ -243,7 +243,7 @@ if (!empty($serverStatus)) { <?php $useBgcolorOne = TRUE; $countRows = 0; - while (list($name, $value) = each($serverStatus)) { + foreach($serverStatus AS $name => $value)= { ?> <tr> <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?> </td> @@ -14,7 +14,7 @@ require('./libraries/common.lib.php'); */ // Security checkings if (!empty($goto)) { - $is_gotofile = ereg_replace('^([^?]+).*$', '\\1', $goto); + $is_gotofile = preg_replace('@^([^?]+).*$@', '\\1', $goto); if (!@file_exists('./' . $is_gotofile)) { unset($goto); } else { @@ -55,7 +55,7 @@ PMA_checkParameters(array('sql_query', 'db')); */ if (!defined('PMA_CHK_DROP') && !$cfg['AllowUserDropDatabase'] - && eregi('DROP[[:space:]]+DATABASE[[:space:]]+', $sql_query)) { + && preg_match('@DROP[[:space:]]+DATABASE[[:space:]]+@i', $sql_query)) { // Checks if the user is a Superuser // TODO: set a global variable with this information // loic1: optimized query @@ -151,7 +151,7 @@ if (isset($btnDrop) && $btnDrop == $strNo) { unset($table); } $active_page = $goto; - include('./' . ereg_replace('\.\.*', '.', $goto)); + include('./' . preg_replace('@\.\.*@', '.', $goto)); } else { header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto)); } @@ -220,7 +220,7 @@ else { // Defines some variables // loic1: A table has to be created -> left frame should be reloaded if ((!isset($reload) || $reload == 0) - && eregi('^CREATE TABLE[[:space:]]+(.*)', $sql_query)) { + && preg_match('@^CREATE TABLE[[:space:]]+(.*)@i', $sql_query)) { $reload = 1; } // Gets the number of rows per page @@ -248,24 +248,24 @@ else { $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE; if ($is_select) { // see line 141 - $is_group = eregi('(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query); - $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query)); - $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query)); - $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query)); - $is_analyse = (eregi('[[:space:]]+PROCEDURE[[:space:]]+ANALYSE', $sql_query)); - } else if (eregi('^EXPLAIN[[:space:]]+', $sql_query)) { + $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query); + $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query)); + $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query)); + $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query)); + $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query)); + } else if (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) { $is_explain = TRUE; - } else if (eregi('^DELETE[[:space:]]+', $sql_query)) { + } else if (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) { $is_delete = TRUE; $is_affected = TRUE; - } else if (eregi('^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+', $sql_query)) { + } else if (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) { $is_insert = TRUE; $is_affected = TRUE; - } else if (eregi('^UPDATE[[:space:]]+', $sql_query)) { + } else if (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) { $is_affected = TRUE; - } else if (eregi('^SHOW[[:space:]]+', $sql_query)) { + } else if (preg_match('@^SHOW[[:space:]]+@i', $sql_query)) { $is_show = TRUE; - } else if (eregi('^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+', $sql_query)) { + } else if (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) { $is_maint = TRUE; } @@ -274,9 +274,9 @@ else { && (!$cfg['ShowAll'] || $session_max_rows != 'all') && !($is_count || $is_export || $is_func || $is_analyse) && isset($analyzed_sql[0]['queryflags']['select_from']) - && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) { + && !preg_match('@[[:space:]]LIMIT[[:space:]0-9,-]+$@i', $sql_query)) { $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows']; - if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) { + if (preg_match('@(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$@i', $sql_query, $regs)) { $full_sql_query = $regs[1] . $sql_limit_to_append . $regs[2]; } else { $full_sql_query = $sql_query . $sql_limit_to_append; @@ -291,8 +291,8 @@ else { // rows that will be deleted (mysql_affected_rows will always return 0 in // this case) if ($is_delete - && eregi('^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$', $sql_query, $parts) - && !eregi('[[:space:]]WHERE[[:space:]]', $parts[3])) { + && preg_match('@^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$@i', $sql_query, $parts) + && !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) { $cnt_all_result = @PMA_mysql_query('SELECT COUNT(*) as count' . $parts[2]); if ($cnt_all_result) { $num_rows = PMA_mysql_result($cnt_all_result, 0, 'count'); @@ -325,7 +325,7 @@ else { if (PMA_mysql_error()) { $error = PMA_mysql_error(); include('./header.inc.php'); - $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url)) + $full_err_url = (preg_match('@^(db_details|tbl_properties)@', $err_url)) ? $err_url . '&show_query=1&sql_query=' . urlencode($sql_query) : $err_url; PMA_mysqlDie($error, $full_sql_query, '', $full_err_url); @@ -391,7 +391,7 @@ else { if (PMA_MYSQL_INT_VERSION < 40000) { // TODO: detect DISTINCT in the parser - if (eregi('DISTINCT(.*)', $sql_query)) { + if (stristr($sql_query, 'DISTINCT')) { $count_what = 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause']; } else { $count_what = '*'; @@ -478,7 +478,7 @@ else { } } else { PMA_mysql_query($count_query); - if (mysql_error()) { + // if (mysql_error()) { // void. I tried the case // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`) // UNION (SELECT `User`, `Host`, "%" AS "Db", @@ -486,7 +486,7 @@ else { // FROM `user`) ORDER BY `User`, `Host`, `Db`; // and although the generated count_query is wrong // the SELECT FOUND_ROWS() work! - } + // } $cnt_all_result = PMA_mysql_query('SELECT FOUND_ROWS() as count'); $unlim_num_rows = PMA_mysql_result($cnt_all_result,0,'count'); } @@ -545,7 +545,7 @@ else { $message .= ' ' . (isset($GLOBALS['querytime']) ? '(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : ''); if ($is_gotofile) { - $goto = ereg_replace('\.\.*', '.', $goto); + $goto = preg_replace('@\.\.*@', '.', $goto); // Checks for a valid target script if (isset($table) && $table == '') { unset($table); @@ -787,4 +787,4 @@ echo "\n\n"; * Displays the footer */ require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/tbl_addfield.php b/tbl_addfield.php index 1e16321142..14d6ab814c 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -50,7 +50,7 @@ if (isset($submit)) { $query .= PMA_backquote($field_name[$i]) . ' ' . $field_type[$i]; if ($field_length[$i] != '' - && !eregi('^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$', $field_type[$i])) { + && !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$@i', $field_type[$i])) { $query .= '(' . $field_length[$i] . ')'; } if ($field_attribute[$i] != '') { @@ -97,7 +97,7 @@ if (isset($submit)) { } $query .= ', ADD '; } // end for - $query = ereg_replace(', ADD $', '', $query); + $query = preg_replace('@, ADD $@', '', $query); // To allow replication, we first select the db to use and then run queries // on this db. @@ -121,7 +121,7 @@ if (isset($submit)) { $primary .= PMA_backquote($field_name[$j]) . ', '; } } // end for - $primary = ereg_replace(', $', '', $primary); + $primary = preg_replace('@, $@', '', $primary); if (!empty($primary)) { $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ')'; $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); @@ -139,7 +139,7 @@ if (isset($submit)) { $index .= PMA_backquote($field_name[$j]) . ', '; } } // end for - $index = ereg_replace(', $', '', $index); + $index = preg_replace('@, $@', '', $index); if (!empty($index)) { $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')'; $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); @@ -157,7 +157,7 @@ if (isset($submit)) { $unique .= PMA_backquote($field_name[$j]) . ', '; } } // end for - $unique = ereg_replace(', $', '', $unique); + $unique = preg_replace('@, $@', '', $unique); if (!empty($unique)) { $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')'; $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); @@ -168,13 +168,13 @@ if (isset($submit)) { // Builds the fulltext statements and updates the table $fulltext = ''; - if (PMA_MYSQL_INT_VERSION >= 32323 && isset($field_fulltext)) { + if (isset($field_fulltext)) { $fulltext_cnt = count($field_fulltext); for ($i = 0; $i < $fulltext_cnt; $i++) { $j = $field_fulltext[$i]; $fulltext .= PMA_backquote($field_name[$j]) . ', '; } // end for - $fulltext = ereg_replace(', $', '', $fulltext); + $fulltext = preg_replace('@, $@', '', $fulltext); if (!empty($fulltext)) { $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')'; $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); @@ -190,16 +190,14 @@ if (isset($submit)) { // garvin: Update comment table, if a comment was set. if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { - @reset($field_comments); - while(list($fieldindex, $fieldcomment) = each($field_comments)) { + foreach($field_comments AS $fieldindex => $fieldcomment) { PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment); } } // garvin: Update comment table for mime types [MIME] if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { - @reset($field_mimetype); - while(list($fieldindex, $mimetype) = each($field_mimetype)) { + foreach($field_mimetype AS $fieldindex => $mimetype) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); } } @@ -236,4 +234,4 @@ if ($abort == FALSE) { include('./footer.inc.php'); } -?> +?>
\ No newline at end of file diff --git a/tbl_alter.php b/tbl_alter.php index 0033b13542..993d4fc8f3 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -47,7 +47,7 @@ if (isset($submit)) { $query .= PMA_backquote($field_orig[$i]) . ' ' . PMA_backquote($field_name[$i]) . ' ' . $field_type[$i]; // Some field types shouldn't have lengths if ($field_length[$i] != '' - && !eregi('^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$', $field_type[$i])) { + && !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$@i', $field_type[$i])) { $query .= '(' . $field_length[$i] . ')'; } if ($field_attribute[$i] != '') { @@ -91,16 +91,14 @@ if (isset($submit)) { // garvin: Update comment table, if a comment was set. if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { - @reset($field_comments); - while(list($fieldindex, $fieldcomment) = each($field_comments)) { + foreach($field_comments AS $fieldindex => $fieldcomment) { PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, $field_orig[$fieldindex]); } } // garvin: Rename relations&display fields, if altered. if (($cfgRelation['displaywork'] || $cfgRelation['relwork']) && isset($field_orig) && is_array($field_orig)) { - @reset($field_orig); - while(list($fieldindex, $fieldcontent) = each($field_orig)) { + foreach($field_orig AS $fieldindex => $fieldcontent) { if ($field_name[$fieldindex] != $fieldcontent) { if ($cfgRelation['displaywork']) { $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info']) @@ -138,8 +136,7 @@ if (isset($submit)) { // garvin: Update comment table for mime types [MIME] if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { - @reset($field_mimetype); - while(list($fieldindex, $mimetype) = each($field_mimetype)) { + foreach($field_mimetype AS $fieldindex => $mimetype) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); } } @@ -195,4 +192,4 @@ if ($abort == FALSE) { * Displays the footer */ require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/tbl_change.php b/tbl_change.php index 9ecb68fb51..24ac731212 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -50,12 +50,12 @@ if (!empty($disp_message)) { if (!isset($goto)) { $goto = 'db_details.php'; } -if (!ereg('^(db_details|tbl_properties|tbl_select)', $goto)) { +if (!preg_match('@^(db_details|tbl_properties|tbl_select)@', $goto)) { $err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query); } else { $err_url = $goto . '?' . PMA_generate_common_url($db) - . ((ereg('^(tbl_properties|tbl_select)', $goto)) ? '&table=' . urlencode($table) : ''); + . ((preg_match('@^(tbl_properties|tbl_select)@', $goto)) ? '&table=' . urlencode($table) : ''); } @@ -220,13 +220,13 @@ for ($i = 0; $i < $fields_cnt; $i++) { echo "\n"; $row_table_def = PMA_mysql_fetch_array($table_def); - $row_table_def['True_Type'] = ereg_replace('\\(.*', '', $row_table_def['Type']); + $row_table_def['True_Type'] = preg_replace('@\\(.*@', '', $row_table_def['Type']); $field = $row_table_def['Field']; // garvin: possible workaround. If current field is numerical, do not try to // access the result-array with its 'associative' key but with its numerical // represantation. - if ((PMA_PHP_INT_VERSION > 40000 && is_numeric($field)) || eregi('^[0-9]*$', $field)) { + if (is_numeric($field)) { $rowfield = $i; } else { $rowfield = $field; @@ -246,15 +246,11 @@ for ($i = 0; $i < $fields_cnt; $i++) { $row[$rowfield] = date('Y-m-d H:i:s', time()); } // UPDATE case with an empty and not NULL value under PHP4 - else if (empty($row[$rowfield]) && function_exists('is_null')) { - $row[$rowfield] = (is_null($row[$rowfield]) ? $row[$rowfield] : date('Y-m-d H:i:s', time())); - } - // UPDATE case with an empty value under PHP3 - else if (empty($row[$rowfield])) { + else if (empty($row[$rowfield]) && is_null($row[$rowfield])) { $row[$rowfield] = date('Y-m-d H:i:s', time()); - } // end if... else if... else if... + } // end if... else if... } - $len = (eregi('float|double', $row_table_def['Type'])) + $len = (preg_match('@float|double@', $row_table_def['Type'])) ? 100 : @mysql_field_len($result, $i); $first_timestamp = 0; @@ -267,9 +263,9 @@ for ($i = 0; $i < $fields_cnt; $i++) { echo "\n"; // The type column - $is_binary = eregi(' binary', $row_table_def['Type']); - $is_blob = eregi('blob', $row_table_def['Type']); - $is_char = eregi('char', $row_table_def['Type']); + $is_binary = stristr($row_table_def['Type'], ' binary'); + $is_blob = stristr($row_table_def['Type'], 'blob'); + $is_char = stristr($row_table_def['Type'], 'car'); switch ($row_table_def['True_Type']) { case 'set': $type = 'set'; @@ -377,7 +373,8 @@ for ($i = 0; $i < $fields_cnt; $i++) { $op_spacing_needed = FALSE; // garvin: loop on the dropdown array and print all available options for that field. - for ($j = 0; $j < count($dropdown); $j++) { + $cnt_dropdown = count($dropdown); + for ($j = 0; $j < $cnt_dropdown; $j++) { // Is current function defined as default? $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp']) || (!$first_timestamp && $dropdown[$j] == $default_function) @@ -392,7 +389,8 @@ for ($i = 0; $i < $fields_cnt; $i++) { // garvin: For compatibility's sake, do not let out all other functions. Instead // print a seperator (blank) and then show ALL functions which weren't shown // yet. - for ($j = 0; $j < count($cfg['Functions']); $j++) { + $cnt_functions = count($cfg['Functions']); + for ($j = 0; $j < $cnt_functions; $j++) { if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') { // Is current function defined as default? $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp']) diff --git a/tbl_create.php b/tbl_create.php index 802c0bd65b..d872f64f24 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -85,8 +85,8 @@ if (isset($submit)) { } // end for unset($field_cnt); unset($query); - $sql_query = ereg_replace(', $', '', $sql_query); - $query_cpy = ereg_replace(', $', '', $query_cpy); + $sql_query = preg_replace('@, $@', '', $sql_query); + $query_cpy = preg_replace('@, $@', '', $query_cpy); // Builds the primary keys statements $primary = ''; @@ -98,7 +98,7 @@ if (isset($submit)) { } } // end for unset($primary_cnt); - $primary = ereg_replace(', $', '', $primary); + $primary = preg_replace('@, $@', '', $primary); if (!empty($primary)) { $sql_query .= ', PRIMARY KEY (' . $primary . ')'; $query_cpy .= ',' . "\n" . ' PRIMARY KEY (' . $primary . ')'; @@ -115,7 +115,7 @@ if (isset($submit)) { } } // end for unset($index_cnt); - $index = ereg_replace(', $', '', $index); + $index = preg_replace('@, $@', '', $index); if (!empty($index)) { $sql_query .= ', INDEX (' . $index . ')'; $query_cpy .= ',' . "\n" . ' INDEX (' . $index . ')'; @@ -132,7 +132,7 @@ if (isset($submit)) { } } // end for unset($unique_cnt); - $unique = ereg_replace(', $', '', $unique); + $unique = preg_replace('@, $@', '', $unique); if (!empty($unique)) { $sql_query .= ', UNIQUE (' . $unique . ')'; $query_cpy .= ',' . "\n" . ' UNIQUE (' . $unique . ')'; @@ -149,7 +149,7 @@ if (isset($submit)) { } } // end for - $fulltext = ereg_replace(', $', '', $fulltext); + $fulltext = preg_replace('@, $@', '', $fulltext); if (!empty($fulltext)) { $sql_query .= ', FULLTEXT (' . $fulltext . ')'; $query_cpy .= ',' . "\n" . ' FULLTEXT (' . $fulltext . ')'; @@ -169,7 +169,8 @@ if (isset($submit)) { $sql_query .= ' CHARACTER SET = ' . $tbl_charset; $query_cpy .= "\n" . 'CHARACTER SET = ' . $tbl_charset; } - if (PMA_MYSQL_INT_VERSION >= 32300 && !empty($comment)) { + + if (!empty($comment)) { $sql_query .= ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\''; $query_cpy .= "\n" . 'COMMENT = \'' . PMA_sqlAddslashes($comment) . '\''; } @@ -191,16 +192,14 @@ if (isset($submit)) { // garvin: Update comment table, if a comment was set. if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { - @reset($field_comments); - while(list($fieldindex, $fieldcomment) = each($field_comments)) { + foreach($field_comments AS $fieldindex => $fieldcomment) { PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment); } } // garvin: Update comment table for mime types [MIME] if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { - @reset($field_mimetype); - while(list($fieldindex, $mimetype) = each($field_mimetype)) { + foreach($field_mimetype AS $fieldindex => $mimetype) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); } } diff --git a/tbl_indexes.php b/tbl_indexes.php index 2dc7b9334e..cd536fcee3 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -17,17 +17,13 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')) { /** * Defines the index types ("FULLTEXT" is available since MySQL 3.23.23) */ -$index_types_cnt = 3; +$index_types_cnt = 4; $index_types = array( 'PRIMARY', 'INDEX', - 'UNIQUE' + 'UNIQUE', + 'FULLTEXT' ); -if (PMA_MYSQL_INT_VERSION >= 32323) { - $index_types[] = 'FULLTEXT'; - $index_types_cnt++; -} - /** * Ensures the db & table are valid, then loads headers and gets indexes @@ -130,8 +126,8 @@ $fields_types = array(); while ($row = PMA_mysql_fetch_array($fields_rs)) { $fields_names[] = $row['Field']; // loic1: set or enum types: slashes single quotes inside options - if (eregi('^(set|enum)\((.+)\)$', $row['Type'], $tmp)) { - $tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1); + if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) { + $tmp[2] = substr(preg_replace('@([^,])\'\@', '\\1\\\'', ',' . $tmp[2]), 1); $fields_types[] = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; } else { $fields_types[] = $row['Type']; @@ -196,7 +192,7 @@ if (!defined('PMA_IDX_INCLUDED') break; } // end switch $index_fields = ''; - while (list($i, $name) = each($column)) { + foreach($column AS $i => $name) { if ($name != '--ignore--') { $index_fields .= (empty($index_fields) ? '' : ',') . PMA_backquote($name) @@ -251,7 +247,7 @@ else if (!defined('PMA_IDX_INCLUDED') $edited_index_data = $indexes_data[$old_index]; - if ((PMA_MYSQL_INT_VERSION >= 32323 && PMA_MYSQL_INT_VERSION < 40002 && $edited_index_info['Comment'] == 'FULLTEXT') + if ((PMA_MYSQL_INT_VERSION < 40002 && $edited_index_info['Comment'] == 'FULLTEXT') || (PMA_MYSQL_INT_VERSION >= 40002 && $edited_index_info['Index_type'] == 'FULLTEXT')) { $index_type = 'FULLTEXT'; } else if ($index == 'PRIMARY') { @@ -274,7 +270,7 @@ else if (!defined('PMA_IDX_INCLUDED') } // end for // Restore entered values - while (list($i, $name) = each($column)) { + foreach($column AS $i => $name) { if ($name != '--ignore--'){ $edited_index_data[$i+1]['Column_name'] = $name; $edited_index_data[$i+1]['Sub_part'] = $sub_part[$i]; @@ -339,7 +335,7 @@ else if (!defined('PMA_IDX_INCLUDED') <th><?php echo $strSize; ?></th> </tr> <?php - while (list($row_no, $seq_index) = each($edited_index_info['Sequences'])) { + foreach($edited_index_info['Sequences'] AS $row_no => $seq_index) { $add_type = (is_array($fields_types) && count($fields_types) == count($fields_names)); $selected = $edited_index_data[$seq_index]['Column_name']; if (!empty($edited_index_data[$seq_index]['Sub_part'])) { @@ -357,9 +353,9 @@ else if (!defined('PMA_IDX_INCLUDED') -- <?php echo $strIgnore; ?> --</option> <?php reset($fields_names); - while (list($key, $val) = each($fields_names)) { + foreach($fields_names AS $key => $val) { if ($index_type != 'FULLTEXT' - || eregi('^(varchar|text|tinytext|mediumtext|longtext)', $fields_types[$key])) { + || preg_match('@^(varchar|text|tinytext|mediumtext|longtext)@i', $fields_types[$key])) { echo "\n" . ' ' . '<option value="' . htmlspecialchars($val) . '"' . (($val == $selected) ? ' selected="selected"' : '') . '>' . htmlspecialchars($val) . (($add_type) ? ' [' . $fields_types[$key] . ']' : '' ) . '</option>' . "\n"; @@ -419,7 +415,7 @@ else if (!defined('PMA_IDX_INCLUDED') </tr> <?php echo "\n"; - while (list($index_no, $index_name) = each($indexes)) { + foreach($indexes AS $index_no => $index_name) { $cell_bgd = (($index_no % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']); $index_td = ' <td bgcolor="' . $cell_bgd . '" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n"; echo ' <tr>' . "\n"; @@ -427,7 +423,7 @@ else if (!defined('PMA_IDX_INCLUDED') . ' ' . htmlspecialchars($index_name) . "\n" . ' </td>' . "\n"; - if ((PMA_MYSQL_INT_VERSION >= 32323 && PMA_MYSQL_INT_VERSION < 40002 && $indexes_info[$index_name]['Comment'] == 'FULLTEXT') + if ((PMA_MYSQL_INT_VERSION < 40002 && $indexes_info[$index_name]['Comment'] == 'FULLTEXT') || (PMA_MYSQL_INT_VERSION >= 40002 && $indexes_info[$index_name]['Index_type'] == 'FULLTEXT')) { $index_type = 'FULLTEXT'; } else if ($index_name == 'PRIMARY') { @@ -462,7 +458,7 @@ else if (!defined('PMA_IDX_INCLUDED') . ' <a href="sql.php?' . $url_query . '&sql_query=' . $local_query . '&zero_rows=' . $zero_rows . '" onclick="return confirmLink(this, \'' . $js_msg . '\')">' . ($cfg['PropertiesIconic'] ? '<img src="./images/button_drop.png" width="11" height="12" hspace="7" border="0" title="' . $strDrop . '" alt="' . $strDrop . '">' : $strDrop) . '</a>' . "\n" . ' </td>' . "\n"; - while (list($row_no, $seq_index) = each($indexes_info[$index_name]['Sequences'])) { + foreach($indexes_info[$index_name]['Sequences'] AS $row_no => $seq_index) { if ($row_no > 0) { echo ' <tr>' . "\n"; } diff --git a/tbl_move_copy.php b/tbl_move_copy.php index 995940d505..f42c0bad45 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -27,7 +27,7 @@ function PMA_myHandler($sql_insert = '') global $db, $table, $target; global $sql_insert_data; - $sql_insert = eregi_replace('INSERT INTO (`?)' . $table . '(`?)', 'INSERT INTO ' . $target, $sql_insert); + $sql_insert = preg_replace('~INSERT INTO (`?)' . $table . '(`?)~i', 'INSERT INTO ' . $target, $sql_insert); $result = PMA_mysql_query($sql_insert) or PMA_mysqlDie('', $sql_insert, '', $GLOBALS['err_url']); $sql_insert_data .= $sql_insert . ';' . "\n"; @@ -60,21 +60,19 @@ global $cfgRelation; @reset($get_fields); $select_parts = array(); $row_fields = array(); - while(list($nr, $get_field) = each($get_fields)) { + foreach($get_fields AS $nr => $get_field) { $select_parts[] = PMA_backquote($get_field); $row_fields[$get_field] = 'cc'; } - @reset($where_fields); $where_parts = array(); - while(list($_where, $_value) = each($where_fields)) { + foreach($where_fields AS $_where => $_value) { $where_parts[] = PMA_backquote($_where) . ' = \'' . PMA_sqlAddslashes($_value) . '\''; } - @reset($new_fields); $new_parts = array(); $new_value_parts = array(); - while(list($_where, $_value) = each($new_fields)) { + foreach($new_fields AS $_where => $_value) { $new_parts[] = PMA_backquote($_where); $new_value_parts[] = PMA_sqlAddslashes($_value); } @@ -86,7 +84,7 @@ global $cfgRelation; while ($table_copy_row = @PMA_mysql_fetch_array($table_copy_rs)) { $value_parts = array(); - while(list($_key, $_val) = each($table_copy_row)) { + foreach($table_copy_row AS $_key => $_val) { if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') { $value_parts[] = PMA_sqlAddslashes($_val); } diff --git a/tbl_printview.php b/tbl_printview.php index 8b218c552d..b5de87e47e 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -54,7 +54,7 @@ $multi_tables = (count($the_tables) > 1); if ($multi_tables) { $tbl_list = ''; - while (list($key, $table) = each($the_tables)) { + foreach($the_tables AS $key => $table) { $tbl_list .= (empty($tbl_list) ? '' : ', ') . PMA_backquote(urldecode($table)); } @@ -63,10 +63,9 @@ if ($multi_tables) { } // end if $tables_cnt = count($the_tables); -reset($the_tables); $counter = 0; -while (list($key, $table) = each($the_tables)) { +foreach($the_tables AS $key => $table) { $table = urldecode($table); if ($counter + 1 >= $tables_cnt) { $breakstyle = ''; @@ -80,20 +79,11 @@ while (list($key, $table) = each($the_tables)) { /** * Gets table informations */ - // The 'show table' statement works correct since 3.23.03 - if (PMA_MYSQL_INT_VERSION >= 32303) { - $local_query = 'SHOW TABLE STATUS 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_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); - $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); - } else { - $local_query = 'SELECT COUNT(*) AS count FROM ' . PMA_backquote($table); - $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); - $showtable = array(); - $num_rows = PMA_mysql_result($result, 0, 'count'); - $show_comment = ''; - } // end display comments + $local_query = 'SHOW TABLE STATUS 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_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); + $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); if ($result) { mysql_free_result($result); } @@ -210,8 +200,8 @@ while (list($key, $table) = each($the_tables)) { $type = $row['Type']; // reformat mysql query output - staybyte - 9. June 2001 // loic1: set or enum types: slashes single quotes inside options - if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) { - $tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1); + if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { + $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1); $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type_nowrap = ''; @@ -220,16 +210,16 @@ while (list($key, $table) = each($the_tables)) { $zerofill = 0; } else { $type_nowrap = ' nowrap="nowrap"'; - $type = eregi_replace('BINARY', '', $type); - $type = eregi_replace('ZEROFILL', '', $type); - $type = eregi_replace('UNSIGNED', '', $type); + $type = preg_replace('@BINARY@i', '', $type); + $type = preg_replace('@ZEROFILL@i', '', $type); + $type = preg_replace('@UNSIGNED@i', '', $type); if (empty($type)) { $type = ' '; } - $binary = eregi('BINARY', $row['Type'], $test); - $unsigned = eregi('UNSIGNED', $row['Type'], $test); - $zerofill = eregi('ZEROFILL', $row['Type'], $test); + $binary = stristr($row['Type'], 'binary'); + $unsigned = stristr($row['Type'], 'unsigned'); + $zerofill = stristr($row['Type'], 'zerofill'); } $strAttribute = ' '; if ($binary) { @@ -326,7 +316,7 @@ while (list($key, $table) = each($the_tables)) { </tr> <?php echo "\n"; - while (list($index_no, $index_name) = each($indexes)) { + foreach($indexes AS $index_no => $index_name) { $cell_bgd = (($index_no % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']); $index_td = ' <td class="print" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n"; echo ' <tr>' . "\n"; @@ -351,7 +341,7 @@ while (list($key, $table) = each($the_tables)) { . ' ' . (isset($indexes_info[$index_name]['Cardinality']) ? $indexes_info[$index_name]['Cardinality'] : $strNone) . "\n" . ' </td>' . "\n"; - while (list($row_no, $seq_index) = each($indexes_info[$index_name]['Sequences'])) { + foreach($indexes_info[$index_name]['Sequences'] AS $row_no => $seq_index) { if ($row_no > 0) { echo ' <tr>' . "\n"; } @@ -386,10 +376,10 @@ while (list($key, $table) = each($the_tables)) { */ if ($cfg['ShowStats']) { $nonisam = FALSE; - if (isset($showtable['Type']) && !eregi('ISAM|HEAP', $showtable['Type'])) { + if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) { $nonisam = TRUE; } - if (PMA_MYSQL_INT_VERSION >= 32303 && $nonisam == FALSE) { + if ($nonisam == FALSE) { // Gets some sizes $mergetable = FALSE; if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') { @@ -605,7 +595,7 @@ while (list($key, $table) = each($the_tables)) { </table> <?php - } // end if (PMA_MYSQL_INT_VERSION >= 32303 && $nonisam == FALSE) + } // end if ($nonisam == FALSE) } // end if ($cfg['ShowStats']) echo "\n"; diff --git a/tbl_properties.inc.php b/tbl_properties.inc.php index e6ec5a9869..6931ecc51c 100644 --- a/tbl_properties.inc.php +++ b/tbl_properties.inc.php @@ -55,8 +55,7 @@ if (isset($after_field)) { } if (isset($selected) && is_array($selected)) { - @reset($selected); - while(list($o_fld_nr, $o_fld_val) = each($selected)) { + foreach($selected AS $o_fld_nr => $o_fld_val) { ?> <input type="hidden" name="selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" /> <?php @@ -69,8 +68,7 @@ if (isset($selected) && is_array($selected)) { } if (isset($true_selected) && is_array($true_selected)) { - @reset($true_selected); - while(list($o_fld_nr, $o_fld_val) = each($true_selected)) { + foreach($true_selected AS $o_fld_nr => $o_fld_val) { ?> <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" /> <?php @@ -139,8 +137,7 @@ if (!$is_backup) { // the index as a value, not a key. Inserted here for easier maintaineance // and less code to change in existing files. if (isset($field_fulltext) && is_array($field_fulltext)) { - @reset($field_fulltext); - while(list($fulltext_nr, $fulltext_indexkey) = each($field_fulltext)) { + foreach($field_fulltext AS $fulltext_nr => $fulltext_indexkey) { $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey; } } @@ -222,13 +219,13 @@ for ($i = 0 ; $i < $num_fields; $i++) { $type = $row['Type']; } // set or enum types: slashes single quotes inside options - if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) { + if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { $type = $tmp[1]; - $length = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1); + $length = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1); } else { - $type = eregi_replace('BINARY', '', $type); - $type = eregi_replace('ZEROFILL', '', $type); - $type = eregi_replace('UNSIGNED', '', $type); + $type = preg_replace('@BINARY@i', '', $type); + $type = preg_replace('@ZEROFILL@i', '', $type); + $type = preg_replace('@UNSIGNED@i', '', $type); if (strpos($type, '(')) { $length = chop(substr($type, (strpos($type, '(') + 1), (strpos($type, ')') - strpos($type, '(') - 1))); @@ -243,7 +240,7 @@ for ($i = 0 ; $i < $num_fields; $i++) { if (PMA_MYSQL_INT_VERSION >= 40100) { $tmp = strpos($type, 'character set'); if ($tmp) { - $type = substr($type,0,$tmp-1); + $type = substr($type, 0, $tmp-1); } } @@ -251,7 +248,8 @@ for ($i = 0 ; $i < $num_fields; $i++) { $length = $submit_length; } - for ($j = 0; $j < count($cfg['ColumnTypes']); $j++) { + $cnt_column_types = count($cfg['ColumnTypes']); + for ($j = 0; $j < $cnt_column_types; $j++) { $content_cells[$i][$ci] .= ' <option value="'. $cfg['ColumnTypes'][$j] . '"'; if (strtoupper($type) == strtoupper($cfg['ColumnTypes'][$j])) { $content_cells[$i][$ci] .= ' selected="selected"'; @@ -271,14 +269,14 @@ for ($i = 0 ; $i < $num_fields; $i++) { $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_length[]" size="8" value="' . str_replace('"', '"', $length) . '" class="textfield" />' . "\n"; $ci++; - if (eregi('^(set|enum)$', $type)) { + if (preg_match('@^(set|enum)$@i', $type)) { $binary = 0; $unsigned = 0; $zerofill = 0; } else { - $binary = eregi('BINARY', $row['Type'], $test_attribute1); - $unsigned = eregi('UNSIGNED', $row['Type'], $test_attribute2); - $zerofill = eregi('ZEROFILL', $row['Type'], $test_attribute3); + $binary = stristr($row['Type'], 'binary'); + $unsigned = stristr($row['Type'], 'unsigned'); + $zerofill = stristr($row['Type'], 'zerofill'); } if (PMA_MYSQL_INT_VERSION >= 40100) { @@ -324,7 +322,8 @@ for ($i = 0 ; $i < $num_fields; $i++) { $strAttribute = $submit_attribute; } - for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) { + $cnt_attribute_types = count($cfg['AttributeTypes']); + for ($j = 0;$j < $cnt_attribute_types; $j++) { $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"'; if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) { $content_cells[$i][$ci] .= ' selected="selected"'; @@ -392,8 +391,7 @@ for ($i = 0 ; $i < $num_fields; $i++) { $content_cells[$i][$ci] .= ' <option value="auto">auto-detect</option>' . "\n"; if (is_array($available_mime['mimetype'])) { - @reset($available_mime['mimetype']); - while(list($mimekey, $mimetype) = each($available_mime['mimetype'])) { + foreach($available_mime['mimetype'] AS $mimekey => $mimetype) { $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : ''); $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>'; } @@ -405,8 +403,7 @@ for ($i = 0 ; $i < $num_fields; $i++) { $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[]">' . "\n"; $content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>' . "\n"; if (is_array($available_mime['transformation'])) { - @reset($available_mime['transformation']); - while(list($mimekey, $transform) = each($available_mime['transformation'])) { + foreach($available_mime['transformation'] AS $mimekey => $transform) { $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation']) && ($mime_map[$row['Field']]['transformation'] == $available_mime['transformation_file'][$mimekey]) ? 'selected ' : ''); $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey])); $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()'); @@ -446,8 +443,7 @@ for ($i = 0 ; $i < $num_fields; $i++) { $checked_none = ''; } - if (PMA_MYSQL_INT_VERSION >= 32323 - &&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) { + if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) { $checked_fulltext = ' checked="checked"'; } else { $checked_fulltext = ''; @@ -465,9 +461,7 @@ for ($i = 0 ; $i < $num_fields; $i++) { $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' . $checked_none . ' />'; $ci++; - if (PMA_MYSQL_INT_VERSION >= 32323) { - $content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' />'; - } // end if (PMA_MYSQL_INT_VERSION >= 32323) + $content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' />'; } // end if ($action ==...) } // end for @@ -476,30 +470,35 @@ if ($cfg['DefaultPropDisplay'] == 'horizontal') { <table border="<?php echo $cfg['Border']; ?>"> <tr> <?php -@reset($header_cells); -while(@list($header_nr, $header_val) = @each($header_cells)) { + if (is_array($header_cells)) { + foreach($header_cells AS $header_nr => $header_val) { ?> <th><?php echo $header_val; ?></th> <?php -} + } + } ?> </tr> <?php -@reset($content_cells); -$i = 0; -while(@list($content_nr, $content_row) = @each($content_cells)) { - $i++; - echo "\n" . '<tr>' . "\n"; - - $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; - - while(list($content_row_nr, $content_row_val) = @each($content_row)) { + if (is_array($content_cells)) { + $i = 0; + foreach($content_cells AS $content_nr => $content_row) { + $i++; + echo "\n" . '<tr>' . "\n"; + + $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; + + if (is_array($content_row)) { + foreach($content_row AS $content_row_nr => $content_row_val) { ?> <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $content_row_val; ?></td> <?php + } + } + + echo "\n" . '</tr>' . "\n"; + } } - echo "\n" . '</tr>' . "\n"; -} ?> </table> <br /> @@ -508,14 +507,15 @@ while(@list($content_nr, $content_row) = @each($content_cells)) { ?> <table border="<?php echo $cfg['Border']; ?>"> <?php -@reset($header_cells); -$i = 0; -while(@list($header_nr, $header_val) = @each($header_cells)) { - echo "\n" . '<tr>' . "\n"; + if (is_array($header_cells)) { + $i = 0; + foreach($header_cells AS $header_nr => $header_val) { + echo "\n" . '<tr>' . "\n"; ?> <th align="right"><?php echo $header_val; ?></th> <?php - for ($j = 0; $j < count($content_cells); $j++) { + $cnt_content_cells = count($content_cells); + for ($j = 0; $j < $cnt_content_cells; $j++) { if (isset($content_cells[$j][$i]) && $content_cells[$j][$i] != '') { $bgcolor = ($j % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?> @@ -526,14 +526,15 @@ while(@list($header_nr, $header_val) = @each($header_cells)) { echo "\n" . '</tr>' . "\n"; $i++; -} + } + } ?> </table> <br /> <?php } -if ($action == 'tbl_create.php' && PMA_MYSQL_INT_VERSION >= 32300) { +if ($action == 'tbl_create.php') { echo "\n"; ?> <table> diff --git a/tbl_properties.php b/tbl_properties.php index d97f214416..0d4749a86e 100644 --- a/tbl_properties.php +++ b/tbl_properties.php @@ -36,4 +36,4 @@ require('./tbl_query_box.php'); */ echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/tbl_properties_common.php b/tbl_properties_common.php index c278da3c76..8b7b0a6829 100644 --- a/tbl_properties_common.php +++ b/tbl_properties_common.php @@ -49,4 +49,4 @@ if (!isset($message)) { */ $url_query = PMA_generate_common_url($db, $table); -?> +?>
\ No newline at end of file diff --git a/tbl_properties_export.php b/tbl_properties_export.php index c1c091c2a9..37fba3c82d 100644 --- a/tbl_properties_export.php +++ b/tbl_properties_export.php @@ -63,4 +63,4 @@ require('./libraries/display_export.lib.php'); * Displays the footer */ require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/tbl_properties_links.php b/tbl_properties_links.php index 24f527110e..94e2385ef2 100644 --- a/tbl_properties_links.php +++ b/tbl_properties_links.php @@ -90,4 +90,3 @@ if (!$cfg['LightTabs']) { } ?><br /> - diff --git a/tbl_properties_operations.php b/tbl_properties_operations.php index d2993d2f59..033246edb1 100644 --- a/tbl_properties_operations.php +++ b/tbl_properties_operations.php @@ -106,8 +106,7 @@ if (PMA_MYSQL_INT_VERSION >= 32334) { <select name="order_field" style="vertical-align: middle"> <?php echo "\n"; - reset($columns); - while (list($junk, $fieldname) = each($columns)) { + foreach($columns AS $junk => $fieldname) { echo ' <option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n"; } unset($columns); @@ -219,8 +218,6 @@ for ($i = 0; $i < $num_dbs; $i++) { } // endif if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') { $pma_switch_to_new = 'true'; - } elseif (isset($HTTP_COOKIE_VARS) && isset($HTTP_COOKIE_VARS['pma_switch_to_new']) && $HTTP_COOKIE_VARS['pma_switch_to_new'] == 'true') { - $pma_switch_to_new = 'true'; } ?> <input type="checkbox" name="switch_to_new" value="true" id="checkbox_switch" <?php echo ((isset($pma_switch_to_new) && $pma_switch_to_new == 'true') ? 'checked="checked"' : ''); ?>/> @@ -239,69 +236,53 @@ for ($i = 0; $i < $num_dbs; $i++) { <?php echo $strTableMaintenance; ?> <ul> <?php -if (PMA_MYSQL_INT_VERSION >= 32322) { - if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB' || $tbl_type == 'INNODB') { - echo "\n"; - if ($tbl_type == 'MYISAM' || $tbl_type == 'INNODB') { - ?> - <li> - <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>"> - <?php echo $strCheckTable; ?></a> - <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?> - </li> - <?php - } - echo "\n"; - if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB') { - ?> - <li> - <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>"> - <?php echo $strAnalyzeTable; ?></a> - <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?> - </li> - <?php - } - echo "\n"; - if ($tbl_type == 'MYISAM') { - ?> - <li> - <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>"> - <?php echo $strRepairTable; ?></a> - <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?> - </li> - <?php - } - echo "\n"; - if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB') { - ?> - <li> - <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"> - <?php echo $strOptimizeTable; ?></a> - <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?> - </li> - <?php - } - echo "\n"; +if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB' || $tbl_type == 'INNODB') { + echo "\n"; + if ($tbl_type == 'MYISAM' || $tbl_type == 'INNODB') { ?> + <li> + <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>"> + <?php echo $strCheckTable; ?></a> + <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?> + </li> <?php - } // end MYISAM or BERKELEYDB case + } echo "\n"; -} // end MySQL >= 3.23.22 - -// loic1: "OPTIMIZE" statement is available for MyISAM and BERKELEYDB tables only and -// MyISAM/BERKELEYDB tables exists since MySQL 3.23.06/3.23.34 -else if (PMA_MYSQL_INT_VERSION >= 32306 - && ($tbl_type == 'MYISAM' or $tbl_type == 'BERKELEYDB')) { - ?> - <li> - <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"> + if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB') { + ?> + <li> + <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>"> + <?php echo $strAnalyzeTable; ?></a> + <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?> + </li> + <?php + } + echo "\n"; + if ($tbl_type == 'MYISAM') { + ?> + <li> + <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>"> + <?php echo $strRepairTable; ?></a> + <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?> + </li> + <?php + } + echo "\n"; + if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB') { + ?> + <li> + <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"> <?php echo $strOptimizeTable; ?></a> - <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?> - </li> - <?php + <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?> + </li> + <?php + } echo "\n"; -} // end 3.23.06 < MySQL < 3.23.22 ?> + <?php +} // end MYISAM or BERKELEYDB case +echo "\n"; +?> <li> <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('FLUSH TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenFlushed, htmlspecialchars($table))); if ($cfg['ShowTooltip']) echo '&reload=1'; ?>"> <?php echo $strFlushTable; ?></a> @@ -330,7 +311,7 @@ if ($cfgRelation['relwork'] && $tbl_type != "INNODB") { <?php echo $strReferentialIntegrity; ?><br /> <?php echo "\n"; - while (list($master, $arr) = each($foreign)){ + foreach($foreign AS $master => $arr) { $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM ' . PMA_backquote($table) . ' LEFT JOIN ' . PMA_backquote($arr['foreign_table']); @@ -374,8 +355,7 @@ if ($cfgRelation['relwork'] && $tbl_type != "INNODB") { /** * Displays form controls */ -if (PMA_MYSQL_INT_VERSION >= 32322) { - ?> +?> <!-- Table comments --> <li> <form method="post" action="tbl_properties_operations.php"> @@ -524,8 +504,7 @@ if (PMA_MYSQL_INT_VERSION >= 32322) { </table> </li> </ul> - <?php -} // end if (PMA_MYSQL_INT_VERSION >= 32322) +<?php /** * Displays the footer diff --git a/tbl_properties_structure.php b/tbl_properties_structure.php index 5eebeec10c..60fc65dd82 100644 --- a/tbl_properties_structure.php +++ b/tbl_properties_structure.php @@ -94,7 +94,7 @@ $fields_cnt = mysql_num_rows($fields_rs); <th><?php echo $strNull; ?></th> <th><?php echo $strDefault; ?></th> <th><?php echo $strExtra; ?></th> - <th colspan="<?php echo((PMA_MYSQL_INT_VERSION >= 32323) ? '6' : '5'); ?>"><?php echo $strAction; ?></th> + <th colspan="6"><?php echo $strAction; ?></th> </tr> <?php @@ -129,8 +129,8 @@ while ($row = PMA_mysql_fetch_array($fields_rs)) { $type = $row['Type']; // reformat mysql query output - staybyte - 9. June 2001 // loic1: set or enum types: slashes single quotes inside options - if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) { - $tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1); + if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { + $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1); $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type_nowrap = ''; @@ -139,16 +139,16 @@ while ($row = PMA_mysql_fetch_array($fields_rs)) { $zerofill = 0; } else { $type_nowrap = ' nowrap="nowrap"'; - $type = eregi_replace('BINARY', '', $type); - $type = eregi_replace('ZEROFILL', '', $type); - $type = eregi_replace('UNSIGNED', '', $type); + $type = preg_replace('@BINARY@i', '', $type); + $type = preg_replace('@ZEROFILL@i', '', $type); + $type = preg_replace('@UNSIGNED@i', '', $type); if (empty($type)) { $type = ' '; } - $binary = eregi('BLOB', $row['Type'], $test) || eregi('BINARY', $row['Type'], $test); - $unsigned = eregi('UNSIGNED', $row['Type'], $test); - $zerofill = eregi('ZEROFILL', $row['Type'], $test); + $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary'); + $unsigned = stristr($row['Type'], 'unsigned'); + $zerofill = stristr($row['Type'], 'zerofill'); } // rabus: Devide charset from the rest of the type definition (MySQL >= 4.1) @@ -342,7 +342,6 @@ while ($row = PMA_mysql_fetch_array($fields_rs)) { ?> </td> <?php - if (PMA_MYSQL_INT_VERSION >= 32323) { if ((!empty($tbl_type) && $tbl_type == 'MYISAM') && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'varchar'))) { echo "\n"; @@ -354,13 +353,12 @@ while ($row = PMA_mysql_fetch_array($fields_rs)) { <?php } else { echo "\n"; - ?> + ?> <td align="center" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"> <?php echo $titles['NoIdxFulltext'] . "\n"; ?> </td> - <?php + <?php } // end if... else... - } // end if echo "\n" ?> </tr> @@ -374,7 +372,7 @@ $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db,$t ?> <tr> - <td colspan="<?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '14' : (PMA_MYSQL_INT_VERSION >= 32323 ? '13' : '12'); ?>"> + <td colspan="<?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '14' : '13'; ?>"> <table> <tr> <td> @@ -471,10 +469,10 @@ require ('./tbl_indexes.php'); if ($cfg['ShowStats']) { $nonisam = FALSE; $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB'); - if (isset($showtable['Type']) && !eregi('ISAM|HEAP', $showtable['Type'])) { + if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) { $nonisam = TRUE; } - if (PMA_MYSQL_INT_VERSION >= 32303 && ($nonisam == FALSE || $is_innodb)) { + if ($nonisam == FALSE || $is_innodb) { // Gets some sizes $mergetable = FALSE; if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') { @@ -742,8 +740,7 @@ echo "\n"; <option value="--end--"><?php echo $strAtEndOfTable; ?></option> <option value="--first--"><?php echo $strAtBeginningOfTable; ?></option> <?php -reset($aryFields); -while (list($junk, $fieldname) = each($aryFields)) { +foreach($aryFields AS $junk => $fieldname) { echo ' <option value="' . htmlspecialchars($fieldname) . '">' . sprintf($strAfter, htmlspecialchars($fieldname)) . '</option>' . "\n"; } unset($aryFields); diff --git a/tbl_properties_table_info.php b/tbl_properties_table_info.php index 37704c5519..bd3ce4ff98 100644 --- a/tbl_properties_table_info.php +++ b/tbl_properties_table_info.php @@ -17,33 +17,25 @@ PMA_checkParameters(array('db', 'table')); * Gets table informations */ // The 'show table' statement works correct since 3.23.03 -if (PMA_MYSQL_INT_VERSION >= 32303) { - $local_query = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''; - $table_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - $showtable = PMA_mysql_fetch_array($table_info_result); - $tbl_type = strtoupper($showtable['Type']); - $tbl_charset = empty($showtable['Charset']) ? '' : $showtable['Charset']; - $table_info_num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); - $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); - $auto_increment = (isset($showtable['Auto_increment']) ? $showtable['Auto_increment'] : ''); - - $tmp = explode(' ', $showtable['Create_options']); - $tmp_cnt = count($tmp); - for ($i = 0; $i < $tmp_cnt; $i++) { - $tmp1 = explode('=', $tmp[$i]); - if (isset($tmp1[1])) { - $$tmp1[0] = $tmp1[1]; - } - } // end for - unset($tmp1); - unset($tmp); -} else { - $local_query = 'SELECT COUNT(*) AS count FROM ' . PMA_backquote($table); - $table_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - $showtable = array(); - $table_info_num_rows = PMA_mysql_result($table_info_result, 0, 'count'); - $show_comment = ''; -} +$local_query = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''; +$table_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); +$showtable = PMA_mysql_fetch_array($table_info_result); +$tbl_type = strtoupper($showtable['Type']); +$tbl_charset = empty($showtable['Charset']) ? '' : $showtable['Charset']; +$table_info_num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); +$show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); +$auto_increment = (isset($showtable['Auto_increment']) ? $showtable['Auto_increment'] : ''); + +$tmp = explode(' ', $showtable['Create_options']); +$tmp_cnt = count($tmp); +for ($i = 0; $i < $tmp_cnt; $i++) { + $tmp1 = explode('=', $tmp[$i]); + if (isset($tmp1[1])) { + $$tmp1[0] = $tmp1[1]; + } +} // end for +unset($tmp1); +unset($tmp); mysql_free_result($table_info_result); diff --git a/tbl_query_box.php b/tbl_query_box.php index 2d2af52018..0c70f1bf09 100644 --- a/tbl_query_box.php +++ b/tbl_query_box.php @@ -37,18 +37,18 @@ unset($sql_query); */ $fields_cnt = 0; if (isset($db) && isset($table) && $table != '' && $db != '') { -$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db); -$result = @PMA_mysql_query($local_query); -if (!$result) { - PMA_mysqlDie('', $local_query, '', $err_url); -} -else { - $fields_cnt = mysql_num_rows($result); - while ($row = PMA_mysql_fetch_array($result)) { - $fields_list[] = $row['Field']; - } // end while - mysql_free_result($result); -} + $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db); + $result = @PMA_mysql_query($local_query); + if (!$result) { + PMA_mysqlDie('', $local_query, '', $err_url); + } + else { + $fields_cnt = mysql_num_rows($result); + while ($row = PMA_mysql_fetch_array($result)) { + $fields_list[] = $row['Field']; + } // end while + mysql_free_result($result); + } } /** @@ -330,7 +330,7 @@ if (!isset($is_inside_querywindow) || echo ' <div style="margin-bottom: 5px">' . "\n"; echo ' <select name="id_bookmark" style="vertical-align: middle">' . "\n"; echo ' <option value=""></option>' . "\n"; - while (list($key, $value) = each($bookmark_list)) { + foreach($bookmark_list AS $key => $value) { echo ' <option value="' . $value . '">' . htmlspecialchars($key) . '</option>' . "\n"; } echo ' </select>' . "<br />\n"; diff --git a/tbl_relation.php b/tbl_relation.php index 6fd82f5ccd..e16ed3fcce 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -37,7 +37,7 @@ function PMA_generate_dropdown($dropdown_question,$radio_name,$choices,$selected echo '<select name="' . $radio_name . '" style="font-size: ' . $font_smallest . '">' . "\n"; echo '<option value="nix" style="font-size: ' . $font_smallest . '" >--</option>' . "\n"; - while (list($one_value, $one_label) = each($choices)) { + foreach($choices AS $one_value => $one_label) { echo '<option value="' . $one_value . '"'; if ($selected_value == $one_value) { echo ' selected="selected" '; @@ -73,7 +73,7 @@ if ($cfgRelation['relwork'] // u p d a t e s f o r I n t e r n a l r e l a t i o n s - while (list($master_field, $foreign_string) = each($destination)) { + foreach($destination AS $master_field => $foreign_string) { if ($foreign_string != 'nix') { list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string); if (!isset($existrel[$master_field])) { @@ -111,7 +111,7 @@ if ($cfgRelation['relwork'] // u p d a t e s f o r I n n o D B // ( for now, same db only, and one index name) if (isset($destination_innodb)) { - while (list($master_field, $foreign_string) = each($destination_innodb)) { + foreach($destination_innodb AS $master_field => $foreign_string) { if ($foreign_string != 'nix') { list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string); if (!isset($existrel_innodb[$master_field])) { @@ -222,7 +222,7 @@ if ($cfgRelation['displaywork'] if ($cfgRelation['commwork'] && isset($submit_comm) && $submit_comm == 'true') { - while (list($key, $value) = each($comment)) { + foreach($comment AS $key => $value) { // garvin: I exported the snippet here to a function (relation.lib.php) , so it can be used multiple times throughout other pages where you can set comments. PMA_setComment($db, $table, $key, $value); } // end while (transferred data) @@ -253,7 +253,7 @@ if ($cfgRelation['relwork']) { // and if PMA version permits and the main table is innodb, // we use SHOW TABLE STATUS because we need to find other InnoDB tables - if (PMA_MYSQL_INT_VERSION >= 32303 && $tbl_type=='INNODB') { + if ($tbl_type=='INNODB') { $tab_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); // [0] of the row is the name // [1] is the type @@ -285,7 +285,7 @@ if ($cfgRelation['relwork']) { // resulting value of SHOW KEYS is InnoDB if ($tbl_type=='INNODB' && isset($curr_table[1]) && $curr_table[1]=='InnoDB') { - $selectboxall_innodb[$field_full] = $field_v; + $selectboxall_innodb[$field_full] = $field_v; } } else if (isset($curr_field['Non_unique']) && $curr_field['Non_unique'] == 0 && $seen_a_primary==FALSE) { @@ -296,7 +296,7 @@ if ($cfgRelation['relwork']) { $field_v = $curr_field['Table'] . '->' . $curr_field['Column_name']; $selectboxall[$field_full] = $field_v; if ($tbl_type=='INNODB' && isset($curr_table[1]) && $curr_table[1]=='InnoDB') { - $selectboxall_innodb[$field_full] = $field_v; + $selectboxall_innodb[$field_full] = $field_v; } // for InnoDB, any index is allowed @@ -321,7 +321,7 @@ if ($cfgRelation['relwork']) { $field_v = $curr_field['Table'] . '->' . $curr_field['Column_name']; $selectboxall[$field_full] = $field_v; if ($tbl_type=='INNODB' && isset($curr_table[1]) && $curr_table[1]=='InnoDB') { - $selectboxall_innodb[$field_full] = $field_v; + $selectboxall_innodb[$field_full] = $field_v; } } // end while } // end if (mysql_num_rows) @@ -388,7 +388,7 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) { $foreign_field = FALSE; } $seen_key = FALSE; - while (list($key, $value) = each($selectboxall)) { + foreach($selectboxall AS $key => $value) { echo ' ' . '<option value="' . htmlspecialchars($key) . '"'; if ($foreign_field && $key == $foreign_field) { @@ -416,7 +416,6 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) { <td> <select name="destination_innodb[<?php echo htmlspecialchars($save_row[$i]['Field']); ?>]"> <?php - reset($selectboxall_innodb); if (isset($existrel_innodb[$myfield])) { $foreign_field = $existrel_innodb[$myfield]['foreign_db'] . '.' . $existrel_innodb[$myfield]['foreign_table'] . '.' @@ -424,7 +423,7 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) { } else { $foreign_field = FALSE; } - while (list($key, $value) = each($selectboxall_innodb)) { + foreach($selectboxall_innodb AS $key => $value) { echo ' ' . '<option value="' . htmlspecialchars($key) . '"'; if ($foreign_field && $key == $foreign_field) { diff --git a/tbl_rename.php b/tbl_rename.php index 2d34f15848..e69a034a51 100644 --- a/tbl_rename.php +++ b/tbl_rename.php @@ -103,4 +103,4 @@ else { * Back to the calling script */ require('./tbl_properties_operations.php'); -?> +?>
\ No newline at end of file diff --git a/tbl_replace.php b/tbl_replace.php index f72507ac0f..f432aef420 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -44,7 +44,7 @@ if (isset($after_insert) && $after_insert == 'new_insert') { . '&sql_query=' . urlencode($sql_query); } else if (!empty($goto)) { // Security checkings - $is_gotofile = ereg_replace('^([^?]+).*$', '\\1', $goto); + $is_gotofile = preg_replace('@^([^?]+).*$@', '\\1', $goto); if (!@file_exists('./' . $is_gotofile)) { $goto = (empty($table)) ? 'db_details.php' : 'tbl_properties.php'; $is_gotofile = TRUE; @@ -80,7 +80,7 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { // Defines the SET part of the sql query $valuelist = ''; - while (list($key, $val) = each($fields)) { + foreach($fields AS $key => $val) { $encoded_key = $key; $key = urldecode($key); @@ -96,7 +96,7 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { if (empty($funcs[$encoded_key])) { $valuelist .= PMA_backquote($key) . ' = ' . $val . ', '; } else if ($val == '\'\'' - && (ereg('^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$', $funcs[$encoded_key]))) { + && (preg_match('@^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$@', $funcs[$encoded_key]))) { $valuelist .= PMA_backquote($key) . ' = ' . $funcs[$encoded_key] . '(), '; } else { $valuelist .= PMA_backquote($key) . ' = ' . $funcs[$encoded_key] . "($val), "; @@ -105,11 +105,11 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { } // end while // Builds the sql update query - $valuelist = ereg_replace(', $', '', $valuelist); + $valuelist = preg_replace('@, $@', '', $valuelist); if (!empty($valuelist)) { PMA_mysql_select_db($db); $query = 'UPDATE ' . PMA_backquote($table) . ' SET ' . $valuelist . ' WHERE' . $primary_key - . ((PMA_MYSQL_INT_VERSION >= 32300) ? ' LIMIT 1' : ''); + . ' LIMIT 1'; $message = $strAffectedRows . ' '; } // No change -> move back to the calling script @@ -118,7 +118,7 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) { if ($is_gotofile) { $js_to_run = 'functions.js'; include('./header.inc.php'); - include('./' . ereg_replace('\.\.*', '.', $goto)); + include('./' . preg_replace('@\.\.*@', '.', $goto)); } else { header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto . '&disp_message=' . urlencode($message) . '&disp_query='); } @@ -143,7 +143,7 @@ else { $prot_row = PMA_mysql_fetch_array($prot_result); } - while (list($key, $val) = each($fields)) { + foreach($fields AS $key => $val) { $encoded_key = $key; $key = urldecode($key); $fieldlist .= PMA_backquote($key) . ', '; @@ -153,8 +153,8 @@ else { if (empty($funcs[$encoded_key])) { $valuelist .= $val . ', '; } else if (($val == '\'\'' - && ereg('^(UNIX_TIMESTAMP|RAND|LAST_INSERT_ID)$', $funcs[$encoded_key])) - || ereg('^(NOW|CURDATE|CURTIME|USER)$', $funcs[$encoded_key])) { + && preg_match('@^(UNIX_TIMESTAMP|RAND|LAST_INSERT_ID)$@', $funcs[$encoded_key])) + || preg_match('@^(NOW|CURDATE|CURTIME|USER)$@', $funcs[$encoded_key])) { $valuelist .= $funcs[$encoded_key] . '(), '; } else { $valuelist .= $funcs[$encoded_key] . '(' . $val . '), '; @@ -162,8 +162,8 @@ else { } // end while // Builds the sql insert query - $fieldlist = ereg_replace(', $', '', $fieldlist); - $valuelist = ereg_replace(', $', '', $valuelist); + $fieldlist = preg_replace('@, $@', '', $fieldlist); + $valuelist = preg_replace('@, $@', '', $valuelist); $query = 'INSERT INTO ' . PMA_backquote($table) . ' (' . $fieldlist . ') VALUES (' . $valuelist . ')'; $message = $strInsertedRows . ' '; } // end row insertion @@ -196,7 +196,7 @@ if (!$result) { $js_to_run = 'functions.js'; $active_page = $goto; include('./header.inc.php'); - include('./' . ereg_replace('\.\.*', '.', $goto)); + include('./' . preg_replace('@\.\.*@', '.', $goto)); } else { // I don't understand this one: //$add_query = (strpos(' ' . $goto, 'tbl_change') ? '&disp_query=' . urlencode($sql_query) : ''); diff --git a/tbl_replace_fields.php b/tbl_replace_fields.php index e95d48c092..0d3371eb79 100644 --- a/tbl_replace_fields.php +++ b/tbl_replace_fields.php @@ -28,18 +28,18 @@ PMA_checkParameters(array('db','encoded_key')); // binary file is uploaded, thus bypassing further manipulation of $val. $check_stop = false; -if (isset(${"fields_upload_" . $encoded_key}) && ${"fields_upload_" . $encoded_key} != 'none'){ +if (isset(${'fields_upload_' . $encoded_key}) && ${'fields_upload_' . $encoded_key} != 'none'){ // garvin: This fields content is a blob-file upload. - if (!empty(${"fields_upload_" . $encoded_key})) { + if (!empty(${'fields_upload_' . $encoded_key})) { // garvin: The blob-field is not empty. Check what we have there. - $data_file = ${"fields_upload_" . $encoded_key}; + $data_file = ${'fields_upload_' . $encoded_key}; if (is_uploaded_file($data_file)) { // garvin: A valid uploaded file is found. Look into the file... - $val = fread(fopen($data_file, "rb"), filesize($data_file)); + $val = fread(fopen($data_file, 'rb'), filesize($data_file)); // nijel: This is probably the best way how to put binary data // into MySQL and it also allow not to care about charset // conversion that would otherwise corrupt the data. @@ -62,16 +62,10 @@ if (isset(${"fields_upload_" . $encoded_key}) && ${"fields_upload_" . $encoded_k if (substr($cfg['UploadDir'], -1) != '/') { $cfg['UploadDir'] .= '/'; } - $file_to_upload = $cfg['UploadDir'] . eregi_replace('\.\.*', '.', ${'fields_uploadlocal_' . $encoded_key}); + $file_to_upload = $cfg['UploadDir'] . preg_replace('@\.\.*@', '.', ${'fields_uploadlocal_' . $encoded_key}); // A local file will be uploaded. - $open_basedir = ''; - if (PMA_PHP_INT_VERSION >= 40000) { - $open_basedir = @ini_get('open_basedir'); - } - if (empty($open_basedir)) { - $open_basedir = @get_cfg_var('open_basedir'); - } + $open_basedir = @ini_get('open_basedir'); // If we are on a server with open_basedir, we must move the file // before opening it. The doc explains how to create the "./tmp" @@ -88,11 +82,7 @@ if (isset(${"fields_upload_" . $encoded_key}) && ${"fields_upload_" . $encoded_k $file_to_upload = ''; } else { $new_file_to_upload = $tmp_subdir . basename($file_to_upload); - if (PMA_PHP_INT_VERSION < 40003) { - copy($file_to_upload, $new_file_to_upload); - } else { - move_uploaded_file($file_to_upload, $new_file_to_upload); - } + move_uploaded_file($file_to_upload, $new_file_to_upload); $file_to_upload = $new_file_to_upload; $unlink = true; @@ -101,7 +91,7 @@ if (isset(${"fields_upload_" . $encoded_key}) && ${"fields_upload_" . $encoded_k if ($file_to_upload != '') { - $val = fread(fopen($file_to_upload, "rb"), filesize($file_to_upload)); + $val = fread(fopen($file_to_upload, 'rb'), filesize($file_to_upload)); if (!empty($val)) { $val = '0x' . bin2hex($val); $seen_binary = TRUE; diff --git a/tbl_row_delete.php b/tbl_row_delete.php index db714a92a7..af5729b06a 100644 --- a/tbl_row_delete.php +++ b/tbl_row_delete.php @@ -64,4 +64,4 @@ include('./sql.php'); */ echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file diff --git a/tbl_select.php b/tbl_select.php index 4b5cf6f0ea..87310b0f84 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -68,11 +68,11 @@ if (!isset($param) || $param[0] == '') { // reformat mysql query output - staybyte - 9. June 2001 $shorttype = substr($type, 0, 3); if ($shorttype == 'set' || $shorttype == 'enu') { - $type = eregi_replace(',', ', ', $type); + $type = str_replace(',', ', ', $type); } else { - $type = eregi_replace('BINARY', '', $type); - $type = eregi_replace('ZEROFILL', '', $type); - $type = eregi_replace('UNSIGNED', '', $type); + $type = preg_replace('@BINARY@i', '', $type); + $type = preg_replace('@ZEROFILL@i', '', $type); + $type = preg_replace('@UNSIGNED@i', '', $type); } if (empty($type)) { $type = ' '; @@ -136,15 +136,13 @@ if (!isset($param) || $param[0] == '') { <td bgcolor="<?php echo $bgcolor; ?>"> <select name="func[]"> <?php - reset($numfunctions); - reset($textfunctions); - if (eregi('char|blob|text|set|enum', $fields_type[$i])) { - while (list($k, $fc) = each($textfunctions)) { + if (preg_match('@char|blob|text|set|enum@i', $fields_type[$i])) { + foreach($textfunctions AS $k => $fc) { echo "\n" . ' ' . '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>'; } // end while } else { - while (list($k, $fc) = each($numfunctions)) { + foreach($numfunctions AS $k => $fc) { echo "\n" . ' ' . '<option value="' . htmlspecialchars($fc) . '">' . htmlspecialchars($fc) . '</option>'; } // end while @@ -179,10 +177,11 @@ if (!isset($param) || $param[0] == '') { <?php } else if (substr($fields_type[$i], 0, 3)=='enu'){ // e n u m s - $enum_value=explode(", ",str_replace("'", "", substr($fields_type[$i], 5, -1))); + $enum_value=explode(', ', str_replace("'", '', substr($fields_type[$i], 5, -1))); echo ' <select name="fields[]">' . "\n"; echo ' <option value=""></option>' . "\n"; - for ($j=0; $j<count($enum_value);$j++){ + $cnt_enum_value = count($enum_value); + for ($j=0; $j<$cnt_enum_value;$j++){ echo ' <option value="' . $enum_value[$j] . '">' . $enum_value[$j] . '</option>'; } // end for echo ' </select>' . "\n"; @@ -266,9 +265,10 @@ else { } else { $sql_query .= ' WHERE 1'; - for ($i = 0; $i < count($fields); $i++) { + $cnt_fields = count($fields); + for ($i = 0; $i < $cnt_fields; $i++) { if (!empty($fields) && $fields[$i] != '') { - if (eregi('char|blob|text|set|enum|date|time|year', $types[$i])) { + if (preg_match('@char|blob|text|set|enum|date|time|year@i', $types[$i])) { $quot = '\''; } else { $quot = ''; diff --git a/transformation_wrapper.php b/transformation_wrapper.php index ca6a0abe64..4de99ec022 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -52,9 +52,8 @@ if ($cfgRelation['commwork'] && $cfgRelation['mimework']) { $mime_map = PMA_getMime($db, $table); $mime_options = PMA_transformation_getOptions((isset($mime_map[urldecode($transform_key)]['transformation_options']) ? $mime_map[urldecode($transform_key)]['transformation_options'] : '')); - @reset($mime_options); - while(list($key, $option) = each($mime_options)) { - if (eregi('^; charset=.*$', $option)) { + foreach($mime_options AS $key => $option) { + if (substr($option, 0, 10) == '; charset=') { $mime_options['charset'] = $option; } } @@ -66,7 +65,7 @@ if ($cfgRelation['commwork'] && $cfgRelation['mimework']) { include('./libraries/header_http.inc.php'); // [MIME] -$content_type = 'Content-Type: ' . (isset($mime_map[urldecode($transform_key)]['mimetype']) ? str_replace("_", "/", $mime_map[urldecode($transform_key)]['mimetype']) : $default_ct) . (isset($mime_options['charset']) ? $mime_options['charset'] : ''); +$content_type = 'Content-Type: ' . (isset($mime_map[urldecode($transform_key)]['mimetype']) ? str_replace('_', '/', $mime_map[urldecode($transform_key)]['mimetype']) : $default_ct) . (isset($mime_options['charset']) ? $mime_options['charset'] : ''); header($content_type); if (!isset($resize)) { @@ -102,10 +101,10 @@ if (!isset($resize)) { // better quality but slower: ImageCopyResampled( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight ); - if ($resize == "jpeg") { - ImageJPEG( $destImage,"",75 ); + if ($resize == 'jpeg') { + ImageJPEG( $destImage,'',75 ); } - if ($resize == "png") { + if ($resize == 'png') { ImagePNG( $destImage); } ImageDestroy( $srcImage ); diff --git a/user_password.php b/user_password.php index 765ac8970a..cb69506737 100644 --- a/user_password.php +++ b/user_password.php @@ -49,7 +49,7 @@ if (isset($nopass)) { $err_url = 'user_password.php?' . $common_url_query; - $sql_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . ereg_replace('.', '*', $pma_pw) . '\')'); + $sql_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . preg_replace('@.@', '*', $pma_pw) . '\')'); $local_query = 'SET password = ' . (($pma_pw == '') ? '\'\'' : 'PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')'); $result = @PMA_mysql_query($local_query) or PMA_mysqlDie('', '', FALSE, $err_url); @@ -137,4 +137,4 @@ $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5) */ echo "\n"; require('./footer.inc.php'); -?> +?>
\ No newline at end of file |