commit | author | age
|
9a3a78
|
1 |
<?php |
L |
2 |
/* |
|
3 |
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh |
|
4 |
All rights reserved. |
|
5 |
|
|
6 |
Redistribution and use in source and binary forms, with or without modification, |
|
7 |
are permitted provided that the following conditions are met: |
|
8 |
|
|
9 |
* Redistributions of source code must retain the above copyright notice, |
|
10 |
this list of conditions and the following disclaimer. |
|
11 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer in the documentation |
|
13 |
and/or other materials provided with the distribution. |
|
14 |
* Neither the name of ISPConfig nor the names of its contributors |
|
15 |
may be used to endorse or promote products derived from this software without |
|
16 |
specific prior written permission. |
|
17 |
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
992797
|
30 |
//* Installer patch stub class |
MC |
31 |
class installer_patch_update { |
121e4d
|
32 |
public function onBeforeSQL() { |
7fe908
|
33 |
} |
MC |
34 |
|
121e4d
|
35 |
public function onAfterSQL() { |
7fe908
|
36 |
} |
MC |
37 |
|
992797
|
38 |
} |
MC |
39 |
|
|
40 |
//* DB dump function |
9a3a78
|
41 |
function prepareDBDump() { |
L |
42 |
global $conf; |
|
43 |
|
|
44 |
//** load the pre update sql script do perform modifications on the database before the database is dumped |
|
45 |
if(is_file(ISPC_INSTALL_ROOT."/install/sql/pre_update.sql")) { |
|
46 |
if($conf['mysql']['admin_password'] == '') { |
02bf99
|
47 |
caselog("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < '".ISPC_INSTALL_ROOT."/install/sql/pre_update.sql' &> /dev/null", __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql'); |
9a3a78
|
48 |
} else { |
02bf99
|
49 |
caselog("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < '".ISPC_INSTALL_ROOT."/install/sql/pre_update.sql' &> /dev/null", __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql'); |
9a3a78
|
50 |
} |
L |
51 |
} |
|
52 |
|
|
53 |
//** export the current database data |
|
54 |
if( !empty($conf["mysql"]["admin_password"]) ) { |
|
55 |
|
02bf99
|
56 |
system("mysqldump -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." -c -t --add-drop-table --create-options --quick --result-file=existing_db.sql ".$conf['mysql']['database']); |
9a3a78
|
57 |
} |
L |
58 |
else { |
|
59 |
|
02bf99
|
60 |
system("mysqldump -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -c -t --add-drop-table --create-options --quick --result-file=existing_db.sql ".$conf['mysql']['database']); |
9a3a78
|
61 |
} |
L |
62 |
|
|
63 |
/* |
|
64 |
* If we have a server with nothing in it except VE's then the database of thie server is empty. |
|
65 |
* so the following line will no longer work! |
|
66 |
*/ |
|
67 |
//if(filesize('existing_db.sql') < 30000) die('Possible problem with dumping the database. We will stop here. Please check the file existing_db.sql'); |
|
68 |
|
|
69 |
// create a backup copy of the ispconfig database in the root folder |
8cf78b
|
70 |
if(isset($conf['backup_path'])) { |
T |
71 |
$backup_db_name = $conf['backup_path'].'/ispconfig_db_backup.sql'; |
|
72 |
} else { |
|
73 |
$backup_db_name = '/root/ispconfig_db_backup_'.@date('Y-m-d_H-i').'.sql'; |
|
74 |
} |
7fe908
|
75 |
copy('existing_db.sql', $backup_db_name); |
9a3a78
|
76 |
chmod($backup_db_name, 0700); |
L |
77 |
chown($backup_db_name, 'root'); |
|
78 |
chgrp($backup_db_name, 'root'); |
|
79 |
|
|
80 |
if ($conf['powerdns']['installed']) { |
|
81 |
//** export the current PowerDNS database data |
7fe908
|
82 |
if( !empty($conf["mysql"]["admin_password"]) ) { |
MC |
83 |
system("mysqldump -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']); |
|
84 |
} else { |
|
85 |
system("mysqldump -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']); |
|
86 |
} |
9a3a78
|
87 |
|
L |
88 |
// create a backup copy of the PowerDNS database in the root folder |
|
89 |
$backup_db_name = '/root/ispconfig_powerdns_db_backup_'.@date('Y-m-d_h-i').'.sql'; |
7fe908
|
90 |
copy('existing_powerdns_db.sql', $backup_db_name); |
9a3a78
|
91 |
chmod($backup_db_name, 0700); |
7fe908
|
92 |
chown($backup_db_name, 'root'); |
MC |
93 |
chgrp($backup_db_name, 'root'); |
9a3a78
|
94 |
} |
L |
95 |
} |
|
96 |
|
|
97 |
function checkDbHealth() { |
|
98 |
global $conf; |
|
99 |
|
|
100 |
//* Array containing non OK tables (can be repaired, crashed, corrupt) |
|
101 |
$notok = array(); |
|
102 |
|
|
103 |
echo "Checking ISPConfig database .. "; |
02bf99
|
104 |
exec("mysqlcheck -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." -r ".escapeshellarg($conf["mysql"]["database"]), $result); |
9a3a78
|
105 |
for( $i=0; $i<sizeof($result);$i++) { |
L |
106 |
if ( substr($result[$i], -2) != "OK" ) { |
|
107 |
$notok[] = $result[$i]; |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
if ( sizeof($notok) > 0 ) { |
|
112 |
echo "\nSome tables where not 'OK'. Please check the list below.\n\n"; |
|
113 |
foreach ($notok as $key => $value) { |
|
114 |
echo "$value\n"; |
|
115 |
} |
|
116 |
echo "\nPress enter to continue or CTRL-C to cancel the installation .."; |
|
117 |
sread(); |
|
118 |
} |
|
119 |
else |
7fe908
|
120 |
echo "OK\n"; |
9a3a78
|
121 |
} |
L |
122 |
|
|
123 |
function updateDbAndIni() { |
|
124 |
global $inst, $conf; |
|
125 |
|
|
126 |
//* Update $conf array with values from the server.ini that shall be preserved |
|
127 |
$tmp = $inst->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); |
|
128 |
$ini_array = ini_to_array(stripslashes($tmp['config'])); |
|
129 |
$current_db_version = (isset($tmp['dbversion']))?intval($tmp['dbversion']):0; |
|
130 |
|
edf806
|
131 |
if(!is_array($ini_array) or count($ini_array) == 0) die('Unable to read server configuration from database.'); |
9a3a78
|
132 |
|
L |
133 |
$conf['services']['mail'] = ($tmp['mail_server'] == 1)?true:false; |
|
134 |
$conf['services']['web'] = ($tmp['web_server'] == 1)?true:false; |
|
135 |
$conf['services']['dns'] = ($tmp['dns_server'] == 1)?true:false; |
|
136 |
$conf['services']['file'] = ($tmp['file_server'] == 1)?true:false; |
|
137 |
$conf['services']['db'] = ($tmp['db_server'] == 1)?true:false; |
|
138 |
$conf['services']['vserver'] = ($tmp['vserver_server'] == 1)?true:false; |
|
139 |
$conf['services']['proxy'] = (isset($tmp['proxy_server']) && $tmp['proxy_server'] == 1)?true:false; |
|
140 |
$conf['services']['firewall'] = (isset($tmp['firewall_server']) && $tmp['firewall_server'] == 1)?true:false; |
7fe908
|
141 |
|
9a3a78
|
142 |
$conf['postfix']['vmail_mailbox_base'] = $ini_array['mail']['homedir_path']; |
7fe908
|
143 |
|
e41fba
|
144 |
if(isset($ini_array['web']['server_type']) && $ini_array['web']['server_type'] != ''){ |
4ffb51
|
145 |
$conf['webserver']['server_type'] = $ini_array['web']['server_type']; |
F |
146 |
if($conf['webserver']['server_type'] == 'nginx'){ |
|
147 |
$conf['apache']['installed'] = false; |
|
148 |
} else { |
|
149 |
$conf['nginx']['installed'] = false; |
|
150 |
} |
|
151 |
} else { |
|
152 |
$conf['webserver']['server_type'] = 'apache'; |
|
153 |
$conf['nginx']['installed'] = false; |
|
154 |
} |
7fe908
|
155 |
|
eb3ab4
|
156 |
//* Do incremental DB updates only on installed ISPConfig versions >= 3.0.3 |
MC |
157 |
if(version_compare('3.0.3', ISPC_APP_VERSION, '<=')) { |
7fe908
|
158 |
|
9a3a78
|
159 |
swriteln($inst->lng('Starting incremental database update.')); |
7fe908
|
160 |
|
MC |
161 |
//* get the version of the db schema from the server table |
9a3a78
|
162 |
$found = true; |
L |
163 |
while($found == true) { |
|
164 |
$next_db_version = intval($current_db_version + 1); |
992797
|
165 |
$sql_patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql'; |
MC |
166 |
$php_patch_filename = realpath(dirname(__FILE__).'/../').'/patches/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.php'; |
0ccfef
|
167 |
|
TB |
168 |
// comma separated list of version numbers were a update has to be done silently |
|
169 |
$silent_update_versions = '75'; |
7fe908
|
170 |
|
992797
|
171 |
if(is_file($sql_patch_filename)) { |
7fe908
|
172 |
|
992797
|
173 |
//* Load php patch file and instantiate object |
MC |
174 |
if(is_file($php_patch_filename)) { |
|
175 |
$php_patch_class_name = 'upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT); |
7fe908
|
176 |
include_once $php_patch_filename; |
992797
|
177 |
if(class_exists($php_patch_class_name)) { |
MC |
178 |
$php_patch = new $php_patch_class_name; |
|
179 |
} else { |
|
180 |
swriteln($inst->lng('WARNING: PHP patch file').': '.$php_patch_filename.' '.$inst->lng('contains errors.')); |
|
181 |
} |
|
182 |
} |
7fe908
|
183 |
|
992797
|
184 |
//* Exec onBeforeSQL function |
MC |
185 |
if(isset($php_patch) && is_object($php_patch)) { |
|
186 |
$php_patch->onBeforeSQL(); |
|
187 |
swriteln($inst->lng('Executing PHP patch file').': '.$php_patch_filename); |
|
188 |
} |
7fe908
|
189 |
|
9a3a78
|
190 |
//* Load patch file into database |
L |
191 |
if( !empty($conf["mysql"]["admin_password"]) ) { |
0ccfef
|
192 |
$cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename; |
9a3a78
|
193 |
} else { |
0ccfef
|
194 |
$cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename; |
9a3a78
|
195 |
} |
0ccfef
|
196 |
|
TB |
197 |
if(in_array($next_db_version,explode(',',$silent_update_versions))) $cmd .= ' > /dev/null 2> /dev/null'; |
|
198 |
system($cmd); |
|
199 |
|
992797
|
200 |
swriteln($inst->lng('Loading SQL patch file').': '.$sql_patch_filename); |
7fe908
|
201 |
|
992797
|
202 |
//* Exec onAfterSQL function |
MC |
203 |
if(isset($php_patch) && is_object($php_patch)) { |
|
204 |
$php_patch->onAfterSQL(); |
|
205 |
} |
7fe908
|
206 |
|
9a3a78
|
207 |
$current_db_version = $next_db_version; |
992797
|
208 |
if(isset($php_patch)) unset($php_patch); |
9a3a78
|
209 |
} else { |
L |
210 |
$found = false; |
|
211 |
} |
|
212 |
} |
7fe908
|
213 |
|
9a3a78
|
214 |
//* update the database version in server table |
L |
215 |
$inst->db->query("UPDATE ".$conf["mysql"]["database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); |
8cf78b
|
216 |
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']); |
7fe908
|
217 |
|
MC |
218 |
|
|
219 |
//* If ISPConfig Version < 3.0.3, we will do a full db update |
9a3a78
|
220 |
} else { |
7fe908
|
221 |
|
9a3a78
|
222 |
swriteln($inst->lng('Starting full database update.')); |
7fe908
|
223 |
|
9a3a78
|
224 |
//** Delete the old database |
L |
225 |
if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['mysql']['database']) ) { |
7fe908
|
226 |
$inst->error('Unable to drop MySQL database: '.$conf['mysql']['database'].'.'); |
9a3a78
|
227 |
} |
L |
228 |
|
|
229 |
//** Create the mysql database |
|
230 |
$inst->configure_database(); |
|
231 |
|
|
232 |
//** empty all databases |
|
233 |
$db_tables = $inst->db->getTables(); |
|
234 |
|
|
235 |
foreach($db_tables as $table) { |
|
236 |
$inst->db->query("TRUNCATE $table"); |
|
237 |
} |
|
238 |
|
|
239 |
//** load old data back into database |
|
240 |
if( !empty($conf["mysql"]["admin_password"]) ) { |
02bf99
|
241 |
system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < existing_db.sql"); |
9a3a78
|
242 |
} else { |
02bf99
|
243 |
system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < existing_db.sql"); |
9a3a78
|
244 |
} |
7fe908
|
245 |
|
9a3a78
|
246 |
//** Get the database version number based on the patchfile |
L |
247 |
$found = true; |
|
248 |
while($found == true) { |
|
249 |
$next_db_version = intval($current_db_version + 1); |
|
250 |
$patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql'; |
|
251 |
if(is_file($patch_filename)) { |
|
252 |
$current_db_version = $next_db_version; |
|
253 |
} else { |
|
254 |
$found = false; |
|
255 |
} |
|
256 |
} |
7fe908
|
257 |
|
9a3a78
|
258 |
//* update the database version in server table |
L |
259 |
$inst->db->query("UPDATE ".$conf["mysql"]["database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); |
8cf78b
|
260 |
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']); |
9a3a78
|
261 |
|
L |
262 |
if ($conf['powerdns']['installed']) { |
7fe908
|
263 |
|
9a3a78
|
264 |
swriteln($inst->lng('Starting full PowerDNS database update.')); |
L |
265 |
|
7fe908
|
266 |
//** Delete the old PowerDNS database |
MC |
267 |
if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['powerdns']['database']) ) { |
9a3a78
|
268 |
$inst->error('Unable to drop MySQL database: '.$conf['powerdns']['database'].'.'); |
7fe908
|
269 |
} |
9a3a78
|
270 |
|
7fe908
|
271 |
//** Create the mysql database |
MC |
272 |
$inst->configure_powerdns(); |
9a3a78
|
273 |
|
7fe908
|
274 |
//** load old data back into the PowerDNS database |
MC |
275 |
if( !empty($conf["mysql"]["admin_password"]) ) { |
|
276 |
system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['powerdns']['database'])." < existing_powerdns_db.sql"); |
|
277 |
} else { |
|
278 |
system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['powerdns']['database'])." < existing_powerdns_db.sql"); |
|
279 |
} |
9a3a78
|
280 |
} |
L |
281 |
} |
|
282 |
|
|
283 |
|
|
284 |
//** Update server ini |
edf806
|
285 |
$tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); |
9a3a78
|
286 |
$old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config'])); |
L |
287 |
unset($tmp_server_rec); |
|
288 |
$tpl_ini_array = ini_to_array(rf('tpl/server.ini.master')); |
7fe908
|
289 |
|
9a3a78
|
290 |
//* Update further distribution specific parameters for server config here |
L |
291 |
//* HINT: Every line added here has to be added in installer_base.lib.php too!! |
|
292 |
$tpl_ini_array['jailkit']['jailkit_chroot_app_programs'] = $conf['jailkit']['jailkit_chroot_app_programs']; |
|
293 |
$tpl_ini_array['fastcgi']['fastcgi_phpini_path'] = $conf['fastcgi']['fastcgi_phpini_path']; |
|
294 |
$tpl_ini_array['fastcgi']['fastcgi_starter_path'] = $conf['fastcgi']['fastcgi_starter_path']; |
526b99
|
295 |
$tpl_ini_array['fastcgi']['fastcgi_bin'] = $conf['fastcgi']['fastcgi_bin']; |
9a3a78
|
296 |
$tpl_ini_array['server']['hostname'] = $conf['hostname']; |
L |
297 |
$tpl_ini_array['server']['ip_address'] = @gethostbyname($conf['hostname']); |
|
298 |
$tpl_ini_array['web']['website_basedir'] = $conf['web']['website_basedir']; |
|
299 |
$tpl_ini_array['web']['website_path'] = $conf['web']['website_path']; |
|
300 |
$tpl_ini_array['web']['website_symlinks'] = $conf['web']['website_symlinks']; |
|
301 |
$tpl_ini_array['cron']['crontab_dir'] = $conf['cron']['crontab_dir']; |
|
302 |
$tpl_ini_array['web']['security_level'] = 20; |
|
303 |
$tpl_ini_array['web']['user'] = $conf['apache']['user']; |
|
304 |
$tpl_ini_array['web']['group'] = $conf['apache']['group']; |
|
305 |
$tpl_ini_array['web']['php_ini_path_apache'] = $conf['apache']['php_ini_path_apache']; |
|
306 |
$tpl_ini_array['web']['php_ini_path_cgi'] = $conf['apache']['php_ini_path_cgi']; |
|
307 |
$tpl_ini_array['mail']['pop3_imap_daemon'] = ($conf['dovecot']['installed'] == true)?'dovecot':'courier'; |
|
308 |
$tpl_ini_array['mail']['mail_filter_syntax'] = ($conf['dovecot']['installed'] == true)?'sieve':'maildrop'; |
|
309 |
$tpl_ini_array['dns']['bind_user'] = $conf['bind']['bind_user']; |
|
310 |
$tpl_ini_array['dns']['bind_group'] = $conf['bind']['bind_group']; |
|
311 |
$tpl_ini_array['dns']['bind_zonefiles_dir'] = $conf['bind']['bind_zonefiles_dir']; |
|
312 |
$tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path']; |
|
313 |
$tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path']; |
7fe908
|
314 |
|
dba68f
|
315 |
$tpl_ini_array['web']['nginx_vhost_conf_dir'] = $conf['nginx']['vhost_conf_dir']; |
T |
316 |
$tpl_ini_array['web']['nginx_vhost_conf_enabled_dir'] = $conf['nginx']['vhost_conf_enabled_dir']; |
|
317 |
$tpl_ini_array['web']['nginx_user'] = $conf['nginx']['user']; |
|
318 |
$tpl_ini_array['web']['nginx_group'] = $conf['nginx']['group']; |
|
319 |
$tpl_ini_array['web']['nginx_cgi_socket'] = $conf['nginx']['cgi_socket']; |
|
320 |
$tpl_ini_array['web']['php_fpm_init_script'] = $conf['nginx']['php_fpm_init_script']; |
|
321 |
$tpl_ini_array['web']['php_fpm_ini_path'] = $conf['nginx']['php_fpm_ini_path']; |
|
322 |
$tpl_ini_array['web']['php_fpm_pool_dir'] = $conf['nginx']['php_fpm_pool_dir']; |
|
323 |
$tpl_ini_array['web']['php_fpm_start_port'] = $conf['nginx']['php_fpm_start_port']; |
|
324 |
$tpl_ini_array['web']['php_fpm_socket_dir'] = $conf['nginx']['php_fpm_socket_dir']; |
7fe908
|
325 |
|
4ffb51
|
326 |
if ($conf['nginx']['installed'] == true) { |
F |
327 |
$tpl_ini_array['web']['server_type'] = 'nginx'; |
|
328 |
$tpl_ini_array['global']['webserver'] = 'nginx'; |
|
329 |
} |
9a3a78
|
330 |
|
8cf78b
|
331 |
//* update the new template with the old values |
9a3a78
|
332 |
if(is_array($old_ini_array)) { |
L |
333 |
foreach($old_ini_array as $tmp_section_name => $tmp_section_content) { |
|
334 |
foreach($tmp_section_content as $tmp_var_name => $tmp_var_content) { |
|
335 |
$tpl_ini_array[$tmp_section_name][$tmp_var_name] = $tmp_var_content; |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
|
|
340 |
$new_ini = array_to_ini($tpl_ini_array); |
edf806
|
341 |
$sql = "UPDATE ".$conf["mysql"]["database"].".server SET config = '".mysql_real_escape_string($new_ini)."' WHERE server_id = ".$conf['server_id']; |
5f221a
|
342 |
$inst->db->query($sql); |
7fe908
|
343 |
|
8cf78b
|
344 |
if($inst->db->dbHost != $inst->dbmaster->dbHost) { |
T |
345 |
$sql = "UPDATE ".$conf["mysql"]["master_database"].".server SET config = '".mysql_real_escape_string($new_ini)."' WHERE server_id = ".$conf['server_id']; |
|
346 |
$inst->dbmaster->query($sql); |
|
347 |
} |
9a3a78
|
348 |
unset($old_ini_array); |
L |
349 |
unset($tpl_ini_array); |
|
350 |
unset($new_ini); |
|
351 |
|
|
352 |
|
|
353 |
//** Update system ini |
edf806
|
354 |
$tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM ".$conf["mysql"]["database"].".sys_ini WHERE sysini_id = 1"); |
9a3a78
|
355 |
$old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config'])); |
L |
356 |
unset($tmp_server_rec); |
|
357 |
$tpl_ini_array = ini_to_array(rf('tpl/system.ini.master')); |
|
358 |
|
|
359 |
// update the new template with the old values |
|
360 |
if(is_array($old_ini_array)) { |
|
361 |
foreach($old_ini_array as $tmp_section_name => $tmp_section_content) { |
|
362 |
foreach($tmp_section_content as $tmp_var_name => $tmp_var_content) { |
|
363 |
$tpl_ini_array[$tmp_section_name][$tmp_var_name] = $tmp_var_content; |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
367 |
|
|
368 |
$new_ini = array_to_ini($tpl_ini_array); |
edf806
|
369 |
$tmp = $inst->db->queryOneRecord('SELECT count(sysini_id) as number FROM '.$conf["mysql"]["database"].'.sys_ini WHERE 1'); |
9a3a78
|
370 |
if($tmp['number'] == 0) { |
edf806
|
371 |
$inst->db->query("INSERT INTO ".$conf["mysql"]["database"].".sys_ini (sysini_id, config) VALUES (1,'".mysql_real_escape_string($new_ini)."')"); |
9a3a78
|
372 |
} else { |
edf806
|
373 |
$inst->db->query("UPDATE ".$conf["mysql"]["database"].".sys_ini SET config = '".mysql_real_escape_string($new_ini)."' WHERE sysini_id = 1"); |
9a3a78
|
374 |
} |
L |
375 |
unset($old_ini_array); |
|
376 |
unset($tpl_ini_array); |
|
377 |
unset($new_ini); |
|
378 |
} |
|
379 |
|
992797
|
380 |
|
MC |
381 |
|
9a3a78
|
382 |
?> |