@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | function init() |
18 | 18 | { |
19 | 19 | // Error occurs if already installed |
20 | - if($this->act !== 'procInstallLicenseAggrement' && Context::isInstalled()) |
|
20 | + if ($this->act !== 'procInstallLicenseAggrement' && Context::isInstalled()) |
|
21 | 21 | { |
22 | 22 | $this->stop('msg_already_installed'); |
23 | 23 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | function _procDBSetting() |
87 | 87 | { |
88 | 88 | // Get DB-related variables |
89 | - $con_string = Context::gets('db_type','db_port','db_hostname','db_userid','db_password','db_database','db_table_prefix'); |
|
89 | + $con_string = Context::gets('db_type', 'db_port', 'db_hostname', 'db_userid', 'db_password', 'db_database', 'db_table_prefix'); |
|
90 | 90 | |
91 | 91 | $db_info = new stdClass(); |
92 | 92 | $db_info->master_db = get_object_vars($con_string); |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | // Check if available to connect to the DB |
102 | 102 | $oDB = &DB::getInstance(); |
103 | 103 | $output = $oDB->getError(); |
104 | - if(!$output->toBool()) return $output; |
|
105 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
104 | + if (!$output->toBool()) return $output; |
|
105 | + if (!$oDB->isConnected()) return $oDB->getError(); |
|
106 | 106 | |
107 | 107 | // Create a db temp config file |
108 | - if(!$this->makeDBConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
108 | + if (!$this->makeDBConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
109 | 109 | |
110 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
110 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
111 | 111 | { |
112 | 112 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallConfigForm'); |
113 | 113 | header('location:'.$returnUrl); |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | function procConfigSetting() |
122 | 122 | { |
123 | 123 | // Get variables |
124 | - $config_info = Context::gets('use_rewrite','time_zone'); |
|
125 | - if($config_info->use_rewrite!='Y') $config_info->use_rewrite = 'N'; |
|
124 | + $config_info = Context::gets('use_rewrite', 'time_zone'); |
|
125 | + if ($config_info->use_rewrite != 'Y') $config_info->use_rewrite = 'N'; |
|
126 | 126 | |
127 | 127 | // Create a db temp config file |
128 | - if(!$this->makeEtcConfigFile($config_info)) return new Object(-1, 'msg_install_failed'); |
|
128 | + if (!$this->makeEtcConfigFile($config_info)) return new Object(-1, 'msg_install_failed'); |
|
129 | 129 | |
130 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
130 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
131 | 131 | { |
132 | 132 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallManagerForm'); |
133 | 133 | header('location:'.$returnUrl); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | function procInstall() |
142 | 142 | { |
143 | 143 | // Check if it is already installed |
144 | - if(Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
144 | + if (Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
145 | 145 | |
146 | 146 | // Assign a temporary administrator when installing |
147 | 147 | $logged_info = new stdClass(); |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | Context::set('logged_info', $logged_info); |
150 | 150 | |
151 | 151 | // check install config |
152 | - if(Context::get('install_config')) |
|
152 | + if (Context::get('install_config')) |
|
153 | 153 | { |
154 | 154 | $db_info = $this->_makeDbInfoByInstallConfig(); |
155 | 155 | } |
156 | 156 | // install by default XE UI |
157 | 157 | else |
158 | 158 | { |
159 | - if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
160 | - if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
159 | + if (FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
160 | + if (FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // Set DB type and information |
@@ -165,30 +165,30 @@ discard block |
||
165 | 165 | // Create DB Instance |
166 | 166 | $oDB = &DB::getInstance(); |
167 | 167 | // Check if available to connect to the DB |
168 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
168 | + if (!$oDB->isConnected()) return $oDB->getError(); |
|
169 | 169 | |
170 | 170 | // Install all the modules |
171 | 171 | try { |
172 | 172 | $oDB->begin(); |
173 | 173 | $this->installDownloadedModule(); |
174 | 174 | $oDB->commit(); |
175 | - } catch(Exception $e) { |
|
175 | + } catch (Exception $e) { |
|
176 | 176 | $oDB->rollback(); |
177 | 177 | return new Object(-1, $e->getMessage()); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Create a config file |
181 | - if(!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
181 | + if (!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
182 | 182 | |
183 | 183 | // load script |
184 | - $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); |
|
185 | - if(count($scripts)>0) |
|
184 | + $scripts = FileHandler::readDir(_XE_PATH_.'modules/install/script', '/(\.php)$/'); |
|
185 | + if (count($scripts) > 0) |
|
186 | 186 | { |
187 | 187 | sort($scripts); |
188 | - foreach($scripts as $script) |
|
188 | + foreach ($scripts as $script) |
|
189 | 189 | { |
190 | 190 | $script_path = FileHandler::getRealPath('./modules/install/script/'); |
191 | - $output = include($script_path . $script); |
|
191 | + $output = include($script_path.$script); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | unset($_SESSION['use_rewrite']); |
203 | 203 | |
204 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
204 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
205 | 205 | { |
206 | 206 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl(''); |
207 | 207 | header('location:'.$returnUrl); |
@@ -239,57 +239,57 @@ discard block |
||
239 | 239 | */ |
240 | 240 | function procInstallFTP() |
241 | 241 | { |
242 | - if(Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
243 | - $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
|
244 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
245 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
246 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
247 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
242 | + if (Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
243 | + $ftp_info = Context::gets('ftp_host', 'ftp_user', 'ftp_password', 'ftp_port', 'ftp_root_path'); |
|
244 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
245 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
246 | + if (!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
247 | + if (!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
248 | 248 | |
249 | 249 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
250 | 250 | $buff[] = "\$ftp_info = new stdClass();"; |
251 | - foreach($ftp_info as $key => $val) |
|
251 | + foreach ($ftp_info as $key => $val) |
|
252 | 252 | { |
253 | - $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'","\\'",$val)); |
|
253 | + $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'", "\\'", $val)); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | // If safe_mode |
257 | - if(ini_get('safe_mode')) |
|
257 | + if (ini_get('safe_mode')) |
|
258 | 258 | { |
259 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
259 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1, 'msg_safe_mode_ftp_needed'); |
|
260 | 260 | |
261 | 261 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
262 | 262 | $oFtp = new ftp(); |
263 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host)); |
|
263 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host)); |
|
264 | 264 | |
265 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
265 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
266 | 266 | { |
267 | 267 | $oFtp->ftp_quit(); |
268 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
268 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
269 | 269 | } |
270 | 270 | |
271 | - if(!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
271 | + if (!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
272 | 272 | { |
273 | 273 | $oFtp->ftp_quit(); |
274 | - return new Object(-1,'msg_ftp_mkdir_fail'); |
|
274 | + return new Object(-1, 'msg_ftp_mkdir_fail'); |
|
275 | 275 | } |
276 | 276 | |
277 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
277 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
278 | 278 | { |
279 | 279 | $oFtp->ftp_quit(); |
280 | - return new Object(-1,'msg_ftp_chmod_fail'); |
|
280 | + return new Object(-1, 'msg_ftp_chmod_fail'); |
|
281 | 281 | } |
282 | 282 | |
283 | - if(!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
283 | + if (!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
284 | 284 | { |
285 | 285 | $oFtp->ftp_quit(); |
286 | - return new Object(-1,'msg_ftp_mkdir_fail'); |
|
286 | + return new Object(-1, 'msg_ftp_mkdir_fail'); |
|
287 | 287 | } |
288 | 288 | |
289 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
289 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
290 | 290 | { |
291 | 291 | $oFtp->ftp_quit(); |
292 | - return new Object(-1,'msg_ftp_chmod_fail'); |
|
292 | + return new Object(-1, 'msg_ftp_chmod_fail'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | $oFtp->ftp_quit(); |
@@ -300,31 +300,31 @@ discard block |
||
300 | 300 | |
301 | 301 | function procInstallCheckFtp() |
302 | 302 | { |
303 | - $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
|
304 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
305 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
306 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
303 | + $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port', 'sftp'); |
|
304 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
305 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
306 | + if (!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
307 | 307 | |
308 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
308 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1, 'msg_safe_mode_ftp_needed'); |
|
309 | 309 | |
310 | - if($ftp_info->sftp == 'Y') |
|
310 | + if ($ftp_info->sftp == 'Y') |
|
311 | 311 | { |
312 | 312 | $connection = ssh2_connect('localhost', $ftp_info->ftp_port); |
313 | - if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
313 | + if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
314 | 314 | { |
315 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
315 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | else |
319 | 319 | { |
320 | 320 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
321 | 321 | $oFtp = new ftp(); |
322 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
322 | + if (!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
323 | 323 | |
324 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
324 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
325 | 325 | { |
326 | 326 | $oFtp->ftp_quit(); |
327 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
327 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
328 | 328 | } |
329 | 329 | $oFtp->ftp_quit(); |
330 | 330 | } |
@@ -341,36 +341,36 @@ discard block |
||
341 | 341 | $checklist = array(); |
342 | 342 | // 0. check your version of php (5.2.4 or higher) |
343 | 343 | $checklist['php_version'] = true; |
344 | - if(version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
344 | + if (version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
345 | 345 | { |
346 | 346 | $checklist['php_version'] = false; |
347 | 347 | } |
348 | 348 | |
349 | - if(version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
349 | + if (version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
350 | 350 | { |
351 | 351 | Context::set('phpversion_warning', true); |
352 | 352 | } |
353 | 353 | |
354 | 354 | // 1. Check permission |
355 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
355 | + if (is_writable('./') || is_writable('./files')) $checklist['permission'] = true; |
|
356 | 356 | else $checklist['permission'] = false; |
357 | 357 | // 2. Check if xml_parser_create exists |
358 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
358 | + if (function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
359 | 359 | else $checklist['xml'] = false; |
360 | 360 | // 3. Check if ini_get (session.auto_start) == 1 |
361 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
361 | + if (ini_get('session.auto_start') != 1) $checklist['session'] = true; |
|
362 | 362 | else $checklist['session'] = false; |
363 | 363 | // 4. Check if iconv exists |
364 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
364 | + if (function_exists('iconv')) $checklist['iconv'] = true; |
|
365 | 365 | else $checklist['iconv'] = false; |
366 | 366 | // 5. Check gd(imagecreatefromgif function) |
367 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
367 | + if (function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
368 | 368 | else $checklist['gd'] = false; |
369 | 369 | // 6. Check DB |
370 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
370 | + if (DB::getEnableList()) $checklist['db'] = true; |
|
371 | 371 | else $checklist['db'] = false; |
372 | 372 | |
373 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
373 | + if (!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
374 | 374 | else $install_enable = true; |
375 | 375 | |
376 | 376 | // Save the checked result to the Context |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | |
391 | 391 | $license_agreement = ($vars->license_agreement == 'Y') ? true : false; |
392 | 392 | |
393 | - if($license_agreement) |
|
393 | + if ($license_agreement) |
|
394 | 394 | { |
395 | 395 | $currentTime = $_SERVER['REQUEST_TIME']; |
396 | 396 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | return new Object(-1, 'msg_must_accept_license_agreement'); |
402 | 402 | } |
403 | 403 | |
404 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
404 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
405 | 405 | { |
406 | 406 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallCheckEnv'); |
407 | 407 | $this->setRedirectUrl($returnUrl); |
@@ -424,25 +424,25 @@ discard block |
||
424 | 424 | $hostname = $_SERVER['SERVER_NAME']; |
425 | 425 | $port = $_SERVER['SERVER_PORT']; |
426 | 426 | $str_port = ''; |
427 | - if($port) |
|
427 | + if ($port) |
|
428 | 428 | { |
429 | - $str_port = ':' . $port; |
|
429 | + $str_port = ':'.$port; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $tmpPath = $_SERVER['DOCUMENT_ROOT']; |
433 | 433 | |
434 | 434 | //if DIRECTORY_SEPARATOR is not /(IIS) |
435 | - if(DIRECTORY_SEPARATOR !== '/') |
|
435 | + if (DIRECTORY_SEPARATOR !== '/') |
|
436 | 436 | { |
437 | 437 | //change to slash for compare |
438 | 438 | $tmpPath = str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']); |
439 | 439 | } |
440 | 440 | |
441 | - $query = "/JUST/CHECK/REWRITE/" . $checkFilePath; |
|
441 | + $query = "/JUST/CHECK/REWRITE/".$checkFilePath; |
|
442 | 442 | $currentPath = str_replace($tmpPath, "", _XE_PATH_); |
443 | - if($currentPath != "") |
|
443 | + if ($currentPath != "") |
|
444 | 444 | { |
445 | - $query = $currentPath . $query; |
|
445 | + $query = $currentPath.$query; |
|
446 | 446 | } |
447 | 447 | $requestUrl = sprintf('%s://%s%s%s', $scheme, $hostname, $str_port, $query); |
448 | 448 | $requestConfig = array(); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | './files/cache/template_compiled', |
468 | 468 | ); |
469 | 469 | |
470 | - foreach($directory_list as $dir) |
|
470 | + foreach ($directory_list as $dir) |
|
471 | 471 | { |
472 | 472 | FileHandler::makeDir($dir); |
473 | 473 | } |
@@ -483,57 +483,57 @@ discard block |
||
483 | 483 | $oModuleModel = getModel('module'); |
484 | 484 | // Create a table ny finding schemas/*.xml file in each module |
485 | 485 | $module_list = FileHandler::readDir('./modules/', NULL, false, true); |
486 | - foreach($module_list as $module_path) |
|
486 | + foreach ($module_list as $module_path) |
|
487 | 487 | { |
488 | 488 | // Get module name |
489 | - $tmp_arr = explode('/',$module_path); |
|
490 | - $module = $tmp_arr[count($tmp_arr)-1]; |
|
489 | + $tmp_arr = explode('/', $module_path); |
|
490 | + $module = $tmp_arr[count($tmp_arr) - 1]; |
|
491 | 491 | |
492 | 492 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
493 | - if(!$xml_info) continue; |
|
493 | + if (!$xml_info) continue; |
|
494 | 494 | $modules[$xml_info->category][] = $module; |
495 | 495 | } |
496 | 496 | // Install "module" module in advance |
497 | - $this->installModule('module','./modules/module'); |
|
497 | + $this->installModule('module', './modules/module'); |
|
498 | 498 | $oModule = getClass('module'); |
499 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
499 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
500 | 500 | // Determine the order of module installation depending on category |
501 | - $install_step = array('system','content','member'); |
|
501 | + $install_step = array('system', 'content', 'member'); |
|
502 | 502 | // Install all the remaining modules |
503 | - foreach($install_step as $category) |
|
503 | + foreach ($install_step as $category) |
|
504 | 504 | { |
505 | - if(count($modules[$category])) |
|
505 | + if (count($modules[$category])) |
|
506 | 506 | { |
507 | - foreach($modules[$category] as $module) |
|
507 | + foreach ($modules[$category] as $module) |
|
508 | 508 | { |
509 | - if($module == 'module') continue; |
|
509 | + if ($module == 'module') continue; |
|
510 | 510 | $this->installModule($module, sprintf('./modules/%s', $module)); |
511 | 511 | |
512 | 512 | $oModule = getClass($module); |
513 | - if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
513 | + if (is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
514 | 514 | { |
515 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
515 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | unset($modules[$category]); |
519 | 519 | } |
520 | 520 | } |
521 | 521 | // Install all the remaining modules |
522 | - if(count($modules)) |
|
522 | + if (count($modules)) |
|
523 | 523 | { |
524 | - foreach($modules as $category => $module_list) |
|
524 | + foreach ($modules as $category => $module_list) |
|
525 | 525 | { |
526 | - if(count($module_list)) |
|
526 | + if (count($module_list)) |
|
527 | 527 | { |
528 | - foreach($module_list as $module) |
|
528 | + foreach ($module_list as $module) |
|
529 | 529 | { |
530 | - if($module == 'module') continue; |
|
530 | + if ($module == 'module') continue; |
|
531 | 531 | $this->installModule($module, sprintf('./modules/%s', $module)); |
532 | 532 | |
533 | 533 | $oModule = getClass($module); |
534 | - if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
534 | + if ($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
535 | 535 | { |
536 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
536 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
537 | 537 | } |
538 | 538 | } |
539 | 539 | } |
@@ -555,31 +555,31 @@ discard block |
||
555 | 555 | $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); |
556 | 556 | |
557 | 557 | $file_cnt = count($schema_files); |
558 | - for($i=0;$i<$file_cnt;$i++) |
|
558 | + for ($i = 0; $i < $file_cnt; $i++) |
|
559 | 559 | { |
560 | 560 | $file = trim($schema_files[$i]); |
561 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
561 | + if (!$file || substr($file, -4) != '.xml') continue; |
|
562 | 562 | $output = $oDB->createTableByXmlFile($file); |
563 | - if($output === false) |
|
563 | + if ($output === false) |
|
564 | 564 | throw new Exception('msg_create_table_failed'); |
565 | 565 | } |
566 | 566 | // Create a table and module instance and then execute install() method |
567 | 567 | unset($oModule); |
568 | 568 | $oModule = getClass($module); |
569 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
569 | + if (method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
570 | 570 | return new Object(); |
571 | 571 | } |
572 | 572 | |
573 | 573 | function _getDBConfigFileContents($db_info) |
574 | 574 | { |
575 | - if(substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
575 | + if (substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
576 | 576 | { |
577 | 577 | $db_info->master_db['db_table_prefix'] .= '_'; |
578 | 578 | } |
579 | 579 | |
580 | - foreach($db_info->slave_db as &$slave) |
|
580 | + foreach ($db_info->slave_db as &$slave) |
|
581 | 581 | { |
582 | - if(substr($slave['db_table_prefix'], -1) != '_') |
|
582 | + if (substr($slave['db_table_prefix'], -1) != '_') |
|
583 | 583 | { |
584 | 584 | $slave['db_table_prefix'] .= '_'; |
585 | 585 | } |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | |
588 | 588 | $buff = array(); |
589 | 589 | $buff[] = '<?php if(!defined("__XE__")) exit();'; |
590 | - $buff[] = '$db_info = (object)' . var_export(get_object_vars($db_info), TRUE) . ';'; |
|
590 | + $buff[] = '$db_info = (object)'.var_export(get_object_vars($db_info), TRUE).';'; |
|
591 | 591 | |
592 | 592 | return implode(PHP_EOL, $buff); |
593 | 593 | } |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | $db_tmp_config_file = $this->db_tmp_config_file; |
602 | 602 | |
603 | 603 | $db_info = Context::getDBInfo(); |
604 | - if(!$db_info) return; |
|
604 | + if (!$db_info) return; |
|
605 | 605 | |
606 | 606 | $buff = $this->_getDBConfigFileContents($db_info); |
607 | 607 | |
608 | 608 | FileHandler::writeFile($db_tmp_config_file, $buff); |
609 | 609 | |
610 | - if(@file_exists($db_tmp_config_file)) return true; |
|
610 | + if (@file_exists($db_tmp_config_file)) return true; |
|
611 | 611 | return false; |
612 | 612 | } |
613 | 613 | |
@@ -620,14 +620,14 @@ discard block |
||
620 | 620 | $etc_tmp_config_file = $this->etc_tmp_config_file; |
621 | 621 | |
622 | 622 | $buff = '<?php if(!defined("__XE__")) exit();'."\n"; |
623 | - foreach($config_info as $key => $val) |
|
623 | + foreach ($config_info as $key => $val) |
|
624 | 624 | { |
625 | - $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'","\\'",$val)); |
|
625 | + $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val)); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
629 | 629 | |
630 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
630 | + if (@file_exists($etc_tmp_config_file)) return true; |
|
631 | 631 | return false; |
632 | 632 | } |
633 | 633 | |
@@ -642,13 +642,13 @@ discard block |
||
642 | 642 | //if(file_exists($config_file)) return; |
643 | 643 | |
644 | 644 | $db_info = Context::getDBInfo(); |
645 | - if(!$db_info) return; |
|
645 | + if (!$db_info) return; |
|
646 | 646 | |
647 | 647 | $buff = $this->_getDBConfigFileContents($db_info); |
648 | 648 | |
649 | 649 | FileHandler::writeFile($config_file, $buff); |
650 | 650 | |
651 | - if(@file_exists($config_file)) |
|
651 | + if (@file_exists($config_file)) |
|
652 | 652 | { |
653 | 653 | FileHandler::removeFile($this->db_tmp_config_file); |
654 | 654 | FileHandler::removeFile($this->etc_tmp_config_file); |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | function installByConfig($install_config_file) |
664 | 664 | { |
665 | 665 | include $install_config_file; |
666 | - if(!is_array($auto_config)) return false; |
|
666 | + if (!is_array($auto_config)) return false; |
|
667 | 667 | |
668 | 668 | $auto_config['module'] = 'install'; |
669 | 669 | $auto_config['act'] = 'procInstall'; |
@@ -671,22 +671,22 @@ discard block |
||
671 | 671 | $fstr = "<%s><![CDATA[%s]]></%s>\r\n"; |
672 | 672 | $fheader = "POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/xml\r\nContent-Length: %s\r\n\r\n%s\r\n"; |
673 | 673 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
674 | - foreach($auto_config as $k => $v) |
|
674 | + foreach ($auto_config as $k => $v) |
|
675 | 675 | { |
676 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
676 | + if (!in_array($k, array('host', 'port', 'path'))) $body .= sprintf($fstr, $k, $v, $k); |
|
677 | 677 | } |
678 | 678 | $body .= "</params>\r\n</methodCall>"; |
679 | 679 | |
680 | - $header = sprintf($fheader,$auto_config['path'],$auto_config['host'],strlen($body),$body); |
|
680 | + $header = sprintf($fheader, $auto_config['path'], $auto_config['host'], strlen($body), $body); |
|
681 | 681 | $fp = @fsockopen($auto_config['host'], $auto_config['port'], $errno, $errstr, 5); |
682 | 682 | |
683 | - if($fp) |
|
683 | + if ($fp) |
|
684 | 684 | { |
685 | 685 | fputs($fp, $header); |
686 | - while(!feof($fp)) |
|
686 | + while (!feof($fp)) |
|
687 | 687 | { |
688 | 688 | $line = trim(fgets($fp, 4096)); |
689 | - if(strncmp('<error>', $line, 7) === 0) |
|
689 | + if (strncmp('<error>', $line, 7) === 0) |
|
690 | 690 | { |
691 | 691 | fclose($fp); |
692 | 692 | return false; |