@@ -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); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $db_info->use_rewrite = Context::get('use_rewrite'); |
| 232 | 232 | $db_info->time_zone = Context::get('time_zone'); |
| 233 | 233 | |
| 234 | - if($_SERVER['HTTPS'] == 'on') |
|
| 234 | + if ($_SERVER['HTTPS'] == 'on') |
|
| 235 | 235 | { |
| 236 | 236 | $https_port = (Context::get('https_port')) ? Context::get('https_port') : $_SERVER['SERVER_PORT']; |
| 237 | 237 | $https_port = (!$https_port != 443) ? $https_port : null; |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | $http_port = (Context::get('http_port')) ? Context::get('http_port') : $_SERVER['SERVER_PORT']; |
| 242 | 242 | $http_port = (!$http_port != 80) ? $http_port : null; |
| 243 | 243 | } |
| 244 | - if($http_port) $db_info->http_port = $http_port; |
|
| 245 | - if($https_port) $db_info->https_port = $https_port; |
|
| 244 | + if ($http_port) $db_info->http_port = $http_port; |
|
| 245 | + if ($https_port) $db_info->https_port = $https_port; |
|
| 246 | 246 | |
| 247 | 247 | return $db_info; |
| 248 | 248 | } |
@@ -252,57 +252,57 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | function procInstallFTP() |
| 254 | 254 | { |
| 255 | - if(Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
| 256 | - $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
|
| 257 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
| 258 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 259 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 260 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 255 | + if (Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
| 256 | + $ftp_info = Context::gets('ftp_host', 'ftp_user', 'ftp_password', 'ftp_port', 'ftp_root_path'); |
|
| 257 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
| 258 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 259 | + if (!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 260 | + if (!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 261 | 261 | |
| 262 | 262 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
| 263 | 263 | $buff[] = "\$ftp_info = new stdClass();"; |
| 264 | - foreach($ftp_info as $key => $val) |
|
| 264 | + foreach ($ftp_info as $key => $val) |
|
| 265 | 265 | { |
| 266 | - $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'","\\'",$val)); |
|
| 266 | + $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'", "\\'", $val)); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // If safe_mode |
| 270 | - if(ini_get('safe_mode')) |
|
| 270 | + if (ini_get('safe_mode')) |
|
| 271 | 271 | { |
| 272 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 272 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1, 'msg_safe_mode_ftp_needed'); |
|
| 273 | 273 | |
| 274 | 274 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 275 | 275 | $oFtp = new ftp(); |
| 276 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 276 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 277 | 277 | |
| 278 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 278 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 279 | 279 | { |
| 280 | 280 | $oFtp->ftp_quit(); |
| 281 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
| 281 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if(!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
| 284 | + if (!is_dir(_XE_PATH_.'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files')) |
|
| 285 | 285 | { |
| 286 | 286 | $oFtp->ftp_quit(); |
| 287 | - return new Object(-1,'msg_ftp_mkdir_fail'); |
|
| 287 | + return new Object(-1, 'msg_ftp_mkdir_fail'); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
| 290 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files')) |
|
| 291 | 291 | { |
| 292 | 292 | $oFtp->ftp_quit(); |
| 293 | - return new Object(-1,'msg_ftp_chmod_fail'); |
|
| 293 | + return new Object(-1, 'msg_ftp_chmod_fail'); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if(!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
| 296 | + if (!is_dir(_XE_PATH_.'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path.'files/config')) |
|
| 297 | 297 | { |
| 298 | 298 | $oFtp->ftp_quit(); |
| 299 | - return new Object(-1,'msg_ftp_mkdir_fail'); |
|
| 299 | + return new Object(-1, 'msg_ftp_mkdir_fail'); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - if(!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
| 302 | + if (!$oFtp->ftp_site("CHMOD 777 ".$ftp_info->ftp_root_path.'files/config')) |
|
| 303 | 303 | { |
| 304 | 304 | $oFtp->ftp_quit(); |
| 305 | - return new Object(-1,'msg_ftp_chmod_fail'); |
|
| 305 | + return new Object(-1, 'msg_ftp_chmod_fail'); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | $oFtp->ftp_quit(); |
@@ -313,31 +313,31 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | function procInstallCheckFtp() |
| 315 | 315 | { |
| 316 | - $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
|
| 317 | - $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
|
| 318 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 319 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 316 | + $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port', 'sftp'); |
|
| 317 | + $ftp_info->ftp_port = (int) $ftp_info->ftp_port; |
|
| 318 | + if (!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 319 | + if (!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 320 | 320 | |
| 321 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 321 | + if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1, 'msg_safe_mode_ftp_needed'); |
|
| 322 | 322 | |
| 323 | - if($ftp_info->sftp == 'Y') |
|
| 323 | + if ($ftp_info->sftp == 'Y') |
|
| 324 | 324 | { |
| 325 | 325 | $connection = ssh2_connect('localhost', $ftp_info->ftp_port); |
| 326 | - if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 326 | + if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 327 | 327 | { |
| 328 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
| 328 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | else |
| 332 | 332 | { |
| 333 | 333 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 334 | 334 | $oFtp = new ftp(); |
| 335 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 335 | + if (!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 336 | 336 | |
| 337 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 337 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 338 | 338 | { |
| 339 | 339 | $oFtp->ftp_quit(); |
| 340 | - return new Object(-1,'msg_ftp_invalid_auth_info'); |
|
| 340 | + return new Object(-1, 'msg_ftp_invalid_auth_info'); |
|
| 341 | 341 | } |
| 342 | 342 | $oFtp->ftp_quit(); |
| 343 | 343 | } |
@@ -354,36 +354,36 @@ discard block |
||
| 354 | 354 | $checklist = array(); |
| 355 | 355 | // 0. check your version of php (5.2.4 or higher) |
| 356 | 356 | $checklist['php_version'] = true; |
| 357 | - if(version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
| 357 | + if (version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) |
|
| 358 | 358 | { |
| 359 | 359 | $checklist['php_version'] = false; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - if(version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
| 362 | + if (version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) |
|
| 363 | 363 | { |
| 364 | 364 | Context::set('phpversion_warning', true); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | // 1. Check permission |
| 368 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
| 368 | + if (is_writable('./') || is_writable('./files')) $checklist['permission'] = true; |
|
| 369 | 369 | else $checklist['permission'] = false; |
| 370 | 370 | // 2. Check if xml_parser_create exists |
| 371 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 371 | + if (function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 372 | 372 | else $checklist['xml'] = false; |
| 373 | 373 | // 3. Check if ini_get (session.auto_start) == 1 |
| 374 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
| 374 | + if (ini_get('session.auto_start') != 1) $checklist['session'] = true; |
|
| 375 | 375 | else $checklist['session'] = false; |
| 376 | 376 | // 4. Check if iconv exists |
| 377 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
| 377 | + if (function_exists('iconv')) $checklist['iconv'] = true; |
|
| 378 | 378 | else $checklist['iconv'] = false; |
| 379 | 379 | // 5. Check gd(imagecreatefromgif function) |
| 380 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 380 | + if (function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 381 | 381 | else $checklist['gd'] = false; |
| 382 | 382 | // 6. Check DB |
| 383 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
| 383 | + if (DB::getEnableList()) $checklist['db'] = true; |
|
| 384 | 384 | else $checklist['db'] = false; |
| 385 | 385 | |
| 386 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 386 | + if (!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 387 | 387 | else $install_enable = true; |
| 388 | 388 | |
| 389 | 389 | // Save the checked result to the Context |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | $license_agreement = ($vars->license_agreement == 'Y') ? true : false; |
| 405 | 405 | |
| 406 | - if($license_agreement) |
|
| 406 | + if ($license_agreement) |
|
| 407 | 407 | { |
| 408 | 408 | $currentTime = $_SERVER['REQUEST_TIME']; |
| 409 | 409 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | return new Object(-1, 'msg_must_accept_license_agreement'); |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
|
| 417 | + if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) |
|
| 418 | 418 | { |
| 419 | 419 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallCheckEnv'); |
| 420 | 420 | $this->setRedirectUrl($returnUrl); |
@@ -437,25 +437,25 @@ discard block |
||
| 437 | 437 | $hostname = $_SERVER['SERVER_NAME']; |
| 438 | 438 | $port = $_SERVER['SERVER_PORT']; |
| 439 | 439 | $str_port = ''; |
| 440 | - if($port) |
|
| 440 | + if ($port) |
|
| 441 | 441 | { |
| 442 | - $str_port = ':' . $port; |
|
| 442 | + $str_port = ':'.$port; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | $tmpPath = $_SERVER['DOCUMENT_ROOT']; |
| 446 | 446 | |
| 447 | 447 | //if DIRECTORY_SEPARATOR is not /(IIS) |
| 448 | - if(DIRECTORY_SEPARATOR !== '/') |
|
| 448 | + if (DIRECTORY_SEPARATOR !== '/') |
|
| 449 | 449 | { |
| 450 | 450 | //change to slash for compare |
| 451 | 451 | $tmpPath = str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']); |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - $query = "/JUST/CHECK/REWRITE/" . $checkFilePath; |
|
| 454 | + $query = "/JUST/CHECK/REWRITE/".$checkFilePath; |
|
| 455 | 455 | $currentPath = str_replace($tmpPath, "", _XE_PATH_); |
| 456 | - if($currentPath != "") |
|
| 456 | + if ($currentPath != "") |
|
| 457 | 457 | { |
| 458 | - $query = $currentPath . $query; |
|
| 458 | + $query = $currentPath.$query; |
|
| 459 | 459 | } |
| 460 | 460 | $requestUrl = sprintf('%s://%s%s%s', $scheme, $hostname, $str_port, $query); |
| 461 | 461 | $requestConfig = array(); |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | './files/cache/template_compiled', |
| 481 | 481 | ); |
| 482 | 482 | |
| 483 | - foreach($directory_list as $dir) |
|
| 483 | + foreach ($directory_list as $dir) |
|
| 484 | 484 | { |
| 485 | 485 | FileHandler::makeDir($dir); |
| 486 | 486 | } |
@@ -496,57 +496,57 @@ discard block |
||
| 496 | 496 | $oModuleModel = getModel('module'); |
| 497 | 497 | // Create a table ny finding schemas/*.xml file in each module |
| 498 | 498 | $module_list = FileHandler::readDir('./modules/', NULL, false, true); |
| 499 | - foreach($module_list as $module_path) |
|
| 499 | + foreach ($module_list as $module_path) |
|
| 500 | 500 | { |
| 501 | 501 | // Get module name |
| 502 | - $tmp_arr = explode('/',$module_path); |
|
| 503 | - $module = $tmp_arr[count($tmp_arr)-1]; |
|
| 502 | + $tmp_arr = explode('/', $module_path); |
|
| 503 | + $module = $tmp_arr[count($tmp_arr) - 1]; |
|
| 504 | 504 | |
| 505 | 505 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
| 506 | - if(!$xml_info) continue; |
|
| 506 | + if (!$xml_info) continue; |
|
| 507 | 507 | $modules[$xml_info->category][] = $module; |
| 508 | 508 | } |
| 509 | 509 | // Install "module" module in advance |
| 510 | - $this->installModule('module','./modules/module'); |
|
| 510 | + $this->installModule('module', './modules/module'); |
|
| 511 | 511 | $oModule = getClass('module'); |
| 512 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 512 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 513 | 513 | // Determine the order of module installation depending on category |
| 514 | - $install_step = array('system','content','member'); |
|
| 514 | + $install_step = array('system', 'content', 'member'); |
|
| 515 | 515 | // Install all the remaining modules |
| 516 | - foreach($install_step as $category) |
|
| 516 | + foreach ($install_step as $category) |
|
| 517 | 517 | { |
| 518 | - if(count($modules[$category])) |
|
| 518 | + if (count($modules[$category])) |
|
| 519 | 519 | { |
| 520 | - foreach($modules[$category] as $module) |
|
| 520 | + foreach ($modules[$category] as $module) |
|
| 521 | 521 | { |
| 522 | - if($module == 'module') continue; |
|
| 522 | + if ($module == 'module') continue; |
|
| 523 | 523 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 524 | 524 | |
| 525 | 525 | $oModule = getClass($module); |
| 526 | - if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
| 526 | + if (is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
|
| 527 | 527 | { |
| 528 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 528 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | unset($modules[$category]); |
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | // Install all the remaining modules |
| 535 | - if(count($modules)) |
|
| 535 | + if (count($modules)) |
|
| 536 | 536 | { |
| 537 | - foreach($modules as $category => $module_list) |
|
| 537 | + foreach ($modules as $category => $module_list) |
|
| 538 | 538 | { |
| 539 | - if(count($module_list)) |
|
| 539 | + if (count($module_list)) |
|
| 540 | 540 | { |
| 541 | - foreach($module_list as $module) |
|
| 541 | + foreach ($module_list as $module) |
|
| 542 | 542 | { |
| 543 | - if($module == 'module') continue; |
|
| 543 | + if ($module == 'module') continue; |
|
| 544 | 544 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 545 | 545 | |
| 546 | 546 | $oModule = getClass($module); |
| 547 | - if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
| 547 | + if ($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
|
| 548 | 548 | { |
| 549 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 549 | + if ($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | } |
@@ -568,31 +568,31 @@ discard block |
||
| 568 | 568 | $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); |
| 569 | 569 | |
| 570 | 570 | $file_cnt = count($schema_files); |
| 571 | - for($i=0;$i<$file_cnt;$i++) |
|
| 571 | + for ($i = 0; $i < $file_cnt; $i++) |
|
| 572 | 572 | { |
| 573 | 573 | $file = trim($schema_files[$i]); |
| 574 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
| 574 | + if (!$file || substr($file, -4) != '.xml') continue; |
|
| 575 | 575 | $output = $oDB->createTableByXmlFile($file); |
| 576 | - if($output === false) |
|
| 576 | + if ($output === false) |
|
| 577 | 577 | throw new Exception('msg_create_table_failed'); |
| 578 | 578 | } |
| 579 | 579 | // Create a table and module instance and then execute install() method |
| 580 | 580 | unset($oModule); |
| 581 | 581 | $oModule = getClass($module); |
| 582 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 582 | + if (method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 583 | 583 | return new Object(); |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | function _getDBConfigFileContents($db_info) |
| 587 | 587 | { |
| 588 | - if(substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
| 588 | + if (substr($db_info->master_db['db_table_prefix'], -1) != '_') |
|
| 589 | 589 | { |
| 590 | 590 | $db_info->master_db['db_table_prefix'] .= '_'; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - foreach($db_info->slave_db as &$slave) |
|
| 593 | + foreach ($db_info->slave_db as &$slave) |
|
| 594 | 594 | { |
| 595 | - if(substr($slave['db_table_prefix'], -1) != '_') |
|
| 595 | + if (substr($slave['db_table_prefix'], -1) != '_') |
|
| 596 | 596 | { |
| 597 | 597 | $slave['db_table_prefix'] .= '_'; |
| 598 | 598 | } |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | |
| 601 | 601 | $buff = array(); |
| 602 | 602 | $buff[] = '<?php if(!defined("__XE__")) exit();'; |
| 603 | - $buff[] = '$db_info = (object)' . var_export(get_object_vars($db_info), TRUE) . ';'; |
|
| 603 | + $buff[] = '$db_info = (object)'.var_export(get_object_vars($db_info), TRUE).';'; |
|
| 604 | 604 | |
| 605 | 605 | return implode(PHP_EOL, $buff); |
| 606 | 606 | } |
@@ -614,13 +614,13 @@ discard block |
||
| 614 | 614 | $db_tmp_config_file = $this->db_tmp_config_file; |
| 615 | 615 | |
| 616 | 616 | $db_info = Context::getDBInfo(); |
| 617 | - if(!$db_info) return; |
|
| 617 | + if (!$db_info) return; |
|
| 618 | 618 | |
| 619 | 619 | $buff = $this->_getDBConfigFileContents($db_info); |
| 620 | 620 | |
| 621 | 621 | FileHandler::writeFile($db_tmp_config_file, $buff); |
| 622 | 622 | |
| 623 | - if(@file_exists($db_tmp_config_file)) return true; |
|
| 623 | + if (@file_exists($db_tmp_config_file)) return true; |
|
| 624 | 624 | return false; |
| 625 | 625 | } |
| 626 | 626 | |
@@ -633,14 +633,14 @@ discard block |
||
| 633 | 633 | $etc_tmp_config_file = $this->etc_tmp_config_file; |
| 634 | 634 | |
| 635 | 635 | $buff = '<?php if(!defined("__XE__")) exit();'."\n"; |
| 636 | - foreach($config_info as $key => $val) |
|
| 636 | + foreach ($config_info as $key => $val) |
|
| 637 | 637 | { |
| 638 | - $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'","\\'",$val)); |
|
| 638 | + $buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val)); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
| 642 | 642 | |
| 643 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
| 643 | + if (@file_exists($etc_tmp_config_file)) return true; |
|
| 644 | 644 | return false; |
| 645 | 645 | } |
| 646 | 646 | |
@@ -655,13 +655,13 @@ discard block |
||
| 655 | 655 | //if(file_exists($config_file)) return; |
| 656 | 656 | |
| 657 | 657 | $db_info = Context::getDBInfo(); |
| 658 | - if(!$db_info) return; |
|
| 658 | + if (!$db_info) return; |
|
| 659 | 659 | |
| 660 | 660 | $buff = $this->_getDBConfigFileContents($db_info); |
| 661 | 661 | |
| 662 | 662 | FileHandler::writeFile($config_file, $buff); |
| 663 | 663 | |
| 664 | - if(@file_exists($config_file)) |
|
| 664 | + if (@file_exists($config_file)) |
|
| 665 | 665 | { |
| 666 | 666 | FileHandler::removeFile($this->db_tmp_config_file); |
| 667 | 667 | FileHandler::removeFile($this->etc_tmp_config_file); |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | function installByConfig($install_config_file) |
| 677 | 677 | { |
| 678 | 678 | include $install_config_file; |
| 679 | - if(!is_array($auto_config)) return false; |
|
| 679 | + if (!is_array($auto_config)) return false; |
|
| 680 | 680 | |
| 681 | 681 | $auto_config['module'] = 'install'; |
| 682 | 682 | $auto_config['act'] = 'procInstall'; |
@@ -684,22 +684,22 @@ discard block |
||
| 684 | 684 | $fstr = "<%s><![CDATA[%s]]></%s>\r\n"; |
| 685 | 685 | $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"; |
| 686 | 686 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
| 687 | - foreach($auto_config as $k => $v) |
|
| 687 | + foreach ($auto_config as $k => $v) |
|
| 688 | 688 | { |
| 689 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
| 689 | + if (!in_array($k, array('host', 'port', 'path'))) $body .= sprintf($fstr, $k, $v, $k); |
|
| 690 | 690 | } |
| 691 | 691 | $body .= "</params>\r\n</methodCall>"; |
| 692 | 692 | |
| 693 | - $header = sprintf($fheader,$auto_config['path'],$auto_config['host'],strlen($body),$body); |
|
| 693 | + $header = sprintf($fheader, $auto_config['path'], $auto_config['host'], strlen($body), $body); |
|
| 694 | 694 | $fp = @fsockopen($auto_config['host'], $auto_config['port'], $errno, $errstr, 5); |
| 695 | 695 | |
| 696 | - if($fp) |
|
| 696 | + if ($fp) |
|
| 697 | 697 | { |
| 698 | 698 | fputs($fp, $header); |
| 699 | - while(!feof($fp)) |
|
| 699 | + while (!feof($fp)) |
|
| 700 | 700 | { |
| 701 | 701 | $line = trim(fgets($fp, 4096)); |
| 702 | - if(strncmp('<error>', $line, 7) === 0) |
|
| 702 | + if (strncmp('<error>', $line, 7) === 0) |
|
| 703 | 703 | { |
| 704 | 704 | fclose($fp); |
| 705 | 705 | 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 | // Assign a temporary administrator when installing |
| 147 | 159 | $logged_info = new stdClass(); |
@@ -156,8 +168,12 @@ discard block |
||
| 156 | 168 | // install by default XE UI |
| 157 | 169 | else |
| 158 | 170 | { |
| 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; |
|
| 171 | + if(FileHandler::exists($this->db_tmp_config_file)) { |
|
| 172 | + include $this->db_tmp_config_file; |
|
| 173 | + } |
|
| 174 | + if(FileHandler::exists($this->etc_tmp_config_file)) { |
|
| 175 | + include $this->etc_tmp_config_file; |
|
| 176 | + } |
|
| 161 | 177 | } |
| 162 | 178 | |
| 163 | 179 | // Set DB type and information |
@@ -165,7 +181,9 @@ discard block |
||
| 165 | 181 | // Create DB Instance |
| 166 | 182 | $oDB = &DB::getInstance(); |
| 167 | 183 | // Check if available to connect to the DB |
| 168 | - if(!$oDB->isConnected()) return $oDB->getError(); |
|
| 184 | + if(!$oDB->isConnected()) { |
|
| 185 | + return $oDB->getError(); |
|
| 186 | + } |
|
| 169 | 187 | |
| 170 | 188 | // Install all the modules |
| 171 | 189 | try { |
@@ -178,7 +196,9 @@ discard block |
||
| 178 | 196 | } |
| 179 | 197 | |
| 180 | 198 | // Create a config file |
| 181 | - if(!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed'); |
|
| 199 | + if(!$this->makeConfigFile()) { |
|
| 200 | + return new Object(-1, 'msg_install_failed'); |
|
| 201 | + } |
|
| 182 | 202 | |
| 183 | 203 | // load script |
| 184 | 204 | $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); |
@@ -235,14 +255,17 @@ discard block |
||
| 235 | 255 | { |
| 236 | 256 | $https_port = (Context::get('https_port')) ? Context::get('https_port') : $_SERVER['SERVER_PORT']; |
| 237 | 257 | $https_port = (!$https_port != 443) ? $https_port : null; |
| 238 | - } |
|
| 239 | - else |
|
| 258 | + } else |
|
| 240 | 259 | { |
| 241 | 260 | $http_port = (Context::get('http_port')) ? Context::get('http_port') : $_SERVER['SERVER_PORT']; |
| 242 | 261 | $http_port = (!$http_port != 80) ? $http_port : null; |
| 243 | 262 | } |
| 244 | - if($http_port) $db_info->http_port = $http_port; |
|
| 245 | - if($https_port) $db_info->https_port = $https_port; |
|
| 263 | + if($http_port) { |
|
| 264 | + $db_info->http_port = $http_port; |
|
| 265 | + } |
|
| 266 | + if($https_port) { |
|
| 267 | + $db_info->https_port = $https_port; |
|
| 268 | + } |
|
| 246 | 269 | |
| 247 | 270 | return $db_info; |
| 248 | 271 | } |
@@ -252,12 +275,20 @@ discard block |
||
| 252 | 275 | */ |
| 253 | 276 | function procInstallFTP() |
| 254 | 277 | { |
| 255 | - if(Context::isInstalled()) return new Object(-1, 'msg_already_installed'); |
|
| 278 | + if(Context::isInstalled()) { |
|
| 279 | + return new Object(-1, 'msg_already_installed'); |
|
| 280 | + } |
|
| 256 | 281 | $ftp_info = Context::gets('ftp_host', 'ftp_user','ftp_password','ftp_port','ftp_root_path'); |
| 257 | 282 | $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
| 258 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 259 | - if(!$ftp_info->ftp_host) $ftp_info->ftp_host = '127.0.0.1'; |
|
| 260 | - if(!$ftp_info->ftp_root_path) $ftp_info->ftp_root_path = '/'; |
|
| 283 | + if(!$ftp_info->ftp_port) { |
|
| 284 | + $ftp_info->ftp_port = 21; |
|
| 285 | + } |
|
| 286 | + if(!$ftp_info->ftp_host) { |
|
| 287 | + $ftp_info->ftp_host = '127.0.0.1'; |
|
| 288 | + } |
|
| 289 | + if(!$ftp_info->ftp_root_path) { |
|
| 290 | + $ftp_info->ftp_root_path = '/'; |
|
| 291 | + } |
|
| 261 | 292 | |
| 262 | 293 | $buff = array('<?php if(!defined("__XE__")) exit();'); |
| 263 | 294 | $buff[] = "\$ftp_info = new stdClass();"; |
@@ -269,11 +300,15 @@ discard block |
||
| 269 | 300 | // If safe_mode |
| 270 | 301 | if(ini_get('safe_mode')) |
| 271 | 302 | { |
| 272 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 303 | + if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { |
|
| 304 | + return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 305 | + } |
|
| 273 | 306 | |
| 274 | 307 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 275 | 308 | $oFtp = new ftp(); |
| 276 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 309 | + if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { |
|
| 310 | + return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'host')); |
|
| 311 | + } |
|
| 277 | 312 | |
| 278 | 313 | if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
| 279 | 314 | { |
@@ -315,10 +350,16 @@ discard block |
||
| 315 | 350 | { |
| 316 | 351 | $ftp_info = Context::gets('ftp_user','ftp_password','ftp_port','sftp'); |
| 317 | 352 | $ftp_info->ftp_port = (int)$ftp_info->ftp_port; |
| 318 | - if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21; |
|
| 319 | - if(!$ftp_info->sftp) $ftp_info->sftp = 'N'; |
|
| 353 | + if(!$ftp_info->ftp_port) { |
|
| 354 | + $ftp_info->ftp_port = 21; |
|
| 355 | + } |
|
| 356 | + if(!$ftp_info->sftp) { |
|
| 357 | + $ftp_info->sftp = 'N'; |
|
| 358 | + } |
|
| 320 | 359 | |
| 321 | - if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 360 | + if(!$ftp_info->ftp_user || !$ftp_info->ftp_password) { |
|
| 361 | + return new Object(-1,'msg_safe_mode_ftp_needed'); |
|
| 362 | + } |
|
| 322 | 363 | |
| 323 | 364 | if($ftp_info->sftp == 'Y') |
| 324 | 365 | { |
@@ -327,12 +368,13 @@ discard block |
||
| 327 | 368 | { |
| 328 | 369 | return new Object(-1,'msg_ftp_invalid_auth_info'); |
| 329 | 370 | } |
| 330 | - } |
|
| 331 | - else |
|
| 371 | + } else |
|
| 332 | 372 | { |
| 333 | 373 | require_once(_XE_PATH_.'libs/ftp.class.php'); |
| 334 | 374 | $oFtp = new ftp(); |
| 335 | - if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 375 | + if(!$oFtp->ftp_connect('127.0.0.1', $ftp_info->ftp_port)) { |
|
| 376 | + return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), 'localhost')); |
|
| 377 | + } |
|
| 336 | 378 | |
| 337 | 379 | if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
| 338 | 380 | { |
@@ -365,26 +407,47 @@ discard block |
||
| 365 | 407 | } |
| 366 | 408 | |
| 367 | 409 | // 1. Check permission |
| 368 | - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; |
|
| 369 | - else $checklist['permission'] = false; |
|
| 410 | + if(is_writable('./')||is_writable('./files')) { |
|
| 411 | + $checklist['permission'] = true; |
|
| 412 | + } else { |
|
| 413 | + $checklist['permission'] = false; |
|
| 414 | + } |
|
| 370 | 415 | // 2. Check if xml_parser_create exists |
| 371 | - if(function_exists('xml_parser_create')) $checklist['xml'] = true; |
|
| 372 | - else $checklist['xml'] = false; |
|
| 416 | + if(function_exists('xml_parser_create')) { |
|
| 417 | + $checklist['xml'] = true; |
|
| 418 | + } else { |
|
| 419 | + $checklist['xml'] = false; |
|
| 420 | + } |
|
| 373 | 421 | // 3. Check if ini_get (session.auto_start) == 1 |
| 374 | - if(ini_get('session.auto_start')!=1) $checklist['session'] = true; |
|
| 375 | - else $checklist['session'] = false; |
|
| 422 | + if(ini_get('session.auto_start')!=1) { |
|
| 423 | + $checklist['session'] = true; |
|
| 424 | + } else { |
|
| 425 | + $checklist['session'] = false; |
|
| 426 | + } |
|
| 376 | 427 | // 4. Check if iconv exists |
| 377 | - if(function_exists('iconv')) $checklist['iconv'] = true; |
|
| 378 | - else $checklist['iconv'] = false; |
|
| 428 | + if(function_exists('iconv')) { |
|
| 429 | + $checklist['iconv'] = true; |
|
| 430 | + } else { |
|
| 431 | + $checklist['iconv'] = false; |
|
| 432 | + } |
|
| 379 | 433 | // 5. Check gd(imagecreatefromgif function) |
| 380 | - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; |
|
| 381 | - else $checklist['gd'] = false; |
|
| 434 | + if(function_exists('imagecreatefromgif')) { |
|
| 435 | + $checklist['gd'] = true; |
|
| 436 | + } else { |
|
| 437 | + $checklist['gd'] = false; |
|
| 438 | + } |
|
| 382 | 439 | // 6. Check DB |
| 383 | - if(DB::getEnableList()) $checklist['db'] = true; |
|
| 384 | - else $checklist['db'] = false; |
|
| 440 | + if(DB::getEnableList()) { |
|
| 441 | + $checklist['db'] = true; |
|
| 442 | + } else { |
|
| 443 | + $checklist['db'] = false; |
|
| 444 | + } |
|
| 385 | 445 | |
| 386 | - if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) $install_enable = false; |
|
| 387 | - else $install_enable = true; |
|
| 446 | + if(!$checklist['php_version'] || !$checklist['permission'] || !$checklist['xml'] || !$checklist['session'] || !$checklist['db']) { |
|
| 447 | + $install_enable = false; |
|
| 448 | + } else { |
|
| 449 | + $install_enable = true; |
|
| 450 | + } |
|
| 388 | 451 | |
| 389 | 452 | // Save the checked result to the Context |
| 390 | 453 | Context::set('checklist', $checklist); |
@@ -407,8 +470,7 @@ discard block |
||
| 407 | 470 | { |
| 408 | 471 | $currentTime = $_SERVER['REQUEST_TIME']; |
| 409 | 472 | FileHandler::writeFile($this->flagLicenseAgreement, $currentTime); |
| 410 | - } |
|
| 411 | - else |
|
| 473 | + } else |
|
| 412 | 474 | { |
| 413 | 475 | FileHandler::removeFile($this->flagLicenseAgreement); |
| 414 | 476 | return new Object(-1, 'msg_must_accept_license_agreement'); |
@@ -503,13 +565,17 @@ discard block |
||
| 503 | 565 | $module = $tmp_arr[count($tmp_arr)-1]; |
| 504 | 566 | |
| 505 | 567 | $xml_info = $oModuleModel->getModuleInfoXml($module); |
| 506 | - if(!$xml_info) continue; |
|
| 568 | + if(!$xml_info) { |
|
| 569 | + continue; |
|
| 570 | + } |
|
| 507 | 571 | $modules[$xml_info->category][] = $module; |
| 508 | 572 | } |
| 509 | 573 | // Install "module" module in advance |
| 510 | 574 | $this->installModule('module','./modules/module'); |
| 511 | 575 | $oModule = getClass('module'); |
| 512 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 576 | + if($oModule->checkUpdate()) { |
|
| 577 | + $oModule->moduleUpdate(); |
|
| 578 | + } |
|
| 513 | 579 | // Determine the order of module installation depending on category |
| 514 | 580 | $install_step = array('system','content','member'); |
| 515 | 581 | // Install all the remaining modules |
@@ -519,13 +585,17 @@ discard block |
||
| 519 | 585 | { |
| 520 | 586 | foreach($modules[$category] as $module) |
| 521 | 587 | { |
| 522 | - if($module == 'module') continue; |
|
| 588 | + if($module == 'module') { |
|
| 589 | + continue; |
|
| 590 | + } |
|
| 523 | 591 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 524 | 592 | |
| 525 | 593 | $oModule = getClass($module); |
| 526 | 594 | if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) |
| 527 | 595 | { |
| 528 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 596 | + if($oModule->checkUpdate()) { |
|
| 597 | + $oModule->moduleUpdate(); |
|
| 598 | + } |
|
| 529 | 599 | } |
| 530 | 600 | } |
| 531 | 601 | unset($modules[$category]); |
@@ -540,13 +610,17 @@ discard block |
||
| 540 | 610 | { |
| 541 | 611 | foreach($module_list as $module) |
| 542 | 612 | { |
| 543 | - if($module == 'module') continue; |
|
| 613 | + if($module == 'module') { |
|
| 614 | + continue; |
|
| 615 | + } |
|
| 544 | 616 | $this->installModule($module, sprintf('./modules/%s', $module)); |
| 545 | 617 | |
| 546 | 618 | $oModule = getClass($module); |
| 547 | 619 | if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) |
| 548 | 620 | { |
| 549 | - if($oModule->checkUpdate()) $oModule->moduleUpdate(); |
|
| 621 | + if($oModule->checkUpdate()) { |
|
| 622 | + $oModule->moduleUpdate(); |
|
| 623 | + } |
|
| 550 | 624 | } |
| 551 | 625 | } |
| 552 | 626 | } |
@@ -571,15 +645,20 @@ discard block |
||
| 571 | 645 | for($i=0;$i<$file_cnt;$i++) |
| 572 | 646 | { |
| 573 | 647 | $file = trim($schema_files[$i]); |
| 574 | - if(!$file || substr($file,-4)!='.xml') continue; |
|
| 648 | + if(!$file || substr($file,-4)!='.xml') { |
|
| 649 | + continue; |
|
| 650 | + } |
|
| 575 | 651 | $output = $oDB->createTableByXmlFile($file); |
| 576 | - if($output === false) |
|
| 577 | - throw new Exception('msg_create_table_failed'); |
|
| 652 | + if($output === false) { |
|
| 653 | + throw new Exception('msg_create_table_failed'); |
|
| 654 | + } |
|
| 578 | 655 | } |
| 579 | 656 | // Create a table and module instance and then execute install() method |
| 580 | 657 | unset($oModule); |
| 581 | 658 | $oModule = getClass($module); |
| 582 | - if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); |
|
| 659 | + if(method_exists($oModule, 'moduleInstall')) { |
|
| 660 | + $oModule->moduleInstall(); |
|
| 661 | + } |
|
| 583 | 662 | return new Object(); |
| 584 | 663 | } |
| 585 | 664 | |
@@ -614,13 +693,17 @@ discard block |
||
| 614 | 693 | $db_tmp_config_file = $this->db_tmp_config_file; |
| 615 | 694 | |
| 616 | 695 | $db_info = Context::getDBInfo(); |
| 617 | - if(!$db_info) return; |
|
| 696 | + if(!$db_info) { |
|
| 697 | + return; |
|
| 698 | + } |
|
| 618 | 699 | |
| 619 | 700 | $buff = $this->_getDBConfigFileContents($db_info); |
| 620 | 701 | |
| 621 | 702 | FileHandler::writeFile($db_tmp_config_file, $buff); |
| 622 | 703 | |
| 623 | - if(@file_exists($db_tmp_config_file)) return true; |
|
| 704 | + if(@file_exists($db_tmp_config_file)) { |
|
| 705 | + return true; |
|
| 706 | + } |
|
| 624 | 707 | return false; |
| 625 | 708 | } |
| 626 | 709 | |
@@ -640,7 +723,9 @@ discard block |
||
| 640 | 723 | |
| 641 | 724 | FileHandler::writeFile($etc_tmp_config_file, $buff); |
| 642 | 725 | |
| 643 | - if(@file_exists($etc_tmp_config_file)) return true; |
|
| 726 | + if(@file_exists($etc_tmp_config_file)) { |
|
| 727 | + return true; |
|
| 728 | + } |
|
| 644 | 729 | return false; |
| 645 | 730 | } |
| 646 | 731 | |
@@ -655,7 +740,9 @@ discard block |
||
| 655 | 740 | //if(file_exists($config_file)) return; |
| 656 | 741 | |
| 657 | 742 | $db_info = Context::getDBInfo(); |
| 658 | - if(!$db_info) return; |
|
| 743 | + if(!$db_info) { |
|
| 744 | + return; |
|
| 745 | + } |
|
| 659 | 746 | |
| 660 | 747 | $buff = $this->_getDBConfigFileContents($db_info); |
| 661 | 748 | |
@@ -676,7 +763,9 @@ discard block |
||
| 676 | 763 | function installByConfig($install_config_file) |
| 677 | 764 | { |
| 678 | 765 | include $install_config_file; |
| 679 | - if(!is_array($auto_config)) return false; |
|
| 766 | + if(!is_array($auto_config)) { |
|
| 767 | + return false; |
|
| 768 | + } |
|
| 680 | 769 | |
| 681 | 770 | $auto_config['module'] = 'install'; |
| 682 | 771 | $auto_config['act'] = 'procInstall'; |
@@ -686,7 +775,9 @@ discard block |
||
| 686 | 775 | $body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n"; |
| 687 | 776 | foreach($auto_config as $k => $v) |
| 688 | 777 | { |
| 689 | - if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k); |
|
| 778 | + if(!in_array($k,array('host','port','path'))) { |
|
| 779 | + $body .= sprintf($fstr,$k,$v,$k); |
|
| 780 | + } |
|
| 690 | 781 | } |
| 691 | 782 | $body .= "</params>\r\n</methodCall>"; |
| 692 | 783 | |