Commit f1926a01 authored by Till Brehm's avatar Till Brehm

Fixed problems that prevented ISPConfig to run on PHP 7, Issue #3716

parent ad576c6a
......@@ -188,7 +188,7 @@ do {
} while (!$check);
// Check if the mysql functions are loaded in PHP
if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.');
if(!function_exists('mysqli_connect')) die('No PHP MySQLi functions available. Please ensure that the PHP MySQL module is loaded.');
//** Get MySQL root credentials
$finished = false;
......@@ -208,7 +208,7 @@ do {
}
//* Initialize the MySQL server connection
if(@mysql_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
if(@mysqli_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
$conf['mysql']['host'] = $tmp_mysql_server_host;
$conf['mysql']['port'] = $tmp_mysql_server_port;
$conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
......@@ -217,7 +217,7 @@ do {
$conf['mysql']['charset'] = $tmp_mysql_server_charset;
$finished = true;
} else {
swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysql_error());
swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysqli_error());
}
} while ($finished == false);
unset($finished);
......@@ -553,7 +553,7 @@ if($install_mode == 'standard') {
$tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
//* Initialize the MySQL server connection
if(@mysql_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
if(@mysqli_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
$conf['mysql']['master_host'] = $tmp_mysql_server_host;
$conf['mysql']['master_port'] = $tmp_mysql_server_port;
$conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
......@@ -561,7 +561,7 @@ if($install_mode == 'standard') {
$conf['mysql']['master_database'] = $tmp_mysql_server_database;
$finished = true;
} else {
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_error());
}
} while ($finished == false);
unset($finished);
......
......@@ -776,7 +776,7 @@ class db_result {
*
* @access private
*/
public function db_result($iResId, $iConnection) {
public function __construct($iResId, $iConnection) {
$this->_iResId = $iResId;
$this->_iConnection = $iConnection;
}
......@@ -902,7 +902,7 @@ class fakedb_result {
*
* @access private
*/
public function fakedb_result($aData) {
public function __construct($aData) {
$this->aResultData = $aData;
$this->aLimitedData = $aData;
reset($this->aLimitedData);
......
......@@ -65,16 +65,16 @@ if($do_uninstall == 'yes') {
//exec("/etc/init.d/mysqld stop");
//exec("rm -rf /var/lib/mysql/".$conf["db_database"]);
//exec("/etc/init.d/mysqld start");
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
$link = mysqli_connect($clientdb_host, $clientdb_user, $clientdb_password);
if (!$link) {
echo "Unable to connect to the database'.mysql_error($link)";
} else {
$result=mysql_query("DROP DATABASE ".$conf['db_database']."';", $link);
if (!$result) echo "Unable to remove the ispconfig-database ".$conf['db_database']." ".mysql_error($link)."\n";
$result=mysql_query("DROP USER '".$conf['db_user'] ."';");
if (!$result) echo "Unable to remove the ispconfig-database-user ".$conf['db_user']." ".mysql_error($link)."\n";
$result=mysqli_query($link,"DROP DATABASE ".$conf['db_database']."';");
if (!$result) echo "Unable to remove the ispconfig-database ".$conf['db_database']." ".mysqli_error($link)."\n";
$result=mysqli_query($link, "DROP USER '".$conf['db_user'] ."';");
if (!$result) echo "Unable to remove the ispconfig-database-user ".$conf['db_user']." ".mysqli_error($link)."\n";
}
mysql_close($link);
mysqli_close($link);
// Deleting the symlink in /var/www
// Apache
......
......@@ -60,16 +60,16 @@ if($do_uninstall == 'yes') {
echo "\n\n>> Uninstalling ISPConfig 3... \n\n";
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
$link = mysqli_connect($clientdb_host, $clientdb_user, $clientdb_password);
if (!$link) {
echo "Unable to connect to the database'.mysql_error($link)";
} else {
$result=mysql_query("DROP DATABASE ".$conf['db_database']."';", $link);
if (!$result) echo "Unable to remove the ispconfig-database ".$conf['db_database']." ".mysql_error($link)."\n";
$result=mysql_query("DROP USER '".$conf['db_user'] ."';");
if (!$result) echo "Unable to remove the ispconfig-database-user ".$conf['db_user']." ".mysql_error($link)."\n";
$result=mysqli_query($link,"DROP DATABASE ".$conf['db_database']."';");
if (!$result) echo "Unable to remove the ispconfig-database ".$conf['db_database']." ".mysqli_error($link)."\n";
$result=mysqli_query($link,"DROP USER '".$conf['db_user'] ."';");
if (!$result) echo "Unable to remove the ispconfig-database-user ".$conf['db_user']." ".mysqli_error($link)."\n";
}
mysql_close($link);
mysqli_close($link);
// Deleting the symlink in /var/www
// Apache
......
......@@ -226,10 +226,10 @@ $clientdb_password = '';
//** Test mysql root connection
$finished = false;
do {
if(@mysql_connect($conf["mysql"]["host"], $conf["mysql"]["admin_user"], $conf["mysql"]["admin_password"])) {
if(@mysqli_connect($conf["mysql"]["host"], $conf["mysql"]["admin_user"], $conf["mysql"]["admin_password"])) {
$finished = true;
} else {
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_error());
$conf["mysql"]["admin_password"] = $inst->free_query('MySQL root password', $conf['mysql']['admin_password'],'mysql_root_password');
}
} while ($finished == false);
......@@ -255,7 +255,7 @@ if($conf['mysql']['master_slave_setup'] == 'y') {
$tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
//* Initialize the MySQL server connection
if(@mysql_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
if(@mysqli_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
$conf['mysql']['master_host'] = $tmp_mysql_server_host;
$conf['mysql']['master_port'] = $tmp_mysql_server_port;
$conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
......@@ -263,7 +263,7 @@ if($conf['mysql']['master_slave_setup'] == 'y') {
$conf['mysql']['master_database'] = $tmp_mysql_server_database;
$finished = true;
} else {
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_error());
}
} while ($finished == false);
unset($finished);
......
......@@ -556,19 +556,19 @@ class db extends mysqli
global $app;
include 'lib/mysql_clientdb.conf';
/* Connect to the database */
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
$link = mysqli_connect($clientdb_host, $clientdb_user, $clientdb_password);
if (!$link) {
$app->log('Unable to connect to the database'.mysql_error($link), LOGLEVEL_DEBUG);
$app->log('Unable to connect to the database'.mysqli_error($link), LOGLEVEL_DEBUG);
return;
}
/* Get database-size from information_schema */
$result=mysql_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".mysql_real_escape_string($database_name)."';", $link);
$result=mysqli_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".mysqli_real_escape_string($database_name)."';", $link);
$this->close;
if (!$result) {
$app->log('Unable to get the database-size'.mysql_error($link), LOGLEVEL_DEBUG);
$app->log('Unable to get the database-size'.mysqli_error($link), LOGLEVEL_DEBUG);
return;
}
$database_size = mysql_fetch_row($result);
$database_size = mysqli_fetch_row($result);
return $database_size[0];
}
......
......@@ -44,7 +44,7 @@ class system{
*/
public function system(){
public function __construct(){
//global $go_info;
//$this->server_id = $go_info['isp']['server_id'];
//$this->server_conf = $go_info['isp']['server_conf'];
......
......@@ -246,29 +246,29 @@ class software_update_plugin {
}
//* Connect to the database
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
$link = mysqli_connect($clientdb_host, $clientdb_user, $clientdb_password);
if (!$link) {
$app->log('Unable to connect to the database'.mysql_error($link), LOGLEVEL_ERROR);
$app->log('Unable to connect to the database'.mysqli_error($link), LOGLEVEL_ERROR);
return;
}
$query_charset_table = '';
//* Create the new database
if (mysql_query('CREATE DATABASE '.mysql_real_escape_string($db_config['database_name']).$query_charset_table, $link)) {
if (mysqli_query($link,'CREATE DATABASE '.mysqli_real_escape_string($link, $db_config['database_name']).$query_charset_table, $link)) {
$app->log('Created MySQL database: '.$db_config['database_name'], LOGLEVEL_DEBUG);
} else {
$app->log('Unable to connect to the database'.mysql_error($link), LOGLEVEL_ERROR);
$app->log('Unable to connect to the database'.mysqli_error($link), LOGLEVEL_ERROR);
}
if(mysql_query("GRANT ALL ON ".mysql_real_escape_string($db_config['database_name'], $link).".* TO '".mysql_real_escape_string($db_config['database_user'], $link)."'@'".$db_config['database_host']."' IDENTIFIED BY '".mysql_real_escape_string($db_config['database_password'], $link)."';", $link)) {
if(mysqli_query("GRANT ALL ON ".mysqli_real_escape_string($link, $db_config['database_name']).".* TO '".mysqli_real_escape_string($link, $db_config['database_user'])."'@'".$db_config['database_host']."' IDENTIFIED BY '".mysqli_real_escape_string($link, $db_config['database_password'])."';", $link)) {
$app->log('Created MySQL user: '.$db_config['database_user'], LOGLEVEL_DEBUG);
} else {
$app->log('Unable to create database user'.$db_config['database_user'].' '.mysql_error($link), LOGLEVEL_ERROR);
$app->log('Unable to create database user'.$db_config['database_user'].' '.mysqli_error($link), LOGLEVEL_ERROR);
}
mysql_query("FLUSH PRIVILEGES;", $link);
mysql_close($link);
mysqli_query($link, "FLUSH PRIVILEGES;");
mysqli_close($link);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment