Skip to content

Commit

Permalink
Final batch of PHP3-Compatibility fixes. Please test. :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garvin Hicking committed Nov 22, 2003
1 parent 096094b commit c2b46ac
Show file tree
Hide file tree
Showing 66 changed files with 567 additions and 986 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ phpMyAdmin - Changelog
$Id$
$Source$

2003-11-22 Garvin Hicking <[email protected]>
* ./*: More PHP3-compatibility removal, see 2003-11-20.

2003-11-22 Marc Delisle <[email protected]>
* tbl_properties_operations.php: display "Add constraints" only
if there are foreign keys in current table
Expand Down
1 change: 0 additions & 1 deletion Documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -3443,7 +3443,6 @@ <h4>
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 &quot;/**/&quot;
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>
Expand Down
2 changes: 1 addition & 1 deletion browse_foreigners.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function formupdate(field, key) {
if ($i == $pageNow) {
$selected = 'selected="selected"';
} else {
$selected = "";
$selected = '';
}
$gotopage .= ' <option ' . $selected . ' value="' . (($i - 1) * $session_max_rows) . '">' . $i . '</option>' . "\n";
}
Expand Down
2 changes: 1 addition & 1 deletion chk_rel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
*/
echo "\n";
require('./footer.inc.php');
?>
?>
2 changes: 1 addition & 1 deletion db_create.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
$message = $strDatabase . ' ' . htmlspecialchars($db) . ' ' . $strHasBeenCreated;
require('./' . $cfg['DefaultTabDatabase']);

?>
?>
48 changes: 16 additions & 32 deletions db_datadict.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@
}
$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);
Expand All @@ -81,19 +76,11 @@
* 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);
}
Expand Down Expand Up @@ -130,10 +117,7 @@
// 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'])) {
Expand Down Expand Up @@ -214,22 +198,22 @@
$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 = '';

$binary = 0;
$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 = '&nbsp;';
}
Expand Down Expand Up @@ -334,4 +318,4 @@ function printPage()
echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";

require('./footer.inc.php');
?>
?>
4 changes: 2 additions & 2 deletions db_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
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";
Expand Down Expand Up @@ -201,4 +201,4 @@
*/
echo "\n";
require('./footer.inc.php');
?>
?>
2 changes: 1 addition & 1 deletion db_details_common.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
*/
$url_query = PMA_generate_common_url($db);

?>
?>
83 changes: 36 additions & 47 deletions db_details_db_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,67 +18,56 @@
*/
// 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
*/
echo '<!-- Top menu links -->' . "\n";
require('./db_details_links.php');

?>
?>
4 changes: 2 additions & 2 deletions db_details_export.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

$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 {
Expand Down Expand Up @@ -63,4 +63,4 @@
* Displays the footer
*/
require('./footer.inc.php');
?>
?>
31 changes: 7 additions & 24 deletions db_details_importdocsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
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();
Expand All @@ -64,8 +64,7 @@ function docsql_check($docpath = '', $file = '', $filename = '', $content = 'non
}

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) {
Expand Down Expand Up @@ -127,15 +126,9 @@ function docsql_check($docpath = '', $file = '', $filename = '', $content = 'non
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');
}
Expand Down Expand Up @@ -163,13 +156,7 @@ function docsql_check($docpath = '', $file = '', $filename = '', $content = 'non
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"
Expand All @@ -189,11 +176,7 @@ function docsql_check($docpath = '', $file = '', $filename = '', $content = 'non
}
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);
}
Expand All @@ -218,7 +201,7 @@ function docsql_check($docpath = '', $file = '', $filename = '', $content = 'non
} else {

// echo '<h1>Starting Import</h1>';
$docpath = $cfg['docSQLDir'] . eregi_replace('\.\.*', '.', $docpath);
$docpath = $cfg['docSQLDir'] . preg_replace('@\.\.*@', '.', $docpath);
if (substr($docpath, -1) != '/') {
$docpath .= '/';
}
Expand Down Expand Up @@ -318,4 +301,4 @@ function docsql_check($docpath = '', $file = '', $filename = '', $content = 'non
echo "\n";
require('./footer.inc.php');

?>
?>
1 change: 0 additions & 1 deletion db_details_links.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@
}
?>
<br />

Loading

0 comments on commit c2b46ac

Please sign in to comment.