diff --git a/db_readdump.php3 b/db_readdump.php3 index 61fd0d7ad..9e8e1cfc6 100755 --- a/db_readdump.php3 +++ b/db_readdump.php3 @@ -55,7 +55,7 @@ if ($sql_file != 'none') { } } } -else if (get_magic_quotes_gpc() == 1) { +else if (empty($id_bookmark) && get_magic_quotes_gpc() == 1) { $sql_query = stripslashes($sql_query); } $sql_query = trim($sql_query); @@ -97,9 +97,9 @@ if ($sql_query != '') { $a_sql_query = trim($pieces[$i]); if (!empty($a_sql_query) && $a_sql_query[0] != '#') { $result = mysql_query($a_sql_query); - if ($result==false) { // readdump failed - $my_die=$a_sql_query; - break; + if ($result == FALSE) { // readdump failed + $my_die = $a_sql_query; + break; } } if (!isset($reload) && eregi('^(DROP|CREATE) +(TABLE|DATABASE) (.+)', $a_sql_query)) { @@ -116,7 +116,9 @@ if ($sql_query != '') { // Copy the original query back for display purposes $sql_query = $sql_query_cpy; include('./header.inc.php3'); -if (isset($my_die)) mysql_die('', $my_die); +if (isset($my_die)) { + mysql_die('', $my_die); +} $message = $strSuccess; require('./db_details.php3'); ?> diff --git a/lib.inc.php3 b/lib.inc.php3 index 14bd8609c..26c92b98f 100755 --- a/lib.inc.php3 +++ b/lib.inc.php3 @@ -2,11 +2,11 @@ /* $Id$ */ - if (!defined('__LIB_INC__')){ define('__LIB_INC__', 1); - /* Order of sections for lib.inc.php3 + /** + * Order of sections for lib.inc.php3: * * in PHP3, functions and constants must be physically defined * before they are referenced @@ -14,33 +14,37 @@ if (!defined('__LIB_INC__')){ * some functions need the constants of defines.inc.php3 * * the include of defines.inc.php3 must be after the connection to db - * + * * the auth() function must be before the connection to db * + * the mysql_die() function must be before the connection to db but after + * mysql extension has been loaded + * * ... so the required order is: * * - definition of auth() * - parsing of the configuration file * - load of mysql extension (if necessary) + * - definition of mysql_die() * - db connection * - defines.inc.php3 * - other functions, respecting dependencies */ - /* avoid undefined variables in PHP3 - * - */ - if (!isset($use_backquotes)) { - $use_backquotes=0; - } - if (!isset($pos)) { - $pos=0; - } - if (!isset($cfgProtectBlob)) { - $cfgProtectBlob=FALSE; - } - /* ---------------------- Advanced authentification -------------------- */ + /** + * Avoids undefined variables in PHP3 + */ + if (!isset($use_backquotes)) { + $use_backquotes = 0; + } + if (!isset($pos)) { + $pos = 0; + } + if (!isset($cfgProtectBlob)) { + $cfgProtectBlob = FALSE; + } + /** * Advanced authentication work @@ -72,6 +76,7 @@ if (!defined('__LIB_INC__')){ exit(); } // end of the 'auth()' function + /** * Parses the configuration file */ @@ -111,6 +116,40 @@ if (!defined('__LIB_INC__')){ } // end load mysql extension + /** + * Displays a MySQL error message in the right frame. + * + * @param string the error mesage + * @param string the sql query that failed + */ + function mysql_die($error_message = '', $the_query = '') + { + global $sql_query; + + if (empty($error_message)) { + $error_message = mysql_error(); + } + if (empty($the_query)) { + $the_query = $GLOBALS['sql_query']; + } + + echo ''. $GLOBALS['strError'] . '' . "\n"; + echo '
' . "\n"; + if (!empty($the_query)) { + $edit_link = '' . $GLOBALS['strEdit'] . ''; + echo ' ' . $GLOBALS['strSQLQuery'] . ' : [' . $edit_link . ']
' . htmlspecialchars($the_query) . '' . "\n"; + } + echo '' . "\n"; + echo '
' . "\n"; + echo ' ' . $GLOBALS['strMySQLSaid'] . ' ' . htmlspecialchars($error_message) . "\n"; + echo '
' . "\n"; + echo '' . $GLOBALS['strBack'] . ''; + + include('./footer.inc.php3'); + exit(); + } // end of the 'mysql_die()' function + + /** * Use mysql_connect() or mysql_pconnect()? */ @@ -157,7 +196,7 @@ if (!defined('__LIB_INC__')){ $dblist[] = $cfgServer['only_db']; } - // Advanced authentification is required + // Advanced authentication is required if ($cfgServer['adv_auth']) { // Grabs the $PHP_AUTH_USER variable whatever are the values of the // 'register_globals' and the 'variables_order' directives @@ -197,7 +236,7 @@ if (!defined('__LIB_INC__')){ $old_usr = $HTTP_GET_VARS['old_usr']; } - // First load -> checks if authentification is required + // First load -> checks if authentication is required if (!isset($old_usr)) { if (empty($PHP_AUTH_USER)) { $do_auth = TRUE; @@ -215,7 +254,7 @@ if (!defined('__LIB_INC__')){ } } - // Calls the authentification window or validates user's login + // Calls the authentication window or validates user's login if ($do_auth) { auth(); } else { @@ -305,7 +344,7 @@ if (!defined('__LIB_INC__')){ // Validation achived -> store user's login/password $cfgServer['user'] = $PHP_AUTH_USER; $cfgServer['password'] = $PHP_AUTH_PW; - } // end Advanced authentification + } // end Advanced authentication // Do connect to the user's database if (empty($cfgServer['port'])) { @@ -322,6 +361,7 @@ if (!defined('__LIB_INC__')){ echo $strHostEmpty; } + /** * Gets constants that defines the PHP, MySQL... releases. * This include must be located physically before any code that @@ -438,40 +478,6 @@ if (!defined('__LIB_INC__')){ } // end of the 'count_records()' function - /** - * Displays a MySQL error message in the right frame. - * - * @param string the error mesage - * @param string the sql query that failed - */ - function mysql_die($error_message = '', $the_query = '') - { - global $sql_query; - - if (empty($error_message)) { - $error_message = mysql_error(); - } - if (empty($the_query)) { - $the_query = $GLOBALS['sql_query']; - } - - echo ''. $GLOBALS['strError'] . '' . "\n"; - echo '' . "\n"; - if (!empty($the_query)) { - $edit_link = '' . $GLOBALS['strEdit'] . ''; - echo ' ' . $GLOBALS['strSQLQuery'] . ' : [' . $edit_link . ']
' . htmlspecialchars($the_query) . '' . "\n"; - } - echo '' . "\n"; - echo '
' . "\n"; - echo ' ' . $GLOBALS['strMySQLSaid'] . ' ' . htmlspecialchars($error_message) . "\n"; - echo '
' . "\n"; - echo '' . $GLOBALS['strBack'] . ''; - - include('./footer.inc.php3'); - exit(); - } // end of the 'mysql_die()' function - - /** * Displays a message at the top of the "main" (right) frame * @@ -1454,7 +1460,7 @@ var errorMsg2 = ' no bookmark table + $cfgBookmark = FALSE; + $cfgBookmark = ''; + + // No server selected -> no bookmark table if ($server == 0) { return ''; - } - - $cfgBookmark['user']=$cfgServer['user']; - $cfgBookmark['db']=$cfgServer['bookmarkdb']; - $cfgBookmark['table']=$cfgServer['bookmarktable']; + } + + $cfgBookmark['user'] = $cfgServer['user']; + $cfgBookmark['db'] = $cfgServer['bookmarkdb']; + $cfgBookmark['table'] = $cfgServer['bookmarktable']; return $cfgBookmark; } // end of the 'get_bookmarks_param()' function @@ -1585,38 +1590,32 @@ var errorMsg2 = ' store them - if($result>0 && mysql_num_rows($result)>0) - { + if ($result > 0 && mysql_num_rows($result) > 0) { $flag = 1; - while($row = mysql_fetch_row($result)) - { - $bookmark_list["$flag - ".$row[0]] = $row[1]; + while ($row = mysql_fetch_row($result)) { + $bookmark_list[$flag . ' - ' . $row[0]] = $row[1]; $flag++; - } - - return $bookmark_list; + } // end while + return $bookmark_list; } // No bookmarks for the current database else { - return false; + return FALSE; } } // end of the 'list_bookmarks()' function @@ -1627,58 +1626,43 @@ var errorMsg2 = '