Skip to content

Commit f1926a0

Browse files
author
Till Brehm
committed
Fixed problems that prevented ISPConfig to run on PHP 7, Issue #3716
1 parent ad576c6 commit f1926a0

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

install/install.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
} while (!$check);
189189

190190
// Check if the mysql functions are loaded in PHP
191-
if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.');
191+
if(!function_exists('mysqli_connect')) die('No PHP MySQLi functions available. Please ensure that the PHP MySQL module is loaded.');
192192

193193
//** Get MySQL root credentials
194194
$finished = false;
@@ -208,7 +208,7 @@
208208
}
209209

210210
//* Initialize the MySQL server connection
211-
if(@mysql_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
211+
if(@mysqli_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
212212
$conf['mysql']['host'] = $tmp_mysql_server_host;
213213
$conf['mysql']['port'] = $tmp_mysql_server_port;
214214
$conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
@@ -217,7 +217,7 @@
217217
$conf['mysql']['charset'] = $tmp_mysql_server_charset;
218218
$finished = true;
219219
} else {
220-
swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysql_error());
220+
swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysqli_error());
221221
}
222222
} while ($finished == false);
223223
unset($finished);
@@ -553,15 +553,15 @@
553553
$tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
554554

555555
//* Initialize the MySQL server connection
556-
if(@mysql_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
556+
if(@mysqli_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
557557
$conf['mysql']['master_host'] = $tmp_mysql_server_host;
558558
$conf['mysql']['master_port'] = $tmp_mysql_server_port;
559559
$conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
560560
$conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
561561
$conf['mysql']['master_database'] = $tmp_mysql_server_database;
562562
$finished = true;
563563
} else {
564-
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
564+
swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_error());
565565
}
566566
} while ($finished == false);
567567
unset($finished);

