From cdacb5697f60bc4378f6b5ee9f760e57d079d7eb Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Tue, 1 Jan 2019 19:24:04 +0000 Subject: [PATCH] improve formatting of error message; remove use of db_array (to be removed). --- config.inc.php | 2 +- functions.inc.php | 12 ++++++------ public/backup.php | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config.inc.php b/config.inc.php index c993038f..370d829e 100644 --- a/config.inc.php +++ b/config.inc.php @@ -104,7 +104,7 @@ $CONF['database_user'] = 'postfix'; $CONF['database_password'] = 'postfixadmin'; $CONF['database_name'] = 'postfix'; -// Database SSL Config +// Database SSL Config (MySQLi only) $CONF['database_use_ssl'] = false; $CONF['database_ssl_key'] = NULL; $CONF['database_ssl_cert'] = NULL; diff --git a/functions.inc.php b/functions.inc.php index 05eeca75..380e253f 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1494,7 +1494,7 @@ function db_connect_with_errors() { @mysql_select_db($CONF['database_name'], $link) or $error_text .= ("

DEBUG INFORMATION:
MySQL Select Database: " . mysql_error() . "$DEBUG_TEXT"); } } else { - $error_text .= "

DEBUG INFORMATION:
MySQL 3.x / 4.0 functions not available! (php5-mysql installed?)
database_type = 'mysql' in config.inc.php, are you using a different database? $DEBUG_TEXT"; + $error_text .= "

DEBUG INFORMATION:
MySQL 3.x / 4.0 functions not available! (php5-mysql installed?)
database_type = 'mysql' in config.inc.php, are you using a different database? $DEBUG_TEXT"; } } elseif ($CONF['database_type'] == "mysqli") { $is_connected = false; @@ -1505,14 +1505,14 @@ function db_connect_with_errors() { $connected = mysqli_real_connect($link, $CONF['database_host'], $CONF['database_user'], $CONF['database_password'], $CONF['database_name'], $CONF['database_port']); $is_connected = $connected; } else { - $error_text .= "

DEBUG INFORMATION:
MySQLi 5 functions not available! (php5-mysqli installed?)
database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT"; + $error_text .= "

DEBUG INFORMATION:
MySQLi 5 functions not available! (php5-mysqli installed?)
database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT"; } } else { if (function_exists("mysqli_connect")) { $link = @mysqli_connect($CONF['database_host'], $CONF['database_user'], $CONF['database_password'], $CONF['database_name'], $CONF['database_port'], $CONF['database_socket']) or $error_text .= ("

DEBUG INFORMATION:
Connect: " . mysqli_connect_error() . "$DEBUG_TEXT"); $is_connected = $link; } else { - $error_text .= "

DEBUG INFORMATION:
MySQL 4.1 functions not available! (php5-mysqli installed?)
database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT"; + $error_text .= "

DEBUG INFORMATION:
MySQL 4.1 functions not available! (php5-mysqli installed?)
database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT"; } } if ($is_connected && $link instanceof mysqli) { @@ -1522,7 +1522,7 @@ function db_connect_with_errors() { } elseif (db_sqlite()) { if (class_exists("SQLite3")) { if ($CONF['database_name'] == '' || !is_dir(dirname($CONF['database_name'])) || !is_writable(dirname($CONF['database_name']))) { - $error_text .= ("

DEBUG INFORMATION
Connect: given database path does not exist, is not writable, or \$CONF['database_name'] is empty."); + $error_text .= ("

DEBUG INFORMATION
Connect: given database path does not exist, is not writable, or \$CONF['database_name'] is empty."); } else { $link = new SQLite3($CONF['database_name']) or $error_text .= ("

DEBUG INFORMATION
Connect: failed to connect to database. $DEBUG_TEXT"); if ($link instanceof SQLite3) { @@ -1530,7 +1530,7 @@ function db_connect_with_errors() { } } } else { - $error_text .= "

DEBUG INFORMATION:
SQLite functions not available! (php5-sqlite installed?)
database_type = 'sqlite' in config.inc.php, are you using a different database? $DEBUG_TEXT"; + $error_text .= "

DEBUG INFORMATION:
SQLite functions not available! (php5-sqlite installed?)
database_type = 'sqlite' in config.inc.php, are you using a different database? $DEBUG_TEXT"; } } elseif (db_pgsql()) { if (function_exists("pg_pconnect")) { @@ -1632,7 +1632,7 @@ function db_mysql() { } /** - * returns true if PostgreSQL is used, false otherwise + * @return bool true if PostgreSQL is used, false otherwise */ function db_pgsql() { if (Config::Read('database_type')=='pgsql') { diff --git a/public/backup.php b/public/backup.php index 3e4e47c2..059571de 100644 --- a/public/backup.php +++ b/public/backup.php @@ -96,8 +96,8 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { for ($i = 0 ; $i < sizeof($tables) ; ++$i) { $result = db_query("SHOW CREATE TABLE " . table_by_key($tables[$i])); if ($result['rows'] > 0) { - while ($row = db_array($result['result'])) { - fwrite($fh, "$row[1];\n\n"); + while ($row = db_row($result['result'])) { + fwrite($fh, "{$row[1]};\n\n"); } } }