Fixed problems that prevented ISPConfig to run on PHP 7, Issue #3716
| | |
| | | } 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; |
| | |
| | | } |
| | | |
| | | //* 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; |
| | |
| | | $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); |
| | |
| | | $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; |
| | |
| | | $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); |
| | |
| | | * |
| | | * @access private |
| | | */ |
| | | public function db_result($iResId, $iConnection) { |
| | | public function __construct($iResId, $iConnection) { |
| | | $this->_iResId = $iResId; |
| | | $this->_iConnection = $iConnection; |
| | | } |
| | |
| | | * |
| | | * @access private |
| | | */ |
| | | public function fakedb_result($aData) { |
| | | public function __construct($aData) { |
| | | $this->aResultData = $aData; |
| | | $this->aLimitedData = $aData; |
| | | reset($this->aLimitedData); |
| | |
| | | //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 |
| | |
| | | |
| | | 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 |
| | |
| | | //** 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); |
| | |
| | | $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; |
| | |
| | | $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); |
| | |
| | | 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]; |
| | | } |
| | | |
| | |
| | | */ |
| | | |
| | | |
| | | 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']; |
| | |
| | | } |
| | | |
| | | //* 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); |
| | | |
| | | } |
| | | |