corrected Database::needSqlData() and Database::getSqlData(), refs #1287
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -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'
|
||||
) {
|
||||
|
||||
@@ -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>', $sql['host'], $lng['mysql']['description']);
|
||||
eval("echo \"" . getTemplate('mysql/mysql') . "\";");
|
||||
} elseif($page == 'mysqls') {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user