@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | private $path = NULL; ///< target directory |
17 | 17 | private $filename = NULL; ///< target filename |
18 | 18 | private $file = NULL; ///< target file (fullpath) |
19 | - private $xe_path = NULL; ///< XpressEngine base path |
|
19 | + private $xe_path = NULL; ///< XpressEngine base path |
|
20 | 20 | private $web_path = NULL; ///< tpl file web path |
21 | 21 | private $compiled_file = NULL; ///< tpl file web path |
22 | 22 | private $config = NULL; |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | { |
34 | 34 | ini_set('pcre.jit', "0"); |
35 | 35 | $this->xe_path = rtrim(getScriptPath(), '/'); |
36 | - $this->compiled_path = _XE_PATH_ . $this->compiled_path; |
|
36 | + $this->compiled_path = _XE_PATH_.$this->compiled_path; |
|
37 | 37 | $this->config = new stdClass(); |
38 | 38 | |
39 | 39 | $this->ignoreEscape = array( |
40 | - 'html_content' => function ($m) { |
|
40 | + 'html_content' => function($m) { |
|
41 | 41 | $list = array( |
42 | 42 | '$content', // 레이아웃 등 |
43 | 43 | '$editor', // 에디터 출력 |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | ); |
55 | 55 | return in_array($m[1], $list); |
56 | 56 | }, |
57 | - 'url' => function ($m) { |
|
57 | + 'url' => function($m) { |
|
58 | 58 | $list = array( |
59 | 59 | 'getUrl', |
60 | 60 | 'getNotEncodedUrl', |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | ); |
70 | 70 | return in_array(array_shift(explode('(', $m[1])), $list); |
71 | 71 | }, |
72 | - 'methods' => function ($m) { |
|
72 | + 'methods' => function($m) { |
|
73 | 73 | $list = array( |
74 | 74 | 'getEditor', |
75 | 75 | 'getCommentEditor', |
@@ -81,16 +81,16 @@ discard block |
||
81 | 81 | 'getSignature', // 회원 서명 |
82 | 82 | 'printExtraImages', // new, file 아이콘 등 |
83 | 83 | ); |
84 | - return preg_match('/\-\>(' . implode('|', $list) . ')\(/', $m[1]); |
|
84 | + return preg_match('/\-\>('.implode('|', $list).')\(/', $m[1]); |
|
85 | 85 | }, |
86 | - 'functions' => function ($m) { |
|
86 | + 'functions' => function($m) { |
|
87 | 87 | $list = array( |
88 | 88 | 'htmlspecialchars', |
89 | 89 | 'nl2br', |
90 | 90 | ); |
91 | - return preg_match('/^(' . implode('|', $list) . ')\(/', $m[1]); |
|
91 | + return preg_match('/^('.implode('|', $list).')\(/', $m[1]); |
|
92 | 92 | }, |
93 | - 'lang' => function ($m) { |
|
93 | + 'lang' => function($m) { |
|
94 | 94 | // 다국어 |
95 | 95 | return preg_match('/^\$lang\-\>/', trim($m[1])); |
96 | 96 | } |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | { |
108 | 108 | static $oTemplate = NULL; |
109 | 109 | |
110 | - if(__DEBUG__ == 3) |
|
110 | + if (__DEBUG__ == 3) |
|
111 | 111 | { |
112 | - if(!isset($GLOBALS['__TemplateHandlerCalled__'])) |
|
112 | + if (!isset($GLOBALS['__TemplateHandlerCalled__'])) |
|
113 | 113 | { |
114 | 114 | $GLOBALS['__TemplateHandlerCalled__'] = 1; |
115 | 115 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - if(!$oTemplate) |
|
122 | + if (!$oTemplate) |
|
123 | 123 | { |
124 | 124 | $oTemplate = new TemplateHandler(); |
125 | 125 | } |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | protected function init($tpl_path, $tpl_filename, $tpl_file = '') |
138 | 138 | { |
139 | 139 | // verify arguments |
140 | - if(substr($tpl_path, -1) != '/') |
|
140 | + if (substr($tpl_path, -1) != '/') |
|
141 | 141 | { |
142 | 142 | $tpl_path .= '/'; |
143 | 143 | } |
144 | - if(!is_dir($tpl_path)) |
|
144 | + if (!is_dir($tpl_path)) |
|
145 | 145 | { |
146 | 146 | return; |
147 | 147 | } |
148 | - if(!file_exists($tpl_path . $tpl_filename) && file_exists($tpl_path . $tpl_filename . '.html')) |
|
148 | + if (!file_exists($tpl_path.$tpl_filename) && file_exists($tpl_path.$tpl_filename.'.html')) |
|
149 | 149 | { |
150 | 150 | $tpl_filename .= '.html'; |
151 | 151 | } |
152 | 152 | |
153 | 153 | // create tpl_file variable |
154 | - if(!$tpl_file) |
|
154 | + if (!$tpl_file) |
|
155 | 155 | { |
156 | - $tpl_file = $tpl_path . $tpl_filename; |
|
156 | + $tpl_file = $tpl_path.$tpl_filename; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // set template file infos. |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | $this->filename = $tpl_filename; |
162 | 162 | $this->file = $tpl_file; |
163 | 163 | |
164 | - $this->web_path = $this->xe_path . '/' . ltrim(preg_replace('@^' . preg_quote(_XE_PATH_, '@') . '|\./@', '', $this->path), '/'); |
|
164 | + $this->web_path = $this->xe_path.'/'.ltrim(preg_replace('@^'.preg_quote(_XE_PATH_, '@').'|\./@', '', $this->path), '/'); |
|
165 | 165 | |
166 | 166 | // get compiled file name |
167 | - $hash = md5($this->file . __XE_VERSION__); |
|
167 | + $hash = md5($this->file.__XE_VERSION__); |
|
168 | 168 | $this->compiled_file = "{$this->compiled_path}{$hash}.compiled.php"; |
169 | 169 | |
170 | 170 | $this->safeguard = $this->isSafeguard(); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $buff = false; |
188 | 188 | |
189 | 189 | // store the starting time for debug information |
190 | - if(__DEBUG__ == 3) |
|
190 | + if (__DEBUG__ == 3) |
|
191 | 191 | { |
192 | 192 | $start = getMicroTime(); |
193 | 193 | } |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | $this->init($tpl_path, $tpl_filename, $tpl_file); |
197 | 197 | |
198 | 198 | // if target file does not exist exit |
199 | - if(!$this->file || !file_exists($this->file)) |
|
199 | + if (!$this->file || !file_exists($this->file)) |
|
200 | 200 | { |
201 | 201 | return "Err : '{$this->file}' template file does not exists."; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // for backward compatibility |
205 | - if(is_null(self::$rootTpl)) |
|
205 | + if (is_null(self::$rootTpl)) |
|
206 | 206 | { |
207 | 207 | self::$rootTpl = $this->file; |
208 | 208 | } |
@@ -214,23 +214,23 @@ discard block |
||
214 | 214 | $oCacheHandler = CacheHandler::getInstance('template'); |
215 | 215 | |
216 | 216 | // get cached buff |
217 | - if($oCacheHandler->isSupport()) |
|
217 | + if ($oCacheHandler->isSupport()) |
|
218 | 218 | { |
219 | - $cache_key = 'template:' . $this->file; |
|
219 | + $cache_key = 'template:'.$this->file; |
|
220 | 220 | $buff = $oCacheHandler->get($cache_key, $latest_mtime); |
221 | 221 | } |
222 | 222 | else |
223 | 223 | { |
224 | - if(is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file)) |
|
224 | + if (is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file)) |
|
225 | 225 | { |
226 | - $buff = 'file://' . $this->compiled_file; |
|
226 | + $buff = 'file://'.$this->compiled_file; |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - if($buff === FALSE) |
|
230 | + if ($buff === FALSE) |
|
231 | 231 | { |
232 | 232 | $buff = $this->parse(); |
233 | - if($oCacheHandler->isSupport()) |
|
233 | + if ($oCacheHandler->isSupport()) |
|
234 | 234 | { |
235 | 235 | $oCacheHandler->put($cache_key, $buff); |
236 | 236 | } |
@@ -242,13 +242,13 @@ discard block |
||
242 | 242 | |
243 | 243 | $output = $this->_fetch($buff); |
244 | 244 | |
245 | - if($__templatehandler_root_tpl == $this->file) |
|
245 | + if ($__templatehandler_root_tpl == $this->file) |
|
246 | 246 | { |
247 | 247 | $__templatehandler_root_tpl = null; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // store the ending time for debug information |
251 | - if(__DEBUG__ == 3) |
|
251 | + if (__DEBUG__ == 3) |
|
252 | 252 | { |
253 | 253 | $GLOBALS['__template_elapsed__'] += getMicroTime() - $start; |
254 | 254 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $this->init($tpl_path, $tpl_filename, null); |
268 | 268 | |
269 | 269 | // if target file does not exist exit |
270 | - if(!$this->file || !file_exists($this->file)) |
|
270 | + if (!$this->file || !file_exists($this->file)) |
|
271 | 271 | { |
272 | 272 | Context::close(); |
273 | 273 | exit("Cannot find the template file: '{$this->file}'"); |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | */ |
284 | 284 | protected function parse($buff = null) |
285 | 285 | { |
286 | - if(is_null($buff)) |
|
286 | + if (is_null($buff)) |
|
287 | 287 | { |
288 | - if(!is_readable($this->file)) |
|
288 | + if (!is_readable($this->file)) |
|
289 | 289 | { |
290 | 290 | return; |
291 | 291 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | // HTML tags to skip |
298 | - if(is_null($this->skipTags)) |
|
298 | + if (is_null($this->skipTags)) |
|
299 | 299 | { |
300 | 300 | $this->skipTags = array('marquee'); |
301 | 301 | } |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | $this->config = new stdClass(); |
306 | 306 | $this->config->autoescape = null; |
307 | 307 | |
308 | - if(preg_match('/\<config( [^\>\/]+)/', $buff, $config_match)) |
|
308 | + if (preg_match('/\<config( [^\>\/]+)/', $buff, $config_match)) |
|
309 | 309 | { |
310 | - if(preg_match_all('@ (?<name>\w+)="(?<value>[^"]+)"@', $config_match[1], $config_matches, PREG_SET_ORDER)) |
|
310 | + if (preg_match_all('@ (?<name>\w+)="(?<value>[^"]+)"@', $config_match[1], $config_matches, PREG_SET_ORDER)) |
|
311 | 311 | { |
312 | - foreach($config_matches as $config_match) |
|
312 | + foreach ($config_matches as $config_match) |
|
313 | 313 | { |
314 | - if($config_match['name'] === 'autoescape') |
|
314 | + if ($config_match['name'] === 'autoescape') |
|
315 | 315 | { |
316 | 316 | $this->config->autoescape = $config_match['value']; |
317 | 317 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | - if($this->config->autoescape === 'on') $this->safeguard = true; |
|
322 | + if ($this->config->autoescape === 'on') $this->safeguard = true; |
|
323 | 323 | |
324 | 324 | // replace comments |
325 | 325 | $buff = preg_replace('@<!--//.*?-->@s', '', $buff); |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | |
339 | 339 | // form auto generation |
340 | 340 | $temp = preg_replace_callback('/(<form(?:<\?php.+?\?>|[^<>]+)*?>)(.*?)(<\/form>)/is', array($this, '_compileFormAuthGeneration'), $buff); |
341 | - if($temp) |
|
341 | + if ($temp) |
|
342 | 342 | { |
343 | 343 | $buff = $temp; |
344 | 344 | } |
345 | 345 | |
346 | 346 | // prevent from calling directly before writing into file |
347 | - $buff = '<?php if(!defined("__XE__"))exit;?>' . $buff; |
|
347 | + $buff = '<?php if(!defined("__XE__"))exit;?>'.$buff; |
|
348 | 348 | |
349 | 349 | // remove php script reopening |
350 | 350 | $buff = preg_replace(array('/(\n|\r\n)+/', '/(;)?( )*\?\>\<\?php([\n\t ]+)?/'), array("\n", ";\n"), $buff); |
@@ -367,40 +367,40 @@ discard block |
||
367 | 367 | private function _compileFormAuthGeneration($matches) |
368 | 368 | { |
369 | 369 | // form ruleset attribute move to hidden tag |
370 | - if($matches[1]) |
|
370 | + if ($matches[1]) |
|
371 | 371 | { |
372 | 372 | preg_match('/ruleset="([^"]*?)"/is', $matches[1], $m); |
373 | - if($m[0]) |
|
373 | + if ($m[0]) |
|
374 | 374 | { |
375 | - $matches[1] = preg_replace('/' . addcslashes($m[0], '?$') . '/i', '', $matches[1]); |
|
375 | + $matches[1] = preg_replace('/'.addcslashes($m[0], '?$').'/i', '', $matches[1]); |
|
376 | 376 | |
377 | - if(strpos($m[1], '@') !== FALSE) |
|
377 | + if (strpos($m[1], '@') !== FALSE) |
|
378 | 378 | { |
379 | 379 | $path = str_replace('@', '', $m[1]); |
380 | - $path = './files/ruleset/' . $path . '.xml'; |
|
380 | + $path = './files/ruleset/'.$path.'.xml'; |
|
381 | 381 | } |
382 | - else if(strpos($m[1], '#') !== FALSE) |
|
382 | + else if (strpos($m[1], '#') !== FALSE) |
|
383 | 383 | { |
384 | 384 | $fileName = str_replace('#', '', $m[1]); |
385 | 385 | $fileName = str_replace('<?php echo ', '', $fileName); |
386 | 386 | $fileName = str_replace(' ?>', '', $fileName); |
387 | - $path = '#./files/ruleset/' . $fileName . '.xml'; |
|
387 | + $path = '#./files/ruleset/'.$fileName.'.xml'; |
|
388 | 388 | |
389 | 389 | preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm); |
390 | 390 | $module_path = $mm[1]; |
391 | 391 | list($rulsetFile) = explode('.', $fileName); |
392 | - $autoPath = $module_path . '/ruleset/' . $rulsetFile . '.xml'; |
|
392 | + $autoPath = $module_path.'/ruleset/'.$rulsetFile.'.xml'; |
|
393 | 393 | $m[1] = $rulsetFile; |
394 | 394 | } |
395 | - else if(preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm)) |
|
395 | + else if (preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm)) |
|
396 | 396 | { |
397 | 397 | $module_path = $mm[1]; |
398 | - $path = $module_path . '/ruleset/' . $m[1] . '.xml'; |
|
398 | + $path = $module_path.'/ruleset/'.$m[1].'.xml'; |
|
399 | 399 | } |
400 | 400 | |
401 | - $matches[2] = '<input type="hidden" name="ruleset" value="' . $m[1] . '" />' . $matches[2]; |
|
401 | + $matches[2] = '<input type="hidden" name="ruleset" value="'.$m[1].'" />'.$matches[2]; |
|
402 | 402 | //assign to addJsFile method for js dynamic recache |
403 | - $matches[1] = '<?php Context::addJsFile("' . $path . '", FALSE, "", 0, "body", TRUE, "' . $autoPath . '") ?' . '>' . $matches[1]; |
|
403 | + $matches[1] = '<?php Context::addJsFile("'.$path.'", FALSE, "", 0, "body", TRUE, "'.$autoPath.'") ?'.'>'.$matches[1]; |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
@@ -408,22 +408,22 @@ discard block |
||
408 | 408 | preg_match_all('/<input[^>]* name="(act|mid|vid)"/is', $matches[2], $m2); |
409 | 409 | $checkVar = array('act', 'mid', 'vid'); |
410 | 410 | $resultArray = array_diff($checkVar, $m2[1]); |
411 | - if(is_array($resultArray)) |
|
411 | + if (is_array($resultArray)) |
|
412 | 412 | { |
413 | 413 | $generatedHidden = ''; |
414 | - foreach($resultArray AS $key => $value) |
|
414 | + foreach ($resultArray AS $key => $value) |
|
415 | 415 | { |
416 | - $generatedHidden .= '<input type="hidden" name="' . $value . '" value="<?php echo $__Context->' . $value . ' ?>" />'; |
|
416 | + $generatedHidden .= '<input type="hidden" name="'.$value.'" value="<?php echo $__Context->'.$value.' ?>" />'; |
|
417 | 417 | } |
418 | - $matches[2] = $generatedHidden . $matches[2]; |
|
418 | + $matches[2] = $generatedHidden.$matches[2]; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | // return url generate |
422 | - if(!preg_match('/no-error-return-url="true"/i', $matches[1])) |
|
422 | + if (!preg_match('/no-error-return-url="true"/i', $matches[1])) |
|
423 | 423 | { |
424 | 424 | preg_match('/<input[^>]*name="error_return_url"[^>]*>/is', $matches[2], $m3); |
425 | - if(!$m3[0]) |
|
426 | - $matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />' . $matches[2]; |
|
425 | + if (!$m3[0]) |
|
426 | + $matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />'.$matches[2]; |
|
427 | 427 | } |
428 | 428 | else |
429 | 429 | { |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | private function _fetch($buff) |
443 | 443 | { |
444 | - if(!$buff) |
|
444 | + if (!$buff) |
|
445 | 445 | { |
446 | 446 | return; |
447 | 447 | } |
@@ -449,20 +449,20 @@ discard block |
||
449 | 449 | $__Context = &$GLOBALS['__Context__']; |
450 | 450 | $__Context->tpl_path = $this->path; |
451 | 451 | |
452 | - if($_SESSION['is_logged']) |
|
452 | + if ($_SESSION['is_logged']) |
|
453 | 453 | { |
454 | 454 | $__Context->logged_info = Context::get('logged_info'); |
455 | 455 | } |
456 | 456 | |
457 | 457 | $level = ob_get_level(); |
458 | 458 | ob_start(); |
459 | - if(substr($buff, 0, 7) == 'file://') |
|
459 | + if (substr($buff, 0, 7) == 'file://') |
|
460 | 460 | { |
461 | - if(__DEBUG__) |
|
461 | + if (__DEBUG__) |
|
462 | 462 | { |
463 | 463 | //load cache file from disk |
464 | 464 | $eval_str = FileHandler::readFile(substr($buff, 7)); |
465 | - $eval_str_buffed = "?>" . $eval_str; |
|
465 | + $eval_str_buffed = "?>".$eval_str; |
|
466 | 466 | @eval($eval_str_buffed); |
467 | 467 | $error_info = error_get_last(); |
468 | 468 | //parse error |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | } |
479 | 479 | else |
480 | 480 | { |
481 | - $eval_str = "?>" . $buff; |
|
481 | + $eval_str = "?>".$buff; |
|
482 | 482 | @eval($eval_str); |
483 | 483 | $error_info = error_get_last(); |
484 | 484 | //parse error |
@@ -507,31 +507,31 @@ discard block |
||
507 | 507 | private function _replacePath($match) |
508 | 508 | { |
509 | 509 | //return origin conde when src value started '${'. |
510 | - if(preg_match('@^\${@', $match[1])) |
|
510 | + if (preg_match('@^\${@', $match[1])) |
|
511 | 511 | { |
512 | 512 | return $match[0]; |
513 | 513 | } |
514 | 514 | |
515 | 515 | //return origin code when src value include variable. |
516 | - if(preg_match('@^[\'|"]\s*\.\s*\$@', $match[1])) |
|
516 | + if (preg_match('@^[\'|"]\s*\.\s*\$@', $match[1])) |
|
517 | 517 | { |
518 | 518 | return $match[0]; |
519 | 519 | } |
520 | 520 | |
521 | 521 | $src = preg_replace('@^(\./)+@', '', trim($match[1])); |
522 | 522 | |
523 | - $src = $this->web_path . $src; |
|
523 | + $src = $this->web_path.$src; |
|
524 | 524 | $src = str_replace('/./', '/', $src); |
525 | 525 | |
526 | 526 | // for backward compatibility |
527 | 527 | $src = preg_replace('@/((?:[\w-]+/)+)\1@', '/\1', $src); |
528 | 528 | |
529 | - while(($tmp = preg_replace('@[^/]+/\.\./@', '', $src, 1)) !== $src) |
|
529 | + while (($tmp = preg_replace('@[^/]+/\.\./@', '', $src, 1)) !== $src) |
|
530 | 530 | { |
531 | 531 | $src = $tmp; |
532 | 532 | } |
533 | 533 | |
534 | - return substr($match[0], 0, -strlen($match[1]) - 6) . "src=\"{$src}\""; |
|
534 | + return substr($match[0], 0, -strlen($match[1]) - 6)."src=\"{$src}\""; |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | */ |
542 | 542 | private function _parseInline($buff) |
543 | 543 | { |
544 | - if(!preg_match_all('/<([a-zA-Z]+\d?)(?:\s)/', $buff, $match)) |
|
544 | + if (!preg_match_all('/<([a-zA-Z]+\d?)(?:\s)/', $buff, $match)) |
|
545 | 545 | { |
546 | 546 | return $buff; |
547 | 547 | } |
548 | 548 | |
549 | 549 | $tags = array_diff(array_unique($match[1]), $this->skipTags); |
550 | 550 | |
551 | - if(!count($tags)) |
|
551 | + if (!count($tags)) |
|
552 | 552 | { |
553 | 553 | return $buff; |
554 | 554 | } |
555 | 555 | |
556 | - $tags = '(?:' . implode('|', $tags) . ')'; |
|
556 | + $tags = '(?:'.implode('|', $tags).')'; |
|
557 | 557 | $split_regex = "@(<(?>/?{$tags})(?>[^<>\{\}\"']+|<!--.*?-->|{[^}]+}|\".*?\"|'.*?'|.)*?>)@s"; |
558 | 558 | |
559 | 559 | $nodes = preg_split($split_regex, $buff, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -561,14 +561,14 @@ discard block |
||
561 | 561 | // list of self closing tags |
562 | 562 | $self_closing = array('area' => 1, 'base' => 1, 'basefont' => 1, 'br' => 1, 'hr' => 1, 'input' => 1, 'img' => 1, 'link' => 1, 'meta' => 1, 'param' => 1, 'frame' => 1, 'col' => 1); |
563 | 563 | |
564 | - for($idx = 1, $node_len = count($nodes); $idx < $node_len; $idx+=2) |
|
564 | + for ($idx = 1, $node_len = count($nodes); $idx < $node_len; $idx += 2) |
|
565 | 565 | { |
566 | - if(!($node = $nodes[$idx])) |
|
566 | + if (!($node = $nodes[$idx])) |
|
567 | 567 | { |
568 | 568 | continue; |
569 | 569 | } |
570 | 570 | |
571 | - if(preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches)) |
|
571 | + if (preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches)) |
|
572 | 572 | { |
573 | 573 | // this tag |
574 | 574 | $tag = substr($node, 1, strpos($node, ' ') - 1); |
@@ -577,37 +577,37 @@ discard block |
||
577 | 577 | $closing = 0; |
578 | 578 | |
579 | 579 | // process opening tag |
580 | - foreach($matches[1] as $n => $stmt) |
|
580 | + foreach ($matches[1] as $n => $stmt) |
|
581 | 581 | { |
582 | 582 | $expr = $matches[2][$n]; |
583 | 583 | $expr = $this->_replaceVar($expr); |
584 | 584 | $closing++; |
585 | 585 | |
586 | - switch($stmt) |
|
586 | + switch ($stmt) |
|
587 | 587 | { |
588 | 588 | case 'cond': |
589 | 589 | $nodes[$idx - 1] .= "<?php if({$expr}){ ?>"; |
590 | 590 | break; |
591 | 591 | case 'loop': |
592 | - if(!preg_match('@^(?:(.+?)=>(.+?)(?:,(.+?))?|(.*?;.*?;.*?)|(.+?)\s*=\s*(.+?))$@', $expr, $expr_m)) |
|
592 | + if (!preg_match('@^(?:(.+?)=>(.+?)(?:,(.+?))?|(.*?;.*?;.*?)|(.+?)\s*=\s*(.+?))$@', $expr, $expr_m)) |
|
593 | 593 | { |
594 | 594 | break; |
595 | 595 | } |
596 | - if($expr_m[1]) |
|
596 | + if ($expr_m[1]) |
|
597 | 597 | { |
598 | 598 | $expr_m[1] = trim($expr_m[1]); |
599 | 599 | $expr_m[2] = trim($expr_m[2]); |
600 | - if($expr_m[3]) |
|
600 | + if ($expr_m[3]) |
|
601 | 601 | { |
602 | - $expr_m[2] .= '=>' . trim($expr_m[3]); |
|
602 | + $expr_m[2] .= '=>'.trim($expr_m[3]); |
|
603 | 603 | } |
604 | 604 | $nodes[$idx - 1] .= "<?php if({$expr_m[1]}&&count({$expr_m[1]}))foreach({$expr_m[1]} as {$expr_m[2]}){ ?>"; |
605 | 605 | } |
606 | - elseif($expr_m[4]) |
|
606 | + elseif ($expr_m[4]) |
|
607 | 607 | { |
608 | 608 | $nodes[$idx - 1] .= "<?php for({$expr_m[4]}){ ?>"; |
609 | 609 | } |
610 | - elseif($expr_m[5]) |
|
610 | + elseif ($expr_m[5]) |
|
611 | 611 | { |
612 | 612 | $nodes[$idx - 1] .= "<?php while({$expr_m[5]}={$expr_m[6]}){ ?>"; |
613 | 613 | } |
@@ -617,28 +617,28 @@ discard block |
||
617 | 617 | $node = preg_replace('@\s(loop|cond)="([^"]+)"@', '', $node); |
618 | 618 | |
619 | 619 | // find closing tag |
620 | - $close_php = '<?php ' . str_repeat('}', $closing) . ' ?>'; |
|
620 | + $close_php = '<?php '.str_repeat('}', $closing).' ?>'; |
|
621 | 621 | // self closing tag |
622 | - if($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag])) |
|
622 | + if ($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag])) |
|
623 | 623 | { |
624 | - $nodes[$idx + 1] = $close_php . $nodes[$idx + 1]; |
|
624 | + $nodes[$idx + 1] = $close_php.$nodes[$idx + 1]; |
|
625 | 625 | } |
626 | 626 | else |
627 | 627 | { |
628 | 628 | $depth = 1; |
629 | - for($i = $idx + 2; $i < $node_len; $i+=2) |
|
629 | + for ($i = $idx + 2; $i < $node_len; $i += 2) |
|
630 | 630 | { |
631 | 631 | $nd = $nodes[$i]; |
632 | - if(strpos($nd, $tag) === 1) |
|
632 | + if (strpos($nd, $tag) === 1) |
|
633 | 633 | { |
634 | 634 | $depth++; |
635 | 635 | } |
636 | - elseif(strpos($nd, '/' . $tag) === 1) |
|
636 | + elseif (strpos($nd, '/'.$tag) === 1) |
|
637 | 637 | { |
638 | 638 | $depth--; |
639 | - if(!$depth) |
|
639 | + if (!$depth) |
|
640 | 640 | { |
641 | - $nodes[$i - 1] .= $nodes[$i] . $close_php; |
|
641 | + $nodes[$i - 1] .= $nodes[$i].$close_php; |
|
642 | 642 | $nodes[$i] = ''; |
643 | 643 | break; |
644 | 644 | } |
@@ -647,13 +647,13 @@ discard block |
||
647 | 647 | } |
648 | 648 | } |
649 | 649 | |
650 | - if(strpos($node, '|cond="') !== false) |
|
650 | + if (strpos($node, '|cond="') !== false) |
|
651 | 651 | { |
652 | 652 | $node = preg_replace('@(\s[-\w:]+(?:="[^"]+?")?)\|cond="(.+?)"@s', '<?php if($2){ ?>$1<?php } ?>', $node); |
653 | 653 | $node = $this->_replaceVar($node); |
654 | 654 | } |
655 | 655 | |
656 | - if($nodes[$idx] != $node) |
|
656 | + if ($nodes[$idx] != $node) |
|
657 | 657 | { |
658 | 658 | $nodes[$idx] = $node; |
659 | 659 | } |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | { |
675 | 675 | $escape_option = 'noescape'; |
676 | 676 | |
677 | - if($this->safeguard) |
|
677 | + if ($this->safeguard) |
|
678 | 678 | { |
679 | 679 | $escape_option = 'autoescape'; |
680 | 680 | } |
@@ -685,14 +685,14 @@ discard block |
||
685 | 685 | } |
686 | 686 | |
687 | 687 | // {@ ... } or {$var} or {func(...)} |
688 | - if($m[1]) |
|
688 | + if ($m[1]) |
|
689 | 689 | { |
690 | - if(preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1])) |
|
690 | + if (preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1])) |
|
691 | 691 | { |
692 | 692 | return $m[0]; |
693 | 693 | } |
694 | 694 | |
695 | - if($m[1]{0} == '@') |
|
695 | + if ($m[1]{0} == '@') |
|
696 | 696 | { |
697 | 697 | $m[1] = $this->_replaceVar(substr($m[1], 1)); |
698 | 698 | return "<?php {$m[1]} ?>"; |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | // Get escape options. |
703 | 703 | foreach ($this->ignoreEscape as $key => $value) |
704 | 704 | { |
705 | - if($this->ignoreEscape[$key]($m)) |
|
705 | + if ($this->ignoreEscape[$key]($m)) |
|
706 | 706 | { |
707 | 707 | $escape_option = 'noescape'; |
708 | 708 | break; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | $filter_option = $matches[2]; |
734 | 734 | if (!self::_isVar($filter_option) && !preg_match("/^'.*'$/", $filter_option) && !preg_match('/^".*"$/', $filter_option)) |
735 | 735 | { |
736 | - $filter_option = "'" . escape_sqstr($filter_option) . "'"; |
|
736 | + $filter_option = "'".escape_sqstr($filter_option)."'"; |
|
737 | 737 | } |
738 | 738 | else |
739 | 739 | { |
@@ -832,18 +832,18 @@ discard block |
||
832 | 832 | } |
833 | 833 | |
834 | 834 | // Apply the escape option and return. |
835 | - return '<?php echo ' . $this->_applyEscapeOption($var, $escape_option) . ' ?>'; |
|
835 | + return '<?php echo '.$this->_applyEscapeOption($var, $escape_option).' ?>'; |
|
836 | 836 | } |
837 | 837 | } |
838 | 838 | |
839 | - if($m[3]) |
|
839 | + if ($m[3]) |
|
840 | 840 | { |
841 | 841 | $attr = array(); |
842 | - if($m[5]) |
|
842 | + if ($m[5]) |
|
843 | 843 | { |
844 | - if(preg_match_all('@,(\w+)="([^"]+)"@', $m[6], $mm)) |
|
844 | + if (preg_match_all('@,(\w+)="([^"]+)"@', $m[6], $mm)) |
|
845 | 845 | { |
846 | - foreach($mm[1] as $idx => $name) |
|
846 | + foreach ($mm[1] as $idx => $name) |
|
847 | 847 | { |
848 | 848 | $attr[$name] = $mm[2][$idx]; |
849 | 849 | } |
@@ -852,21 +852,21 @@ discard block |
||
852 | 852 | } |
853 | 853 | else |
854 | 854 | { |
855 | - if(!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm)) |
|
855 | + if (!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm)) |
|
856 | 856 | { |
857 | 857 | return $m[0]; |
858 | 858 | } |
859 | - foreach($mm[1] as $idx => $name) |
|
859 | + foreach ($mm[1] as $idx => $name) |
|
860 | 860 | { |
861 | 861 | $attr[$name] = $mm[2][$idx]; |
862 | 862 | } |
863 | 863 | } |
864 | 864 | |
865 | - switch($m[3]) |
|
865 | + switch ($m[3]) |
|
866 | 866 | { |
867 | 867 | // <!--#include--> or <include ..> |
868 | 868 | case 'include': |
869 | - if(!$this->file || !$attr['target']) |
|
869 | + if (!$this->file || !$attr['target']) |
|
870 | 870 | { |
871 | 871 | return ''; |
872 | 872 | } |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | $pathinfo = pathinfo($attr['target']); |
875 | 875 | $fileDir = $this->_getRelativeDir($pathinfo['dirname']); |
876 | 876 | |
877 | - if(!$fileDir) |
|
877 | + if (!$fileDir) |
|
878 | 878 | { |
879 | 879 | return ''; |
880 | 880 | } |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | case 'load_js_plugin': |
885 | 885 | $plugin = $this->_replaceVar($m[5]); |
886 | 886 | $s = "<!--#JSPLUGIN:{$plugin}-->"; |
887 | - if(strpos($plugin, '$__Context') === false) |
|
887 | + if (strpos($plugin, '$__Context') === false) |
|
888 | 888 | { |
889 | 889 | $plugin = "'{$plugin}'"; |
890 | 890 | } |
@@ -900,13 +900,13 @@ discard block |
||
900 | 900 | $doUnload = ($m[3] === 'unload'); |
901 | 901 | $isRemote = !!preg_match('@^(https?:)?//@i', $attr['target']); |
902 | 902 | |
903 | - if(!$isRemote) |
|
903 | + if (!$isRemote) |
|
904 | 904 | { |
905 | - if(!preg_match('@^\.?/@', $attr['target'])) |
|
905 | + if (!preg_match('@^\.?/@', $attr['target'])) |
|
906 | 906 | { |
907 | - $attr['target'] = './' . $attr['target']; |
|
907 | + $attr['target'] = './'.$attr['target']; |
|
908 | 908 | } |
909 | - if(substr($attr['target'], -5) == '/lang') |
|
909 | + if (substr($attr['target'], -5) == '/lang') |
|
910 | 910 | { |
911 | 911 | $pathinfo['dirname'] .= '/lang'; |
912 | 912 | $pathinfo['basename'] = ''; |
@@ -915,18 +915,18 @@ discard block |
||
915 | 915 | |
916 | 916 | $relativeDir = $this->_getRelativeDir($pathinfo['dirname']); |
917 | 917 | |
918 | - $attr['target'] = $relativeDir . '/' . $pathinfo['basename']; |
|
918 | + $attr['target'] = $relativeDir.'/'.$pathinfo['basename']; |
|
919 | 919 | } |
920 | 920 | |
921 | - switch($pathinfo['extension']) |
|
921 | + switch ($pathinfo['extension']) |
|
922 | 922 | { |
923 | 923 | case 'xml': |
924 | - if($isRemote || $doUnload) |
|
924 | + if ($isRemote || $doUnload) |
|
925 | 925 | { |
926 | 926 | return ''; |
927 | 927 | } |
928 | 928 | // language file? |
929 | - if($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang') |
|
929 | + if ($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang') |
|
930 | 930 | { |
931 | 931 | $result = "Context::loadLang('{$relativeDir}');"; |
932 | 932 | } |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | } |
937 | 937 | break; |
938 | 938 | case 'js': |
939 | - if($doUnload) |
|
939 | + if ($doUnload) |
|
940 | 940 | { |
941 | 941 | $result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}');"; |
942 | 942 | } |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | } |
948 | 948 | break; |
949 | 949 | case 'css': |
950 | - if($doUnload) |
|
950 | + if ($doUnload) |
|
951 | 951 | { |
952 | 952 | $result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}','{$attr['media']}');"; |
953 | 953 | } |
@@ -960,20 +960,20 @@ discard block |
||
960 | 960 | } |
961 | 961 | |
962 | 962 | $result = "<?php {$result} ?>"; |
963 | - if($metafile) |
|
963 | + if ($metafile) |
|
964 | 964 | { |
965 | - $result = "<!--#Meta:{$metafile}-->" . $result; |
|
965 | + $result = "<!--#Meta:{$metafile}-->".$result; |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | return $result; |
969 | 969 | // <config ...> |
970 | 970 | case 'config': |
971 | 971 | $result = ''; |
972 | - if(preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $config_matches, PREG_SET_ORDER)) |
|
972 | + if (preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $config_matches, PREG_SET_ORDER)) |
|
973 | 973 | { |
974 | - foreach($config_matches as $config_match) |
|
974 | + foreach ($config_matches as $config_match) |
|
975 | 975 | { |
976 | - $result .= "\$this->config->{$config_match[1]} = '" . trim(strtolower($config_match[2])) . "';"; |
|
976 | + $result .= "\$this->config->{$config_match[1]} = '".trim(strtolower($config_match[2]))."';"; |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | return "<?php {$result} ?>"; |
@@ -981,45 +981,45 @@ discard block |
||
981 | 981 | } |
982 | 982 | |
983 | 983 | // <[email protected]> such as <!--@if($cond)-->, <!--@else-->, <!--@end--> |
984 | - if($m[7]) |
|
984 | + if ($m[7]) |
|
985 | 985 | { |
986 | 986 | $m[7] = substr($m[7], 1); |
987 | - if(!$m[7]) |
|
987 | + if (!$m[7]) |
|
988 | 988 | { |
989 | - return '<?php ' . $this->_replaceVar($m[8]) . '{ ?>' . $m[9]; |
|
989 | + return '<?php '.$this->_replaceVar($m[8]).'{ ?>'.$m[9]; |
|
990 | 990 | } |
991 | - if(!preg_match('/^(?:((?:end)?(?:if|switch|for(?:each)?|while)|end)|(else(?:if)?)|(break@)?(case|default)|(break))$/', $m[7], $mm)) |
|
991 | + if (!preg_match('/^(?:((?:end)?(?:if|switch|for(?:each)?|while)|end)|(else(?:if)?)|(break@)?(case|default)|(break))$/', $m[7], $mm)) |
|
992 | 992 | { |
993 | 993 | return ''; |
994 | 994 | } |
995 | - if($mm[1]) |
|
995 | + if ($mm[1]) |
|
996 | 996 | { |
997 | - if($mm[1]{0} == 'e') |
|
997 | + if ($mm[1]{0} == 'e') |
|
998 | 998 | { |
999 | - return '<?php } ?>' . $m[9]; |
|
999 | + return '<?php } ?>'.$m[9]; |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | $precheck = ''; |
1003 | - if($mm[1] == 'switch') |
|
1003 | + if ($mm[1] == 'switch') |
|
1004 | 1004 | { |
1005 | 1005 | $m[9] = ''; |
1006 | 1006 | } |
1007 | - elseif($mm[1] == 'foreach') |
|
1007 | + elseif ($mm[1] == 'foreach') |
|
1008 | 1008 | { |
1009 | 1009 | $var = preg_replace('/^\s*\(\s*(.+?) .*$/', '$1', $m[8]); |
1010 | 1010 | $precheck = "if({$var}&&count({$var}))"; |
1011 | 1011 | } |
1012 | - return '<?php ' . $this->_replaceVar($precheck . $m[7] . $m[8]) . '{ ?>' . $m[9]; |
|
1012 | + return '<?php '.$this->_replaceVar($precheck.$m[7].$m[8]).'{ ?>'.$m[9]; |
|
1013 | 1013 | } |
1014 | - if($mm[2]) |
|
1014 | + if ($mm[2]) |
|
1015 | 1015 | { |
1016 | - return "<?php }{$m[7]}" . $this->_replaceVar($m[8]) . "{ ?>" . $m[9]; |
|
1016 | + return "<?php }{$m[7]}".$this->_replaceVar($m[8])."{ ?>".$m[9]; |
|
1017 | 1017 | } |
1018 | - if($mm[4]) |
|
1018 | + if ($mm[4]) |
|
1019 | 1019 | { |
1020 | - return "<?php " . ($mm[3] ? 'break;' : '') . "{$m[7]} " . trim($m[8], '()') . ": ?>" . $m[9]; |
|
1020 | + return "<?php ".($mm[3] ? 'break;' : '')."{$m[7]} ".trim($m[8], '()').": ?>".$m[9]; |
|
1021 | 1021 | } |
1022 | - if($mm[5]) |
|
1022 | + if ($mm[5]) |
|
1023 | 1023 | { |
1024 | 1024 | return "<?php break; ?>"; |
1025 | 1025 | } |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | */ |
1034 | 1034 | private function _applyEscapeOption($str, $escape_option = 'noescape') |
1035 | 1035 | { |
1036 | - switch($escape_option) |
|
1036 | + switch ($escape_option) |
|
1037 | 1037 | { |
1038 | 1038 | case 'escape': |
1039 | 1039 | return "escape({$str}, true)"; |
@@ -1057,30 +1057,30 @@ discard block |
||
1057 | 1057 | $_path = $path; |
1058 | 1058 | |
1059 | 1059 | $fileDir = strtr(realpath($this->path), '\\', '/'); |
1060 | - if($path{0} != '/') |
|
1060 | + if ($path{0} != '/') |
|
1061 | 1061 | { |
1062 | - $path = strtr(realpath($fileDir . '/' . $path), '\\', '/'); |
|
1062 | + $path = strtr(realpath($fileDir.'/'.$path), '\\', '/'); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | // for backward compatibility |
1066 | - if(!$path) |
|
1066 | + if (!$path) |
|
1067 | 1067 | { |
1068 | 1068 | $dirs = explode('/', $fileDir); |
1069 | 1069 | $paths = explode('/', $_path); |
1070 | 1070 | $idx = array_search($paths[0], $dirs); |
1071 | 1071 | |
1072 | - if($idx !== false) |
|
1072 | + if ($idx !== false) |
|
1073 | 1073 | { |
1074 | - while($dirs[$idx] && $dirs[$idx] === $paths[0]) |
|
1074 | + while ($dirs[$idx] && $dirs[$idx] === $paths[0]) |
|
1075 | 1075 | { |
1076 | 1076 | array_splice($dirs, $idx, 1); |
1077 | 1077 | array_shift($paths); |
1078 | 1078 | } |
1079 | - $path = strtr(realpath($fileDir . '/' . implode('/', $paths)), '\\', '/'); |
|
1079 | + $path = strtr(realpath($fileDir.'/'.implode('/', $paths)), '\\', '/'); |
|
1080 | 1080 | } |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - $path = preg_replace('/^' . preg_quote(_XE_PATH_, '/') . '/', '', $path); |
|
1083 | + $path = preg_replace('/^'.preg_quote(_XE_PATH_, '/').'/', '', $path); |
|
1084 | 1084 | |
1085 | 1085 | return $path; |
1086 | 1086 | } |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | */ |
1104 | 1104 | function _replaceVar($php) |
1105 | 1105 | { |
1106 | - if(!strlen($php)) |
|
1106 | + if (!strlen($php)) |
|
1107 | 1107 | { |
1108 | 1108 | return ''; |
1109 | 1109 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | $modules = '(addon|admin|adminlogging|autoinstall|board|comment|communication|counter|document|editor|file|importer|install|integration_search|krzip|layout|member|menu|message|module|page|point|poll|rss|seo|session|spamfilter|syndication|tag|trash|widget)'; |
1119 | 1119 | |
1120 | 1120 | // admin, common layout |
1121 | - if(preg_match('/^(\.\/)?(modules\/' . $modules . '|common)\/tpl\//', $absPath)) |
|
1121 | + if (preg_match('/^(\.\/)?(modules\/'.$modules.'|common)\/tpl\//', $absPath)) |
|
1122 | 1122 | { |
1123 | 1123 | return true; |
1124 | 1124 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | function &getInstance() |
163 | 163 | { |
164 | 164 | static $theInstance = null; |
165 | - if(!$theInstance) |
|
165 | + if (!$theInstance) |
|
166 | 166 | { |
167 | 167 | $theInstance = new Context(); |
168 | 168 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | |
183 | 183 | // include ssl action cache file |
184 | 184 | $this->sslActionCacheFile = FileHandler::getRealPath($this->sslActionCacheFile); |
185 | - if(is_readable($this->sslActionCacheFile)) |
|
185 | + if (is_readable($this->sslActionCacheFile)) |
|
186 | 186 | { |
187 | 187 | require($this->sslActionCacheFile); |
188 | - if(isset($sslActions)) |
|
188 | + if (isset($sslActions)) |
|
189 | 189 | { |
190 | 190 | $this->ssl_actions = $sslActions; |
191 | 191 | } |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | function init() |
202 | 202 | { |
203 | 203 | // fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above |
204 | - if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE) |
|
204 | + if (!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE) |
|
205 | 205 | { |
206 | 206 | $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input"); |
207 | 207 | |
208 | 208 | // If content is not XML JSON, unset |
209 | - if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE) |
|
209 | + if (!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE) |
|
210 | 210 | { |
211 | 211 | unset($GLOBALS['HTTP_RAW_POST_DATA']); |
212 | 212 | } |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | $this->_setUploadedArgument(); |
229 | 229 | |
230 | 230 | $this->loadDBInfo(); |
231 | - if($this->db_info->use_sitelock == 'Y') |
|
231 | + if ($this->db_info->use_sitelock == 'Y') |
|
232 | 232 | { |
233 | - if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist; |
|
233 | + if (is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist; |
|
234 | 234 | |
235 | - if(!IpFilter::filter($whitelist)) |
|
235 | + if (!IpFilter::filter($whitelist)) |
|
236 | 236 | { |
237 | 237 | $title = ($this->db_info->sitelock_title) ? $this->db_info->sitelock_title : 'Maintenance in progress...'; |
238 | 238 | $message = $this->db_info->sitelock_message; |
@@ -242,52 +242,52 @@ discard block |
||
242 | 242 | define('_XE_SITELOCK_MESSAGE_', $message); |
243 | 243 | |
244 | 244 | header("HTTP/1.1 403 Forbidden"); |
245 | - if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html')) |
|
245 | + if (FileHandler::exists(_XE_PATH_.'common/tpl/sitelock.user.html')) |
|
246 | 246 | { |
247 | - include _XE_PATH_ . 'common/tpl/sitelock.user.html'; |
|
247 | + include _XE_PATH_.'common/tpl/sitelock.user.html'; |
|
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | - include _XE_PATH_ . 'common/tpl/sitelock.html'; |
|
251 | + include _XE_PATH_.'common/tpl/sitelock.html'; |
|
252 | 252 | } |
253 | 253 | exit; |
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | 257 | // If XE is installed, get virtual site information |
258 | - if(self::isInstalled()) |
|
258 | + if (self::isInstalled()) |
|
259 | 259 | { |
260 | 260 | $oModuleModel = getModel('module'); |
261 | 261 | $site_module_info = $oModuleModel->getDefaultMid(); |
262 | 262 | |
263 | - if(!isset($site_module_info)) |
|
263 | + if (!isset($site_module_info)) |
|
264 | 264 | { |
265 | 265 | $site_module_info = new stdClass(); |
266 | 266 | } |
267 | 267 | |
268 | 268 | // if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config |
269 | - if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) |
|
269 | + if ($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) |
|
270 | 270 | { |
271 | 271 | $site_module_info->domain = $this->db_info->default_url; |
272 | 272 | } |
273 | 273 | |
274 | 274 | $this->set('site_module_info', $site_module_info); |
275 | - if($site_module_info->site_srl && isSiteID($site_module_info->domain)) |
|
275 | + if ($site_module_info->site_srl && isSiteID($site_module_info->domain)) |
|
276 | 276 | { |
277 | 277 | $this->set('vid', $site_module_info->domain, TRUE); |
278 | 278 | } |
279 | 279 | |
280 | - if(!isset($this->db_info)) |
|
280 | + if (!isset($this->db_info)) |
|
281 | 281 | { |
282 | 282 | $this->db_info = new stdClass(); |
283 | 283 | } |
284 | 284 | |
285 | 285 | $this->db_info->lang_type = $site_module_info->default_language; |
286 | - if(!$this->db_info->lang_type) |
|
286 | + if (!$this->db_info->lang_type) |
|
287 | 287 | { |
288 | 288 | $this->db_info->lang_type = 'en'; |
289 | 289 | } |
290 | - if(!$this->db_info->use_db_session) |
|
290 | + if (!$this->db_info->use_db_session) |
|
291 | 291 | { |
292 | 292 | $this->db_info->use_db_session = 'N'; |
293 | 293 | } |
@@ -297,30 +297,30 @@ discard block |
||
297 | 297 | $lang_supported = $this->loadLangSelected(); |
298 | 298 | |
299 | 299 | // Retrieve language type set in user's cookie |
300 | - if($this->lang_type = $this->get('l')) |
|
300 | + if ($this->lang_type = $this->get('l')) |
|
301 | 301 | { |
302 | - if($_COOKIE['lang_type'] != $this->lang_type) |
|
302 | + if ($_COOKIE['lang_type'] != $this->lang_type) |
|
303 | 303 | { |
304 | 304 | setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000); |
305 | 305 | } |
306 | 306 | } |
307 | - elseif($_COOKIE['lang_type']) |
|
307 | + elseif ($_COOKIE['lang_type']) |
|
308 | 308 | { |
309 | 309 | $this->lang_type = $_COOKIE['lang_type']; |
310 | 310 | } |
311 | 311 | |
312 | 312 | // If it's not exists, follow default language type set in db_info |
313 | - if(!$this->lang_type) |
|
313 | + if (!$this->lang_type) |
|
314 | 314 | { |
315 | 315 | $this->lang_type = $this->db_info->lang_type; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // if still lang_type has not been set or has not-supported type , set as English. |
319 | - if(!$this->lang_type) |
|
319 | + if (!$this->lang_type) |
|
320 | 320 | { |
321 | 321 | $this->lang_type = 'en'; |
322 | 322 | } |
323 | - if(is_array($lang_supported) && !isset($lang_supported[$this->lang_type])) |
|
323 | + if (is_array($lang_supported) && !isset($lang_supported[$this->lang_type])) |
|
324 | 324 | { |
325 | 325 | $this->lang_type = 'en'; |
326 | 326 | } |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | $this->setLangType($this->lang_type); |
330 | 330 | |
331 | 331 | // load module module's language file according to language setting |
332 | - $this->loadLang(_XE_PATH_ . 'modules/module/lang'); |
|
332 | + $this->loadLang(_XE_PATH_.'modules/module/lang'); |
|
333 | 333 | |
334 | 334 | // set session handler |
335 | - if(self::isInstalled() && $this->db_info->use_db_session == 'Y') |
|
335 | + if (self::isInstalled() && $this->db_info->use_db_session == 'Y') |
|
336 | 336 | { |
337 | 337 | $oSessionModel = getModel('session'); |
338 | 338 | $oSessionController = getController('session'); |
@@ -341,11 +341,11 @@ discard block |
||
341 | 341 | ); |
342 | 342 | } |
343 | 343 | |
344 | - if($sess = $_POST[session_name()]) session_id($sess); |
|
344 | + if ($sess = $_POST[session_name()]) session_id($sess); |
|
345 | 345 | session_start(); |
346 | 346 | |
347 | 347 | // set authentication information in Context and session |
348 | - if(self::isInstalled()) |
|
348 | + if (self::isInstalled()) |
|
349 | 349 | { |
350 | 350 | $oModuleModel = getModel('module'); |
351 | 351 | $oModuleModel->loadModuleExtends(); |
@@ -353,15 +353,15 @@ discard block |
||
353 | 353 | $oMemberModel = getModel('member'); |
354 | 354 | $oMemberController = getController('member'); |
355 | 355 | |
356 | - if($oMemberController && $oMemberModel) |
|
356 | + if ($oMemberController && $oMemberModel) |
|
357 | 357 | { |
358 | 358 | // if signed in, validate it. |
359 | - if($oMemberModel->isLogged()) |
|
359 | + if ($oMemberModel->isLogged()) |
|
360 | 360 | { |
361 | 361 | $oMemberController->setSessionInfo(); |
362 | 362 | } |
363 | 363 | // check auto sign-in |
364 | - elseif($_COOKIE['xeak']) |
|
364 | + elseif ($_COOKIE['xeak']) |
|
365 | 365 | { |
366 | 366 | $oMemberController->doAutologin(); |
367 | 367 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | // load common language file |
375 | 375 | $this->lang = &$GLOBALS['lang']; |
376 | - $this->loadLang(_XE_PATH_ . 'common/lang/'); |
|
376 | + $this->loadLang(_XE_PATH_.'common/lang/'); |
|
377 | 377 | |
378 | 378 | // check if using rewrite module |
379 | 379 | $this->allow_rewrite = ($this->db_info->use_rewrite == 'Y' ? TRUE : FALSE); |
@@ -381,28 +381,28 @@ discard block |
||
381 | 381 | // set locations for javascript use |
382 | 382 | $url = array(); |
383 | 383 | $current_url = self::getRequestUri(); |
384 | - if($_SERVER['REQUEST_METHOD'] == 'GET') |
|
384 | + if ($_SERVER['REQUEST_METHOD'] == 'GET') |
|
385 | 385 | { |
386 | - if($this->get_vars) |
|
386 | + if ($this->get_vars) |
|
387 | 387 | { |
388 | 388 | $url = array(); |
389 | - foreach($this->get_vars as $key => $val) |
|
389 | + foreach ($this->get_vars as $key => $val) |
|
390 | 390 | { |
391 | - if(is_array($val) && count($val) > 0) |
|
391 | + if (is_array($val) && count($val) > 0) |
|
392 | 392 | { |
393 | - foreach($val as $k => $v) |
|
393 | + foreach ($val as $k => $v) |
|
394 | 394 | { |
395 | - $url[] = $key . '[' . $k . ']=' . urlencode($v); |
|
395 | + $url[] = $key.'['.$k.']='.urlencode($v); |
|
396 | 396 | } |
397 | 397 | } |
398 | - elseif($val) |
|
398 | + elseif ($val) |
|
399 | 399 | { |
400 | - $url[] = $key . '=' . urlencode($val); |
|
400 | + $url[] = $key.'='.urlencode($val); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | 404 | $current_url = self::getRequestUri(); |
405 | - if($url) $current_url .= '?' . join('&', $url); |
|
405 | + if ($url) $current_url .= '?'.join('&', $url); |
|
406 | 406 | } |
407 | 407 | else |
408 | 408 | { |
@@ -417,12 +417,12 @@ discard block |
||
417 | 417 | $this->set('current_url', $current_url); |
418 | 418 | $this->set('request_uri', self::getRequestUri()); |
419 | 419 | |
420 | - if(strpos($current_url, 'xn--') !== FALSE) |
|
420 | + if (strpos($current_url, 'xn--') !== FALSE) |
|
421 | 421 | { |
422 | 422 | $this->set('current_url', self::decodeIdna($current_url)); |
423 | 423 | } |
424 | 424 | |
425 | - if(strpos(self::getRequestUri(), 'xn--') !== FALSE) |
|
425 | + if (strpos(self::getRequestUri(), 'xn--') !== FALSE) |
|
426 | 426 | { |
427 | 427 | $this->set('request_uri', self::decodeIdna(self::getRequestUri())); |
428 | 428 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | { |
448 | 448 | $self = self::getInstance(); |
449 | 449 | |
450 | - if(!$self->isInstalled()) |
|
450 | + if (!$self->isInstalled()) |
|
451 | 451 | { |
452 | 452 | return; |
453 | 453 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | ob_end_clean(); |
458 | 458 | |
459 | 459 | // If master_db information does not exist, the config file needs to be updated |
460 | - if(!isset($db_info->master_db)) |
|
460 | + if (!isset($db_info->master_db)) |
|
461 | 461 | { |
462 | 462 | $db_info->master_db = array(); |
463 | 463 | $db_info->master_db["db_type"] = $db_info->db_type; |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | $db_info->master_db["db_table_prefix"] = $db_info->db_table_prefix; |
476 | 476 | unset($db_info->db_table_prefix); |
477 | 477 | |
478 | - if(isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0) |
|
478 | + if (isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0) |
|
479 | 479 | { |
480 | 480 | $db_info->master_db["db_table_prefix"] .= '_'; |
481 | 481 | } |
@@ -487,36 +487,36 @@ discard block |
||
487 | 487 | $oInstallController->makeConfigFile(); |
488 | 488 | } |
489 | 489 | |
490 | - if(!$db_info->use_prepared_statements) |
|
490 | + if (!$db_info->use_prepared_statements) |
|
491 | 491 | { |
492 | 492 | $db_info->use_prepared_statements = 'Y'; |
493 | 493 | } |
494 | 494 | |
495 | - if(!$db_info->time_zone) |
|
495 | + if (!$db_info->time_zone) |
|
496 | 496 | $db_info->time_zone = date('O'); |
497 | 497 | $GLOBALS['_time_zone'] = $db_info->time_zone; |
498 | 498 | |
499 | - if($db_info->qmail_compatibility != 'Y') |
|
499 | + if ($db_info->qmail_compatibility != 'Y') |
|
500 | 500 | $db_info->qmail_compatibility = 'N'; |
501 | 501 | $GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility; |
502 | 502 | |
503 | - if(!$db_info->use_db_session) |
|
503 | + if (!$db_info->use_db_session) |
|
504 | 504 | $db_info->use_db_session = 'N'; |
505 | - if(!$db_info->use_ssl) |
|
505 | + if (!$db_info->use_ssl) |
|
506 | 506 | $db_info->use_ssl = 'none'; |
507 | 507 | $this->set('_use_ssl', $db_info->use_ssl); |
508 | 508 | |
509 | 509 | $self->set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL); |
510 | 510 | $self->set('_https_port', ($db_info->https_port) ? $db_info->https_port : NULL); |
511 | 511 | |
512 | - if(!$db_info->sitelock_whitelist) { |
|
512 | + if (!$db_info->sitelock_whitelist) { |
|
513 | 513 | $db_info->sitelock_whitelist = '127.0.0.1'; |
514 | 514 | } |
515 | 515 | |
516 | 516 | // @see https://github.com/xpressengine/xe-core/issues/2301 |
517 | - if($db_info->safeguard !== 'Y') $db_info->safeguard = 'N'; |
|
517 | + if ($db_info->safeguard !== 'Y') $db_info->safeguard = 'N'; |
|
518 | 518 | |
519 | - if(is_string($db_info->sitelock_whitelist)) { |
|
519 | + if (is_string($db_info->sitelock_whitelist)) { |
|
520 | 520 | $db_info->sitelock_whitelist = explode(',', $db_info->sitelock_whitelist); |
521 | 521 | } |
522 | 522 | |
@@ -587,10 +587,10 @@ discard block |
||
587 | 587 | function loadLangSupported() |
588 | 588 | { |
589 | 589 | static $lang_supported = null; |
590 | - if(!$lang_supported) |
|
590 | + if (!$lang_supported) |
|
591 | 591 | { |
592 | - $langs = file(_XE_PATH_ . 'common/lang/lang.info'); |
|
593 | - foreach($langs as $val) |
|
592 | + $langs = file(_XE_PATH_.'common/lang/lang.info'); |
|
593 | + foreach ($langs as $val) |
|
594 | 594 | { |
595 | 595 | list($lang_prefix, $lang_text) = explode(',', $val); |
596 | 596 | $lang_text = trim($lang_text); |
@@ -608,17 +608,17 @@ discard block |
||
608 | 608 | function loadLangSelected() |
609 | 609 | { |
610 | 610 | static $lang_selected = null; |
611 | - if(!$lang_selected) |
|
611 | + if (!$lang_selected) |
|
612 | 612 | { |
613 | - $orig_lang_file = _XE_PATH_ . 'common/lang/lang.info'; |
|
614 | - $selected_lang_file = _XE_PATH_ . 'files/config/lang_selected.info'; |
|
615 | - if(!FileHandler::hasContent($selected_lang_file)) |
|
613 | + $orig_lang_file = _XE_PATH_.'common/lang/lang.info'; |
|
614 | + $selected_lang_file = _XE_PATH_.'files/config/lang_selected.info'; |
|
615 | + if (!FileHandler::hasContent($selected_lang_file)) |
|
616 | 616 | { |
617 | - $old_selected_lang_file = _XE_PATH_ . 'files/cache/lang_selected.info'; |
|
617 | + $old_selected_lang_file = _XE_PATH_.'files/cache/lang_selected.info'; |
|
618 | 618 | FileHandler::moveFile($old_selected_lang_file, $selected_lang_file); |
619 | 619 | } |
620 | 620 | |
621 | - if(!FileHandler::hasContent($selected_lang_file)) |
|
621 | + if (!FileHandler::hasContent($selected_lang_file)) |
|
622 | 622 | { |
623 | 623 | $buff = FileHandler::readFile($orig_lang_file); |
624 | 624 | FileHandler::writeFile($selected_lang_file, $buff); |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | else |
628 | 628 | { |
629 | 629 | $langs = file($selected_lang_file); |
630 | - foreach($langs as $val) |
|
630 | + foreach ($langs as $val) |
|
631 | 631 | { |
632 | 632 | list($lang_prefix, $lang_text) = explode(',', $val); |
633 | 633 | $lang_text = trim($lang_text); |
@@ -646,56 +646,56 @@ discard block |
||
646 | 646 | function checkSSO() |
647 | 647 | { |
648 | 648 | // pass if it's not GET request or XE is not yet installed |
649 | - if($this->db_info->use_sso != 'Y' || isCrawler()) |
|
649 | + if ($this->db_info->use_sso != 'Y' || isCrawler()) |
|
650 | 650 | { |
651 | 651 | return TRUE; |
652 | 652 | } |
653 | 653 | $checkActList = array('rss' => 1, 'atom' => 1); |
654 | - if(self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')])) |
|
654 | + if (self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')])) |
|
655 | 655 | { |
656 | 656 | return TRUE; |
657 | 657 | } |
658 | 658 | |
659 | 659 | // pass if default URL is not set |
660 | 660 | $default_url = trim($this->db_info->default_url); |
661 | - if(!$default_url) |
|
661 | + if (!$default_url) |
|
662 | 662 | { |
663 | 663 | return TRUE; |
664 | 664 | } |
665 | 665 | |
666 | - if(substr_compare($default_url, '/', -1) !== 0) |
|
666 | + if (substr_compare($default_url, '/', -1) !== 0) |
|
667 | 667 | { |
668 | 668 | $default_url .= '/'; |
669 | 669 | } |
670 | 670 | |
671 | 671 | // for sites recieving SSO valdiation |
672 | - if($default_url == self::getRequestUri()) |
|
672 | + if ($default_url == self::getRequestUri()) |
|
673 | 673 | { |
674 | - if(self::get('url')) |
|
674 | + if (self::get('url')) |
|
675 | 675 | { |
676 | 676 | $url = base64_decode(self::get('url')); |
677 | 677 | $url_info = parse_url($url); |
678 | - if(!Password::checkSignature($url, self::get('sig'))) |
|
678 | + if (!Password::checkSignature($url, self::get('sig'))) |
|
679 | 679 | { |
680 | 680 | echo self::get('lang')->msg_invalid_request; |
681 | 681 | return false; |
682 | 682 | } |
683 | 683 | |
684 | 684 | $oModuleModel = getModel('module'); |
685 | - $domain = $url_info['host'] . $url_info['path']; |
|
686 | - if(substr_compare($domain, '/', -1) === 0) $domain = substr($domain, 0, -1); |
|
685 | + $domain = $url_info['host'].$url_info['path']; |
|
686 | + if (substr_compare($domain, '/', -1) === 0) $domain = substr($domain, 0, -1); |
|
687 | 687 | $site_info = $oModuleModel->getSiteInfoByDomain($domain); |
688 | 688 | |
689 | - if($site_info->site_srl) |
|
689 | + if ($site_info->site_srl) |
|
690 | 690 | { |
691 | - $url_info['query'].= ($url_info['query'] ? '&' : '') . 'SSOID=' . urlencode(session_id()) . '&sig=' . urlencode(Password::createSignature(session_id())); |
|
692 | - $redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']); |
|
691 | + $url_info['query'] .= ($url_info['query'] ? '&' : '').'SSOID='.urlencode(session_id()).'&sig='.urlencode(Password::createSignature(session_id())); |
|
692 | + $redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':'.$url_info['port'] : '', $url_info['path'], $url_info['query']); |
|
693 | 693 | } |
694 | 694 | else |
695 | 695 | { |
696 | 696 | $redirect_url = $url; |
697 | 697 | } |
698 | - header('location:' . $redirect_url); |
|
698 | + header('location:'.$redirect_url); |
|
699 | 699 | |
700 | 700 | return FALSE; |
701 | 701 | } |
@@ -704,9 +704,9 @@ discard block |
||
704 | 704 | else |
705 | 705 | { |
706 | 706 | // result handling : set session_name() |
707 | - if($session_name = self::get('SSOID')) |
|
707 | + if ($session_name = self::get('SSOID')) |
|
708 | 708 | { |
709 | - if(!Password::checkSignature($session_name, self::get('sig'))) |
|
709 | + if (!Password::checkSignature($session_name, self::get('sig'))) |
|
710 | 710 | { |
711 | 711 | echo self::get('lang')->msg_invalid_request; |
712 | 712 | return false; |
@@ -715,17 +715,17 @@ discard block |
||
715 | 715 | setcookie(session_name(), $session_name); |
716 | 716 | |
717 | 717 | $url = preg_replace('/[\?\&]SSOID=.+$/', '', self::getRequestUrl()); |
718 | - header('location:' . $url); |
|
718 | + header('location:'.$url); |
|
719 | 719 | return FALSE; |
720 | 720 | // send SSO request |
721 | 721 | } |
722 | - else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri())) |
|
722 | + else if (!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri())) |
|
723 | 723 | { |
724 | 724 | setcookie('sso', md5(self::getRequestUri())); |
725 | 725 | $origin_url = self::getRequestUrl(); |
726 | 726 | $origin_sig = Password::createSignature($origin_url); |
727 | 727 | $url = sprintf("%s?url=%s&sig=%s", $default_url, urlencode(base64_encode($origin_url)), urlencode($origin_sig)); |
728 | - header('location:' . $url); |
|
728 | + header('location:'.$url); |
|
729 | 729 | return FALSE; |
730 | 730 | } |
731 | 731 | } |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | { |
753 | 753 | $self = self::getInstance(); |
754 | 754 | |
755 | - if(!$self->isFTPRegisted()) |
|
755 | + if (!$self->isFTPRegisted()) |
|
756 | 756 | { |
757 | 757 | return null; |
758 | 758 | } |
@@ -770,15 +770,15 @@ discard block |
||
770 | 770 | */ |
771 | 771 | function addBrowserTitle($site_title) |
772 | 772 | { |
773 | - if(!$site_title) |
|
773 | + if (!$site_title) |
|
774 | 774 | { |
775 | 775 | return; |
776 | 776 | } |
777 | 777 | $self = self::getInstance(); |
778 | 778 | |
779 | - if($self->site_title) |
|
779 | + if ($self->site_title) |
|
780 | 780 | { |
781 | - $self->site_title .= ' - ' . $site_title; |
|
781 | + $self->site_title .= ' - '.$site_title; |
|
782 | 782 | } |
783 | 783 | else |
784 | 784 | { |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | */ |
795 | 795 | function setBrowserTitle($site_title) |
796 | 796 | { |
797 | - if(!$site_title) |
|
797 | + if (!$site_title) |
|
798 | 798 | { |
799 | 799 | return; |
800 | 800 | } |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | $oModuleModel = getModel('module'); |
827 | 827 | $moduleConfig = $oModuleModel->getModuleConfig('module'); |
828 | 828 | |
829 | - if(isset($moduleConfig->siteTitle)) |
|
829 | + if (isset($moduleConfig->siteTitle)) |
|
830 | 830 | { |
831 | 831 | return $moduleConfig->siteTitle; |
832 | 832 | } |
@@ -853,30 +853,30 @@ discard block |
||
853 | 853 | global $lang; |
854 | 854 | |
855 | 855 | $self = self::getInstance(); |
856 | - if(!$self->lang_type) |
|
856 | + if (!$self->lang_type) |
|
857 | 857 | { |
858 | 858 | return; |
859 | 859 | } |
860 | - if(!is_object($lang)) |
|
860 | + if (!is_object($lang)) |
|
861 | 861 | { |
862 | 862 | $lang = new stdClass; |
863 | 863 | } |
864 | 864 | |
865 | - if(!($filename = $self->_loadXmlLang($path))) |
|
865 | + if (!($filename = $self->_loadXmlLang($path))) |
|
866 | 866 | { |
867 | 867 | $filename = $self->_loadPhpLang($path); |
868 | 868 | } |
869 | 869 | |
870 | - if(!is_array($self->loaded_lang_files)) |
|
870 | + if (!is_array($self->loaded_lang_files)) |
|
871 | 871 | { |
872 | 872 | $self->loaded_lang_files = array(); |
873 | 873 | } |
874 | - if(in_array($filename, $self->loaded_lang_files)) |
|
874 | + if (in_array($filename, $self->loaded_lang_files)) |
|
875 | 875 | { |
876 | 876 | return; |
877 | 877 | } |
878 | 878 | |
879 | - if($filename && is_readable($filename)) |
|
879 | + if ($filename && is_readable($filename)) |
|
880 | 880 | { |
881 | 881 | $self->loaded_lang_files[] = $filename; |
882 | 882 | include($filename); |
@@ -897,24 +897,24 @@ discard block |
||
897 | 897 | { |
898 | 898 | global $lang; |
899 | 899 | |
900 | - if(!$path) return; |
|
900 | + if (!$path) return; |
|
901 | 901 | |
902 | - $_path = 'eval://' . $path; |
|
902 | + $_path = 'eval://'.$path; |
|
903 | 903 | |
904 | - if(in_array($_path, $this->loaded_lang_files)) |
|
904 | + if (in_array($_path, $this->loaded_lang_files)) |
|
905 | 905 | { |
906 | 906 | return; |
907 | 907 | } |
908 | 908 | |
909 | - if(substr_compare($path, '/', -1) !== 0) |
|
909 | + if (substr_compare($path, '/', -1) !== 0) |
|
910 | 910 | { |
911 | 911 | $path .= '/'; |
912 | 912 | } |
913 | 913 | |
914 | - $oXmlLangParser = new XmlLangParser($path . 'lang.xml', $this->lang_type); |
|
914 | + $oXmlLangParser = new XmlLangParser($path.'lang.xml', $this->lang_type); |
|
915 | 915 | $content = $oXmlLangParser->getCompileContent(); |
916 | 916 | |
917 | - if($content) |
|
917 | + if ($content) |
|
918 | 918 | { |
919 | 919 | $this->loaded_lang_files[] = $_path; |
920 | 920 | eval($content); |
@@ -929,9 +929,9 @@ discard block |
||
929 | 929 | */ |
930 | 930 | function _loadXmlLang($path) |
931 | 931 | { |
932 | - if(!$path) return; |
|
932 | + if (!$path) return; |
|
933 | 933 | |
934 | - $oXmlLangParser = new XmlLangParser($path . ((substr_compare($path, '/', -1) !== 0) ? '/' : '') . 'lang.xml', $this->lang_type); |
|
934 | + $oXmlLangParser = new XmlLangParser($path.((substr_compare($path, '/', -1) !== 0) ? '/' : '').'lang.xml', $this->lang_type); |
|
935 | 935 | return $oXmlLangParser->compile(); |
936 | 936 | } |
937 | 937 | |
@@ -943,22 +943,22 @@ discard block |
||
943 | 943 | */ |
944 | 944 | function _loadPhpLang($path) |
945 | 945 | { |
946 | - if(!$path) return; |
|
946 | + if (!$path) return; |
|
947 | 947 | |
948 | - if(substr_compare($path, '/', -1) !== 0) |
|
948 | + if (substr_compare($path, '/', -1) !== 0) |
|
949 | 949 | { |
950 | 950 | $path .= '/'; |
951 | 951 | } |
952 | - $path_tpl = $path . '%s.lang.php'; |
|
952 | + $path_tpl = $path.'%s.lang.php'; |
|
953 | 953 | $file = sprintf($path_tpl, $this->lang_type); |
954 | 954 | |
955 | 955 | $langs = array('ko', 'en'); // this will be configurable. |
956 | - while(!is_readable($file) && $langs[0]) |
|
956 | + while (!is_readable($file) && $langs[0]) |
|
957 | 957 | { |
958 | 958 | $file = sprintf($path_tpl, array_shift($langs)); |
959 | 959 | } |
960 | 960 | |
961 | - if(!is_readable($file)) |
|
961 | + if (!is_readable($file)) |
|
962 | 962 | { |
963 | 963 | return FALSE; |
964 | 964 | } |
@@ -1000,11 +1000,11 @@ discard block |
||
1000 | 1000 | */ |
1001 | 1001 | function getLang($code) |
1002 | 1002 | { |
1003 | - if(!$code) |
|
1003 | + if (!$code) |
|
1004 | 1004 | { |
1005 | 1005 | return; |
1006 | 1006 | } |
1007 | - if($GLOBALS['lang']->{$code}) |
|
1007 | + if ($GLOBALS['lang']->{$code}) |
|
1008 | 1008 | { |
1009 | 1009 | return $GLOBALS['lang']->{$code}; |
1010 | 1010 | } |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | */ |
1021 | 1021 | function setLang($code, $val) |
1022 | 1022 | { |
1023 | - if(!isset($GLOBALS['lang'])) |
|
1023 | + if (!isset($GLOBALS['lang'])) |
|
1024 | 1024 | { |
1025 | 1025 | $GLOBALS['lang'] = new stdClass(); |
1026 | 1026 | } |
@@ -1045,17 +1045,17 @@ discard block |
||
1045 | 1045 | |
1046 | 1046 | $obj = clone $source_obj; |
1047 | 1047 | |
1048 | - foreach($charset_list as $charset) |
|
1048 | + foreach ($charset_list as $charset) |
|
1049 | 1049 | { |
1050 | - array_walk($obj,'Context::checkConvertFlag',$charset); |
|
1050 | + array_walk($obj, 'Context::checkConvertFlag', $charset); |
|
1051 | 1051 | $flag = self::checkConvertFlag($flag = TRUE); |
1052 | - if($flag) |
|
1052 | + if ($flag) |
|
1053 | 1053 | { |
1054 | - if($charset == 'UTF-8') |
|
1054 | + if ($charset == 'UTF-8') |
|
1055 | 1055 | { |
1056 | 1056 | return $obj; |
1057 | 1057 | } |
1058 | - array_walk($obj,'Context::doConvertEncoding',$charset); |
|
1058 | + array_walk($obj, 'Context::doConvertEncoding', $charset); |
|
1059 | 1059 | return $obj; |
1060 | 1060 | } |
1061 | 1061 | } |
@@ -1074,11 +1074,11 @@ discard block |
||
1074 | 1074 | function checkConvertFlag(&$val, $key = null, $charset = null) |
1075 | 1075 | { |
1076 | 1076 | static $flag = TRUE; |
1077 | - if($charset) |
|
1077 | + if ($charset) |
|
1078 | 1078 | { |
1079 | - if(is_array($val)) |
|
1080 | - array_walk($val,'Context::checkConvertFlag',$charset); |
|
1081 | - else if($val && iconv($charset,$charset,$val)!=$val) $flag = FALSE; |
|
1079 | + if (is_array($val)) |
|
1080 | + array_walk($val, 'Context::checkConvertFlag', $charset); |
|
1081 | + else if ($val && iconv($charset, $charset, $val) != $val) $flag = FALSE; |
|
1082 | 1082 | else $flag = FALSE; |
1083 | 1083 | } |
1084 | 1084 | else |
@@ -1102,9 +1102,9 @@ discard block |
||
1102 | 1102 | { |
1103 | 1103 | if (is_array($val)) |
1104 | 1104 | { |
1105 | - array_walk($val,'Context::doConvertEncoding',$charset); |
|
1105 | + array_walk($val, 'Context::doConvertEncoding', $charset); |
|
1106 | 1106 | } |
1107 | - else $val = iconv($charset,'UTF-8',$val); |
|
1107 | + else $val = iconv($charset, 'UTF-8', $val); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | /** |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | function convertEncodingStr($str) |
1117 | 1117 | { |
1118 | - if(!$str) return null; |
|
1118 | + if (!$str) return null; |
|
1119 | 1119 | $obj = new stdClass(); |
1120 | 1120 | $obj->str = $str; |
1121 | 1121 | $obj = self::convertEncoding($obj); |
@@ -1124,9 +1124,9 @@ discard block |
||
1124 | 1124 | |
1125 | 1125 | function decodeIdna($domain) |
1126 | 1126 | { |
1127 | - if(strpos($domain, 'xn--') !== FALSE) |
|
1127 | + if (strpos($domain, 'xn--') !== FALSE) |
|
1128 | 1128 | { |
1129 | - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
|
1129 | + require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php'); |
|
1130 | 1130 | $IDN = new idna_convert(array('idn_version' => 2008)); |
1131 | 1131 | $domain = $IDN->decode($domain); |
1132 | 1132 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | { |
1158 | 1158 | $self = self::getInstance(); |
1159 | 1159 | |
1160 | - if($self->response_method) |
|
1160 | + if ($self->response_method) |
|
1161 | 1161 | { |
1162 | 1162 | return $self->response_method; |
1163 | 1163 | } |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | $this->_recursiveCheckVar($_SERVER['HTTP_HOST']); |
1198 | 1198 | |
1199 | 1199 | $pattern = "/[\,\"\'\{\}\[\]\(\);$]/"; |
1200 | - if(preg_match($pattern, $_SERVER['HTTP_HOST'])) |
|
1200 | + if (preg_match($pattern, $_SERVER['HTTP_HOST'])) |
|
1201 | 1201 | { |
1202 | 1202 | $this->isSuccessInit = FALSE; |
1203 | 1203 | } |
@@ -1210,30 +1210,30 @@ discard block |
||
1210 | 1210 | */ |
1211 | 1211 | function _setRequestArgument() |
1212 | 1212 | { |
1213 | - if(!count($_REQUEST)) |
|
1213 | + if (!count($_REQUEST)) |
|
1214 | 1214 | { |
1215 | 1215 | return; |
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | $requestMethod = $this->getRequestMethod(); |
1219 | - foreach($_REQUEST as $key => $val) |
|
1219 | + foreach ($_REQUEST as $key => $val) |
|
1220 | 1220 | { |
1221 | - if($val === '' || self::get($key)) |
|
1221 | + if ($val === '' || self::get($key)) |
|
1222 | 1222 | { |
1223 | 1223 | continue; |
1224 | 1224 | } |
1225 | 1225 | $key = htmlentities($key); |
1226 | 1226 | $val = $this->_filterRequestVar($key, $val, false, ($requestMethod == 'GET')); |
1227 | 1227 | |
1228 | - if($requestMethod == 'GET' && isset($_GET[$key])) |
|
1228 | + if ($requestMethod == 'GET' && isset($_GET[$key])) |
|
1229 | 1229 | { |
1230 | 1230 | $set_to_vars = TRUE; |
1231 | 1231 | } |
1232 | - elseif($requestMethod == 'POST' && isset($_POST[$key])) |
|
1232 | + elseif ($requestMethod == 'POST' && isset($_POST[$key])) |
|
1233 | 1233 | { |
1234 | 1234 | $set_to_vars = TRUE; |
1235 | 1235 | } |
1236 | - elseif($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key]))) |
|
1236 | + elseif ($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key]))) |
|
1237 | 1237 | { |
1238 | 1238 | $set_to_vars = TRUE; |
1239 | 1239 | } |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | $set_to_vars = FALSE; |
1243 | 1243 | } |
1244 | 1244 | |
1245 | - if($set_to_vars) |
|
1245 | + if ($set_to_vars) |
|
1246 | 1246 | { |
1247 | 1247 | $this->_recursiveCheckVar($val); |
1248 | 1248 | } |
@@ -1253,20 +1253,20 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | function _recursiveCheckVar($val) |
1255 | 1255 | { |
1256 | - if(is_string($val)) |
|
1256 | + if (is_string($val)) |
|
1257 | 1257 | { |
1258 | - foreach($this->patterns as $pattern) |
|
1258 | + foreach ($this->patterns as $pattern) |
|
1259 | 1259 | { |
1260 | - if(preg_match($pattern, $val)) |
|
1260 | + if (preg_match($pattern, $val)) |
|
1261 | 1261 | { |
1262 | 1262 | $this->isSuccessInit = FALSE; |
1263 | 1263 | return; |
1264 | 1264 | } |
1265 | 1265 | } |
1266 | 1266 | } |
1267 | - else if(is_array($val)) |
|
1267 | + else if (is_array($val)) |
|
1268 | 1268 | { |
1269 | - foreach($val as $val2) |
|
1269 | + foreach ($val as $val2) |
|
1270 | 1270 | { |
1271 | 1271 | $this->_recursiveCheckVar($val2); |
1272 | 1272 | } |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | */ |
1281 | 1281 | function _setJSONRequestArgument() |
1282 | 1282 | { |
1283 | - if($this->getRequestMethod() != 'JSON') |
|
1283 | + if ($this->getRequestMethod() != 'JSON') |
|
1284 | 1284 | { |
1285 | 1285 | return; |
1286 | 1286 | } |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | $params = array(); |
1289 | 1289 | parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params); |
1290 | 1290 | |
1291 | - foreach($params as $key => $val) |
|
1291 | + foreach ($params as $key => $val) |
|
1292 | 1292 | { |
1293 | 1293 | $this->set($key, $this->_filterRequestVar($key, $val, 1), TRUE); |
1294 | 1294 | } |
@@ -1301,13 +1301,13 @@ discard block |
||
1301 | 1301 | */ |
1302 | 1302 | function _setXmlRpcArgument() |
1303 | 1303 | { |
1304 | - if($this->getRequestMethod() != 'XMLRPC') |
|
1304 | + if ($this->getRequestMethod() != 'XMLRPC') |
|
1305 | 1305 | { |
1306 | 1306 | return; |
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | $xml = $GLOBALS['HTTP_RAW_POST_DATA']; |
1310 | - if(Security::detectingXEE($xml)) |
|
1310 | + if (Security::detectingXEE($xml)) |
|
1311 | 1311 | { |
1312 | 1312 | header("HTTP/1.0 400 Bad Request"); |
1313 | 1313 | exit; |
@@ -1319,12 +1319,12 @@ discard block |
||
1319 | 1319 | $params = $xml_obj->methodcall->params; |
1320 | 1320 | unset($params->node_name, $params->attrs, $params->body); |
1321 | 1321 | |
1322 | - if(!count(get_object_vars($params))) |
|
1322 | + if (!count(get_object_vars($params))) |
|
1323 | 1323 | { |
1324 | 1324 | return; |
1325 | 1325 | } |
1326 | 1326 | |
1327 | - foreach($params as $key => $val) |
|
1327 | + foreach ($params as $key => $val) |
|
1328 | 1328 | { |
1329 | 1329 | $this->set($key, $this->_filterXmlVars($key, $val), TRUE); |
1330 | 1330 | } |
@@ -1339,10 +1339,10 @@ discard block |
||
1339 | 1339 | */ |
1340 | 1340 | function _filterXmlVars($key, $val) |
1341 | 1341 | { |
1342 | - if(is_array($val)) |
|
1342 | + if (is_array($val)) |
|
1343 | 1343 | { |
1344 | 1344 | $stack = array(); |
1345 | - foreach($val as $k => $v) |
|
1345 | + foreach ($val as $k => $v) |
|
1346 | 1346 | { |
1347 | 1347 | $stack[$k] = $this->_filterXmlVars($k, $v); |
1348 | 1348 | } |
@@ -1352,20 +1352,20 @@ discard block |
||
1352 | 1352 | |
1353 | 1353 | $body = $val->body; |
1354 | 1354 | unset($val->node_name, $val->attrs, $val->body); |
1355 | - if(!count(get_object_vars($val))) |
|
1355 | + if (!count(get_object_vars($val))) |
|
1356 | 1356 | { |
1357 | 1357 | return $this->_filterRequestVar($key, $body, 0); |
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | $stack = new stdClass(); |
1361 | - foreach($val as $k => $v) |
|
1361 | + foreach ($val as $k => $v) |
|
1362 | 1362 | { |
1363 | 1363 | $output = $this->_filterXmlVars($k, $v); |
1364 | - if(is_object($v) && $v->attrs->type == 'array') |
|
1364 | + if (is_object($v) && $v->attrs->type == 'array') |
|
1365 | 1365 | { |
1366 | 1366 | $output = array($output); |
1367 | 1367 | } |
1368 | - if($k == 'value' && (is_array($v) || $v->attrs->type == 'array')) |
|
1368 | + if ($k == 'value' && (is_array($v) || $v->attrs->type == 'array')) |
|
1369 | 1369 | { |
1370 | 1370 | return $output; |
1371 | 1371 | } |
@@ -1373,7 +1373,7 @@ discard block |
||
1373 | 1373 | $stack->{$k} = $output; |
1374 | 1374 | } |
1375 | 1375 | |
1376 | - if(!count(get_object_vars($stack))) |
|
1376 | + if (!count(get_object_vars($stack))) |
|
1377 | 1377 | { |
1378 | 1378 | return NULL; |
1379 | 1379 | } |
@@ -1392,16 +1392,16 @@ discard block |
||
1392 | 1392 | */ |
1393 | 1393 | function _filterRequestVar($key, $val, $do_stripslashes = true, $remove_hack = false) |
1394 | 1394 | { |
1395 | - if(!($isArray = is_array($val))) |
|
1395 | + if (!($isArray = is_array($val))) |
|
1396 | 1396 | { |
1397 | 1397 | $val = array($val); |
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 | $result = array(); |
1401 | - foreach($val as $k => $v) |
|
1401 | + foreach ($val as $k => $v) |
|
1402 | 1402 | { |
1403 | - if($remove_hack && !is_array($v)) { |
|
1404 | - if(stripos($v, '<script') || stripos($v, 'lt;script') || stripos($v, '%3Cscript')) |
|
1403 | + if ($remove_hack && !is_array($v)) { |
|
1404 | + if (stripos($v, '<script') || stripos($v, 'lt;script') || stripos($v, '%3Cscript')) |
|
1405 | 1405 | { |
1406 | 1406 | $result[$k] = escape($v); |
1407 | 1407 | continue; |
@@ -1409,23 +1409,23 @@ discard block |
||
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | $k = htmlentities($k); |
1412 | - if($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0) |
|
1412 | + if ($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0) |
|
1413 | 1413 | { |
1414 | 1414 | $result[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int) $v : $v; |
1415 | 1415 | } |
1416 | - elseif($key === 'mid' || $key === 'search_keyword') |
|
1416 | + elseif ($key === 'mid' || $key === 'search_keyword') |
|
1417 | 1417 | { |
1418 | 1418 | $result[$k] = escape($v, false); |
1419 | 1419 | } |
1420 | - elseif($key === 'vid') |
|
1420 | + elseif ($key === 'vid') |
|
1421 | 1421 | { |
1422 | 1422 | $result[$k] = urlencode($v); |
1423 | 1423 | } |
1424 | - elseif($key === 'xe_validator_id') |
|
1424 | + elseif ($key === 'xe_validator_id') |
|
1425 | 1425 | { |
1426 | 1426 | $result[$k] = escape($v, false); |
1427 | 1427 | } |
1428 | - elseif(stripos($key, 'XE_VALIDATOR', 0) === 0) |
|
1428 | + elseif (stripos($key, 'XE_VALIDATOR', 0) === 0) |
|
1429 | 1429 | { |
1430 | 1430 | unset($result[$k]); |
1431 | 1431 | } |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | { |
1434 | 1434 | $result[$k] = $v; |
1435 | 1435 | |
1436 | - if($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc()) |
|
1436 | + if ($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc()) |
|
1437 | 1437 | { |
1438 | 1438 | if (is_array($result[$k])) |
1439 | 1439 | { |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | } |
1446 | 1446 | } |
1447 | 1447 | |
1448 | - if(is_array($result[$k])) |
|
1448 | + if (is_array($result[$k])) |
|
1449 | 1449 | { |
1450 | 1450 | array_walk_recursive($result[$k], function(&$val) { $val = trim($val); }); |
1451 | 1451 | } |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | $result[$k] = trim($result[$k]); |
1455 | 1455 | } |
1456 | 1456 | |
1457 | - if($remove_hack) |
|
1457 | + if ($remove_hack) |
|
1458 | 1458 | { |
1459 | 1459 | $result[$k] = escape($result[$k], false); |
1460 | 1460 | } |
@@ -1482,17 +1482,17 @@ discard block |
||
1482 | 1482 | */ |
1483 | 1483 | function _setUploadedArgument() |
1484 | 1484 | { |
1485 | - if($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE)) |
|
1485 | + if ($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE)) |
|
1486 | 1486 | { |
1487 | 1487 | return; |
1488 | 1488 | } |
1489 | 1489 | |
1490 | - foreach($_FILES as $key => $val) |
|
1490 | + foreach ($_FILES as $key => $val) |
|
1491 | 1491 | { |
1492 | 1492 | $tmp_name = $val['tmp_name']; |
1493 | - if(!is_array($tmp_name)) |
|
1493 | + if (!is_array($tmp_name)) |
|
1494 | 1494 | { |
1495 | - if(!$tmp_name || !is_uploaded_file($tmp_name)) |
|
1495 | + if (!$tmp_name || !is_uploaded_file($tmp_name)) |
|
1496 | 1496 | { |
1497 | 1497 | continue; |
1498 | 1498 | } |
@@ -1505,9 +1505,9 @@ discard block |
||
1505 | 1505 | $files = array(); |
1506 | 1506 | $count_files = count($tmp_name); |
1507 | 1507 | |
1508 | - for($i = 0; $i < $count_files; $i++) |
|
1508 | + for ($i = 0; $i < $count_files; $i++) |
|
1509 | 1509 | { |
1510 | - if($val['size'][$i] > 0) |
|
1510 | + if ($val['size'][$i] > 0) |
|
1511 | 1511 | { |
1512 | 1512 | $file = array(); |
1513 | 1513 | $file['name'] = $val['name'][$i]; |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | $files[] = $file; |
1519 | 1519 | } |
1520 | 1520 | } |
1521 | - if($files) $this->set($key, $files, TRUE); |
|
1521 | + if ($files) $this->set($key, $files, TRUE); |
|
1522 | 1522 | } |
1523 | 1523 | } |
1524 | 1524 | } |
@@ -1540,16 +1540,16 @@ discard block |
||
1540 | 1540 | function getRequestUrl() |
1541 | 1541 | { |
1542 | 1542 | static $url = null; |
1543 | - if(is_null($url)) |
|
1543 | + if (is_null($url)) |
|
1544 | 1544 | { |
1545 | 1545 | $url = self::getRequestUri(); |
1546 | - if(count($_GET) > 0) |
|
1546 | + if (count($_GET) > 0) |
|
1547 | 1547 | { |
1548 | - foreach($_GET as $key => $val) |
|
1548 | + foreach ($_GET as $key => $val) |
|
1549 | 1549 | { |
1550 | - $vars[] = $key . '=' . ($val ? urlencode(self::convertEncodingStr($val)) : ''); |
|
1550 | + $vars[] = $key.'='.($val ? urlencode(self::convertEncodingStr($val)) : ''); |
|
1551 | 1551 | } |
1552 | - $url .= '?' . join('&', $vars); |
|
1552 | + $url .= '?'.join('&', $vars); |
|
1553 | 1553 | } |
1554 | 1554 | } |
1555 | 1555 | return $url; |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | $self = self::getInstance(); |
1565 | 1565 | $js_callback_func = isset($_GET['xe_js_callback']) ? $_GET['xe_js_callback'] : $_POST['xe_js_callback']; |
1566 | 1566 | |
1567 | - if(!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func)) |
|
1567 | + if (!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func)) |
|
1568 | 1568 | { |
1569 | 1569 | unset($js_callback_func); |
1570 | 1570 | unset($_GET['xe_js_callback']); |
@@ -1592,22 +1592,22 @@ discard block |
||
1592 | 1592 | $self = self::getInstance(); |
1593 | 1593 | |
1594 | 1594 | // retrieve virtual site information |
1595 | - if(is_null($site_module_info)) |
|
1595 | + if (is_null($site_module_info)) |
|
1596 | 1596 | { |
1597 | 1597 | $site_module_info = self::get('site_module_info'); |
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | // If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid) |
1601 | - if($domain && isSiteID($domain)) |
|
1601 | + if ($domain && isSiteID($domain)) |
|
1602 | 1602 | { |
1603 | 1603 | $vid = $domain; |
1604 | 1604 | $domain = ''; |
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | // If $domain, $vid are not set, use current site information |
1608 | - if(!$domain && !$vid) |
|
1608 | + if (!$domain && !$vid) |
|
1609 | 1609 | { |
1610 | - if($site_module_info->domain && isSiteID($site_module_info->domain)) |
|
1610 | + if ($site_module_info->domain && isSiteID($site_module_info->domain)) |
|
1611 | 1611 | { |
1612 | 1612 | $vid = $site_module_info->domain; |
1613 | 1613 | } |
@@ -1618,21 +1618,21 @@ discard block |
||
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | // if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain. |
1621 | - if($domain) |
|
1621 | + if ($domain) |
|
1622 | 1622 | { |
1623 | 1623 | $domain_info = parse_url($domain); |
1624 | - if(is_null($current_info)) |
|
1624 | + if (is_null($current_info)) |
|
1625 | 1625 | { |
1626 | - $current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . getScriptPath()); |
|
1626 | + $current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].getScriptPath()); |
|
1627 | 1627 | } |
1628 | - if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path']) |
|
1628 | + if ($domain_info['host'].$domain_info['path'] == $current_info['host'].$current_info['path']) |
|
1629 | 1629 | { |
1630 | 1630 | unset($domain); |
1631 | 1631 | } |
1632 | 1632 | else |
1633 | 1633 | { |
1634 | 1634 | $domain = preg_replace('/^(http|https):\/\//i', '', trim($domain)); |
1635 | - if(substr_compare($domain, '/', -1) !== 0) |
|
1635 | + if (substr_compare($domain, '/', -1) !== 0) |
|
1636 | 1636 | { |
1637 | 1637 | $domain .= '/'; |
1638 | 1638 | } |
@@ -1642,41 +1642,41 @@ discard block |
||
1642 | 1642 | $get_vars = array(); |
1643 | 1643 | |
1644 | 1644 | // If there is no GET variables or first argument is '' to reset variables |
1645 | - if(!$self->get_vars || $args_list[0] == '') |
|
1645 | + if (!$self->get_vars || $args_list[0] == '') |
|
1646 | 1646 | { |
1647 | 1647 | // rearrange args_list |
1648 | - if(is_array($args_list) && $args_list[0] == '') |
|
1648 | + if (is_array($args_list) && $args_list[0] == '') |
|
1649 | 1649 | { |
1650 | 1650 | array_shift($args_list); |
1651 | 1651 | } |
1652 | 1652 | } |
1653 | - elseif($_SERVER['REQUEST_METHOD'] == 'GET') |
|
1653 | + elseif ($_SERVER['REQUEST_METHOD'] == 'GET') |
|
1654 | 1654 | { |
1655 | 1655 | // Otherwise, make GET variables into array |
1656 | 1656 | $get_vars = get_object_vars($self->get_vars); |
1657 | 1657 | } |
1658 | 1658 | else |
1659 | 1659 | { |
1660 | - if(!!$self->get_vars->module) $get_vars['module'] = $self->get_vars->module; |
|
1661 | - if(!!$self->get_vars->mid) $get_vars['mid'] = $self->get_vars->mid; |
|
1662 | - if(!!$self->get_vars->act) $get_vars['act'] = $self->get_vars->act; |
|
1663 | - if(!!$self->get_vars->page) $get_vars['page'] = $self->get_vars->page; |
|
1664 | - if(!!$self->get_vars->search_target) $get_vars['search_target'] = $self->get_vars->search_target; |
|
1665 | - if(!!$self->get_vars->search_keyword) $get_vars['search_keyword'] = $self->get_vars->search_keyword; |
|
1666 | - if($get_vars['act'] == 'IS') |
|
1660 | + if (!!$self->get_vars->module) $get_vars['module'] = $self->get_vars->module; |
|
1661 | + if (!!$self->get_vars->mid) $get_vars['mid'] = $self->get_vars->mid; |
|
1662 | + if (!!$self->get_vars->act) $get_vars['act'] = $self->get_vars->act; |
|
1663 | + if (!!$self->get_vars->page) $get_vars['page'] = $self->get_vars->page; |
|
1664 | + if (!!$self->get_vars->search_target) $get_vars['search_target'] = $self->get_vars->search_target; |
|
1665 | + if (!!$self->get_vars->search_keyword) $get_vars['search_keyword'] = $self->get_vars->search_keyword; |
|
1666 | + if ($get_vars['act'] == 'IS') |
|
1667 | 1667 | { |
1668 | - if(!!$self->get_vars->is_keyword) $get_vars['is_keyword'] = $self->get_vars->is_keyword; |
|
1668 | + if (!!$self->get_vars->is_keyword) $get_vars['is_keyword'] = $self->get_vars->is_keyword; |
|
1669 | 1669 | } |
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | // arrange args_list |
1673 | - for($i = 0, $c = count($args_list); $i < $c; $i += 2) |
|
1673 | + for ($i = 0, $c = count($args_list); $i < $c; $i += 2) |
|
1674 | 1674 | { |
1675 | 1675 | $key = $args_list[$i]; |
1676 | 1676 | $val = trim($args_list[$i + 1]); |
1677 | 1677 | |
1678 | 1678 | // If value is not set, remove the key |
1679 | - if(!isset($val) || !strlen($val)) |
|
1679 | + if (!isset($val) || !strlen($val)) |
|
1680 | 1680 | { |
1681 | 1681 | unset($get_vars[$key]); |
1682 | 1682 | continue; |
@@ -1687,7 +1687,7 @@ discard block |
||
1687 | 1687 | |
1688 | 1688 | // remove vid, rnd |
1689 | 1689 | unset($get_vars['rnd']); |
1690 | - if($vid) |
|
1690 | + if ($vid) |
|
1691 | 1691 | { |
1692 | 1692 | $get_vars['vid'] = $vid; |
1693 | 1693 | } |
@@ -1704,17 +1704,17 @@ discard block |
||
1704 | 1704 | 'dispDocumentAdminManageDocument' => 'dispDocumentManageDocument', |
1705 | 1705 | 'dispModuleAdminSelectList' => 'dispModuleSelectList' |
1706 | 1706 | ); |
1707 | - if($act_alias[$act]) |
|
1707 | + if ($act_alias[$act]) |
|
1708 | 1708 | { |
1709 | 1709 | $get_vars['act'] = $act_alias[$act]; |
1710 | 1710 | } |
1711 | 1711 | |
1712 | 1712 | // organize URL |
1713 | 1713 | $query = ''; |
1714 | - if(count($get_vars) > 0) |
|
1714 | + if (count($get_vars) > 0) |
|
1715 | 1715 | { |
1716 | 1716 | // if using rewrite mod |
1717 | - if($self->allow_rewrite) |
|
1717 | + if ($self->allow_rewrite) |
|
1718 | 1718 | { |
1719 | 1719 | $var_keys = array_keys($get_vars); |
1720 | 1720 | sort($var_keys); |
@@ -1734,8 +1734,8 @@ discard block |
||
1734 | 1734 | 'vid' => $vid, |
1735 | 1735 | 'mid' => $mid, |
1736 | 1736 | 'mid.vid' => "$vid/$mid", |
1737 | - 'entry.mid' => "$mid/entry/" . $get_vars['entry'], |
|
1738 | - 'entry.mid.vid' => "$vid/$mid/entry/" . $get_vars['entry'], |
|
1737 | + 'entry.mid' => "$mid/entry/".$get_vars['entry'], |
|
1738 | + 'entry.mid.vid' => "$vid/$mid/entry/".$get_vars['entry'], |
|
1739 | 1739 | 'document_srl' => $srl, |
1740 | 1740 | 'document_srl.mid' => "$mid/$srl", |
1741 | 1741 | 'document_srl.vid' => "$vid/$srl", |
@@ -1752,66 +1752,66 @@ discard block |
||
1752 | 1752 | $query = $target_map[$target]; |
1753 | 1753 | } |
1754 | 1754 | |
1755 | - if(!$query) |
|
1755 | + if (!$query) |
|
1756 | 1756 | { |
1757 | 1757 | $queries = array(); |
1758 | - foreach($get_vars as $key => $val) |
|
1758 | + foreach ($get_vars as $key => $val) |
|
1759 | 1759 | { |
1760 | - if(is_array($val) && count($val) > 0) |
|
1760 | + if (is_array($val) && count($val) > 0) |
|
1761 | 1761 | { |
1762 | - foreach($val as $k => $v) |
|
1762 | + foreach ($val as $k => $v) |
|
1763 | 1763 | { |
1764 | - $queries[] = $key . '[' . $k . ']=' . urlencode($v); |
|
1764 | + $queries[] = $key.'['.$k.']='.urlencode($v); |
|
1765 | 1765 | } |
1766 | 1766 | } |
1767 | - elseif(!is_array($val)) |
|
1767 | + elseif (!is_array($val)) |
|
1768 | 1768 | { |
1769 | - $queries[] = $key . '=' . urlencode($val); |
|
1769 | + $queries[] = $key.'='.urlencode($val); |
|
1770 | 1770 | } |
1771 | 1771 | } |
1772 | - if(count($queries) > 0) |
|
1772 | + if (count($queries) > 0) |
|
1773 | 1773 | { |
1774 | - $query = 'index.php?' . join('&', $queries); |
|
1774 | + $query = 'index.php?'.join('&', $queries); |
|
1775 | 1775 | } |
1776 | 1776 | } |
1777 | 1777 | } |
1778 | 1778 | |
1779 | 1779 | // If using SSL always |
1780 | 1780 | $_use_ssl = $self->get('_use_ssl'); |
1781 | - if($_use_ssl == 'always') |
|
1781 | + if ($_use_ssl == 'always') |
|
1782 | 1782 | { |
1783 | - $query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query; |
|
1783 | + $query = $self->getRequestUri(ENFORCE_SSL, $domain).$query; |
|
1784 | 1784 | // optional SSL use |
1785 | 1785 | } |
1786 | - elseif($_use_ssl == 'optional') |
|
1786 | + elseif ($_use_ssl == 'optional') |
|
1787 | 1787 | { |
1788 | 1788 | $ssl_mode = (($self->get('module') === 'admin') || ($get_vars['module'] === 'admin') || (isset($get_vars['act']) && $self->isExistsSSLAction($get_vars['act']))) ? ENFORCE_SSL : RELEASE_SSL; |
1789 | - $query = $self->getRequestUri($ssl_mode, $domain) . $query; |
|
1789 | + $query = $self->getRequestUri($ssl_mode, $domain).$query; |
|
1790 | 1790 | // no SSL |
1791 | 1791 | } |
1792 | 1792 | else |
1793 | 1793 | { |
1794 | 1794 | // currently on SSL but target is not based on SSL |
1795 | - if($_SERVER['HTTPS'] == 'on') |
|
1795 | + if ($_SERVER['HTTPS'] == 'on') |
|
1796 | 1796 | { |
1797 | - $query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query; |
|
1797 | + $query = $self->getRequestUri(ENFORCE_SSL, $domain).$query; |
|
1798 | 1798 | } |
1799 | - else if($domain) // if $domain is set |
|
1799 | + else if ($domain) // if $domain is set |
|
1800 | 1800 | { |
1801 | - $query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain) . $query; |
|
1801 | + $query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain).$query; |
|
1802 | 1802 | } |
1803 | 1803 | else |
1804 | 1804 | { |
1805 | - $query = getScriptPath() . $query; |
|
1805 | + $query = getScriptPath().$query; |
|
1806 | 1806 | } |
1807 | 1807 | } |
1808 | 1808 | |
1809 | - if(!$encode) |
|
1809 | + if (!$encode) |
|
1810 | 1810 | { |
1811 | 1811 | return $query; |
1812 | 1812 | } |
1813 | 1813 | |
1814 | - if(!$autoEncode) |
|
1814 | + if (!$autoEncode) |
|
1815 | 1815 | { |
1816 | 1816 | return htmlspecialchars($query, ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE); |
1817 | 1817 | } |
@@ -1820,16 +1820,16 @@ discard block |
||
1820 | 1820 | $encode_queries = array(); |
1821 | 1821 | $parsedUrl = parse_url($query); |
1822 | 1822 | parse_str($parsedUrl['query'], $output); |
1823 | - foreach($output as $key => $value) |
|
1823 | + foreach ($output as $key => $value) |
|
1824 | 1824 | { |
1825 | - if(preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value))) |
|
1825 | + if (preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value))) |
|
1826 | 1826 | { |
1827 | 1827 | $value = urlencode(htmlspecialchars_decode(urldecode($value))); |
1828 | 1828 | } |
1829 | - $encode_queries[] = $key . '=' . $value; |
|
1829 | + $encode_queries[] = $key.'='.$value; |
|
1830 | 1830 | } |
1831 | 1831 | |
1832 | - return htmlspecialchars($parsedUrl['path'] . '?' . join('&', $encode_queries), ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE); |
|
1832 | + return htmlspecialchars($parsedUrl['path'].'?'.join('&', $encode_queries), ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE); |
|
1833 | 1833 | } |
1834 | 1834 | |
1835 | 1835 | /** |
@@ -1844,17 +1844,17 @@ discard block |
||
1844 | 1844 | static $url = array(); |
1845 | 1845 | |
1846 | 1846 | // Check HTTP Request |
1847 | - if(!isset($_SERVER['SERVER_PROTOCOL'])) |
|
1847 | + if (!isset($_SERVER['SERVER_PROTOCOL'])) |
|
1848 | 1848 | { |
1849 | 1849 | return; |
1850 | 1850 | } |
1851 | 1851 | |
1852 | - if(self::get('_use_ssl') == 'always') |
|
1852 | + if (self::get('_use_ssl') == 'always') |
|
1853 | 1853 | { |
1854 | 1854 | $ssl_mode = ENFORCE_SSL; |
1855 | 1855 | } |
1856 | 1856 | |
1857 | - if($domain) |
|
1857 | + if ($domain) |
|
1858 | 1858 | { |
1859 | 1859 | $domain_key = md5($domain); |
1860 | 1860 | } |
@@ -1863,14 +1863,14 @@ discard block |
||
1863 | 1863 | $domain_key = 'default'; |
1864 | 1864 | } |
1865 | 1865 | |
1866 | - if(isset($url[$ssl_mode][$domain_key])) |
|
1866 | + if (isset($url[$ssl_mode][$domain_key])) |
|
1867 | 1867 | { |
1868 | 1868 | return $url[$ssl_mode][$domain_key]; |
1869 | 1869 | } |
1870 | 1870 | |
1871 | 1871 | $current_use_ssl = ($_SERVER['HTTPS'] == 'on'); |
1872 | 1872 | |
1873 | - switch($ssl_mode) |
|
1873 | + switch ($ssl_mode) |
|
1874 | 1874 | { |
1875 | 1875 | case FOLLOW_REQUEST_SSL: $use_ssl = $current_use_ssl; |
1876 | 1876 | break; |
@@ -1880,34 +1880,34 @@ discard block |
||
1880 | 1880 | break; |
1881 | 1881 | } |
1882 | 1882 | |
1883 | - if($domain) |
|
1883 | + if ($domain) |
|
1884 | 1884 | { |
1885 | 1885 | $target_url = trim($domain); |
1886 | - if(substr_compare($target_url, '/', -1) !== 0) |
|
1886 | + if (substr_compare($target_url, '/', -1) !== 0) |
|
1887 | 1887 | { |
1888 | - $target_url.= '/'; |
|
1888 | + $target_url .= '/'; |
|
1889 | 1889 | } |
1890 | 1890 | } |
1891 | 1891 | else |
1892 | 1892 | { |
1893 | - $target_url = $_SERVER['HTTP_HOST'] . getScriptPath(); |
|
1893 | + $target_url = $_SERVER['HTTP_HOST'].getScriptPath(); |
|
1894 | 1894 | } |
1895 | 1895 | |
1896 | - $url_info = parse_url('http://' . $target_url); |
|
1896 | + $url_info = parse_url('http://'.$target_url); |
|
1897 | 1897 | |
1898 | - if($current_use_ssl != $use_ssl) |
|
1898 | + if ($current_use_ssl != $use_ssl) |
|
1899 | 1899 | { |
1900 | 1900 | unset($url_info['port']); |
1901 | 1901 | } |
1902 | 1902 | |
1903 | - if($use_ssl) |
|
1903 | + if ($use_ssl) |
|
1904 | 1904 | { |
1905 | 1905 | $port = self::get('_https_port'); |
1906 | - if($port && $port != 443) |
|
1906 | + if ($port && $port != 443) |
|
1907 | 1907 | { |
1908 | 1908 | $url_info['port'] = $port; |
1909 | 1909 | } |
1910 | - elseif($url_info['port'] == 443) |
|
1910 | + elseif ($url_info['port'] == 443) |
|
1911 | 1911 | { |
1912 | 1912 | unset($url_info['port']); |
1913 | 1913 | } |
@@ -1915,17 +1915,17 @@ discard block |
||
1915 | 1915 | else |
1916 | 1916 | { |
1917 | 1917 | $port = self::get('_http_port'); |
1918 | - if($port && $port != 80) |
|
1918 | + if ($port && $port != 80) |
|
1919 | 1919 | { |
1920 | 1920 | $url_info['port'] = $port; |
1921 | 1921 | } |
1922 | - elseif($url_info['port'] == 80) |
|
1922 | + elseif ($url_info['port'] == 80) |
|
1923 | 1923 | { |
1924 | 1924 | unset($url_info['port']); |
1925 | 1925 | } |
1926 | 1926 | } |
1927 | 1927 | |
1928 | - $url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s', $use_ssl ? 'https' : $url_info['scheme'], $url_info['host'], $url_info['port'] && $url_info['port'] != 80 ? ':' . $url_info['port'] : '', $url_info['path']); |
|
1928 | + $url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s', $use_ssl ? 'https' : $url_info['scheme'], $url_info['host'], $url_info['port'] && $url_info['port'] != 80 ? ':'.$url_info['port'] : '', $url_info['path']); |
|
1929 | 1929 | |
1930 | 1930 | return $url[$ssl_mode][$domain_key]; |
1931 | 1931 | } |
@@ -1942,16 +1942,16 @@ discard block |
||
1942 | 1942 | { |
1943 | 1943 | $self = self::getInstance(); |
1944 | 1944 | $self->context->{$key} = $val; |
1945 | - if($set_to_get_vars === FALSE) |
|
1945 | + if ($set_to_get_vars === FALSE) |
|
1946 | 1946 | { |
1947 | 1947 | return; |
1948 | 1948 | } |
1949 | - if($val === NULL || $val === '') |
|
1949 | + if ($val === NULL || $val === '') |
|
1950 | 1950 | { |
1951 | 1951 | unset($self->get_vars->{$key}); |
1952 | 1952 | return; |
1953 | 1953 | } |
1954 | - if($set_to_get_vars || $self->get_vars->{$key}) |
|
1954 | + if ($set_to_get_vars || $self->get_vars->{$key}) |
|
1955 | 1955 | { |
1956 | 1956 | $self->get_vars->{$key} = $val; |
1957 | 1957 | } |
@@ -1967,7 +1967,7 @@ discard block |
||
1967 | 1967 | { |
1968 | 1968 | $self = self::getInstance(); |
1969 | 1969 | |
1970 | - if(!isset($self->context->{$key})) |
|
1970 | + if (!isset($self->context->{$key})) |
|
1971 | 1971 | { |
1972 | 1972 | return null; |
1973 | 1973 | } |
@@ -1982,7 +1982,7 @@ discard block |
||
1982 | 1982 | function gets() |
1983 | 1983 | { |
1984 | 1984 | $num_args = func_num_args(); |
1985 | - if($num_args < 1) |
|
1985 | + if ($num_args < 1) |
|
1986 | 1986 | { |
1987 | 1987 | return; |
1988 | 1988 | } |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | |
1991 | 1991 | $args_list = func_get_args(); |
1992 | 1992 | $output = new stdClass(); |
1993 | - foreach($args_list as $v) |
|
1993 | + foreach ($args_list as $v) |
|
1994 | 1994 | { |
1995 | 1995 | $output->{$v} = $self->get($v); |
1996 | 1996 | } |
@@ -2016,7 +2016,7 @@ discard block |
||
2016 | 2016 | function getRequestVars() |
2017 | 2017 | { |
2018 | 2018 | $self = self::getInstance(); |
2019 | - if($self->get_vars) |
|
2019 | + if ($self->get_vars) |
|
2020 | 2020 | { |
2021 | 2021 | return clone($self->get_vars); |
2022 | 2022 | } |
@@ -2033,13 +2033,13 @@ discard block |
||
2033 | 2033 | { |
2034 | 2034 | $self = self::getInstance(); |
2035 | 2035 | |
2036 | - if(!is_readable($self->sslActionCacheFile)) |
|
2036 | + if (!is_readable($self->sslActionCacheFile)) |
|
2037 | 2037 | { |
2038 | 2038 | $buff = '<?php if(!defined("__XE__"))exit;'; |
2039 | 2039 | FileHandler::writeFile($self->sslActionCacheFile, $buff); |
2040 | 2040 | } |
2041 | 2041 | |
2042 | - if(!isset($self->ssl_actions[$action])) |
|
2042 | + if (!isset($self->ssl_actions[$action])) |
|
2043 | 2043 | { |
2044 | 2044 | $self->ssl_actions[$action] = 1; |
2045 | 2045 | $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action); |
@@ -2057,16 +2057,16 @@ discard block |
||
2057 | 2057 | { |
2058 | 2058 | $self = self::getInstance(); |
2059 | 2059 | |
2060 | - if(!is_readable($self->sslActionCacheFile)) |
|
2060 | + if (!is_readable($self->sslActionCacheFile)) |
|
2061 | 2061 | { |
2062 | 2062 | unset($self->ssl_actions); |
2063 | 2063 | $buff = '<?php if(!defined("__XE__"))exit;'; |
2064 | 2064 | FileHandler::writeFile($self->sslActionCacheFile, $buff); |
2065 | 2065 | } |
2066 | 2066 | |
2067 | - foreach($action_array as $action) |
|
2067 | + foreach ($action_array as $action) |
|
2068 | 2068 | { |
2069 | - if(!isset($self->ssl_actions[$action])) |
|
2069 | + if (!isset($self->ssl_actions[$action])) |
|
2070 | 2070 | { |
2071 | 2071 | $self->ssl_actions[$action] = 1; |
2072 | 2072 | $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action); |
@@ -2085,7 +2085,7 @@ discard block |
||
2085 | 2085 | { |
2086 | 2086 | $self = self::getInstance(); |
2087 | 2087 | |
2088 | - if($self->isExistsSSLAction($action)) |
|
2088 | + if ($self->isExistsSSLAction($action)) |
|
2089 | 2089 | { |
2090 | 2090 | $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action); |
2091 | 2091 | $buff = FileHandler::readFile($self->sslActionCacheFile); |
@@ -2102,7 +2102,7 @@ discard block |
||
2102 | 2102 | function getSSLActions() |
2103 | 2103 | { |
2104 | 2104 | $self = self::getInstance(); |
2105 | - if($self->getSslStatus() == 'optional') |
|
2105 | + if ($self->getSslStatus() == 'optional') |
|
2106 | 2106 | { |
2107 | 2107 | return $self->ssl_actions; |
2108 | 2108 | } |
@@ -2129,12 +2129,12 @@ discard block |
||
2129 | 2129 | */ |
2130 | 2130 | function normalizeFilePath($file) |
2131 | 2131 | { |
2132 | - if($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE) |
|
2132 | + if ($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE) |
|
2133 | 2133 | { |
2134 | - $file = './' . $file; |
|
2134 | + $file = './'.$file; |
|
2135 | 2135 | } |
2136 | 2136 | $file = preg_replace('@/\./|(?<!:)\/\/@', '/', $file); |
2137 | - while(strpos($file, '/../') !== FALSE) |
|
2137 | + while (strpos($file, '/../') !== FALSE) |
|
2138 | 2138 | { |
2139 | 2139 | $file = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $file, 1); |
2140 | 2140 | } |
@@ -2153,13 +2153,13 @@ discard block |
||
2153 | 2153 | { |
2154 | 2154 | $file = self::normalizeFilePath($file); |
2155 | 2155 | $script_path = getScriptPath(); |
2156 | - if(strpos($file, './') === 0) |
|
2156 | + if (strpos($file, './') === 0) |
|
2157 | 2157 | { |
2158 | - $file = $script_path . substr($file, 2); |
|
2158 | + $file = $script_path.substr($file, 2); |
|
2159 | 2159 | } |
2160 | - elseif(strpos($file, '../') === 0) |
|
2160 | + elseif (strpos($file, '../') === 0) |
|
2161 | 2161 | { |
2162 | - $file = self::normalizeFilePath($script_path . $file); |
|
2162 | + $file = self::normalizeFilePath($script_path.$file); |
|
2163 | 2163 | } |
2164 | 2164 | |
2165 | 2165 | return $file; |
@@ -2229,12 +2229,12 @@ discard block |
||
2229 | 2229 | */ |
2230 | 2230 | function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null) |
2231 | 2231 | { |
2232 | - if($isRuleset) |
|
2232 | + if ($isRuleset) |
|
2233 | 2233 | { |
2234 | - if(strpos($file, '#') !== FALSE) |
|
2234 | + if (strpos($file, '#') !== FALSE) |
|
2235 | 2235 | { |
2236 | 2236 | $file = str_replace('#', '', $file); |
2237 | - if(!is_readable($file)) |
|
2237 | + if (!is_readable($file)) |
|
2238 | 2238 | { |
2239 | 2239 | $file = $autoPath; |
2240 | 2240 | } |
@@ -2299,9 +2299,9 @@ discard block |
||
2299 | 2299 | ksort($files); |
2300 | 2300 | $files = array_values($files); |
2301 | 2301 | $filenames = array(); |
2302 | - for($i = 0, $c = count($files); $i < $c; ++$i) |
|
2302 | + for ($i = 0, $c = count($files); $i < $c; ++$i) |
|
2303 | 2303 | { |
2304 | - if(in_array($files[$i]['file'], $filenames)) |
|
2304 | + if (in_array($files[$i]['file'], $filenames)) |
|
2305 | 2305 | { |
2306 | 2306 | unset($files[$i]); |
2307 | 2307 | } |
@@ -2386,14 +2386,14 @@ discard block |
||
2386 | 2386 | */ |
2387 | 2387 | function getJavascriptPluginInfo($pluginName) |
2388 | 2388 | { |
2389 | - if($plugin_name == 'ui.datepicker') |
|
2389 | + if ($plugin_name == 'ui.datepicker') |
|
2390 | 2390 | { |
2391 | 2391 | $plugin_name = 'ui'; |
2392 | 2392 | } |
2393 | 2393 | |
2394 | - $plugin_path = './common/js/plugins/' . $pluginName . '/'; |
|
2395 | - $info_file = $plugin_path . 'plugin.load'; |
|
2396 | - if(!is_readable($info_file)) |
|
2394 | + $plugin_path = './common/js/plugins/'.$pluginName.'/'; |
|
2395 | + $info_file = $plugin_path.'plugin.load'; |
|
2396 | + if (!is_readable($info_file)) |
|
2397 | 2397 | { |
2398 | 2398 | return; |
2399 | 2399 | } |
@@ -2403,32 +2403,32 @@ discard block |
||
2403 | 2403 | $result->jsList = array(); |
2404 | 2404 | $result->cssList = array(); |
2405 | 2405 | |
2406 | - foreach($list as $filename) |
|
2406 | + foreach ($list as $filename) |
|
2407 | 2407 | { |
2408 | 2408 | $filename = trim($filename); |
2409 | - if(!$filename) |
|
2409 | + if (!$filename) |
|
2410 | 2410 | { |
2411 | 2411 | continue; |
2412 | 2412 | } |
2413 | 2413 | |
2414 | - if(strncasecmp('./', $filename, 2) === 0) |
|
2414 | + if (strncasecmp('./', $filename, 2) === 0) |
|
2415 | 2415 | { |
2416 | 2416 | $filename = substr($filename, 2); |
2417 | 2417 | } |
2418 | 2418 | |
2419 | - if(substr_compare($filename, '.js', -3) === 0) |
|
2419 | + if (substr_compare($filename, '.js', -3) === 0) |
|
2420 | 2420 | { |
2421 | - $result->jsList[] = $plugin_path . $filename; |
|
2421 | + $result->jsList[] = $plugin_path.$filename; |
|
2422 | 2422 | } |
2423 | - elseif(substr_compare($filename, '.css', -4) === 0) |
|
2423 | + elseif (substr_compare($filename, '.css', -4) === 0) |
|
2424 | 2424 | { |
2425 | - $result->cssList[] = $plugin_path . $filename; |
|
2425 | + $result->cssList[] = $plugin_path.$filename; |
|
2426 | 2426 | } |
2427 | 2427 | } |
2428 | 2428 | |
2429 | - if(is_dir($plugin_path . 'lang')) |
|
2429 | + if (is_dir($plugin_path.'lang')) |
|
2430 | 2430 | { |
2431 | - $result->langPath = $plugin_path . 'lang'; |
|
2431 | + $result->langPath = $plugin_path.'lang'; |
|
2432 | 2432 | } |
2433 | 2433 | |
2434 | 2434 | return $result; |
@@ -2444,50 +2444,50 @@ discard block |
||
2444 | 2444 | static $loaded_plugins = array(); |
2445 | 2445 | |
2446 | 2446 | $self = self::getInstance(); |
2447 | - if($plugin_name == 'ui.datepicker') |
|
2447 | + if ($plugin_name == 'ui.datepicker') |
|
2448 | 2448 | { |
2449 | 2449 | $plugin_name = 'ui'; |
2450 | 2450 | } |
2451 | 2451 | |
2452 | - if($loaded_plugins[$plugin_name]) |
|
2452 | + if ($loaded_plugins[$plugin_name]) |
|
2453 | 2453 | { |
2454 | 2454 | return; |
2455 | 2455 | } |
2456 | 2456 | $loaded_plugins[$plugin_name] = TRUE; |
2457 | 2457 | |
2458 | - $plugin_path = './common/js/plugins/' . $plugin_name . '/'; |
|
2459 | - $info_file = $plugin_path . 'plugin.load'; |
|
2460 | - if(!is_readable($info_file)) |
|
2458 | + $plugin_path = './common/js/plugins/'.$plugin_name.'/'; |
|
2459 | + $info_file = $plugin_path.'plugin.load'; |
|
2460 | + if (!is_readable($info_file)) |
|
2461 | 2461 | { |
2462 | 2462 | return; |
2463 | 2463 | } |
2464 | 2464 | |
2465 | 2465 | $list = file($info_file); |
2466 | - foreach($list as $filename) |
|
2466 | + foreach ($list as $filename) |
|
2467 | 2467 | { |
2468 | 2468 | $filename = trim($filename); |
2469 | - if(!$filename) |
|
2469 | + if (!$filename) |
|
2470 | 2470 | { |
2471 | 2471 | continue; |
2472 | 2472 | } |
2473 | 2473 | |
2474 | - if(strncasecmp('./', $filename, 2) === 0) |
|
2474 | + if (strncasecmp('./', $filename, 2) === 0) |
|
2475 | 2475 | { |
2476 | 2476 | $filename = substr($filename, 2); |
2477 | 2477 | } |
2478 | - if(substr_compare($filename, '.js', -3) === 0) |
|
2478 | + if (substr_compare($filename, '.js', -3) === 0) |
|
2479 | 2479 | { |
2480 | - $self->loadFile(array($plugin_path . $filename, 'body', '', 0), TRUE); |
|
2480 | + $self->loadFile(array($plugin_path.$filename, 'body', '', 0), TRUE); |
|
2481 | 2481 | } |
2482 | - if(substr_compare($filename, '.css', -4) === 0) |
|
2482 | + if (substr_compare($filename, '.css', -4) === 0) |
|
2483 | 2483 | { |
2484 | - $self->loadFile(array($plugin_path . $filename, 'all', '', 0), TRUE); |
|
2484 | + $self->loadFile(array($plugin_path.$filename, 'all', '', 0), TRUE); |
|
2485 | 2485 | } |
2486 | 2486 | } |
2487 | 2487 | |
2488 | - if(is_dir($plugin_path . 'lang')) |
|
2488 | + if (is_dir($plugin_path.'lang')) |
|
2489 | 2489 | { |
2490 | - $self->loadLang($plugin_path . 'lang'); |
|
2490 | + $self->loadLang($plugin_path.'lang'); |
|
2491 | 2491 | } |
2492 | 2492 | } |
2493 | 2493 | |
@@ -2500,7 +2500,7 @@ discard block |
||
2500 | 2500 | function addHtmlHeader($header) |
2501 | 2501 | { |
2502 | 2502 | $self = self::getInstance(); |
2503 | - $self->html_header .= "\n" . $header; |
|
2503 | + $self->html_header .= "\n".$header; |
|
2504 | 2504 | } |
2505 | 2505 | |
2506 | 2506 | function clearHtmlHeader() |
@@ -2552,7 +2552,7 @@ discard block |
||
2552 | 2552 | function addBodyHeader($header) |
2553 | 2553 | { |
2554 | 2554 | $self = self::getInstance(); |
2555 | - $self->body_header .= "\n" . $header; |
|
2555 | + $self->body_header .= "\n".$header; |
|
2556 | 2556 | } |
2557 | 2557 | |
2558 | 2558 | /** |
@@ -2574,7 +2574,7 @@ discard block |
||
2574 | 2574 | function addHtmlFooter($footer) |
2575 | 2575 | { |
2576 | 2576 | $self = self::getInstance(); |
2577 | - $self->html_footer .= ($self->Htmlfooter ? "\n" : '') . $footer; |
|
2577 | + $self->html_footer .= ($self->Htmlfooter ? "\n" : '').$footer; |
|
2578 | 2578 | } |
2579 | 2579 | |
2580 | 2580 | /** |
@@ -2595,7 +2595,7 @@ discard block |
||
2595 | 2595 | */ |
2596 | 2596 | function getConfigFile() |
2597 | 2597 | { |
2598 | - return _XE_PATH_ . 'files/config/db.config.php'; |
|
2598 | + return _XE_PATH_.'files/config/db.config.php'; |
|
2599 | 2599 | } |
2600 | 2600 | |
2601 | 2601 | /** |
@@ -2605,7 +2605,7 @@ discard block |
||
2605 | 2605 | */ |
2606 | 2606 | function getFTPConfigFile() |
2607 | 2607 | { |
2608 | - return _XE_PATH_ . 'files/config/ftp.config.php'; |
|
2608 | + return _XE_PATH_.'files/config/ftp.config.php'; |
|
2609 | 2609 | } |
2610 | 2610 | |
2611 | 2611 | /** |
@@ -2657,14 +2657,14 @@ discard block |
||
2657 | 2657 | $_path = explode('/', $path); |
2658 | 2658 | $_base = explode('/', $base_url); |
2659 | 2659 | |
2660 | - if(!$_base[count($_base) - 1]) |
|
2660 | + if (!$_base[count($_base) - 1]) |
|
2661 | 2661 | { |
2662 | 2662 | array_pop($_base); |
2663 | 2663 | } |
2664 | 2664 | |
2665 | - foreach($_xe as $idx => $dir) |
|
2665 | + foreach ($_xe as $idx => $dir) |
|
2666 | 2666 | { |
2667 | - if($_path[0] != $dir) |
|
2667 | + if ($_path[0] != $dir) |
|
2668 | 2668 | { |
2669 | 2669 | break; |
2670 | 2670 | } |
@@ -2672,9 +2672,9 @@ discard block |
||
2672 | 2672 | } |
2673 | 2673 | |
2674 | 2674 | $idx = count($_xe) - $idx - 1; |
2675 | - while($idx--) |
|
2675 | + while ($idx--) |
|
2676 | 2676 | { |
2677 | - if(count($_base) > 0) |
|
2677 | + if (count($_base) > 0) |
|
2678 | 2678 | { |
2679 | 2679 | array_shift($_base); |
2680 | 2680 | } |
@@ -2684,13 +2684,13 @@ discard block |
||
2684 | 2684 | } |
2685 | 2685 | } |
2686 | 2686 | |
2687 | - if(count($_base) > 0) |
|
2687 | + if (count($_base) > 0) |
|
2688 | 2688 | { |
2689 | 2689 | array_unshift($_path, join('/', $_base)); |
2690 | 2690 | } |
2691 | 2691 | |
2692 | - $path = '/' . join('/', $_path); |
|
2693 | - if(substr_compare($path, '/', -1) !== 0) |
|
2692 | + $path = '/'.join('/', $_path); |
|
2693 | + if (substr_compare($path, '/', -1) !== 0) |
|
2694 | 2694 | { |
2695 | 2695 | $path .= '/'; |
2696 | 2696 | } |
@@ -2705,13 +2705,13 @@ discard block |
||
2705 | 2705 | { |
2706 | 2706 | $self = self::getInstance(); |
2707 | 2707 | |
2708 | - if(!is_array($self->meta_tags)) |
|
2708 | + if (!is_array($self->meta_tags)) |
|
2709 | 2709 | { |
2710 | 2710 | $self->meta_tags = array(); |
2711 | 2711 | } |
2712 | 2712 | |
2713 | 2713 | $ret = array(); |
2714 | - foreach($self->meta_tags as $key => $val) |
|
2714 | + foreach ($self->meta_tags as $key => $val) |
|
2715 | 2715 | { |
2716 | 2716 | list($name, $is_http_equiv) = explode("\t", $key); |
2717 | 2717 | $ret[] = array('name' => $name, 'is_http_equiv' => $is_http_equiv, 'content' => $val); |
@@ -2731,7 +2731,7 @@ discard block |
||
2731 | 2731 | function addMetaTag($name, $content, $is_http_equiv = FALSE) |
2732 | 2732 | { |
2733 | 2733 | $self = self::getInstance(); |
2734 | - $self->meta_tags[$name . "\t" . ($is_http_equiv ? '1' : '0')] = $content; |
|
2734 | + $self->meta_tags[$name."\t".($is_http_equiv ? '1' : '0')] = $content; |
|
2735 | 2735 | } |
2736 | 2736 | |
2737 | 2737 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | function ModuleHandler($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '') |
36 | 36 | { |
37 | 37 | // If XE has not installed yet, set module as install |
38 | - if(!Context::isInstalled()) |
|
38 | + if (!Context::isInstalled()) |
|
39 | 39 | { |
40 | 40 | $this->module = 'install'; |
41 | 41 | $this->act = Context::get('act'); |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | $oContext = Context::getInstance(); |
46 | - if($oContext->isSuccessInit == FALSE) |
|
46 | + if ($oContext->isSuccessInit == FALSE) |
|
47 | 47 | { |
48 | 48 | $logged_info = Context::get('logged_info'); |
49 | 49 | $dbInfo = Context::getDBInfo(); |
50 | 50 | // @see https://github.com/xpressengine/xe-core/issues/2304 |
51 | - if($dbInfo->safeguard === 'Y' || $logged_info->is_admin != "Y") |
|
51 | + if ($dbInfo->safeguard === 'Y' || $logged_info->is_admin != "Y") |
|
52 | 52 | { |
53 | 53 | $this->error = 'msg_invalid_request'; |
54 | 54 | return; |
@@ -61,26 +61,26 @@ discard block |
||
61 | 61 | $this->mid = $mid ? $mid : Context::get('mid'); |
62 | 62 | $this->document_srl = $document_srl ? (int) $document_srl : (int) Context::get('document_srl'); |
63 | 63 | $this->module_srl = $module_srl ? (int) $module_srl : (int) Context::get('module_srl'); |
64 | - if($entry = Context::get('entry')) |
|
64 | + if ($entry = Context::get('entry')) |
|
65 | 65 | { |
66 | 66 | $this->entry = Context::convertEncodingStr($entry); |
67 | 67 | } |
68 | 68 | |
69 | 69 | // Validate variables to prevent XSS |
70 | 70 | $isInvalid = NULL; |
71 | - if($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->module)) |
|
71 | + if ($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->module)) |
|
72 | 72 | { |
73 | 73 | $isInvalid = TRUE; |
74 | 74 | } |
75 | - if($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->mid)) |
|
75 | + if ($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->mid)) |
|
76 | 76 | { |
77 | 77 | $isInvalid = TRUE; |
78 | 78 | } |
79 | - if($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->act)) |
|
79 | + if ($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->act)) |
|
80 | 80 | { |
81 | 81 | $isInvalid = TRUE; |
82 | 82 | } |
83 | - if($isInvalid) |
|
83 | + if ($isInvalid) |
|
84 | 84 | { |
85 | 85 | htmlHeader(); |
86 | 86 | echo Context::getLang("msg_invalid_request"); |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | exit; |
90 | 90 | } |
91 | 91 | |
92 | - if(isset($this->act) && (strlen($this->act) >= 4 && substr_compare($this->act, 'disp', 0, 4) === 0)) |
|
92 | + if (isset($this->act) && (strlen($this->act) >= 4 && substr_compare($this->act, 'disp', 0, 4) === 0)) |
|
93 | 93 | { |
94 | - if(Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && $_SERVER['HTTPS'] != 'on') |
|
94 | + if (Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && $_SERVER['HTTPS'] != 'on') |
|
95 | 95 | { |
96 | - if(Context::get('_https_port')!=null) { |
|
97 | - header('location:https://' . $_SERVER['HTTP_HOST'] . ':' . Context::get('_https_port') . $_SERVER['REQUEST_URI']); |
|
96 | + if (Context::get('_https_port') != null) { |
|
97 | + header('location:https://'.$_SERVER['HTTP_HOST'].':'.Context::get('_https_port').$_SERVER['REQUEST_URI']); |
|
98 | 98 | } else { |
99 | - header('location:https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
99 | + header('location:https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
100 | 100 | } |
101 | 101 | return; |
102 | 102 | } |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | |
105 | 105 | // call a trigger before moduleHandler init |
106 | 106 | ModuleHandler::triggerCall('moduleHandler.init', 'before', $this); |
107 | - if(__ERROR_LOG__ == 1 && __DEBUG_OUTPUT__ == 0) |
|
107 | + if (__ERROR_LOG__ == 1 && __DEBUG_OUTPUT__ == 0) |
|
108 | 108 | { |
109 | - if(__DEBUG_PROTECT__ === 0 || __DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ == $_SERVER['REMOTE_ADDR']) |
|
109 | + if (__DEBUG_PROTECT__ === 0 || __DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ == $_SERVER['REMOTE_ADDR']) |
|
110 | 110 | { |
111 | 111 | set_error_handler(array($this, 'xeErrorLog'), E_WARNING); |
112 | 112 | register_shutdown_function(array($this, 'shutdownHandler')); |
@@ -117,40 +117,40 @@ discard block |
||
117 | 117 | $called_position = 'before_module_init'; |
118 | 118 | $oAddonController = getController('addon'); |
119 | 119 | $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? 'mobile' : 'pc'); |
120 | - if(file_exists($addon_file)) include($addon_file); |
|
120 | + if (file_exists($addon_file)) include($addon_file); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | public static function xeErrorLog($errnumber, $errormassage, $errorfile, $errorline, $errorcontext) |
124 | 124 | { |
125 | - if(($errnumber & 3) == 0 || error_reporting() == 0) |
|
125 | + if (($errnumber & 3) == 0 || error_reporting() == 0) |
|
126 | 126 | { |
127 | 127 | return false; |
128 | 128 | } |
129 | 129 | |
130 | 130 | set_error_handler(function() { }, ~0); |
131 | 131 | |
132 | - $debug_file = _XE_PATH_ . 'files/_debug_message.php'; |
|
133 | - if(!file_exists($debug_file)) |
|
132 | + $debug_file = _XE_PATH_.'files/_debug_message.php'; |
|
133 | + if (!file_exists($debug_file)) |
|
134 | 134 | { |
135 | 135 | $print[] = '<?php exit() ?>'; |
136 | 136 | } |
137 | 137 | |
138 | 138 | $errorname = self::getErrorType($errnumber); |
139 | - $print[] = '['.date('Y-m-d H:i:s').'] ' . $errorname . ' : ' . $errormassage; |
|
139 | + $print[] = '['.date('Y-m-d H:i:s').'] '.$errorname.' : '.$errormassage; |
|
140 | 140 | $backtrace_args = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? \DEBUG_BACKTRACE_IGNORE_ARGS : 0; |
141 | 141 | $backtrace = debug_backtrace($backtrace_args); |
142 | - if(count($backtrace) > 1 && $backtrace[1]['function'] === 'xeErrorLog' && !$backtrace[1]['class']) |
|
142 | + if (count($backtrace) > 1 && $backtrace[1]['function'] === 'xeErrorLog' && !$backtrace[1]['class']) |
|
143 | 143 | { |
144 | 144 | array_shift($backtrace); |
145 | 145 | } |
146 | 146 | |
147 | - foreach($backtrace as $key => $value) |
|
147 | + foreach ($backtrace as $key => $value) |
|
148 | 148 | { |
149 | - $message = ' - ' . $value['file'] . ' : ' . $value['line']; |
|
149 | + $message = ' - '.$value['file'].' : '.$value['line']; |
|
150 | 150 | $print[] = $message; |
151 | 151 | } |
152 | 152 | $print[] = PHP_EOL; |
153 | - @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX); |
|
153 | + @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND | LOCK_EX); |
|
154 | 154 | restore_error_handler(); |
155 | 155 | |
156 | 156 | return true; |
@@ -166,21 +166,21 @@ discard block |
||
166 | 166 | |
167 | 167 | set_error_handler(function() { }, ~0); |
168 | 168 | |
169 | - $debug_file = _XE_PATH_ . 'files/_debug_message.php'; |
|
170 | - if(!file_exists($debug_file)) |
|
169 | + $debug_file = _XE_PATH_.'files/_debug_message.php'; |
|
170 | + if (!file_exists($debug_file)) |
|
171 | 171 | { |
172 | 172 | $print[] = '<?php exit() ?>'; |
173 | 173 | } |
174 | 174 | |
175 | 175 | $errorname = self::getErrorType($errinfo['type']); |
176 | 176 | $print[] = '['.date('Y-m-d H:i:s').']'; |
177 | - $print[] = $errorname . ' : ' . $errinfo['message']; |
|
177 | + $print[] = $errorname.' : '.$errinfo['message']; |
|
178 | 178 | |
179 | - $message = ' - ' . $errinfo['file'] . ' : ' . $errinfo['line']; |
|
179 | + $message = ' - '.$errinfo['file'].' : '.$errinfo['line']; |
|
180 | 180 | $print[] = $message; |
181 | 181 | |
182 | 182 | $print[] = PHP_EOL; |
183 | - @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX); |
|
183 | + @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND | LOCK_EX); |
|
184 | 184 | set_error_handler(array($this, 'dummyHandler'), ~0); |
185 | 185 | |
186 | 186 | return true; |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | $defaultUrlInfo = parse_url($dbInfo->default_url); |
225 | 225 | $defaultHost = $defaultUrlInfo['host']; |
226 | 226 | |
227 | - foreach($urls as $url) |
|
227 | + foreach ($urls as $url) |
|
228 | 228 | { |
229 | - if(empty($url)) |
|
229 | + if (empty($url)) |
|
230 | 230 | { |
231 | 231 | continue; |
232 | 232 | } |
@@ -234,29 +234,29 @@ discard block |
||
234 | 234 | $urlInfo = parse_url($url); |
235 | 235 | $host = $urlInfo['host']; |
236 | 236 | |
237 | - if($host && ($host != $defaultHost && $host != $site_module_info->domain)) |
|
237 | + if ($host && ($host != $defaultHost && $host != $site_module_info->domain)) |
|
238 | 238 | { |
239 | 239 | throw new Exception('msg_default_url_is_null'); |
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - if(!$this->document_srl && $this->mid && $this->entry) |
|
243 | + if (!$this->document_srl && $this->mid && $this->entry) |
|
244 | 244 | { |
245 | 245 | $oDocumentModel = getModel('document'); |
246 | 246 | $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry); |
247 | - if($this->document_srl) |
|
247 | + if ($this->document_srl) |
|
248 | 248 | { |
249 | 249 | Context::set('document_srl', $this->document_srl); |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | // Get module's information based on document_srl, if it's specified |
254 | - if($this->document_srl) |
|
254 | + if ($this->document_srl) |
|
255 | 255 | { |
256 | 256 | |
257 | 257 | $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl); |
258 | 258 | // If the document does not exist, remove document_srl |
259 | - if(!$module_info) |
|
259 | + if (!$module_info) |
|
260 | 260 | { |
261 | 261 | unset($this->document_srl); |
262 | 262 | } |
@@ -264,13 +264,13 @@ discard block |
||
264 | 264 | { |
265 | 265 | // If it exists, compare mid based on the module information |
266 | 266 | // if mids are not matching, set it as the document's mid |
267 | - if(!$this->mid || ($this->mid != $module_info->mid)) |
|
267 | + if (!$this->mid || ($this->mid != $module_info->mid)) |
|
268 | 268 | { |
269 | 269 | |
270 | - if(Context::getRequestMethod() == 'GET') |
|
270 | + if (Context::getRequestMethod() == 'GET') |
|
271 | 271 | { |
272 | 272 | $this->mid = $module_info->mid; |
273 | - header('location:' . getNotEncodedSiteUrl($site_module_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl)); |
|
273 | + header('location:'.getNotEncodedSiteUrl($site_module_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl)); |
|
274 | 274 | return FALSE; |
275 | 275 | } |
276 | 276 | else |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | } |
283 | 283 | // if requested module is different from one of the document, remove the module information retrieved based on the document number |
284 | - if($this->module && $module_info->module != $this->module) |
|
284 | + if ($this->module && $module_info->module != $this->module) |
|
285 | 285 | { |
286 | 286 | unset($module_info); |
287 | 287 | } |
@@ -290,36 +290,36 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | // If module_info is not set yet, and there exists mid information, get module information based on the mid |
293 | - if(!$module_info && $this->mid) |
|
293 | + if (!$module_info && $this->mid) |
|
294 | 294 | { |
295 | 295 | $module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl); |
296 | 296 | //if($this->module && $module_info->module != $this->module) unset($module_info); |
297 | 297 | } |
298 | 298 | |
299 | 299 | // redirect, if module_site_srl and site_srl are different |
300 | - if(!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) |
|
300 | + if (!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) |
|
301 | 301 | { |
302 | 302 | $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl); |
303 | - header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid)); |
|
303 | + header("location:".getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid)); |
|
304 | 304 | return FALSE; |
305 | 305 | } |
306 | 306 | |
307 | 307 | // If module_info is not set still, and $module does not exist, find the default module |
308 | - if(!$module_info && !$this->module && !$this->mid) |
|
308 | + if (!$module_info && !$this->module && !$this->mid) |
|
309 | 309 | { |
310 | 310 | $module_info = $site_module_info; |
311 | 311 | } |
312 | 312 | |
313 | - if(!$module_info && !$this->module && $site_module_info->module_site_srl) |
|
313 | + if (!$module_info && !$this->module && $site_module_info->module_site_srl) |
|
314 | 314 | { |
315 | 315 | $module_info = $site_module_info; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // redirect, if site_srl of module_info is different from one of site's module_info |
319 | - if($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler()) |
|
319 | + if ($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler()) |
|
320 | 320 | { |
321 | 321 | // If the module is of virtual site |
322 | - if($module_info->site_srl) |
|
322 | + if ($module_info->site_srl) |
|
323 | 323 | { |
324 | 324 | $site_info = $oModuleModel->getSiteInfo($module_info->site_srl); |
325 | 325 | $redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | else |
329 | 329 | { |
330 | 330 | $db_info = Context::getDBInfo(); |
331 | - if(!$db_info->default_url) |
|
331 | + if (!$db_info->default_url) |
|
332 | 332 | { |
333 | 333 | return Context::getLang('msg_default_url_is_not_defined'); |
334 | 334 | } |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | $redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); |
338 | 338 | } |
339 | 339 | } |
340 | - header("location:" . $redirect_url); |
|
340 | + header("location:".$redirect_url); |
|
341 | 341 | return FALSE; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // If module info was set, retrieve variables from the module information |
345 | - if($module_info) |
|
345 | + if ($module_info) |
|
346 | 346 | { |
347 | 347 | $this->module = $module_info->module; |
348 | 348 | $this->mid = $module_info->mid; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $targetSrl = (Mobile::isFromMobilePhone()) ? 'mlayout_srl' : 'layout_srl'; |
354 | 354 | |
355 | 355 | // use the site default layout. |
356 | - if($module_info->{$targetSrl} == -1) |
|
356 | + if ($module_info->{$targetSrl} == -1) |
|
357 | 357 | { |
358 | 358 | $oLayoutAdminModel = getAdminModel('layout'); |
359 | 359 | $layoutSrl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $module_info->site_srl); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | } |
372 | 372 | |
373 | 373 | // Set module and mid into module_info |
374 | - if(!isset($this->module_info)) |
|
374 | + if (!isset($this->module_info)) |
|
375 | 375 | { |
376 | 376 | $this->module_info = new stdClass(); |
377 | 377 | } |
@@ -382,21 +382,21 @@ discard block |
||
382 | 382 | $this->module_info->site_srl = $site_module_info->site_srl; |
383 | 383 | |
384 | 384 | // Still no module? it's an error |
385 | - if(!$this->module) |
|
385 | + if (!$this->module) |
|
386 | 386 | { |
387 | 387 | $this->error = 'msg_module_is_not_exists'; |
388 | 388 | $this->httpStatusCode = '404'; |
389 | 389 | } |
390 | 390 | |
391 | 391 | // If mid exists, set mid into context |
392 | - if($this->mid) |
|
392 | + if ($this->mid) |
|
393 | 393 | { |
394 | 394 | Context::set('mid', $this->mid, TRUE); |
395 | 395 | } |
396 | 396 | |
397 | 397 | // Call a trigger after moduleHandler init |
398 | 398 | $output = ModuleHandler::triggerCall('moduleHandler.init', 'after', $this->module_info); |
399 | - if(!$output->toBool()) |
|
399 | + if (!$output->toBool()) |
|
400 | 400 | { |
401 | 401 | $this->error = $output->getMessage(); |
402 | 402 | return TRUE; |
@@ -418,14 +418,14 @@ discard block |
||
418 | 418 | $display_mode = Mobile::isFromMobilePhone() ? 'mobile' : 'view'; |
419 | 419 | |
420 | 420 | // If error occurred while preparation, return a message instance |
421 | - if($this->error) |
|
421 | + if ($this->error) |
|
422 | 422 | { |
423 | 423 | $this->_setInputErrorToContext(); |
424 | 424 | $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode); |
425 | 425 | $oMessageObject->setError(-1); |
426 | 426 | $oMessageObject->setMessage($this->error); |
427 | 427 | $oMessageObject->dispMessage(); |
428 | - if($this->httpStatusCode) |
|
428 | + if ($this->httpStatusCode) |
|
429 | 429 | { |
430 | 430 | $oMessageObject->setHttpStatusCode($this->httpStatusCode); |
431 | 431 | } |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | $xml_info = $oModuleModel->getModuleActionXml($this->module); |
437 | 437 | |
438 | 438 | // If not installed yet, modify act |
439 | - if($this->module == "install") |
|
439 | + if ($this->module == "install") |
|
440 | 440 | { |
441 | - if(!$this->act || !$xml_info->action->{$this->act}) |
|
441 | + if (!$this->act || !$xml_info->action->{$this->act}) |
|
442 | 442 | { |
443 | 443 | $this->act = $xml_info->default_index_act; |
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | 447 | // if act exists, find type of the action, if not use default index act |
448 | - if(!$this->act) |
|
448 | + if (!$this->act) |
|
449 | 449 | { |
450 | 450 | $this->act = $xml_info->default_index_act; |
451 | 451 | } |
452 | 452 | |
453 | 453 | // still no act means error |
454 | - if(!$this->act) |
|
454 | + if (!$this->act) |
|
455 | 455 | { |
456 | 456 | $this->error = 'msg_module_is_not_exists'; |
457 | 457 | $this->httpStatusCode = '404'; |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $oMessageObject->setError(-1); |
462 | 462 | $oMessageObject->setMessage($this->error); |
463 | 463 | $oMessageObject->dispMessage(); |
464 | - if($this->httpStatusCode) |
|
464 | + if ($this->httpStatusCode) |
|
465 | 465 | { |
466 | 466 | $oMessageObject->setHttpStatusCode($this->httpStatusCode); |
467 | 467 | } |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | Context::addMetaTag('robots', 'noindex'); |
480 | 480 | } |
481 | 481 | |
482 | - if(!$kind && $this->module == 'admin') |
|
482 | + if (!$kind && $this->module == 'admin') |
|
483 | 483 | { |
484 | 484 | $kind = 'admin'; |
485 | 485 | } |
486 | 486 | |
487 | 487 | // check REQUEST_METHOD in controller |
488 | - if($type == 'controller') |
|
488 | + if ($type == 'controller') |
|
489 | 489 | { |
490 | 490 | $allowedMethod = $xml_info->action->{$this->act}->method; |
491 | 491 | |
492 | - if(!$allowedMethod) |
|
492 | + if (!$allowedMethod) |
|
493 | 493 | { |
494 | 494 | $allowedMethodList[0] = 'POST'; |
495 | 495 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $allowedMethodList = explode('|', strtoupper($allowedMethod)); |
499 | 499 | } |
500 | 500 | |
501 | - if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) |
|
501 | + if (!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) |
|
502 | 502 | { |
503 | 503 | $this->error = "msg_invalid_request"; |
504 | 504 | $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | } |
510 | 510 | } |
511 | 511 | |
512 | - if($this->module_info->use_mobile != "Y") |
|
512 | + if ($this->module_info->use_mobile != "Y") |
|
513 | 513 | { |
514 | 514 | Mobile::setMobile(FALSE); |
515 | 515 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | |
519 | 519 | // check CSRF for non-GET actions |
520 | 520 | $use_check_csrf = isset($xml_info->action->{$this->act}) && $xml_info->action->{$this->act}->check_csrf !== 'false'; |
521 | - if($use_check_csrf && $_SERVER['REQUEST_METHOD'] !== 'GET' && Context::isInstalled() && !checkCSRF()) |
|
521 | + if ($use_check_csrf && $_SERVER['REQUEST_METHOD'] !== 'GET' && Context::isInstalled() && !checkCSRF()) |
|
522 | 522 | { |
523 | 523 | $this->error = 'msg_invalid_request'; |
524 | 524 | $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode); |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | } |
530 | 530 | |
531 | 531 | // Admin ip |
532 | - if($kind == 'admin' && $_SESSION['denied_admin'] == 'Y') |
|
532 | + if ($kind == 'admin' && $_SESSION['denied_admin'] == 'Y') |
|
533 | 533 | { |
534 | 534 | $this->_setInputErrorToContext(); |
535 | 535 | $this->error = "msg_not_permitted_act"; |
@@ -541,13 +541,13 @@ discard block |
||
541 | 541 | } |
542 | 542 | |
543 | 543 | // if(type == view, and case for using mobilephone) |
544 | - if($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled()) |
|
544 | + if ($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled()) |
|
545 | 545 | { |
546 | 546 | $orig_type = "view"; |
547 | 547 | $type = "mobile"; |
548 | 548 | // create a module instance |
549 | 549 | $oModule = $this->getModuleInstance($this->module, $type, $kind); |
550 | - if(!is_object($oModule) || !method_exists($oModule, $this->act)) |
|
550 | + if (!is_object($oModule) || !method_exists($oModule, $this->act)) |
|
551 | 551 | { |
552 | 552 | $type = $orig_type; |
553 | 553 | Mobile::setMobile(FALSE); |
@@ -560,14 +560,14 @@ discard block |
||
560 | 560 | $oModule = $this->getModuleInstance($this->module, $type, $kind); |
561 | 561 | } |
562 | 562 | |
563 | - if(!is_object($oModule)) |
|
563 | + if (!is_object($oModule)) |
|
564 | 564 | { |
565 | 565 | $this->_setInputErrorToContext(); |
566 | 566 | $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode); |
567 | 567 | $oMessageObject->setError(-1); |
568 | 568 | $oMessageObject->setMessage($this->error); |
569 | 569 | $oMessageObject->dispMessage(); |
570 | - if($this->httpStatusCode) |
|
570 | + if ($this->httpStatusCode) |
|
571 | 571 | { |
572 | 572 | $oMessageObject->setHttpStatusCode($this->httpStatusCode); |
573 | 573 | } |
@@ -575,10 +575,10 @@ discard block |
||
575 | 575 | } |
576 | 576 | |
577 | 577 | // If there is no such action in the module object |
578 | - if(!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act)) |
|
578 | + if (!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act)) |
|
579 | 579 | { |
580 | 580 | |
581 | - if(!Context::isInstalled()) |
|
581 | + if (!Context::isInstalled()) |
|
582 | 582 | { |
583 | 583 | $this->_setInputErrorToContext(); |
584 | 584 | $this->error = 'msg_invalid_request'; |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $oMessageObject->setError(-1); |
587 | 587 | $oMessageObject->setMessage($this->error); |
588 | 588 | $oMessageObject->dispMessage(); |
589 | - if($this->httpStatusCode) |
|
589 | + if ($this->httpStatusCode) |
|
590 | 590 | { |
591 | 591 | $oMessageObject->setHttpStatusCode($this->httpStatusCode); |
592 | 592 | } |
@@ -595,12 +595,12 @@ discard block |
||
595 | 595 | |
596 | 596 | $forward = NULL; |
597 | 597 | // 1. Look for the module with action name |
598 | - if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches)) |
|
598 | + if (preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches)) |
|
599 | 599 | { |
600 | - $module = strtolower($matches[2] . $matches[3]); |
|
600 | + $module = strtolower($matches[2].$matches[3]); |
|
601 | 601 | $xml_info = $oModuleModel->getModuleActionXml($module); |
602 | 602 | |
603 | - if($xml_info->action->{$this->act} && ((stripos($this->act, 'admin') !== FALSE) || $xml_info->action->{$this->act}->standalone != 'false')) |
|
603 | + if ($xml_info->action->{$this->act} && ((stripos($this->act, 'admin') !== FALSE) || $xml_info->action->{$this->act}->standalone != 'false')) |
|
604 | 604 | { |
605 | 605 | $forward = new stdClass(); |
606 | 606 | $forward->module = $module; |
@@ -621,12 +621,12 @@ discard block |
||
621 | 621 | } |
622 | 622 | } |
623 | 623 | |
624 | - if(!$forward) |
|
624 | + if (!$forward) |
|
625 | 625 | { |
626 | 626 | $forward = $oModuleModel->getActionForward($this->act); |
627 | 627 | } |
628 | 628 | |
629 | - if($forward->module && $forward->type && $forward->act && $forward->act == $this->act) |
|
629 | + if ($forward->module && $forward->type && $forward->act && $forward->act == $this->act) |
|
630 | 630 | { |
631 | 631 | $kind = stripos($forward->act, 'admin') !== FALSE ? 'admin' : ''; |
632 | 632 | $type = $forward->type; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | $tpl_path = $oModule->getTemplatePath(); |
635 | 635 | $orig_module = $oModule; |
636 | 636 | |
637 | - if($forward->meta_noindex === 'true') { |
|
637 | + if ($forward->meta_noindex === 'true') { |
|
638 | 638 | Context::addMetaTag('robots', 'noindex'); |
639 | 639 | } |
640 | 640 | |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | |
643 | 643 | // check CSRF for non-GET actions |
644 | 644 | $use_check_csrf = isset($xml_info->action->{$this->act}) && $xml_info->action->{$this->act}->check_csrf !== 'false'; |
645 | - if($use_check_csrf && $_SERVER['REQUEST_METHOD'] !== 'GET' && Context::isInstalled() && !checkCSRF()) |
|
645 | + if ($use_check_csrf && $_SERVER['REQUEST_METHOD'] !== 'GET' && Context::isInstalled() && !checkCSRF()) |
|
646 | 646 | { |
647 | 647 | $this->error = 'msg_invalid_request'; |
648 | 648 | $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode); |
@@ -654,11 +654,11 @@ discard block |
||
654 | 654 | |
655 | 655 | // SECISSUE also check foward act method |
656 | 656 | // check REQUEST_METHOD in controller |
657 | - if($type == 'controller') |
|
657 | + if ($type == 'controller') |
|
658 | 658 | { |
659 | 659 | $allowedMethod = $xml_info->action->{$forward->act}->method; |
660 | 660 | |
661 | - if(!$allowedMethod) |
|
661 | + if (!$allowedMethod) |
|
662 | 662 | { |
663 | 663 | $allowedMethodList[0] = 'POST'; |
664 | 664 | } |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | $allowedMethodList = explode('|', strtoupper($allowedMethod)); |
668 | 668 | } |
669 | 669 | |
670 | - if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) |
|
670 | + if (!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) |
|
671 | 671 | { |
672 | 672 | $this->error = "msg_invalid_request"; |
673 | 673 | $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode); |
@@ -678,13 +678,13 @@ discard block |
||
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
681 | - if($type == "view" && Mobile::isFromMobilePhone()) |
|
681 | + if ($type == "view" && Mobile::isFromMobilePhone()) |
|
682 | 682 | { |
683 | 683 | $orig_type = "view"; |
684 | 684 | $type = "mobile"; |
685 | 685 | // create a module instance |
686 | 686 | $oModule = $this->getModuleInstance($forward->module, $type, $kind); |
687 | - if(!is_object($oModule) || !method_exists($oModule, $this->act)) |
|
687 | + if (!is_object($oModule) || !method_exists($oModule, $this->act)) |
|
688 | 688 | { |
689 | 689 | $type = $orig_type; |
690 | 690 | Mobile::setMobile(FALSE); |
@@ -696,25 +696,25 @@ discard block |
||
696 | 696 | $oModule = $this->getModuleInstance($forward->module, $type, $kind); |
697 | 697 | } |
698 | 698 | |
699 | - if(!is_object($oModule)) |
|
699 | + if (!is_object($oModule)) |
|
700 | 700 | { |
701 | 701 | $this->_setInputErrorToContext(); |
702 | 702 | $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode); |
703 | 703 | $oMessageObject->setError(-1); |
704 | 704 | $oMessageObject->setMessage('msg_module_is_not_exists'); |
705 | 705 | $oMessageObject->dispMessage(); |
706 | - if($this->httpStatusCode) |
|
706 | + if ($this->httpStatusCode) |
|
707 | 707 | { |
708 | 708 | $oMessageObject->setHttpStatusCode($this->httpStatusCode); |
709 | 709 | } |
710 | 710 | return $oMessageObject; |
711 | 711 | } |
712 | 712 | |
713 | - if($this->module == "admin" && $type == "view") |
|
713 | + if ($this->module == "admin" && $type == "view") |
|
714 | 714 | { |
715 | - if($logged_info->is_admin == 'Y') |
|
715 | + if ($logged_info->is_admin == 'Y') |
|
716 | 716 | { |
717 | - if($this->act != 'dispLayoutAdminLayoutModify') |
|
717 | + if ($this->act != 'dispLayoutAdminLayoutModify') |
|
718 | 718 | { |
719 | 719 | $oAdminView = getAdminView('admin'); |
720 | 720 | $oAdminView->makeGnbUrl($forward->module); |
@@ -734,10 +734,10 @@ discard block |
||
734 | 734 | return $oMessageObject; |
735 | 735 | } |
736 | 736 | } |
737 | - if($kind == 'admin') |
|
737 | + if ($kind == 'admin') |
|
738 | 738 | { |
739 | 739 | $grant = $oModuleModel->getGrant($this->module_info, $logged_info); |
740 | - if(!$grant->manager) |
|
740 | + if (!$grant->manager) |
|
741 | 741 | { |
742 | 742 | $this->_setInputErrorToContext(); |
743 | 743 | $this->error = 'msg_is_not_manager'; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | } |
750 | 750 | else |
751 | 751 | { |
752 | - if(!$grant->is_admin && $this->module != $this->orig_module->module && $xml_info->permission->{$this->act} != 'manager') |
|
752 | + if (!$grant->is_admin && $this->module != $this->orig_module->module && $xml_info->permission->{$this->act} != 'manager') |
|
753 | 753 | { |
754 | 754 | $this->_setInputErrorToContext(); |
755 | 755 | $this->error = 'msg_is_not_administrator'; |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | } |
763 | 763 | } |
764 | 764 | } |
765 | - else if($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act)) |
|
765 | + else if ($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act)) |
|
766 | 766 | { |
767 | 767 | $this->act = $xml_info->default_index_act; |
768 | 768 | } |
@@ -776,16 +776,16 @@ discard block |
||
776 | 776 | } |
777 | 777 | |
778 | 778 | // ruleset check... |
779 | - if(!empty($ruleset)) |
|
779 | + if (!empty($ruleset)) |
|
780 | 780 | { |
781 | 781 | $rulesetModule = $forward->module ? $forward->module : $this->module; |
782 | 782 | $rulesetFile = $oModuleModel->getValidatorFilePath($rulesetModule, $ruleset, $this->mid); |
783 | - if(!empty($rulesetFile)) |
|
783 | + if (!empty($rulesetFile)) |
|
784 | 784 | { |
785 | - if($_SESSION['XE_VALIDATOR_ERROR_LANG']) |
|
785 | + if ($_SESSION['XE_VALIDATOR_ERROR_LANG']) |
|
786 | 786 | { |
787 | 787 | $errorLang = $_SESSION['XE_VALIDATOR_ERROR_LANG']; |
788 | - foreach($errorLang as $key => $val) |
|
788 | + foreach ($errorLang as $key => $val) |
|
789 | 789 | { |
790 | 790 | Context::setLang($key, $val); |
791 | 791 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | |
795 | 795 | $Validator = new Validator($rulesetFile); |
796 | 796 | $result = $Validator->validate(); |
797 | - if(!$result) |
|
797 | + if (!$result) |
|
798 | 798 | { |
799 | 799 | $lastError = $Validator->getLastError(); |
800 | 800 | $returnUrl = Context::get('error_return_url'); |
@@ -826,26 +826,26 @@ discard block |
||
826 | 826 | 'dispLayoutPreviewWithModule' => 1 |
827 | 827 | ); |
828 | 828 | $db_use_mobile = Mobile::isMobileEnabled(); |
829 | - if($type == "view" && $this->module_info->use_mobile == "Y" && Mobile::isMobileCheckByAgent() && !isset($skipAct[Context::get('act')]) && $db_use_mobile === true) |
|
829 | + if ($type == "view" && $this->module_info->use_mobile == "Y" && Mobile::isMobileCheckByAgent() && !isset($skipAct[Context::get('act')]) && $db_use_mobile === true) |
|
830 | 830 | { |
831 | 831 | global $lang; |
832 | 832 | $header = '<style>div.xe_mobile{opacity:0.7;margin:1em 0;padding:.5em;background:#333;border:1px solid #666;border-left:0;border-right:0}p.xe_mobile{text-align:center;margin:1em 0}a.xe_mobile{color:#ff0;font-weight:bold;font-size:24px}@media only screen and (min-width:500px){a.xe_mobile{font-size:15px}}</style>'; |
833 | - $footer = '<div class="xe_mobile"><p class="xe_mobile"><a class="xe_mobile" href="' . getUrl('m', '1') . '">' . $lang->msg_pc_to_mobile . '</a></p></div>'; |
|
833 | + $footer = '<div class="xe_mobile"><p class="xe_mobile"><a class="xe_mobile" href="'.getUrl('m', '1').'">'.$lang->msg_pc_to_mobile.'</a></p></div>'; |
|
834 | 834 | Context::addHtmlHeader($header); |
835 | 835 | Context::addHtmlFooter($footer); |
836 | 836 | } |
837 | 837 | |
838 | - if(($type == 'view' || $type == 'mobile') && $kind != 'admin') |
|
838 | + if (($type == 'view' || $type == 'mobile') && $kind != 'admin') |
|
839 | 839 | { |
840 | 840 | $module_config = $oModuleModel->getModuleConfig('module'); |
841 | - if($module_config->htmlFooter) |
|
841 | + if ($module_config->htmlFooter) |
|
842 | 842 | { |
843 | 843 | Context::addHtmlFooter($module_config->htmlFooter); |
844 | 844 | } |
845 | - if($module_config->siteTitle) |
|
845 | + if ($module_config->siteTitle) |
|
846 | 846 | { |
847 | 847 | $siteTitle = Context::getBrowserTitle(); |
848 | - if(!$siteTitle) |
|
848 | + if (!$siteTitle) |
|
849 | 849 | { |
850 | 850 | Context::setBrowserTitle($module_config->siteTitle); |
851 | 851 | } |
@@ -862,18 +862,18 @@ discard block |
||
862 | 862 | $procResult = $oModule->proc(); |
863 | 863 | |
864 | 864 | $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1); |
865 | - if(!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()])) |
|
865 | + if (!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()])) |
|
866 | 866 | { |
867 | 867 | $error = $oModule->getError(); |
868 | 868 | $message = $oModule->getMessage(); |
869 | 869 | $messageType = $oModule->getMessageType(); |
870 | 870 | $redirectUrl = $oModule->getRedirectUrl(); |
871 | - if($messageType == 'error') debugPrint($message, 'ERROR'); |
|
871 | + if ($messageType == 'error') debugPrint($message, 'ERROR'); |
|
872 | 872 | |
873 | - if(!$procResult) |
|
873 | + if (!$procResult) |
|
874 | 874 | { |
875 | 875 | $this->error = $message; |
876 | - if(!$redirectUrl && Context::get('error_return_url')) |
|
876 | + if (!$redirectUrl && Context::get('error_return_url')) |
|
877 | 877 | { |
878 | 878 | $redirectUrl = Context::get('error_return_url'); |
879 | 879 | } |
@@ -886,13 +886,13 @@ discard block |
||
886 | 886 | |
887 | 887 | $_SESSION['XE_VALIDATOR_ERROR'] = $error; |
888 | 888 | $_SESSION['XE_VALIDATOR_ID'] = Context::get('xe_validator_id'); |
889 | - if($message != 'success') |
|
889 | + if ($message != 'success') |
|
890 | 890 | { |
891 | 891 | $_SESSION['XE_VALIDATOR_MESSAGE'] = $message; |
892 | 892 | } |
893 | 893 | $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType; |
894 | 894 | |
895 | - if(Context::get('xeVirtualRequestMethod') != 'xml') |
|
895 | + if (Context::get('xeVirtualRequestMethod') != 'xml') |
|
896 | 896 | { |
897 | 897 | $_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl; |
898 | 898 | } |
@@ -908,27 +908,27 @@ discard block |
||
908 | 908 | * */ |
909 | 909 | function _setInputErrorToContext() |
910 | 910 | { |
911 | - if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR')) |
|
911 | + if ($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR')) |
|
912 | 912 | { |
913 | 913 | Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']); |
914 | 914 | } |
915 | - if($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE')) |
|
915 | + if ($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE')) |
|
916 | 916 | { |
917 | 917 | Context::set('XE_VALIDATOR_MESSAGE', $_SESSION['XE_VALIDATOR_MESSAGE']); |
918 | 918 | } |
919 | - if($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE')) |
|
919 | + if ($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE')) |
|
920 | 920 | { |
921 | 921 | Context::set('XE_VALIDATOR_MESSAGE_TYPE', $_SESSION['XE_VALIDATOR_MESSAGE_TYPE']); |
922 | 922 | } |
923 | - if($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL')) |
|
923 | + if ($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL')) |
|
924 | 924 | { |
925 | 925 | Context::set('XE_VALIDATOR_RETURN_URL', $_SESSION['XE_VALIDATOR_RETURN_URL']); |
926 | 926 | } |
927 | - if($_SESSION['XE_VALIDATOR_ID'] && !Context::get('XE_VALIDATOR_ID')) |
|
927 | + if ($_SESSION['XE_VALIDATOR_ID'] && !Context::get('XE_VALIDATOR_ID')) |
|
928 | 928 | { |
929 | 929 | Context::set('XE_VALIDATOR_ID', $_SESSION['XE_VALIDATOR_ID']); |
930 | 930 | } |
931 | - if(count($_SESSION['INPUT_ERROR'])) |
|
931 | + if (count($_SESSION['INPUT_ERROR'])) |
|
932 | 932 | { |
933 | 933 | Context::set('INPUT_ERROR', $_SESSION['INPUT_ERROR']); |
934 | 934 | } |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | { |
959 | 959 | $requestVars = Context::getRequestVars(); |
960 | 960 | unset($requestVars->act, $requestVars->mid, $requestVars->vid, $requestVars->success_return_url, $requestVars->error_return_url); |
961 | - foreach($requestVars AS $key => $value) |
|
961 | + foreach ($requestVars AS $key => $value) |
|
962 | 962 | { |
963 | 963 | $_SESSION['INPUT_ERROR'][$key] = $value; |
964 | 964 | } |
@@ -972,41 +972,41 @@ discard block |
||
972 | 972 | function displayContent($oModule = NULL) |
973 | 973 | { |
974 | 974 | // If the module is not set or not an object, set error |
975 | - if(!$oModule || !is_object($oModule)) |
|
975 | + if (!$oModule || !is_object($oModule)) |
|
976 | 976 | { |
977 | 977 | $this->error = 'msg_module_is_not_exists'; |
978 | 978 | $this->httpStatusCode = '404'; |
979 | 979 | } |
980 | 980 | |
981 | 981 | // If connection to DB has a problem even though it's not install module, set error |
982 | - if($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE) |
|
982 | + if ($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE) |
|
983 | 983 | { |
984 | 984 | $this->error = 'msg_dbconnect_failed'; |
985 | 985 | } |
986 | 986 | |
987 | 987 | // Call trigger after moduleHandler proc |
988 | 988 | $output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule); |
989 | - if(!$output->toBool()) |
|
989 | + if (!$output->toBool()) |
|
990 | 990 | { |
991 | 991 | $this->error = $output->getMessage(); |
992 | 992 | } |
993 | 993 | |
994 | 994 | // Use message view object, if HTML call |
995 | 995 | $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1); |
996 | - if(!isset($methodList[Context::getRequestMethod()])) |
|
996 | + if (!isset($methodList[Context::getRequestMethod()])) |
|
997 | 997 | { |
998 | 998 | |
999 | - if($_SESSION['XE_VALIDATOR_RETURN_URL']) |
|
999 | + if ($_SESSION['XE_VALIDATOR_RETURN_URL']) |
|
1000 | 1000 | { |
1001 | 1001 | $display_handler = new DisplayHandler(); |
1002 | 1002 | $display_handler->_debugOutput(); |
1003 | 1003 | |
1004 | - header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']); |
|
1004 | + header('location:'.$_SESSION['XE_VALIDATOR_RETURN_URL']); |
|
1005 | 1005 | return; |
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | // If error occurred, handle it |
1009 | - if($this->error) |
|
1009 | + if ($this->error) |
|
1010 | 1010 | { |
1011 | 1011 | // display content with message module instance |
1012 | 1012 | $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view'; |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | $oMessageObject->setMessage($this->error); |
1016 | 1016 | $oMessageObject->dispMessage(); |
1017 | 1017 | |
1018 | - if($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200') |
|
1018 | + if ($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200') |
|
1019 | 1019 | { |
1020 | 1020 | $this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode()); |
1021 | 1021 | $oMessageObject->setTemplateFile('http_status_code'); |
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | // If module was called normally, change the templates of the module into ones of the message view module |
1025 | - if($oModule) |
|
1025 | + if ($oModule) |
|
1026 | 1026 | { |
1027 | 1027 | $oModule->setTemplatePath($oMessageObject->getTemplatePath()); |
1028 | 1028 | $oModule->setTemplateFile($oMessageObject->getTemplateFile()); |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | // Check if layout_srl exists for the module |
1040 | - if(Mobile::isFromMobilePhone()) |
|
1040 | + if (Mobile::isFromMobilePhone()) |
|
1041 | 1041 | { |
1042 | 1042 | $layout_srl = $oModule->module_info->mlayout_srl; |
1043 | 1043 | } |
@@ -1047,58 +1047,58 @@ discard block |
||
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | // if layout_srl is rollback by module, set default layout |
1050 | - if($layout_srl == -1) |
|
1050 | + if ($layout_srl == -1) |
|
1051 | 1051 | { |
1052 | 1052 | $viewType = (Mobile::isFromMobilePhone()) ? 'M' : 'P'; |
1053 | 1053 | $oLayoutAdminModel = getAdminModel('layout'); |
1054 | 1054 | $layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl); |
1055 | 1055 | } |
1056 | 1056 | |
1057 | - if($layout_srl && !$oModule->getLayoutFile()) |
|
1057 | + if ($layout_srl && !$oModule->getLayoutFile()) |
|
1058 | 1058 | { |
1059 | 1059 | |
1060 | 1060 | // If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file |
1061 | 1061 | $oLayoutModel = getModel('layout'); |
1062 | 1062 | $layout_info = $oLayoutModel->getLayout($layout_srl); |
1063 | - if($layout_info) |
|
1063 | + if ($layout_info) |
|
1064 | 1064 | { |
1065 | 1065 | |
1066 | 1066 | // Input extra_vars into $layout_info |
1067 | - if($layout_info->extra_var_count) |
|
1067 | + if ($layout_info->extra_var_count) |
|
1068 | 1068 | { |
1069 | 1069 | |
1070 | - foreach($layout_info->extra_var as $var_id => $val) |
|
1070 | + foreach ($layout_info->extra_var as $var_id => $val) |
|
1071 | 1071 | { |
1072 | - if($val->type == 'image') |
|
1072 | + if ($val->type == 'image') |
|
1073 | 1073 | { |
1074 | - if(strncmp('./files/attach/images/', $val->value, 22) === 0) |
|
1074 | + if (strncmp('./files/attach/images/', $val->value, 22) === 0) |
|
1075 | 1075 | { |
1076 | - $val->value = Context::getRequestUri() . substr($val->value, 2); |
|
1076 | + $val->value = Context::getRequestUri().substr($val->value, 2); |
|
1077 | 1077 | } |
1078 | 1078 | } |
1079 | 1079 | $layout_info->{$var_id} = $val->value; |
1080 | 1080 | } |
1081 | 1081 | } |
1082 | 1082 | // Set menus into context |
1083 | - if($layout_info->menu_count) |
|
1083 | + if ($layout_info->menu_count) |
|
1084 | 1084 | { |
1085 | - foreach($layout_info->menu as $menu_id => $menu) |
|
1085 | + foreach ($layout_info->menu as $menu_id => $menu) |
|
1086 | 1086 | { |
1087 | 1087 | // set default menu set(included home menu) |
1088 | - if(!$menu->menu_srl || $menu->menu_srl == -1) |
|
1088 | + if (!$menu->menu_srl || $menu->menu_srl == -1) |
|
1089 | 1089 | { |
1090 | 1090 | $oMenuAdminController = getAdminController('menu'); |
1091 | 1091 | $homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile(); |
1092 | 1092 | |
1093 | - if(FileHandler::exists($homeMenuCacheFile)) |
|
1093 | + if (FileHandler::exists($homeMenuCacheFile)) |
|
1094 | 1094 | { |
1095 | 1095 | include($homeMenuCacheFile); |
1096 | 1096 | } |
1097 | 1097 | |
1098 | - if(!$menu->menu_srl) |
|
1098 | + if (!$menu->menu_srl) |
|
1099 | 1099 | { |
1100 | - $menu->xml_file = str_replace('.xml.php', $homeMenuSrl . '.xml.php', $menu->xml_file); |
|
1101 | - $menu->php_file = str_replace('.php', $homeMenuSrl . '.php', $menu->php_file); |
|
1100 | + $menu->xml_file = str_replace('.xml.php', $homeMenuSrl.'.xml.php', $menu->xml_file); |
|
1101 | + $menu->php_file = str_replace('.php', $homeMenuSrl.'.php', $menu->php_file); |
|
1102 | 1102 | $layout_info->menu->{$menu_id}->menu_srl = $homeMenuSrl; |
1103 | 1103 | } |
1104 | 1104 | else |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | $php_file = FileHandler::exists($menu->php_file); |
1112 | - if($php_file) |
|
1112 | + if ($php_file) |
|
1113 | 1113 | { |
1114 | 1114 | include($php_file); |
1115 | 1115 | } |
@@ -1125,17 +1125,17 @@ discard block |
||
1125 | 1125 | |
1126 | 1126 | // If layout was modified, use the modified version |
1127 | 1127 | $edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl); |
1128 | - if(file_exists($edited_layout)) |
|
1128 | + if (file_exists($edited_layout)) |
|
1129 | 1129 | { |
1130 | 1130 | $oModule->setEditedLayoutFile($edited_layout); |
1131 | 1131 | } |
1132 | 1132 | } |
1133 | 1133 | } |
1134 | 1134 | $isLayoutDrop = Context::get('isLayoutDrop'); |
1135 | - if($isLayoutDrop) |
|
1135 | + if ($isLayoutDrop) |
|
1136 | 1136 | { |
1137 | 1137 | $kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : ''; |
1138 | - if($kind == 'admin') |
|
1138 | + if ($kind == 'admin') |
|
1139 | 1139 | { |
1140 | 1140 | $oModule->setLayoutFile('popup_layout'); |
1141 | 1141 | } |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | function &getModuleInstance($module, $type = 'view', $kind = '') |
1174 | 1174 | { |
1175 | 1175 | |
1176 | - if(__DEBUG__ == 3) |
|
1176 | + if (__DEBUG__ == 3) |
|
1177 | 1177 | { |
1178 | 1178 | $start_time = getMicroTime(); |
1179 | 1179 | } |
@@ -1183,51 +1183,51 @@ discard block |
||
1183 | 1183 | $type = strtolower($type); |
1184 | 1184 | |
1185 | 1185 | $kinds = array('svc' => 1, 'admin' => 1); |
1186 | - if(!isset($kinds[$kind])) |
|
1186 | + if (!isset($kinds[$kind])) |
|
1187 | 1187 | { |
1188 | 1188 | $kind = 'svc'; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - $key = $module . '.' . ($kind != 'admin' ? '' : 'admin') . '.' . $type; |
|
1191 | + $key = $module.'.'.($kind != 'admin' ? '' : 'admin').'.'.$type; |
|
1192 | 1192 | |
1193 | - if(is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__'])) |
|
1193 | + if (is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__'])) |
|
1194 | 1194 | { |
1195 | 1195 | $module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key]; |
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | // if there is no instance of the module in global variable, create a new one |
1199 | - if(!isset($GLOBALS['_loaded_module'][$module][$type][$kind])) |
|
1199 | + if (!isset($GLOBALS['_loaded_module'][$module][$type][$kind])) |
|
1200 | 1200 | { |
1201 | 1201 | ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name); |
1202 | 1202 | |
1203 | - if($extend_module && (!is_readable($high_class_file) || !is_readable($class_file))) |
|
1203 | + if ($extend_module && (!is_readable($high_class_file) || !is_readable($class_file))) |
|
1204 | 1204 | { |
1205 | 1205 | $module = $parent_module; |
1206 | 1206 | ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name); |
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | // Check if the base class and instance class exist |
1210 | - if(!class_exists($module, true)) |
|
1210 | + if (!class_exists($module, true)) |
|
1211 | 1211 | { |
1212 | 1212 | return NULL; |
1213 | 1213 | } |
1214 | - if(!class_exists($instance_name, true)) |
|
1214 | + if (!class_exists($instance_name, true)) |
|
1215 | 1215 | { |
1216 | 1216 | return NULL; |
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | // Create an instance |
1220 | 1220 | $oModule = new $instance_name(); |
1221 | - if(!is_object($oModule)) |
|
1221 | + if (!is_object($oModule)) |
|
1222 | 1222 | { |
1223 | 1223 | return NULL; |
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | // Load language files for the class |
1227 | - Context::loadLang($class_path . 'lang'); |
|
1228 | - if($extend_module) |
|
1227 | + Context::loadLang($class_path.'lang'); |
|
1228 | + if ($extend_module) |
|
1229 | 1229 | { |
1230 | - Context::loadLang(ModuleHandler::getModulePath($parent_module) . 'lang'); |
|
1230 | + Context::loadLang(ModuleHandler::getModulePath($parent_module).'lang'); |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | // Set variables to the instance |
@@ -1235,10 +1235,10 @@ discard block |
||
1235 | 1235 | $oModule->setModulePath($class_path); |
1236 | 1236 | |
1237 | 1237 | // If the module has a constructor, run it. |
1238 | - if(!isset($GLOBALS['_called_constructor'][$instance_name])) |
|
1238 | + if (!isset($GLOBALS['_called_constructor'][$instance_name])) |
|
1239 | 1239 | { |
1240 | 1240 | $GLOBALS['_called_constructor'][$instance_name] = TRUE; |
1241 | - if(@method_exists($oModule, $instance_name)) |
|
1241 | + if (@method_exists($oModule, $instance_name)) |
|
1242 | 1242 | { |
1243 | 1243 | $oModule->{$instance_name}(); |
1244 | 1244 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule; |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - if(__DEBUG__ == 3) |
|
1251 | + if (__DEBUG__ == 3) |
|
1252 | 1252 | { |
1253 | 1253 | $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time; |
1254 | 1254 | } |
@@ -1264,17 +1264,17 @@ discard block |
||
1264 | 1264 | $highClassFile = sprintf('%s%s%s.class.php', _XE_PATH_, $classPath, $module); |
1265 | 1265 | $highClassFile = FileHandler::getRealPath($highClassFile); |
1266 | 1266 | |
1267 | - $types = array('view','controller','model','api','wap','mobile','class'); |
|
1268 | - if(!in_array($type, $types)) |
|
1267 | + $types = array('view', 'controller', 'model', 'api', 'wap', 'mobile', 'class'); |
|
1268 | + if (!in_array($type, $types)) |
|
1269 | 1269 | { |
1270 | 1270 | $type = $types[0]; |
1271 | 1271 | } |
1272 | - if($type == 'class') |
|
1272 | + if ($type == 'class') |
|
1273 | 1273 | { |
1274 | 1274 | $instanceName = '%s'; |
1275 | 1275 | $classFile = '%s%s.%s.php'; |
1276 | 1276 | } |
1277 | - elseif($kind == 'admin' && array_search($type, $types) < 3) |
|
1277 | + elseif ($kind == 'admin' && array_search($type, $types) < 3) |
|
1278 | 1278 | { |
1279 | 1279 | $instanceName = '%sAdmin%s'; |
1280 | 1280 | $classFile = '%s%s.admin.%s.php'; |
@@ -1299,26 +1299,26 @@ discard block |
||
1299 | 1299 | function triggerCall($trigger_name, $called_position, &$obj) |
1300 | 1300 | { |
1301 | 1301 | // skip if not installed |
1302 | - if(!Context::isInstalled()) |
|
1302 | + if (!Context::isInstalled()) |
|
1303 | 1303 | { |
1304 | 1304 | return new BaseObject(); |
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | $oModuleModel = getModel('module'); |
1308 | 1308 | $triggers = $oModuleModel->getTriggers($trigger_name, $called_position); |
1309 | - if(!$triggers || count($triggers) < 1) |
|
1309 | + if (!$triggers || count($triggers) < 1) |
|
1310 | 1310 | { |
1311 | 1311 | return new BaseObject(); |
1312 | 1312 | } |
1313 | 1313 | |
1314 | 1314 | //store before trigger call time |
1315 | 1315 | $before_trigger_time = NULL; |
1316 | - if(__LOG_SLOW_TRIGGER__> 0) |
|
1316 | + if (__LOG_SLOW_TRIGGER__ > 0) |
|
1317 | 1317 | { |
1318 | 1318 | $before_trigger_time = microtime(true); |
1319 | 1319 | } |
1320 | 1320 | |
1321 | - foreach($triggers as $item) |
|
1321 | + foreach ($triggers as $item) |
|
1322 | 1322 | { |
1323 | 1323 | $module = $item->module; |
1324 | 1324 | $type = $item->type; |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | |
1327 | 1327 | // todo why don't we call a normal class object ? |
1328 | 1328 | $oModule = getModule($module, $type); |
1329 | - if(!$oModule || !method_exists($oModule, $called_method)) |
|
1329 | + if (!$oModule || !method_exists($oModule, $called_method)) |
|
1330 | 1330 | { |
1331 | 1331 | continue; |
1332 | 1332 | } |
@@ -1339,12 +1339,12 @@ discard block |
||
1339 | 1339 | $elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time; |
1340 | 1340 | |
1341 | 1341 | $slowlog = new stdClass; |
1342 | - $slowlog->caller = $trigger_name . '.' . $called_position; |
|
1343 | - $slowlog->called = $module . '.' . $called_method; |
|
1342 | + $slowlog->caller = $trigger_name.'.'.$called_position; |
|
1343 | + $slowlog->called = $module.'.'.$called_method; |
|
1344 | 1344 | $slowlog->called_extension = $module; |
1345 | - if($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog); |
|
1345 | + if ($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog); |
|
1346 | 1346 | |
1347 | - if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) |
|
1347 | + if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) |
|
1348 | 1348 | { |
1349 | 1349 | return $output; |
1350 | 1350 | } |
@@ -1429,9 +1429,9 @@ discard block |
||
1429 | 1429 | '511' => 'Network Authentication Required', |
1430 | 1430 | ); |
1431 | 1431 | $statusMessage = $statusMessageList[$code]; |
1432 | - if(!$statusMessage) |
|
1432 | + if (!$statusMessage) |
|
1433 | 1433 | { |
1434 | - $statusMessage = 'HTTP ' . $code; |
|
1434 | + $statusMessage = 'HTTP '.$code; |
|
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | Context::set('http_status_code', $code); |