install/lib/mysql.lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ class db_result {
776776
*
777777
* @access private
778778
*/
779-
public function db_result($iResId, $iConnection) {
779+
public function __construct($iResId, $iConnection) {
780780
$this->_iResId = $iResId;
781781
$this->_iConnection = $iConnection;
782782
}
@@ -902,7 +902,7 @@ class fakedb_result {
902902
*
903903
* @access private
904904
*/
905-
public function fakedb_result($aData) {
905+
public function __construct($aData) {
906906
$this->aResultData = $aData;
907907
$this->aLimitedData = $aData;
908908
reset($this->aLimitedData);

install/uninstall-fedora.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@
6565
//exec("/etc/init.d/mysqld stop");
6666
//exec("rm -rf /var/lib/mysql/".$conf["db_database"]);
6767
//exec("/etc/init.d/mysqld start");
68-
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
68+
$link = mysqli_connect($clientdb_host, $clientdb_user, $clientdb_password);
6969
if (!$link) {
7070
echo "Unable to connect to the database'.mysql_error($link)";
7171
} else {
72-
$result=mysql_query("DROP DATABASE ".$conf['db_database']."';", $link);
73-
if (!$result) echo "Unable to remove the ispconfig-database ".$conf['db_database']." ".mysql_error($link)."\n";
74-
$result=mysql_query("DROP USER '".$conf['db_user'] ."';");
75-
if (!$result) echo "Unable to remove the ispconfig-database-user ".$conf['db_user']." ".mysql_error($link)."\n";
72+
$result=mysqli_query($link,"DROP DATABASE ".$conf['db_database']."';");
73+
if (!$result) echo "Unable to remove the ispconfig-database ".$conf['db_database']." ".mysqli_error($link)."\n";
74+
$result=mysqli_query($link, "DROP USER '".$conf['db_user'] ."';");
75+
if (!$result) echo "Unable to remove the ispconfig-database-user ".$conf['db_user']." ".mysqli_error($link)."\n";
7676
}
77-
mysql_close($link);
77+
mysqli_close($link);
7878

7979
// Deleting the symlink in /var/www
8080
// Apache

install/uninstall.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@
6060

6161
echo "\n\n>> Uninstalling ISPConfig 3... \n\n";
6262

63-
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
63+
$link = mysqli_connect($clientdb_host, $clientdb_user, $clientdb_password);
6464
if (!$link) {
6565
echo "Unable to connect to the database'.mysql_error($link)";
6666
} else {
67-
$result=mysql_query("DROP DATABASE ".$conf['db_database']."';", $link);
68-
if (!$result) echo "Unable to remove the ispconfig-database ".$conf['db_database']." ".mysql_error($link)."\n";
69-
$result=mysql_query("DROP USER '".$conf['db_user'] ."';");
70-
if (!$result) echo "Unable to remove the ispconfig-database-user ".$conf['db_user']." ".mysql_error($link)."\n";
67+
$result=mysqli_query($link,"DROP DATABASE ".$conf['db_database']."';");
68+
if (!$result) echo "Unable to remove the ispconfig-database ".$conf['db_database']." ".mysqli_error($link)."\n";
69+
$result=mysqli_query($link,"DROP USER '".$conf['db_user'] ."';");
70+
if (!$result) echo "Unable to remove the ispconfig-database-user ".$conf['db_user']." ".mysqli_error($link)."\n";
7171
}
72-
mysql_close($link);
72+
mysqli_close($link);
7373

7474
// Deleting the symlink in /var/www
7575
// Apache

install/update.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@
226226
//** Test mysql root connection
227227
$finished = false;
228228
do {
229-
if(@mysql_connect($conf["mysql"]["host"], $conf["mysql"]["admin_user"], $conf["mysql"]["admin_password"])) {
229+
if(@mysqli_connect($conf["mysql"]["host"], $conf["mysql"]["admin_user"], $conf["mysql"]["admin_password"])) {
230230
$finished = true;
231231
} else {
232-
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
232+
swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_error());
233233
$conf["mysql"]["admin_password"] = $inst->free_query('MySQL root password', $conf['mysql']['admin_password'],'mysql_root_password');
234234
}
235235
} while ($finished == false);
@@ -255,15 +255,15 @@
255255
$tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
256256

257257
//* Initialize the MySQL server connection
258-
if(@mysql_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
258+
if(@mysqli_connect($tmp_mysql_server_host . ':' . (int)$tmp_mysql_server_port, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
259259
$conf['mysql']['master_host'] = $tmp_mysql_server_host;
260260
$conf['mysql']['master_port'] = $tmp_mysql_server_port;
261261
$conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
262262
$conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
263263
$conf['mysql']['master_database'] = $tmp_mysql_server_database;
264264
$finished = true;
265265
} else {
266-
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
266+
swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_error());
267267
}
268268
} while ($finished == false);
269269
unset($finished);

server/lib/classes/db_mysql.inc.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,19 +556,19 @@ public function getDatabaseSize($database_name) {
556556
global $app;
557557
include 'lib/mysql_clientdb.conf';
558558
/* Connect to the database */
559-
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
559+
$link = mysqli_connect($clientdb_host, $clientdb_user, $clientdb_password);
560560
if (!$link) {
561-
$app->log('Unable to connect to the database'.mysql_error($link), LOGLEVEL_DEBUG);
561+
$app->log('Unable to connect to the database'.mysqli_error($link), LOGLEVEL_DEBUG);
562562
return;
563563
}
564564
/* Get database-size from information_schema */
565-
$result=mysql_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".mysql_real_escape_string($database_name)."';", $link);
565+
$result=mysqli_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".mysqli_real_escape_string($database_name)."';", $link);
566566
$this->close;
567567
if (!$result) {
568-
$app->log('Unable to get the database-size'.mysql_error($link), LOGLEVEL_DEBUG);
568+
$app->log('Unable to get the database-size'.mysqli_error($link), LOGLEVEL_DEBUG);
569569
return;
570570
}
571-
$database_size = mysql_fetch_row($result);
571+
$database_size = mysqli_fetch_row($result);
572572
return $database_size[0];
573573
}
574574

server/lib/classes/system.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class system{
4444
*/
4545

4646

47-
public function system(){
47+
public function __construct(){
4848
//global $go_info;
4949
//$this->server_id = $go_info['isp']['server_id'];
5050
//$this->server_conf = $go_info['isp']['server_conf'];

server/plugins-available/software_update_plugin.inc.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,29 +246,29 @@ private function create_app_db($db_config) {
246246
}
247247

248248
//* Connect to the database
249-
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
249+
$link = mysqli_connect($clientdb_host, $clientdb_user, $clientdb_password);
250250
if (!$link) {
251-
$app->log('Unable to connect to the database'.mysql_error($link), LOGLEVEL_ERROR);
251+
$app->log('Unable to connect to the database'.mysqli_error($link), LOGLEVEL_ERROR);
252252
return;
253253
}
254254

255255
$query_charset_table = '';
256256

257257
//* Create the new database
258-
if (mysql_query('CREATE DATABASE '.mysql_real_escape_string($db_config['database_name']).$query_charset_table, $link)) {
258+
if (mysqli_query($link,'CREATE DATABASE '.mysqli_real_escape_string($link, $db_config['database_name']).$query_charset_table, $link)) {
259259
$app->log('Created MySQL database: '.$db_config['database_name'], LOGLEVEL_DEBUG);
260260
} else {
261-
$app->log('Unable to connect to the database'.mysql_error($link), LOGLEVEL_ERROR);
261+
$app->log('Unable to connect to the database'.mysqli_error($link), LOGLEVEL_ERROR);
262262
}
263263

264-
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)) {
264+
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)) {
265265
$app->log('Created MySQL user: '.$db_config['database_user'], LOGLEVEL_DEBUG);
266266
} else {
267-
$app->log('Unable to create database user'.$db_config['database_user'].' '.mysql_error($link), LOGLEVEL_ERROR);
267+
$app->log('Unable to create database user'.$db_config['database_user'].' '.mysqli_error($link), LOGLEVEL_ERROR);
268268
}
269269

270-
mysql_query("FLUSH PRIVILEGES;", $link);
271-
mysql_close($link);
270+
mysqli_query($link, "FLUSH PRIVILEGES;");
271+
mysqli_close($link);
272272

273273
}
274274

0 commit comments

Comments
 (0)