| | |
| | | //if(filesize('existing_db.sql') < 30000) die('Possible problem with dumping the database. We will stop here. Please check the file existing_db.sql'); |
| | | |
| | | // create a backup copy of the ispconfig database in the root folder |
| | | $backup_db_name = '/root/ispconfig_db_backup_'.@date('Y-m-d_h-i').'.sql'; |
| | | if(isset($conf['backup_path'])) { |
| | | $backup_db_name = $conf['backup_path'].'/ispconfig_db_backup.sql'; |
| | | } else { |
| | | $backup_db_name = '/root/ispconfig_db_backup_'.@date('Y-m-d_H-i').'.sql'; |
| | | } |
| | | copy('existing_db.sql',$backup_db_name); |
| | | chmod($backup_db_name, 0700); |
| | | chown($backup_db_name, 'root'); |
| | |
| | | $ini_array = ini_to_array(stripslashes($tmp['config'])); |
| | | $current_db_version = (isset($tmp['dbversion']))?intval($tmp['dbversion']):0; |
| | | |
| | | if(count($ini_array) == 0) die('Unable to read server configuration from database.'); |
| | | if(!is_array($ini_array) or count($ini_array) == 0) die('Unable to read server configuration from database.'); |
| | | |
| | | $conf['services']['mail'] = ($tmp['mail_server'] == 1)?true:false; |
| | | $conf['services']['web'] = ($tmp['web_server'] == 1)?true:false; |
| | |
| | | |
| | | //* update the database version in server table |
| | | $inst->db->query("UPDATE ".$conf["mysql"]["database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); |
| | | if($inst->db->dbHost != $inst->dbmaster->dbHost) $inst->dbmaster->query("UPDATE ".$conf["mysql"]["master_database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); |
| | | |
| | | |
| | | //* If ISPConfig Version < 3.0.3, we will do a full db update |
| | |
| | | |
| | | //* update the database version in server table |
| | | $inst->db->query("UPDATE ".$conf["mysql"]["database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); |
| | | if($inst->db->dbHost != $inst->dbmaster->dbHost) $inst->dbmaster->query("UPDATE ".$conf["mysql"]["master_database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); |
| | | |
| | | if ($conf['powerdns']['installed']) { |
| | | |
| | |
| | | |
| | | |
| | | //** Update server ini |
| | | $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']); |
| | | $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); |
| | | $old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config'])); |
| | | unset($tmp_server_rec); |
| | | $tpl_ini_array = ini_to_array(rf('tpl/server.ini.master')); |
| | |
| | | $tpl_ini_array['global']['webserver'] = 'nginx'; |
| | | } |
| | | |
| | | // update the new template with the old values |
| | | //* update the new template with the old values |
| | | if(is_array($old_ini_array)) { |
| | | foreach($old_ini_array as $tmp_section_name => $tmp_section_content) { |
| | | foreach($tmp_section_content as $tmp_var_name => $tmp_var_content) { |
| | |
| | | } |
| | | |
| | | $new_ini = array_to_ini($tpl_ini_array); |
| | | $inst->db->query("UPDATE server SET config = '".mysql_real_escape_string($new_ini)."' WHERE server_id = ".$conf['server_id']); |
| | | $sql = "UPDATE ".$conf["mysql"]["database"].".server SET config = '".mysql_real_escape_string($new_ini)."' WHERE server_id = ".$conf['server_id']; |
| | | $inst->db->query($sql); |
| | | |
| | | if($inst->db->dbHost != $inst->dbmaster->dbHost) { |
| | | $sql = "UPDATE ".$conf["mysql"]["master_database"].".server SET config = '".mysql_real_escape_string($new_ini)."' WHERE server_id = ".$conf['server_id']; |
| | | $inst->dbmaster->query($sql); |
| | | } |
| | | unset($old_ini_array); |
| | | unset($tpl_ini_array); |
| | | unset($new_ini); |
| | | |
| | | |
| | | //** Update system ini |
| | | $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM sys_ini WHERE sysini_id = 1"); |
| | | $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM ".$conf["mysql"]["database"].".sys_ini WHERE sysini_id = 1"); |
| | | $old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config'])); |
| | | unset($tmp_server_rec); |
| | | $tpl_ini_array = ini_to_array(rf('tpl/system.ini.master')); |
| | |
| | | } |
| | | |
| | | $new_ini = array_to_ini($tpl_ini_array); |
| | | $tmp = $inst->db->queryOneRecord('SELECT count(sysini_id) as number FROM sys_ini WHERE 1'); |
| | | $tmp = $inst->db->queryOneRecord('SELECT count(sysini_id) as number FROM '.$conf["mysql"]["database"].'.sys_ini WHERE 1'); |
| | | if($tmp['number'] == 0) { |
| | | $inst->db->query("INSERT INTO sys_ini (sysini_id, config) VALUES (1,'".mysql_real_escape_string($new_ini)."')"); |
| | | $inst->db->query("INSERT INTO ".$conf["mysql"]["database"].".sys_ini (sysini_id, config) VALUES (1,'".mysql_real_escape_string($new_ini)."')"); |
| | | } else { |
| | | $inst->db->query("UPDATE sys_ini SET config = '".mysql_real_escape_string($new_ini)."' WHERE sysini_id = 1"); |
| | | $inst->db->query("UPDATE ".$conf["mysql"]["database"].".sys_ini SET config = '".mysql_real_escape_string($new_ini)."' WHERE sysini_id = 1"); |
| | | } |
| | | unset($old_ini_array); |
| | | unset($tpl_ini_array); |