diff --git a/admin_settings.php b/admin_settings.php index 8339b3e7..c11ef5e2 100644 --- a/admin_settings.php +++ b/admin_settings.php @@ -18,10 +18,14 @@ */ define('AREA', 'admin'); -$need_db_sql_data = true; -$need_root_db_sql_data = true; require './lib/init.php'; +// get sql-root access data +Database::needRoot(true); +Database::needSqlData(); +$sql_root = Database::getSqlData(); +Database::needRoot(false); + if (($page == 'settings' || $page == 'overview') && $userinfo['change_serversettings'] == '1' ) { diff --git a/customer_mysql.php b/customer_mysql.php index 5f9ae522..bfbe905c 100644 --- a/customer_mysql.php +++ b/customer_mysql.php @@ -22,7 +22,7 @@ require './lib/init.php'; // get sql-root access data Database::needRoot(true); -Database::needSqlData(true); +Database::needSqlData(); $sql_root = Database::getSqlData(); Database::needRoot(false); @@ -34,6 +34,8 @@ if (isset($_POST['id'])) { if ($page == 'overview') { $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql"); + Database::needSqlData(); + $sql = Database::getSqlData(); $lng['mysql']['description'] = str_replace('', $sql['host'], $lng['mysql']['description']); eval("echo \"" . getTemplate('mysql/mysql') . "\";"); } elseif($page == 'mysqls') { diff --git a/lib/classes/database/class.Database.php b/lib/classes/database/class.Database.php index ea3a3516..7dcfdff8 100644 --- a/lib/classes/database/class.Database.php +++ b/lib/classes/database/class.Database.php @@ -132,12 +132,17 @@ class Database { * only give you the data ONCE as it disable itself * after the first access to the data * - * @param bool $needsql */ - public static function needSqlData($needsql = false) { - self::$_needsqldata = $needsql; + public static function needSqlData() { + self::$_needsqldata = true; self::$_sqldata = array(); self::$_link = null; + // we need a connection here because + // if getSqlData() is called RIGHT after + // this function and no "real" PDO + // function was called, getDB() wasn't + // involved and no data collected + self::getDB(); } /** @@ -147,16 +152,17 @@ class Database { * @return array|bool */ public static function getSqlData() { + $return = false; if (self::$_sqldata !== null && is_array(self::$_sqldata) && isset(self::$_sqldata['user']) ) { - return self::$_sqldata; + $return = self::$_sqldata; // automatically disable sql-data self::$_sqldata = null; self::$_needsqldata = false; } - return false; + return $return; } /** diff --git a/lib/functions/database/function.correctMysqlUsers.php b/lib/functions/database/function.correctMysqlUsers.php index 10e38457..61b8acee 100644 --- a/lib/functions/database/function.correctMysqlUsers.php +++ b/lib/functions/database/function.correctMysqlUsers.php @@ -23,7 +23,7 @@ function correctMysqlUsers($mysql_access_host_array) { // get sql-root access data Database::needRoot(true); - Database::needSqlData(true); + Database::needSqlData(); $sql_root = Database::getSqlData(); Database::needRoot(false); diff --git a/scripts/jobs/cron_backup.php b/scripts/jobs/cron_backup.php index 76ebee09..852c283a 100644 --- a/scripts/jobs/cron_backup.php +++ b/scripts/jobs/cron_backup.php @@ -24,7 +24,7 @@ if ($settings['system']['backup_enabled'] == '1') { // get sql-root access data for mysqldump Database::needRoot(true); - Database::needSqlData(true); + Database::needSqlData(); $sql_root = Database::getSqlData(); Database::needRoot(false);