@@ -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,13 +141,13 @@ 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 | Context::loadLang('modules/member/lang'); |
| 147 | 147 | $oMemberModel = getModel('member'); |
| 148 | 148 | $vars = Context::getRequestVars(); |
| 149 | 149 | |
| 150 | - if(!$oMemberModel->checkPasswordStrength($vars->password, 'high')) |
|
| 150 | + if (!$oMemberModel->checkPasswordStrength($vars->password, 'high')) |
|
| 151 | 151 | { |
| 152 | 152 | Context::loadLang('modules/member/lang'); |
| 153 | 153 | $message = Context::getLang('about_password_strength'); |
@@ -160,15 +160,15 @@ discard block |
||
| 160 | 160 | Context::set('logged_info', $logged_info); |
| 161 | 161 | |
| 162 | 162 | // check install config |
| 163 | - if(Context::get('install_config')) |
|
| 163 | + if (Context::get('install_config')) |
|
| 164 | 164 | { |
| 165 | 165 | $db_info = $this->_makeDbInfoByInstallConfig(); |
| 166 | 166 | } |
| 167 | 167 | // install by default XE UI |
| 168 | 168 | else |
| 169 | 169 | { |
| 170 | - if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
| 171 | - if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
| 170 | + if (FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
| 171 | + if (FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Set DB type and information |
@@ -176,30 +176,30 @@ discard block |
||
| 176 | 176 | // Create DB Instance |
| 177 | 177 | $oDB = &DB::getInstance(); |
| 178 | 178 | // Check if available to connect to the DB |
| 179 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
| 179 | + if (!$oDB->isConnected()) return $oDB->getError(); |
|
| 180 | 180 | |
| 181 | 181 | // Install all the modules |
| 182 | 182 | try { |
| 183 | 183 | $oDB->begin(); |
| 184 | 184 | $this->installDownloadedModule(); |
| 185 | 185 | $oDB->commit(); |
| 186 | - } catch(Exception $e) { |
|
| 186 | + } catch (Exception $e) { |
|
| 187 | 187 | $oDB->rollback(); |
| 188 | 188 | return new Object(-1, $e->getMessage()); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // Create a config file |
| 192 | - if(!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
| 192 | + if (!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
| 193 | 193 | |
| 194 | 194 | // load script |
| 195 | - $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); |
|
| 196 | - if(count($scripts)>0) |
|
| 195 | + $scripts = FileHandler::readDir(_XE_PATH_.'modules/install/script', '/(\.php)$/'); |
|
| 196 | + if (count($scripts) > 0) |
|
| 197 | 197 | { |
| 198 | 198 | sort($scripts); |
| 199 | - foreach($scripts as $script) |
|
| 199 | + foreach ($scripts as $script) |
|
| 200 | 200 | { |
| 201 | 201 | $script_path = FileHandler::getRealPath('./modules/install/script/'); |
| 202 | - $output = include($script_path . $script); |
|
| 202 | + $output = include($script_path.$script); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | unset($_SESSION['use_rewrite']); |
| 214 | 214 | |
| 215 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
| 215 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
| 216 | 216 | { |
| 217 | 217 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl(''); |
| 218 | 218 | header('location:'.$returnUrl); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $db_info->use_rewrite = Context::get('use_rewrite'); |
| 243 | 243 | $db_info->time_zone = Context::get('time_zone'); |
| 244 | 244 | |
| 245 | - if($_SERVER['HTTPS'] == 'on') |
|
| 245 | + if ($_SERVER['HTTPS'] == 'on') |
|
| 246 | 246 | { |
| 247 | 247 | $https_port = (Context::get('https_port')) ? Context::get('https_port') : $_SERVER['SERVER_PORT']; |
| 248 | 248 | $https_port = (!$https_port != 443) ? $https_port : null; |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | $http_port = (Context::get('http_port')) ? Context::get('http_port') : $_SERVER['SERVER_PORT']; |
| 253 | 253 | $http_port = (!$http_port != 80) ? $http_port : null; |
| 254 | 254 | } |
| 255 | - if($http_port) $db_info->http_port = $http_port; |
|
| 256 | - if($https_port) $db_info->https_port = $https_port; |
|
| 255 | + if ($http_port) $db_info->http_port = $http_port; |
|
| 256 | + if ($https_port) $db_info->https_port = $https_port; |
|
| 257 | 257 | |
| 258 | 258 | return $db_info; |
| 259 | 259 | } |
@@ -263,57 +263,57 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | function procInstallFTP() |
| 265 | 265 | { |
| 266 | - if(Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
| 267 | - $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
|
| 268 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
| 269 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 270 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 271 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 266 | + if (Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
| 267 | + $ftp_info = Context::gets('ftp_host', 'ftp_user', 'ftp_password', 'ftp_port', 'ftp_root_path'); |
|
| 268 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
| 269 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 270 | + if (!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 271 | + if (!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 272 | 272 | |
| 273 | 273 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
| 274 | 274 | $buff[] = "\$ftp_info = new stdClass();"; |
| 275 | - foreach($ftp_info as $key => $val) |
|
| 275 | + foreach ($ftp_info as $key => $val) |
|
| 276 | 276 | { |
| 277 | - $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'","\\'",$val)); |
|
| 277 | + $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'", "\\'", $val)); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // If safe_mode |
| 281 | - if(ini_get('safe_mode')) |
|
| 281 | + if (ini_get('safe_mode')) |
|
| 282 | 282 | { |
| 283 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 283 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1, 'msg_safe_mode_ftp_needed'); |
|
| 284 | 284 | |
| 285 | 285 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 286 | 286 | $oFtp = new ftp(); |
| 287 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 287 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 288 | 288 | |
| 289 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 289 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 290 | 290 | { |
| 291 | 291 | $oFtp->ftp_quit(); |
| 292 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
| 292 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - if(!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
| 295 | + if (!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
| 296 | 296 | { |
| 297 | 297 | $oFtp->ftp_quit(); |
| 298 | - return new Object(-1,'msg_ftp_mkdir_fail'); |
|
| 298 | + return new Object(-1, 'msg_ftp_mkdir_fail'); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
| 301 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
| 302 | 302 | { |
| 303 | 303 | $oFtp->ftp_quit(); |
| 304 | - return new Object(-1,'msg_ftp_chmod_fail'); |
|
| 304 | + return new Object(-1, 'msg_ftp_chmod_fail'); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if(!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
| 307 | + if (!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
| 308 | 308 | { |
| 309 | 309 | $oFtp->ftp_quit(); |
| 310 | - return new Object(-1,'msg_ftp_mkdir_fail'); |
|
| 310 | + return new Object(-1, 'msg_ftp_mkdir_fail'); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
| 313 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
| 314 | 314 | { |
| 315 | 315 | $oFtp->ftp_quit(); |
| 316 | - return new Object(-1,'msg_ftp_chmod_fail'); |
|
| 316 | + return new Object(-1, 'msg_ftp_chmod_fail'); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | $oFtp->ftp_quit(); |
@@ -324,31 +324,31 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | function procInstallCheckFtp() |
| 326 | 326 | { |
| 327 | - $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
|
| 328 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
| 329 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 330 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 327 | + $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port', 'sftp'); |
|
| 328 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
| 329 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 330 | + if (!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 331 | 331 | |
| 332 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 332 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1, 'msg_safe_mode_ftp_needed'); |
|
| 333 | 333 | |
| 334 | - if($ftp_info->sftp == 'Y') |
|
| 334 | + if ($ftp_info->sftp == 'Y') |
|
| 335 | 335 | { |
| 336 | 336 | $connection = ssh2_connect('localhost', $ftp_info->ftp_port); |
| 337 | - if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 337 | + if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 338 | 338 | { |
| 339 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
| 339 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | else |
| 343 | 343 | { |
| 344 | 344 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 345 | 345 | $oFtp = new ftp(); |
| 346 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 346 | + if (!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 347 | 347 | |
| 348 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 348 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 349 | 349 | { |
| 350 | 350 | $oFtp->ftp_quit(); |
| 351 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
| 351 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
| 352 | 352 | } |
| 353 | 353 | $oFtp->ftp_quit(); |
| 354 | 354 | } |
@@ -365,36 +365,36 @@ discard block |
||
| 365 | 365 | $checklist = array(); |
| 366 | 366 | // 0. check your version of php (5.2.4 or higher) |
| 367 | 367 | $checklist['php_version'] = true; |
| 368 | - if(version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
| 368 | + if (version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
| 369 | 369 | { |
| 370 | 370 | $checklist['php_version'] = false; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if(version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
| 373 | + if (version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
| 374 | 374 | { |
| 375 | 375 | Context::set('phpversion_warning', true); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | // 1. Check permission |
| 379 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
| 379 | + if (is_writable('./') || is_writable('./files')) $checklist['permission'] = true; |
|
| 380 | 380 | else $checklist['permission'] = false; |
| 381 | 381 | // 2. Check if xml_parser_create exists |
| 382 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 382 | + if (function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 383 | 383 | else $checklist['xml'] = false; |
| 384 | 384 | // 3. Check if ini_get (session.auto_start) == 1 |
| 385 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
| 385 | + if (ini_get('session.auto_start') != 1) $checklist['session'] = true; |
|
| 386 | 386 | else $checklist['session'] = false; |
| 387 | 387 | // 4. Check if iconv exists |
| 388 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
| 388 | + if (function_exists('iconv')) $checklist['iconv'] = true; |
|
| 389 | 389 | else $checklist['iconv'] = false; |
| 390 | 390 | // 5. Check gd(imagecreatefromgif function) |
| 391 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 391 | + if (function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 392 | 392 | else $checklist['gd'] = false; |
| 393 | 393 | // 6. Check DB |
| 394 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
| 394 | + if (DB::getEnableList()) $checklist['db'] = true; |
|
| 395 | 395 | else $checklist['db'] = false; |
| 396 | 396 | |
| 397 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 397 | + if (!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 398 | 398 | else $install_enable = true; |
| 399 | 399 | |
| 400 | 400 | // Save the checked result to the Context |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | $license_agreement = ($vars->license_agreement == 'Y') ? true : false; |
| 416 | 416 | |
| 417 | - if($license_agreement) |
|
| 417 | + if ($license_agreement) |
|
| 418 | 418 | { |
| 419 | 419 | $currentTime = $_SERVER['REQUEST_TIME']; |
| 420 | 420 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | return new Object(-1, 'msg_must_accept_license_agreement'); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
| 428 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
| 429 | 429 | { |
| 430 | 430 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallCheckEnv'); |
| 431 | 431 | $this->setRedirectUrl($returnUrl); |
@@ -448,25 +448,25 @@ discard block |
||
| 448 | 448 | $hostname = $_SERVER['SERVER_NAME']; |
| 449 | 449 | $port = $_SERVER['SERVER_PORT']; |
| 450 | 450 | $str_port = ''; |
| 451 | - if($port) |
|
| 451 | + if ($port) |
|
| 452 | 452 | { |
| 453 | - $str_port = ':' . $port; |
|
| 453 | + $str_port = ':'.$port; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | $tmpPath = $_SERVER['DOCUMENT_ROOT']; |
| 457 | 457 | |
| 458 | 458 | //if DIRECTORY_SEPARATOR is not /(IIS) |
| 459 | - if(DIRECTORY_SEPARATOR !== '/') |
|
| 459 | + if (DIRECTORY_SEPARATOR !== '/') |
|
| 460 | 460 | { |
| 461 | 461 | //change to slash for compare |
| 462 | 462 | $tmpPath = str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']); |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - $query = "/JUST/CHECK/REWRITE/" . $checkFilePath; |
|
| 465 | + $query = "/JUST/CHECK/REWRITE/".$checkFilePath; |
|
| 466 | 466 | $currentPath = str_replace($tmpPath, "", _XE_PATH_); |
| 467 | - if($currentPath != "") |
|
| 467 | + if ($currentPath != "") |
|
| 468 | 468 | { |
| 469 | - $query = $currentPath . $query; |
|
| 469 | + $query = $currentPath.$query; |
|
| 470 | 470 | } |
| 471 | 471 | $requestUrl = sprintf('%s://%s%s%s', $scheme, $hostname, $str_port, $query); |
| 472 | 472 | $requestConfig = array(); |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | './files/cache/template_compiled', |
| 492 | 492 | ); |
| 493 | 493 | |
| 494 | - foreach($directory_list as $dir) |
|
| 494 | + foreach ($directory_list as $dir) |
|
| 495 | 495 | { |
| 496 | 496 | FileHandler::makeDir($dir); |
| 497 | 497 | } |
@@ -507,57 +507,57 @@ discard block |
||
| 507 | 507 | $oModuleModel = getModel('module'); |
| 508 | 508 | // Create a table ny finding schemas/*.xml file in each module |
| 509 | 509 | $module_list = FileHandler::readDir('./modules/', NULL, false, true); |
| 510 | - foreach($module_list as $module_path) |
|
| 510 | + foreach ($module_list as $module_path) |
|
| 511 | 511 | { |
| 512 | 512 | // Get module name |
| 513 | - $tmp_arr = explode('/',$module_path); |
|
| 514 | - $module = $tmp_arr[count($tmp_arr)-1]; |
|
| 513 | + $tmp_arr = explode('/', $module_path); |
|
| 514 | + $module = $tmp_arr[count($tmp_arr) - 1]; |
|
| 515 | 515 | |
| 516 | 516 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
| 517 | - if(!$xml_info) continue; |
|
| 517 | + if (!$xml_info) continue; |
|
| 518 | 518 | $modules[$xml_info->category][] = $module; |
| 519 | 519 | } |
| 520 | 520 | // Install "module" module in advance |
| 521 | - $this->installModule('module','./modules/module'); |
|
| 521 | + $this->installModule('module', './modules/module'); |
|
| 522 | 522 | $oModule = getClass('module'); |
| 523 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 523 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 524 | 524 | // Determine the order of module installation depending on category |
| 525 | - $install_step = array('system','content','member'); |
|
| 525 | + $install_step = array('system', 'content', 'member'); |
|
| 526 | 526 | // Install all the remaining modules |
| 527 | - foreach($install_step as $category) |
|
| 527 | + foreach ($install_step as $category) |
|
| 528 | 528 | { |
| 529 | - if(count($modules[$category])) |
|
| 529 | + if (count($modules[$category])) |
|
| 530 | 530 | { |
| 531 | - foreach($modules[$category] as $module) |
|
| 531 | + foreach ($modules[$category] as $module) |
|
| 532 | 532 | { |
| 533 | - if($module == 'module') continue; |
|
| 533 | + if ($module == 'module') continue; |
|
| 534 | 534 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 535 | 535 | |
| 536 | 536 | $oModule = getClass($module); |
| 537 | - if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
| 537 | + if (is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
| 538 | 538 | { |
| 539 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 539 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | unset($modules[$category]); |
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | // Install all the remaining modules |
| 546 | - if(count($modules)) |
|
| 546 | + if (count($modules)) |
|
| 547 | 547 | { |
| 548 | - foreach($modules as $category => $module_list) |
|
| 548 | + foreach ($modules as $category => $module_list) |
|
| 549 | 549 | { |
| 550 | - if(count($module_list)) |
|
| 550 | + if (count($module_list)) |
|
| 551 | 551 | { |
| 552 | - foreach($module_list as $module) |
|
| 552 | + foreach ($module_list as $module) |
|
| 553 | 553 | { |
| 554 | - if($module == 'module') continue; |
|
| 554 | + if ($module == 'module') continue; |
|
| 555 | 555 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 556 | 556 | |
| 557 | 557 | $oModule = getClass($module); |
| 558 | - if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
| 558 | + if ($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
| 559 | 559 | { |
| 560 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 560 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | } |
@@ -579,31 +579,31 @@ discard block |
||
| 579 | 579 | $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); |
| 580 | 580 | |
| 581 | 581 | $file_cnt = count($schema_files); |
| 582 | - for($i=0;$i<$file_cnt;$i++) |
|
| 582 | + for ($i = 0; $i < $file_cnt; $i++) |
|
| 583 | 583 | { |
| 584 | 584 | $file = trim($schema_files[$i]); |
| 585 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
| 585 | + if (!$file || substr($file, -4) != '.xml') continue; |
|
| 586 | 586 | $output = $oDB->createTableByXmlFile($file); |
| 587 | - if($output === false) |
|
| 587 | + if ($output === false) |
|
| 588 | 588 | throw new Exception('msg_create_table_failed'); |
| 589 | 589 | } |
| 590 | 590 | // Create a table and module instance and then execute install() method |
| 591 | 591 | unset($oModule); |
| 592 | 592 | $oModule = getClass($module); |
| 593 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 593 | + if (method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 594 | 594 | return new Object(); |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | function _getDBConfigFileContents($db_info) |
| 598 | 598 | { |
| 599 | - if(substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
| 599 | + if (substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
| 600 | 600 | { |
| 601 | 601 | $db_info->master_db['db_table_prefix'] .= '_'; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - foreach($db_info->slave_db as &$slave) |
|
| 604 | + foreach ($db_info->slave_db as &$slave) |
|
| 605 | 605 | { |
| 606 | - if(substr($slave['db_table_prefix'], -1) != '_') |
|
| 606 | + if (substr($slave['db_table_prefix'], -1) != '_') |
|
| 607 | 607 | { |
| 608 | 608 | $slave['db_table_prefix'] .= '_'; |
| 609 | 609 | } |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | |
| 612 | 612 | $buff = array(); |
| 613 | 613 | $buff[] = '<?php if(!defined("__XE__")) exit();'; |
| 614 | - $buff[] = '$db_info = (object)' . var_export(get_object_vars($db_info), TRUE) . ';'; |
|
| 614 | + $buff[] = '$db_info = (object)'.var_export(get_object_vars($db_info), TRUE).';'; |
|
| 615 | 615 | |
| 616 | 616 | return implode(PHP_EOL, $buff); |
| 617 | 617 | } |
@@ -625,13 +625,13 @@ discard block |
||
| 625 | 625 | $db_tmp_config_file = $this->db_tmp_config_file; |
| 626 | 626 | |
| 627 | 627 | $db_info = Context::getDBInfo(); |
| 628 | - if(!$db_info) return; |
|
| 628 | + if (!$db_info) return; |
|
| 629 | 629 | |
| 630 | 630 | $buff = $this->_getDBConfigFileContents($db_info); |
| 631 | 631 | |
| 632 | 632 | FileHandler::writeFile($db_tmp_config_file, $buff); |
| 633 | 633 | |
| 634 | - if(@file_exists($db_tmp_config_file)) return true; |
|
| 634 | + if (@file_exists($db_tmp_config_file)) return true; |
|
| 635 | 635 | return false; |
| 636 | 636 | } |
| 637 | 637 | |
@@ -644,14 +644,14 @@ discard block |
||
| 644 | 644 | $etc_tmp_config_file = $this->etc_tmp_config_file; |
| 645 | 645 | |
| 646 | 646 | $buff = '<?php if(!defined("__XE__")) exit();'."\n"; |
| 647 | - foreach($config_info as $key => $val) |
|
| 647 | + foreach ($config_info as $key => $val) |
|
| 648 | 648 | { |
| 649 | - $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'","\\'",$val)); |
|
| 649 | + $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val)); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
| 653 | 653 | |
| 654 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
| 654 | + if (@file_exists($etc_tmp_config_file)) return true; |
|
| 655 | 655 | return false; |
| 656 | 656 | } |
| 657 | 657 | |
@@ -666,13 +666,13 @@ discard block |
||
| 666 | 666 | //if(file_exists($config_file)) return; |
| 667 | 667 | |
| 668 | 668 | $db_info = Context::getDBInfo(); |
| 669 | - if(!$db_info) return; |
|
| 669 | + if (!$db_info) return; |
|
| 670 | 670 | |
| 671 | 671 | $buff = $this->_getDBConfigFileContents($db_info); |
| 672 | 672 | |
| 673 | 673 | FileHandler::writeFile($config_file, $buff); |
| 674 | 674 | |
| 675 | - if(@file_exists($config_file)) |
|
| 675 | + if (@file_exists($config_file)) |
|
| 676 | 676 | { |
| 677 | 677 | FileHandler::removeFile($this->db_tmp_config_file); |
| 678 | 678 | FileHandler::removeFile($this->etc_tmp_config_file); |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | function installByConfig($install_config_file) |
| 688 | 688 | { |
| 689 | 689 | include $install_config_file; |
| 690 | - if(!is_array($auto_config)) return false; |
|
| 690 | + if (!is_array($auto_config)) return false; |
|
| 691 | 691 | |
| 692 | 692 | $auto_config['module'] = 'install'; |
| 693 | 693 | $auto_config['act'] = 'procInstall'; |
@@ -695,22 +695,22 @@ discard block |
||
| 695 | 695 | $fstr = "<%s><![CDATA[%s]]></%s>\r\n"; |
| 696 | 696 | $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"; |
| 697 | 697 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
| 698 | - foreach($auto_config as $k => $v) |
|
| 698 | + foreach ($auto_config as $k => $v) |
|
| 699 | 699 | { |
| 700 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
| 700 | + if (!in_array($k, array('host', 'port', 'path'))) $body .= sprintf($fstr, $k, $v, $k); |
|
| 701 | 701 | } |
| 702 | 702 | $body .= "</params>\r\n</methodCall>"; |
| 703 | 703 | |
| 704 | - $header = sprintf($fheader,$auto_config['path'],$auto_config['host'],strlen($body),$body); |
|
| 704 | + $header = sprintf($fheader, $auto_config['path'], $auto_config['host'], strlen($body), $body); |
|
| 705 | 705 | $fp = @fsockopen($auto_config['host'], $auto_config['port'], $errno, $errstr, 5); |
| 706 | 706 | |
| 707 | - if($fp) |
|
| 707 | + if ($fp) |
|
| 708 | 708 | { |
| 709 | 709 | fputs($fp, $header); |
| 710 | - while(!feof($fp)) |
|
| 710 | + while (!feof($fp)) |
|
| 711 | 711 | { |
| 712 | 712 | $line = trim(fgets($fp, 4096)); |
| 713 | - if(strncmp('<error>', $line, 7) === 0) |
|
| 713 | + if (strncmp('<error>', $line, 7) === 0) |
|
| 714 | 714 | { |
| 715 | 715 | fclose($fp); |
| 716 | 716 | return false; |
@@ -101,11 +101,17 @@ 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()) { |
|
| 105 | + return $output; |
|
| 106 | + } |
|
| 107 | + if(!$oDB->isConnected()) { |
|
| 108 | + return $oDB->getError(); |
|
| 109 | + } |
|
| 106 | 110 | |
| 107 | 111 | // Create a db temp config file |
| 108 | - if(!$this->makeDBConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
| 112 | + if(!$this->makeDBConfigFile()) { |
|
| 113 | + return new Object(-1, 'msg_install_failed'); |
|
| 114 | + } |
|
| 109 | 115 | |
| 110 | 116 | if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
| 111 | 117 | { |
@@ -122,10 +128,14 @@ discard block |
||
| 122 | 128 | { |
| 123 | 129 | // Get variables |
| 124 | 130 | $config_info = Context::gets('use_rewrite','time_zone'); |
| 125 | - if($config_info->use_rewrite!='Y') $config_info->use_rewrite = 'N'; |
|
| 131 | + if($config_info->use_rewrite!='Y') { |
|
| 132 | + $config_info->use_rewrite = 'N'; |
|
| 133 | + } |
|
| 126 | 134 | |
| 127 | 135 | // Create a db temp config file |
| 128 | - if(!$this->makeEtcConfigFile($config_info)) return new Object(-1, 'msg_install_failed'); |
|
| 136 | + if(!$this->makeEtcConfigFile($config_info)) { |
|
| 137 | + return new Object(-1, 'msg_install_failed'); |
|
| 138 | + } |
|
| 129 | 139 | |
| 130 | 140 | if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
| 131 | 141 | { |
@@ -141,7 +151,9 @@ discard block |
||
| 141 | 151 | function procInstall() |
| 142 | 152 | { |
| 143 | 153 | // Check if it is already installed |
| 144 | - if(Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
| 154 | + if(Context::isInstalled()) { |
|
| 155 | + return new Object(-1, 'msg_already_installed'); |
|
| 156 | + } |
|
| 145 | 157 | |
| 146 | 158 | Context::loadLang('modules/member/lang'); |
| 147 | 159 | $oMemberModel = getModel('member'); |
@@ -167,8 +179,12 @@ discard block |
||
| 167 | 179 | // install by default XE UI |
| 168 | 180 | else |
| 169 | 181 | { |
| 170 | - if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; |
|
| 171 | - if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; |
|
| 182 | + if(FileHandler::exists($this->db_tmp_config_file)) { |
|
| 183 | + include $this->db_tmp_config_file; |
|
| 184 | + } |
|
| 185 | + if(FileHandler::exists($this->etc_tmp_config_file)) { |
|
| 186 | + include $this->etc_tmp_config_file; |
|
| 187 | + } |
|
| 172 | 188 | } |
| 173 | 189 | |
| 174 | 190 | // Set DB type and information |
@@ -176,7 +192,9 @@ discard block |
||
| 176 | 192 | // Create DB Instance |
| 177 | 193 | $oDB = &DB::getInstance(); |
| 178 | 194 | // Check if available to connect to the DB |
| 179 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
| 195 | + if(!$oDB->isConnected()) { |
|
| 196 | + return $oDB->getError(); |
|
| 197 | + } |
|
| 180 | 198 | |
| 181 | 199 | // Install all the modules |
| 182 | 200 | try { |
@@ -189,7 +207,9 @@ discard block |
||
| 189 | 207 | } |
| 190 | 208 | |
| 191 | 209 | // Create a config file |
| 192 | - if(!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
| 210 | + if(!$this->makeConfigFile()) { |
|
| 211 | + return new Object(-1, 'msg_install_failed'); |
|
| 212 | + } |
|
| 193 | 213 | |
| 194 | 214 | // load script |
| 195 | 215 | $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); |
@@ -246,14 +266,17 @@ discard block |
||
| 246 | 266 | { |
| 247 | 267 | $https_port = (Context::get('https_port')) ? Context::get('https_port') : $_SERVER['SERVER_PORT']; |
| 248 | 268 | $https_port = (!$https_port != 443) ? $https_port : null; |
| 249 | - } |
|
| 250 | - else |
|
| 269 | + } else |
|
| 251 | 270 | { |
| 252 | 271 | $http_port = (Context::get('http_port')) ? Context::get('http_port') : $_SERVER['SERVER_PORT']; |
| 253 | 272 | $http_port = (!$http_port != 80) ? $http_port : null; |
| 254 | 273 | } |
| 255 | - if($http_port) $db_info->http_port = $http_port; |
|
| 256 | - if($https_port) $db_info->https_port = $https_port; |
|
| 274 | + if($http_port) { |
|
| 275 | + $db_info->http_port = $http_port; |
|
| 276 | + } |
|
| 277 | + if($https_port) { |
|
| 278 | + $db_info->https_port = $https_port; |
|
| 279 | + } |
|
| 257 | 280 | |
| 258 | 281 | return $db_info; |
| 259 | 282 | } |
@@ -263,12 +286,20 @@ discard block |
||
| 263 | 286 | */ |
| 264 | 287 | function procInstallFTP() |
| 265 | 288 | { |
| 266 | - if(Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
| 289 | + if(Context::isInstalled()) { |
|
| 290 | + return new Object(-1, 'msg_already_installed'); |
|
| 291 | + } |
|
| 267 | 292 | $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
| 268 | 293 | $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
| 269 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 270 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 271 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 294 | + if(!$ftp_info->ftp_port) { |
|
| 295 | + $ftp_info->ftp_port = 21; |
|
| 296 | + } |
|
| 297 | + if(!$ftp_info->ftp_host) { |
|
| 298 | + $ftp_info->ftp_host = '127.0.0.1'; |
|
| 299 | + } |
|
| 300 | + if(!$ftp_info->ftp_root_path) { |
|
| 301 | + $ftp_info->ftp_root_path = '/'; |
|
| 302 | + } |
|
| 272 | 303 | |
| 273 | 304 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
| 274 | 305 | $buff[] = "\$ftp_info = new stdClass();"; |
@@ -280,11 +311,15 @@ discard block |
||
| 280 | 311 | // If safe_mode |
| 281 | 312 | if(ini_get('safe_mode')) |
| 282 | 313 | { |
| 283 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 314 | + if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { |
|
| 315 | + return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 316 | + } |
|
| 284 | 317 | |
| 285 | 318 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 286 | 319 | $oFtp = new ftp(); |
| 287 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 320 | + if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { |
|
| 321 | + return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 322 | + } |
|
| 288 | 323 | |
| 289 | 324 | if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
| 290 | 325 | { |
@@ -326,10 +361,16 @@ discard block |
||
| 326 | 361 | { |
| 327 | 362 | $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
| 328 | 363 | $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
| 329 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 330 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 364 | + if(!$ftp_info->ftp_port) { |
|
| 365 | + $ftp_info->ftp_port = 21; |
|
| 366 | + } |
|
| 367 | + if(!$ftp_info->sftp) { |
|
| 368 | + $ftp_info->sftp = 'N'; |
|
| 369 | + } |
|
| 331 | 370 | |
| 332 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 371 | + if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { |
|
| 372 | + return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 373 | + } |
|
| 333 | 374 | |
| 334 | 375 | if($ftp_info->sftp == 'Y') |
| 335 | 376 | { |
@@ -338,12 +379,13 @@ discard block |
||
| 338 | 379 | { |
| 339 | 380 | return new Object(-1,'msg_ftp_invalid_auth_info'); |
| 340 | 381 | } |
| 341 | - } |
|
| 342 | - else |
|
| 382 | + } else |
|
| 343 | 383 | { |
| 344 | 384 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 345 | 385 | $oFtp = new ftp(); |
| 346 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 386 | + if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) { |
|
| 387 | + return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 388 | + } |
|
| 347 | 389 | |
| 348 | 390 | if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
| 349 | 391 | { |
@@ -376,26 +418,47 @@ discard block |
||
| 376 | 418 | } |
| 377 | 419 | |
| 378 | 420 | // 1. Check permission |
| 379 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
| 380 | - else $checklist['permission'] = false; |
|
| 421 | + if(is_writable('./')||is_writable('./files')) { |
|
| 422 | + $checklist['permission'] = true; |
|
| 423 | + } else { |
|
| 424 | + $checklist['permission'] = false; |
|
| 425 | + } |
|
| 381 | 426 | // 2. Check if xml_parser_create exists |
| 382 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 383 | - else $checklist['xml'] = false; |
|
| 427 | + if(function_exists('xml_parser_create')) { |
|
| 428 | + $checklist['xml'] = true; |
|
| 429 | + } else { |
|
| 430 | + $checklist['xml'] = false; |
|
| 431 | + } |
|
| 384 | 432 | // 3. Check if ini_get (session.auto_start) == 1 |
| 385 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
| 386 | - else $checklist['session'] = false; |
|
| 433 | + if(ini_get('session.auto_start')!=1) { |
|
| 434 | + $checklist['session'] = true; |
|
| 435 | + } else { |
|
| 436 | + $checklist['session'] = false; |
|
| 437 | + } |
|
| 387 | 438 | // 4. Check if iconv exists |
| 388 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
| 389 | - else $checklist['iconv'] = false; |
|
| 439 | + if(function_exists('iconv')) { |
|
| 440 | + $checklist['iconv'] = true; |
|
| 441 | + } else { |
|
| 442 | + $checklist['iconv'] = false; |
|
| 443 | + } |
|
| 390 | 444 | // 5. Check gd(imagecreatefromgif function) |
| 391 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 392 | - else $checklist['gd'] = false; |
|
| 445 | + if(function_exists('imagecreatefromgif')) { |
|
| 446 | + $checklist['gd'] = true; |
|
| 447 | + } else { |
|
| 448 | + $checklist['gd'] = false; |
|
| 449 | + } |
|
| 393 | 450 | // 6. Check DB |
| 394 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
| 395 | - else $checklist['db'] = false; |
|
| 451 | + if(DB::getEnableList()) { |
|
| 452 | + $checklist['db'] = true; |
|
| 453 | + } else { |
|
| 454 | + $checklist['db'] = false; |
|
| 455 | + } |
|
| 396 | 456 | |
| 397 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 398 | - else $install_enable = true; |
|
| 457 | + if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) { |
|
| 458 | + $install_enable = false; |
|
| 459 | + } else { |
|
| 460 | + $install_enable = true; |
|
| 461 | + } |
|
| 399 | 462 | |
| 400 | 463 | // Save the checked result to the Context |
| 401 | 464 | Context::set('checklist', $checklist); |
@@ -418,8 +481,7 @@ discard block |
||
| 418 | 481 | { |
| 419 | 482 | $currentTime = $_SERVER['REQUEST_TIME']; |
| 420 | 483 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
| 421 | - } |
|
| 422 | - else |
|
| 484 | + } else |
|
| 423 | 485 | { |
| 424 | 486 | FileHandler::removeFile($this->flagLicenseAgreement); |
| 425 | 487 | return new Object(-1, 'msg_must_accept_license_agreement'); |
@@ -514,13 +576,17 @@ discard block |
||
| 514 | 576 | $module = $tmp_arr[count($tmp_arr)-1]; |
| 515 | 577 | |
| 516 | 578 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
| 517 | - if(!$xml_info) continue; |
|
| 579 | + if(!$xml_info) { |
|
| 580 | + continue; |
|
| 581 | + } |
|
| 518 | 582 | $modules[$xml_info->category][] = $module; |
| 519 | 583 | } |
| 520 | 584 | // Install "module" module in advance |
| 521 | 585 | $this->installModule('module','./modules/module'); |
| 522 | 586 | $oModule = getClass('module'); |
| 523 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 587 | + if($oModule->checkUpdate()) { |
|
| 588 | + $oModule->moduleUpdate(); |
|
| 589 | + } |
|
| 524 | 590 | // Determine the order of module installation depending on category |
| 525 | 591 | $install_step = array('system','content','member'); |
| 526 | 592 | // Install all the remaining modules |
@@ -530,13 +596,17 @@ discard block |
||
| 530 | 596 | { |
| 531 | 597 | foreach($modules[$category] as $module) |
| 532 | 598 | { |
| 533 | - if($module == 'module') continue; |
|
| 599 | + if($module == 'module') { |
|
| 600 | + continue; |
|
| 601 | + } |
|
| 534 | 602 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 535 | 603 | |
| 536 | 604 | $oModule = getClass($module); |
| 537 | 605 | if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
| 538 | 606 | { |
| 539 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 607 | + if($oModule->checkUpdate()) { |
|
| 608 | + $oModule->moduleUpdate(); |
|
| 609 | + } |
|
| 540 | 610 | } |
| 541 | 611 | } |
| 542 | 612 | unset($modules[$category]); |
@@ -551,13 +621,17 @@ discard block |
||
| 551 | 621 | { |
| 552 | 622 | foreach($module_list as $module) |
| 553 | 623 | { |
| 554 | - if($module == 'module') continue; |
|
| 624 | + if($module == 'module') { |
|
| 625 | + continue; |
|
| 626 | + } |
|
| 555 | 627 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 556 | 628 | |
| 557 | 629 | $oModule = getClass($module); |
| 558 | 630 | if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
| 559 | 631 | { |
| 560 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 632 | + if($oModule->checkUpdate()) { |
|
| 633 | + $oModule->moduleUpdate(); |
|
| 634 | + } |
|
| 561 | 635 | } |
| 562 | 636 | } |
| 563 | 637 | } |
@@ -582,15 +656,20 @@ discard block |
||
| 582 | 656 | for($i=0;$i<$file_cnt;$i++) |
| 583 | 657 | { |
| 584 | 658 | $file = trim($schema_files[$i]); |
| 585 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
| 659 | + if(!$file || substr($file,-4)!='.xml') { |
|
| 660 | + continue; |
|
| 661 | + } |
|
| 586 | 662 | $output = $oDB->createTableByXmlFile($file); |
| 587 | - if($output === false) |
|
| 588 | - throw new Exception('msg_create_table_failed'); |
|
| 663 | + if($output === false) { |
|
| 664 | + throw new Exception('msg_create_table_failed'); |
|
| 665 | + } |
|
| 589 | 666 | } |
| 590 | 667 | // Create a table and module instance and then execute install() method |
| 591 | 668 | unset($oModule); |
| 592 | 669 | $oModule = getClass($module); |
| 593 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 670 | + if(method_exists($oModule, 'moduleInstall')) { |
|
| 671 | + $oModule->moduleInstall(); |
|
| 672 | + } |
|
| 594 | 673 | return new Object(); |
| 595 | 674 | } |
| 596 | 675 | |
@@ -625,13 +704,17 @@ discard block |
||
| 625 | 704 | $db_tmp_config_file = $this->db_tmp_config_file; |
| 626 | 705 | |
| 627 | 706 | $db_info = Context::getDBInfo(); |
| 628 | - if(!$db_info) return; |
|
| 707 | + if(!$db_info) { |
|
| 708 | + return; |
|
| 709 | + } |
|
| 629 | 710 | |
| 630 | 711 | $buff = $this->_getDBConfigFileContents($db_info); |
| 631 | 712 | |
| 632 | 713 | FileHandler::writeFile($db_tmp_config_file, $buff); |
| 633 | 714 | |
| 634 | - if(@file_exists($db_tmp_config_file)) return true; |
|
| 715 | + if(@file_exists($db_tmp_config_file)) { |
|
| 716 | + return true; |
|
| 717 | + } |
|
| 635 | 718 | return false; |
| 636 | 719 | } |
| 637 | 720 | |
@@ -651,7 +734,9 @@ discard block |
||
| 651 | 734 | |
| 652 | 735 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
| 653 | 736 | |
| 654 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
| 737 | + if(@file_exists($etc_tmp_config_file)) { |
|
| 738 | + return true; |
|
| 739 | + } |
|
| 655 | 740 | return false; |
| 656 | 741 | } |
| 657 | 742 | |
@@ -666,7 +751,9 @@ discard block |
||
| 666 | 751 | //if(file_exists($config_file)) return; |
| 667 | 752 | |
| 668 | 753 | $db_info = Context::getDBInfo(); |
| 669 | - if(!$db_info) return; |
|
| 754 | + if(!$db_info) { |
|
| 755 | + return; |
|
| 756 | + } |
|
| 670 | 757 | |
| 671 | 758 | $buff = $this->_getDBConfigFileContents($db_info); |
| 672 | 759 | |
@@ -687,7 +774,9 @@ discard block |
||
| 687 | 774 | function installByConfig($install_config_file) |
| 688 | 775 | { |
| 689 | 776 | include $install_config_file; |
| 690 | - if(!is_array($auto_config)) return false; |
|
| 777 | + if(!is_array($auto_config)) { |
|
| 778 | + return false; |
|
| 779 | + } |
|
| 691 | 780 | |
| 692 | 781 | $auto_config['module'] = 'install'; |
| 693 | 782 | $auto_config['act'] = 'procInstall'; |
@@ -697,7 +786,9 @@ discard block |
||
| 697 | 786 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
| 698 | 787 | foreach($auto_config as $k => $v) |
| 699 | 788 | { |
| 700 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
| 789 | + if(!in_array($k,array('host','port','path'))) { |
|
| 790 | + $body .= sprintf($fstr,$k,$v,$k); |
|
| 791 | + } |
|
| 701 | 792 | } |
| 702 | 793 | $body .= "</params>\r\n</methodCall>"; |
| 703 | 794 | |