GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 90ae2d...5dc740 )
by gyeong-won
07:17
created
classes/template/TemplateHandler.class.php 2 patches
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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',
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 					'getSignature', // 회원 서명
83 83
 					'printExtraImages', // new, file 아이콘 등
84 84
 				);
85
-				return preg_match('/\-\>(' . implode('|', $list) . ')\(/', $m[1]);
85
+				return preg_match('/\-\>('.implode('|', $list).')\(/', $m[1]);
86 86
 			},
87
-			'functions' => function ($m) {
87
+			'functions' => function($m) {
88 88
 				$list = array(
89 89
 					'htmlspecialchars',
90 90
 					'nl2br',
91 91
 				);
92
-				return preg_match('/^(' . implode('|', $list) . ')\(/', $m[1]);
92
+				return preg_match('/^('.implode('|', $list).')\(/', $m[1]);
93 93
 			},
94
-			'lang' => function ($m) {
94
+			'lang' => function($m) {
95 95
 				// 다국어
96 96
 				return preg_match('/^\$lang\-\>/', trim($m[1]));
97 97
 			}
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	{
109 109
 		static $oTemplate = NULL;
110 110
 
111
-		if(__DEBUG__ == 3)
111
+		if (__DEBUG__ == 3)
112 112
 		{
113
-			if(!isset($GLOBALS['__TemplateHandlerCalled__']))
113
+			if (!isset($GLOBALS['__TemplateHandlerCalled__']))
114 114
 			{
115 115
 				$GLOBALS['__TemplateHandlerCalled__'] = 1;
116 116
 			}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			}
121 121
 		}
122 122
 
123
-		if(!$oTemplate)
123
+		if (!$oTemplate)
124 124
 		{
125 125
 			$oTemplate = new TemplateHandler();
126 126
 		}
@@ -138,23 +138,23 @@  discard block
 block discarded – undo
138 138
 	protected function init($tpl_path, $tpl_filename, $tpl_file = '')
139 139
 	{
140 140
 		// verify arguments
141
-		if(substr($tpl_path, -1) != '/')
141
+		if (substr($tpl_path, -1) != '/')
142 142
 		{
143 143
 			$tpl_path .= '/';
144 144
 		}
145
-		if(!is_dir($tpl_path))
145
+		if (!is_dir($tpl_path))
146 146
 		{
147 147
 			return;
148 148
 		}
149
-		if(!file_exists($tpl_path . $tpl_filename) && file_exists($tpl_path . $tpl_filename . '.html'))
149
+		if (!file_exists($tpl_path.$tpl_filename) && file_exists($tpl_path.$tpl_filename.'.html'))
150 150
 		{
151 151
 			$tpl_filename .= '.html';
152 152
 		}
153 153
 
154 154
 		// create tpl_file variable
155
-		if(!$tpl_file)
155
+		if (!$tpl_file)
156 156
 		{
157
-			$tpl_file = $tpl_path . $tpl_filename;
157
+			$tpl_file = $tpl_path.$tpl_filename;
158 158
 		}
159 159
 
160 160
 		// set template file infos.
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 		$this->filename = $tpl_filename;
163 163
 		$this->file = $tpl_file;
164 164
 
165
-		$this->web_path = $this->xe_path . '/' . ltrim(preg_replace('@^' . preg_quote(_XE_PATH_, '@') . '|\./@', '', $this->path), '/');
165
+		$this->web_path = $this->xe_path.'/'.ltrim(preg_replace('@^'.preg_quote(_XE_PATH_, '@').'|\./@', '', $this->path), '/');
166 166
 
167 167
 		// get compiled file name
168
-		$hash = md5($this->file . __XE_VERSION__);
168
+		$hash = md5($this->file.__XE_VERSION__);
169 169
 		$this->compiled_file = "{$this->compiled_path}{$hash}.compiled.php";
170 170
 
171 171
 		$this->safeguard = $this->isSafeguard();
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		$buff = false;
189 189
 
190 190
 		// store the starting time for debug information
191
-		if(__DEBUG__ == 3)
191
+		if (__DEBUG__ == 3)
192 192
 		{
193 193
 			$start = getMicroTime();
194 194
 		}
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 		$this->init($tpl_path, $tpl_filename, $tpl_file);
198 198
 
199 199
 		// if target file does not exist exit
200
-		if(!$this->file || !file_exists($this->file))
200
+		if (!$this->file || !file_exists($this->file))
201 201
 		{
202 202
 			return "Err : '{$this->file}' template file does not exists.";
203 203
 		}
204 204
 
205 205
 		// for backward compatibility
206
-		if(is_null(self::$rootTpl))
206
+		if (is_null(self::$rootTpl))
207 207
 		{
208 208
 			self::$rootTpl = $this->file;
209 209
 		}
@@ -215,23 +215,23 @@  discard block
 block discarded – undo
215 215
 		$oCacheHandler = CacheHandler::getInstance('template');
216 216
 
217 217
 		// get cached buff
218
-		if($oCacheHandler->isSupport())
218
+		if ($oCacheHandler->isSupport())
219 219
 		{
220
-			$cache_key = 'template:' . $this->file;
220
+			$cache_key = 'template:'.$this->file;
221 221
 			$buff = $oCacheHandler->get($cache_key, $latest_mtime);
222 222
 		}
223 223
 		else
224 224
 		{
225
-			if(is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file))
225
+			if (is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file))
226 226
 			{
227
-				$buff = 'file://' . $this->compiled_file;
227
+				$buff = 'file://'.$this->compiled_file;
228 228
 			}
229 229
 		}
230 230
 
231
-		if($buff === FALSE)
231
+		if ($buff === FALSE)
232 232
 		{
233 233
 			$buff = $this->parse();
234
-			if($oCacheHandler->isSupport())
234
+			if ($oCacheHandler->isSupport())
235 235
 			{
236 236
 				$oCacheHandler->put($cache_key, $buff);
237 237
 			}
@@ -243,13 +243,13 @@  discard block
 block discarded – undo
243 243
 
244 244
 		$output = $this->_fetch($buff);
245 245
 
246
-		if($__templatehandler_root_tpl == $this->file)
246
+		if ($__templatehandler_root_tpl == $this->file)
247 247
 		{
248 248
 			$__templatehandler_root_tpl = null;
249 249
 		}
250 250
 
251 251
 		// store the ending time for debug information
252
-		if(__DEBUG__ == 3)
252
+		if (__DEBUG__ == 3)
253 253
 		{
254 254
 			$GLOBALS['__template_elapsed__'] += getMicroTime() - $start;
255 255
 		}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		$this->init($tpl_path, $tpl_filename, null);
269 269
 
270 270
 		// if target file does not exist exit
271
-		if(!$this->file || !file_exists($this->file))
271
+		if (!$this->file || !file_exists($this->file))
272 272
 		{
273 273
 			Context::close();
274 274
 			exit("Cannot find the template file: '{$this->file}'");
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	protected function parse($buff = null)
286 286
 	{
287
-		if(is_null($buff))
287
+		if (is_null($buff))
288 288
 		{
289
-			if(!is_readable($this->file))
289
+			if (!is_readable($this->file))
290 290
 			{
291 291
 				return;
292 292
 			}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 		}
297 297
 
298 298
 		// HTML tags to skip
299
-		if(is_null($this->skipTags))
299
+		if (is_null($this->skipTags))
300 300
 		{
301 301
 			$this->skipTags = array('marquee');
302 302
 		}
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 		$this->config = new stdClass();
307 307
 		$this->config->autoescape = null;
308 308
 
309
-		if(preg_match('/\<config( [^\>\/]+)/', $buff, $config_match))
309
+		if (preg_match('/\<config( [^\>\/]+)/', $buff, $config_match))
310 310
 		{
311
-			if(preg_match_all('@ (?<name>\w+)="(?<value>[^"]+)"@', $config_match[1], $config_matches, PREG_SET_ORDER))
311
+			if (preg_match_all('@ (?<name>\w+)="(?<value>[^"]+)"@', $config_match[1], $config_matches, PREG_SET_ORDER))
312 312
 			{
313
-				foreach($config_matches as $config_match)
313
+				foreach ($config_matches as $config_match)
314 314
 				{
315
-					if($config_match['name'] === 'autoescape')
315
+					if ($config_match['name'] === 'autoescape')
316 316
 					{
317 317
 						$this->config->autoescape = $config_match['value'];
318 318
 					}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			}
321 321
 		}
322 322
 
323
-		if($this->config->autoescape === 'on') $this->safeguard = true;
323
+		if ($this->config->autoescape === 'on') $this->safeguard = true;
324 324
 
325 325
 		// replace comments
326 326
 		$buff = preg_replace('@<!--//.*?-->@s', '', $buff);
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 
340 340
 		// form auto generation
341 341
 		$temp = preg_replace_callback('/(<form(?:<\?php.+?\?>|[^<>]+)*?>)(.*?)(<\/form>)/is', array($this, '_compileFormAuthGeneration'), $buff);
342
-		if($temp)
342
+		if ($temp)
343 343
 		{
344 344
 			$buff = $temp;
345 345
 		}
346 346
 
347 347
 		// prevent from calling directly before writing into file
348
-		$buff = '<?php if(!defined("__XE__"))exit;?>' . $buff;
348
+		$buff = '<?php if(!defined("__XE__"))exit;?>'.$buff;
349 349
 
350 350
 		// remove php script reopening
351 351
 		$buff = preg_replace(array('/(\n|\r\n)+/', '/(;)?( )*\?\>\<\?php([\n\t ]+)?/'), array("\n", ";\n"), $buff);
@@ -368,40 +368,40 @@  discard block
 block discarded – undo
368 368
 	private function _compileFormAuthGeneration($matches)
369 369
 	{
370 370
 		// form ruleset attribute move to hidden tag
371
-		if($matches[1])
371
+		if ($matches[1])
372 372
 		{
373 373
 			preg_match('/ruleset="([^"]*?)"/is', $matches[1], $m);
374
-			if($m[0])
374
+			if ($m[0])
375 375
 			{
376
-				$matches[1] = preg_replace('/' . addcslashes($m[0], '?$') . '/i', '', $matches[1]);
376
+				$matches[1] = preg_replace('/'.addcslashes($m[0], '?$').'/i', '', $matches[1]);
377 377
 
378
-				if(strpos($m[1], '@') !== FALSE)
378
+				if (strpos($m[1], '@') !== FALSE)
379 379
 				{
380 380
 					$path = str_replace('@', '', $m[1]);
381
-					$path = './files/ruleset/' . $path . '.xml';
381
+					$path = './files/ruleset/'.$path.'.xml';
382 382
 				}
383
-				else if(strpos($m[1], '#') !== FALSE)
383
+				else if (strpos($m[1], '#') !== FALSE)
384 384
 				{
385 385
 					$fileName = str_replace('#', '', $m[1]);
386 386
 					$fileName = str_replace('<?php echo ', '', $fileName);
387 387
 					$fileName = str_replace(' ?>', '', $fileName);
388
-					$path = '#./files/ruleset/' . $fileName . '.xml';
388
+					$path = '#./files/ruleset/'.$fileName.'.xml';
389 389
 
390 390
 					preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm);
391 391
 					$module_path = $mm[1];
392 392
 					list($rulsetFile) = explode('.', $fileName);
393
-					$autoPath = $module_path . '/ruleset/' . $rulsetFile . '.xml';
393
+					$autoPath = $module_path.'/ruleset/'.$rulsetFile.'.xml';
394 394
 					$m[1] = $rulsetFile;
395 395
 				}
396
-				else if(preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm))
396
+				else if (preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm))
397 397
 				{
398 398
 					$module_path = $mm[1];
399
-					$path = $module_path . '/ruleset/' . $m[1] . '.xml';
399
+					$path = $module_path.'/ruleset/'.$m[1].'.xml';
400 400
 				}
401 401
 
402
-				$matches[2] = '<input type="hidden" name="ruleset" value="' . $m[1] . '" />' . $matches[2];
402
+				$matches[2] = '<input type="hidden" name="ruleset" value="'.$m[1].'" />'.$matches[2];
403 403
 				//assign to addJsFile method for js dynamic recache
404
-				$matches[1] = '<?php Context::addJsFile("' . $path . '", FALSE, "", 0, "body", TRUE, "' . $autoPath . '") ?' . '>' . $matches[1];
404
+				$matches[1] = '<?php Context::addJsFile("'.$path.'", FALSE, "", 0, "body", TRUE, "'.$autoPath.'") ?'.'>'.$matches[1];
405 405
 			}
406 406
 		}
407 407
 
@@ -409,22 +409,22 @@  discard block
 block discarded – undo
409 409
 		preg_match_all('/<input[^>]* name="(act|mid|vid)"/is', $matches[2], $m2);
410 410
 		$checkVar = array('act', 'mid', 'vid');
411 411
 		$resultArray = array_diff($checkVar, $m2[1]);
412
-		if(is_array($resultArray))
412
+		if (is_array($resultArray))
413 413
 		{
414 414
 			$generatedHidden = '';
415
-			foreach($resultArray AS $key => $value)
415
+			foreach ($resultArray AS $key => $value)
416 416
 			{
417
-				$generatedHidden .= '<input type="hidden" name="' . $value . '" value="<?php echo $__Context->' . $value . ' ?>" />';
417
+				$generatedHidden .= '<input type="hidden" name="'.$value.'" value="<?php echo $__Context->'.$value.' ?>" />';
418 418
 			}
419
-			$matches[2] = $generatedHidden . $matches[2];
419
+			$matches[2] = $generatedHidden.$matches[2];
420 420
 		}
421 421
 
422 422
 		// return url generate
423
-		if(!preg_match('/no-error-return-url="true"/i', $matches[1]))
423
+		if (!preg_match('/no-error-return-url="true"/i', $matches[1]))
424 424
 		{
425 425
 			preg_match('/<input[^>]*name="error_return_url"[^>]*>/is', $matches[2], $m3);
426
-			if(!$m3[0])
427
-				$matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />' . $matches[2];
426
+			if (!$m3[0])
427
+				$matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />'.$matches[2];
428 428
 		}
429 429
 		else
430 430
 		{
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 */
443 443
 	private function _fetch($buff)
444 444
 	{
445
-		if(!$buff)
445
+		if (!$buff)
446 446
 		{
447 447
 			return;
448 448
 		}
@@ -450,20 +450,20 @@  discard block
 block discarded – undo
450 450
 		$__Context = &$GLOBALS['__Context__'];
451 451
 		$__Context->tpl_path = $this->path;
452 452
 
453
-		if($_SESSION['is_logged'])
453
+		if ($_SESSION['is_logged'])
454 454
 		{
455 455
 			$__Context->logged_info = Context::get('logged_info');
456 456
 		}
457 457
 
458 458
 		$level = ob_get_level();
459 459
 		ob_start();
460
-		if(substr($buff, 0, 7) == 'file://')
460
+		if (substr($buff, 0, 7) == 'file://')
461 461
 		{
462
-			if(__DEBUG__)
462
+			if (__DEBUG__)
463 463
 			{
464 464
 				//load cache file from disk
465 465
 				$eval_str = FileHandler::readFile(substr($buff, 7));
466
-				$eval_str_buffed = "?>" . $eval_str;
466
+				$eval_str_buffed = "?>".$eval_str;
467 467
 				@eval($eval_str_buffed);
468 468
 				$error_info = error_get_last();
469 469
 				//parse error
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 		}
480 480
 		else
481 481
 		{
482
-			$eval_str = "?>" . $buff;
482
+			$eval_str = "?>".$buff;
483 483
 			@eval($eval_str);
484 484
 			$error_info = error_get_last();
485 485
 			//parse error
@@ -508,31 +508,31 @@  discard block
 block discarded – undo
508 508
 	private function _replacePath($match)
509 509
 	{
510 510
 		//return origin conde when src value started '${'.
511
-		if(preg_match('@^\${@', $match[1]))
511
+		if (preg_match('@^\${@', $match[1]))
512 512
 		{
513 513
 			return $match[0];
514 514
 		}
515 515
 
516 516
 		//return origin code when src value include variable.
517
-		if(preg_match('@^[\'|"]\s*\.\s*\$@', $match[1]))
517
+		if (preg_match('@^[\'|"]\s*\.\s*\$@', $match[1]))
518 518
 		{
519 519
 			return $match[0];
520 520
 		}
521 521
 
522 522
 		$src = preg_replace('@^(\./)+@', '', trim($match[1]));
523 523
 
524
-		$src = $this->web_path . $src;
524
+		$src = $this->web_path.$src;
525 525
 		$src = str_replace('/./', '/', $src);
526 526
 
527 527
 		// for backward compatibility
528 528
 		$src = preg_replace('@/((?:[\w-]+/)+)\1@', '/\1', $src);
529 529
 
530
-		while(($tmp = preg_replace('@[^/]+/\.\./@', '', $src, 1)) !== $src)
530
+		while (($tmp = preg_replace('@[^/]+/\.\./@', '', $src, 1)) !== $src)
531 531
 		{
532 532
 			$src = $tmp;
533 533
 		}
534 534
 
535
-		return substr($match[0], 0, -strlen($match[1]) - 6) . "src=\"{$src}\"";
535
+		return substr($match[0], 0, -strlen($match[1]) - 6)."src=\"{$src}\"";
536 536
 	}
537 537
 
538 538
 	/**
@@ -542,19 +542,19 @@  discard block
 block discarded – undo
542 542
 	 */
543 543
 	private function _parseInline($buff)
544 544
 	{
545
-		if(!preg_match_all('/<([a-zA-Z]+\d?)(?:\s)/', $buff, $match))
545
+		if (!preg_match_all('/<([a-zA-Z]+\d?)(?:\s)/', $buff, $match))
546 546
 		{
547 547
 			return $buff;
548 548
 		}
549 549
 
550 550
 		$tags = array_diff(array_unique($match[1]), $this->skipTags);
551 551
 
552
-		if(!count($tags))
552
+		if (!count($tags))
553 553
 		{
554 554
 			return $buff;
555 555
 		}
556 556
 
557
-		$tags = '(?:' . implode('|', $tags) . ')';
557
+		$tags = '(?:'.implode('|', $tags).')';
558 558
 		$split_regex = "@(<(?>/?{$tags})(?>[^<>\{\}\"']+|<!--.*?-->|{[^}]+}|\".*?\"|'.*?'|.)*?>)@s";
559 559
 
560 560
 		$nodes = preg_split($split_regex, $buff, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -562,14 +562,14 @@  discard block
 block discarded – undo
562 562
 		// list of self closing tags
563 563
 		$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);
564 564
 
565
-		for($idx = 1, $node_len = count($nodes); $idx < $node_len; $idx+=2)
565
+		for ($idx = 1, $node_len = count($nodes); $idx < $node_len; $idx += 2)
566 566
 		{
567
-			if(!($node = $nodes[$idx]))
567
+			if (!($node = $nodes[$idx]))
568 568
 			{
569 569
 				continue;
570 570
 			}
571 571
 
572
-			if(preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches))
572
+			if (preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches))
573 573
 			{
574 574
 				// this tag
575 575
 				$tag = substr($node, 1, strpos($node, ' ') - 1);
@@ -578,37 +578,37 @@  discard block
 block discarded – undo
578 578
 				$closing = 0;
579 579
 
580 580
 				// process opening tag
581
-				foreach($matches[1] as $n => $stmt)
581
+				foreach ($matches[1] as $n => $stmt)
582 582
 				{
583 583
 					$expr = $matches[2][$n];
584 584
 					$expr = $this->_replaceVar($expr);
585 585
 					$closing++;
586 586
 
587
-					switch($stmt)
587
+					switch ($stmt)
588 588
 					{
589 589
 						case 'cond':
590 590
 							$nodes[$idx - 1] .= "<?php if({$expr}){ ?>";
591 591
 							break;
592 592
 						case 'loop':
593
-							if(!preg_match('@^(?:(.+?)=>(.+?)(?:,(.+?))?|(.*?;.*?;.*?)|(.+?)\s*=\s*(.+?))$@', $expr, $expr_m))
593
+							if (!preg_match('@^(?:(.+?)=>(.+?)(?:,(.+?))?|(.*?;.*?;.*?)|(.+?)\s*=\s*(.+?))$@', $expr, $expr_m))
594 594
 							{
595 595
 								break;
596 596
 							}
597
-							if($expr_m[1])
597
+							if ($expr_m[1])
598 598
 							{
599 599
 								$expr_m[1] = trim($expr_m[1]);
600 600
 								$expr_m[2] = trim($expr_m[2]);
601
-								if($expr_m[3])
601
+								if ($expr_m[3])
602 602
 								{
603
-									$expr_m[2] .= '=>' . trim($expr_m[3]);
603
+									$expr_m[2] .= '=>'.trim($expr_m[3]);
604 604
 								}
605 605
 								$nodes[$idx - 1] .= "<?php if({$expr_m[1]}&&count({$expr_m[1]}))foreach({$expr_m[1]} as {$expr_m[2]}){ ?>";
606 606
 							}
607
-							elseif($expr_m[4])
607
+							elseif ($expr_m[4])
608 608
 							{
609 609
 								$nodes[$idx - 1] .= "<?php for({$expr_m[4]}){ ?>";
610 610
 							}
611
-							elseif($expr_m[5])
611
+							elseif ($expr_m[5])
612 612
 							{
613 613
 								$nodes[$idx - 1] .= "<?php while({$expr_m[5]}={$expr_m[6]}){ ?>";
614 614
 							}
@@ -618,28 +618,28 @@  discard block
 block discarded – undo
618 618
 				$node = preg_replace('@\s(loop|cond)="([^"]+)"@', '', $node);
619 619
 
620 620
 				// find closing tag
621
-				$close_php = '<?php ' . str_repeat('}', $closing) . ' ?>';
621
+				$close_php = '<?php '.str_repeat('}', $closing).' ?>';
622 622
 				//  self closing tag
623
-				if($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag]))
623
+				if ($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag]))
624 624
 				{
625
-					$nodes[$idx + 1] = $close_php . $nodes[$idx + 1];
625
+					$nodes[$idx + 1] = $close_php.$nodes[$idx + 1];
626 626
 				}
627 627
 				else
628 628
 				{
629 629
 					$depth = 1;
630
-					for($i = $idx + 2; $i < $node_len; $i+=2)
630
+					for ($i = $idx + 2; $i < $node_len; $i += 2)
631 631
 					{
632 632
 						$nd = $nodes[$i];
633
-						if(strpos($nd, $tag) === 1)
633
+						if (strpos($nd, $tag) === 1)
634 634
 						{
635 635
 							$depth++;
636 636
 						}
637
-						elseif(strpos($nd, '/' . $tag) === 1)
637
+						elseif (strpos($nd, '/'.$tag) === 1)
638 638
 						{
639 639
 							$depth--;
640
-							if(!$depth)
640
+							if (!$depth)
641 641
 							{
642
-								$nodes[$i - 1] .= $nodes[$i] . $close_php;
642
+								$nodes[$i - 1] .= $nodes[$i].$close_php;
643 643
 								$nodes[$i] = '';
644 644
 								break;
645 645
 							}
@@ -648,13 +648,13 @@  discard block
 block discarded – undo
648 648
 				}
649 649
 			}
650 650
 
651
-			if(strpos($node, '|cond="') !== false)
651
+			if (strpos($node, '|cond="') !== false)
652 652
 			{
653 653
 				$node = preg_replace('@(\s[-\w:]+(?:="[^"]+?")?)\|cond="(.+?)"@s', '<?php if($2){ ?>$1<?php } ?>', $node);
654 654
 				$node = $this->_replaceVar($node);
655 655
 			}
656 656
 
657
-			if($nodes[$idx] != $node)
657
+			if ($nodes[$idx] != $node)
658 658
 			{
659 659
 				$nodes[$idx] = $node;
660 660
 			}
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 	{
676 676
 		$escape_option = 'noescape';
677 677
 
678
-		if($this->safeguard)
678
+		if ($this->safeguard)
679 679
 		{
680 680
 			$escape_option = 'autoescape';
681 681
 		}
@@ -686,14 +686,14 @@  discard block
 block discarded – undo
686 686
 		}
687 687
 
688 688
 		// {@ ... } or {$var} or {func(...)}
689
-		if($m[1])
689
+		if ($m[1])
690 690
 		{
691
-			if(preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1]))
691
+			if (preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1]))
692 692
 			{
693 693
 				return $m[0];
694 694
 			}
695 695
 			
696
-			if($m[1]{0} == '@')
696
+			if ($m[1]{0} == '@')
697 697
 			{
698 698
 				$m[1] = $this->_replaceVar(substr($m[1], 1));
699 699
 				return "<?php {$m[1]} ?>";
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 				// Get escape options.
704 704
 				foreach ($this->ignoreEscape as $key => $value)
705 705
 				{
706
-					if($this->ignoreEscape[$key]($m))
706
+					if ($this->ignoreEscape[$key]($m))
707 707
 					{
708 708
 						$escape_option = 'noescape';
709 709
 						break;
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 						$filter_option = $matches[2];
735 735
 						if (!self::_isVar($filter_option) && !preg_match("/^'.*'$/", $filter_option) && !preg_match('/^".*"$/', $filter_option))
736 736
 						{
737
-							$filter_option = "'" . escape_sqstr($filter_option) . "'";
737
+							$filter_option = "'".escape_sqstr($filter_option)."'";
738 738
 						}
739 739
 						else
740 740
 						{
@@ -833,18 +833,18 @@  discard block
 block discarded – undo
833 833
 				}
834 834
 
835 835
 				// Apply the escape option and return.
836
-				return '<?php echo ' . $this->_applyEscapeOption($var, $escape_option) . ' ?>';
836
+				return '<?php echo '.$this->_applyEscapeOption($var, $escape_option).' ?>';
837 837
 			}
838 838
 		}
839 839
 
840
-		if($m[3])
840
+		if ($m[3])
841 841
 		{
842 842
 			$attr = array();
843
-			if($m[5])
843
+			if ($m[5])
844 844
 			{
845
-				if(preg_match_all('@,(\w+)="([^"]+)"@', $m[6], $mm))
845
+				if (preg_match_all('@,(\w+)="([^"]+)"@', $m[6], $mm))
846 846
 				{
847
-					foreach($mm[1] as $idx => $name)
847
+					foreach ($mm[1] as $idx => $name)
848 848
 					{
849 849
 						$attr[$name] = $mm[2][$idx];
850 850
 					}
@@ -853,21 +853,21 @@  discard block
 block discarded – undo
853 853
 			}
854 854
 			else
855 855
 			{
856
-				if(!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm))
856
+				if (!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm))
857 857
 				{
858 858
 					return $m[0];
859 859
 				}
860
-				foreach($mm[1] as $idx => $name)
860
+				foreach ($mm[1] as $idx => $name)
861 861
 				{
862 862
 					$attr[$name] = $mm[2][$idx];
863 863
 				}
864 864
 			}
865 865
 
866
-			switch($m[3])
866
+			switch ($m[3])
867 867
 			{
868 868
 				// <!--#include--> or <include ..>
869 869
 				case 'include':
870
-					if(!$this->file || !$attr['target'])
870
+					if (!$this->file || !$attr['target'])
871 871
 					{
872 872
 						return '';
873 873
 					}
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 					$pathinfo = pathinfo($attr['target']);
876 876
 					$fileDir = $this->_getRelativeDir($pathinfo['dirname']);
877 877
 
878
-					if(!$fileDir)
878
+					if (!$fileDir)
879 879
 					{
880 880
 						return '';
881 881
 					}
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 				case 'load_js_plugin':
886 886
 					$plugin = $this->_replaceVar($m[5]);
887 887
 					$s = "<!--#JSPLUGIN:{$plugin}-->";
888
-					if(strpos($plugin, '$__Context') === false)
888
+					if (strpos($plugin, '$__Context') === false)
889 889
 					{
890 890
 						$plugin = "'{$plugin}'";
891 891
 					}
@@ -901,13 +901,13 @@  discard block
 block discarded – undo
901 901
 					$doUnload = ($m[3] === 'unload');
902 902
 					$isRemote = !!preg_match('@^(https?:)?//@i', $attr['target']);
903 903
 
904
-					if(!$isRemote)
904
+					if (!$isRemote)
905 905
 					{
906
-						if(!preg_match('@^\.?/@', $attr['target']))
906
+						if (!preg_match('@^\.?/@', $attr['target']))
907 907
 						{
908
-							$attr['target'] = './' . $attr['target'];
908
+							$attr['target'] = './'.$attr['target'];
909 909
 						}
910
-						if(substr($attr['target'], -5) == '/lang')
910
+						if (substr($attr['target'], -5) == '/lang')
911 911
 						{
912 912
 							$pathinfo['dirname'] .= '/lang';
913 913
 							$pathinfo['basename'] = '';
@@ -916,18 +916,18 @@  discard block
 block discarded – undo
916 916
 
917 917
 						$relativeDir = $this->_getRelativeDir($pathinfo['dirname']);
918 918
 
919
-						$attr['target'] = $relativeDir . '/' . $pathinfo['basename'];
919
+						$attr['target'] = $relativeDir.'/'.$pathinfo['basename'];
920 920
 					}
921 921
 
922
-					switch($pathinfo['extension'])
922
+					switch ($pathinfo['extension'])
923 923
 					{
924 924
 						case 'xml':
925
-							if($isRemote || $doUnload)
925
+							if ($isRemote || $doUnload)
926 926
 							{
927 927
 								return '';
928 928
 							}
929 929
 							// language file?
930
-							if($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang')
930
+							if ($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang')
931 931
 							{
932 932
 								$result = "Context::loadLang('{$relativeDir}');";
933 933
 							}
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 							}
938 938
 							break;
939 939
 						case 'js':
940
-							if($doUnload)
940
+							if ($doUnload)
941 941
 							{
942 942
 								$result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}');";
943 943
 							}
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 							}
949 949
 							break;
950 950
 						case 'css':
951
-							if($doUnload)
951
+							if ($doUnload)
952 952
 							{
953 953
 								$result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}','{$attr['media']}');";
954 954
 							}
@@ -961,20 +961,20 @@  discard block
 block discarded – undo
961 961
 					}
962 962
 
963 963
 					$result = "<?php {$result} ?>";
964
-					if($metafile)
964
+					if ($metafile)
965 965
 					{
966
-						$result = "<!--#Meta:{$metafile}-->" . $result;
966
+						$result = "<!--#Meta:{$metafile}-->".$result;
967 967
 					}
968 968
 
969 969
 					return $result;
970 970
 				// <config ...>
971 971
 				case 'config':
972 972
 					$result = '';
973
-					if(preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $config_matches, PREG_SET_ORDER))
973
+					if (preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $config_matches, PREG_SET_ORDER))
974 974
 					{
975
-						foreach($config_matches as $config_match)
975
+						foreach ($config_matches as $config_match)
976 976
 						{
977
-							$result .= "\$this->config->{$config_match[1]} = '" . trim(strtolower($config_match[2])) . "';";
977
+							$result .= "\$this->config->{$config_match[1]} = '".trim(strtolower($config_match[2]))."';";
978 978
 						}
979 979
 					}
980 980
 					return "<?php {$result} ?>";
@@ -982,45 +982,45 @@  discard block
 block discarded – undo
982 982
 		}
983 983
 
984 984
 		// <[email protected]> such as <!--@if($cond)-->, <!--@else-->, <!--@end-->
985
-		if($m[7])
985
+		if ($m[7])
986 986
 		{
987 987
 			$m[7] = substr($m[7], 1);
988
-			if(!$m[7])
988
+			if (!$m[7])
989 989
 			{
990
-				return '<?php ' . $this->_replaceVar($m[8]) . '{ ?>' . $m[9];
990
+				return '<?php '.$this->_replaceVar($m[8]).'{ ?>'.$m[9];
991 991
 			}
992
-			if(!preg_match('/^(?:((?:end)?(?:if|switch|for(?:each)?|while)|end)|(else(?:if)?)|(break@)?(case|default)|(break))$/', $m[7], $mm))
992
+			if (!preg_match('/^(?:((?:end)?(?:if|switch|for(?:each)?|while)|end)|(else(?:if)?)|(break@)?(case|default)|(break))$/', $m[7], $mm))
993 993
 			{
994 994
 				return '';
995 995
 			}
996
-			if($mm[1])
996
+			if ($mm[1])
997 997
 			{
998
-				if($mm[1]{0} == 'e')
998
+				if ($mm[1]{0} == 'e')
999 999
 				{
1000
-					return '<?php } ?>' . $m[9];
1000
+					return '<?php } ?>'.$m[9];
1001 1001
 				}
1002 1002
 
1003 1003
 				$precheck = '';
1004
-				if($mm[1] == 'switch')
1004
+				if ($mm[1] == 'switch')
1005 1005
 				{
1006 1006
 					$m[9] = '';
1007 1007
 				}
1008
-				elseif($mm[1] == 'foreach')
1008
+				elseif ($mm[1] == 'foreach')
1009 1009
 				{
1010 1010
 					$var = preg_replace('/^\s*\(\s*(.+?) .*$/', '$1', $m[8]);
1011 1011
 					$precheck = "if({$var}&&count({$var}))";
1012 1012
 				}
1013
-				return '<?php ' . $this->_replaceVar($precheck . $m[7] . $m[8]) . '{ ?>' . $m[9];
1013
+				return '<?php '.$this->_replaceVar($precheck.$m[7].$m[8]).'{ ?>'.$m[9];
1014 1014
 			}
1015
-			if($mm[2])
1015
+			if ($mm[2])
1016 1016
 			{
1017
-				return "<?php }{$m[7]}" . $this->_replaceVar($m[8]) . "{ ?>" . $m[9];
1017
+				return "<?php }{$m[7]}".$this->_replaceVar($m[8])."{ ?>".$m[9];
1018 1018
 			}
1019
-			if($mm[4])
1019
+			if ($mm[4])
1020 1020
 			{
1021
-				return "<?php " . ($mm[3] ? 'break;' : '') . "{$m[7]} " . trim($m[8], '()') . ": ?>" . $m[9];
1021
+				return "<?php ".($mm[3] ? 'break;' : '')."{$m[7]} ".trim($m[8], '()').": ?>".$m[9];
1022 1022
 			}
1023
-			if($mm[5])
1023
+			if ($mm[5])
1024 1024
 			{
1025 1025
 				return "<?php break; ?>";
1026 1026
 			}
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
  	 */
1035 1035
  	private function _applyEscapeOption($str, $escape_option = 'noescape')
1036 1036
  	{
1037
- 		switch($escape_option)
1037
+ 		switch ($escape_option)
1038 1038
  		{
1039 1039
  			case 'escape':
1040 1040
  				return "escape({$str}, true)";
@@ -1058,30 +1058,30 @@  discard block
 block discarded – undo
1058 1058
 		$_path = $path;
1059 1059
 
1060 1060
 		$fileDir = strtr(realpath($this->path), '\\', '/');
1061
-		if($path{0} != '/')
1061
+		if ($path{0} != '/')
1062 1062
 		{
1063
-			$path = strtr(realpath($fileDir . '/' . $path), '\\', '/');
1063
+			$path = strtr(realpath($fileDir.'/'.$path), '\\', '/');
1064 1064
 		}
1065 1065
 
1066 1066
 		// for backward compatibility
1067
-		if(!$path)
1067
+		if (!$path)
1068 1068
 		{
1069 1069
 			$dirs = explode('/', $fileDir);
1070 1070
 			$paths = explode('/', $_path);
1071 1071
 			$idx = array_search($paths[0], $dirs);
1072 1072
 
1073
-			if($idx !== false)
1073
+			if ($idx !== false)
1074 1074
 			{
1075
-				while($dirs[$idx] && $dirs[$idx] === $paths[0])
1075
+				while ($dirs[$idx] && $dirs[$idx] === $paths[0])
1076 1076
 				{
1077 1077
 					array_splice($dirs, $idx, 1);
1078 1078
 					array_shift($paths);
1079 1079
 				}
1080
-				$path = strtr(realpath($fileDir . '/' . implode('/', $paths)), '\\', '/');
1080
+				$path = strtr(realpath($fileDir.'/'.implode('/', $paths)), '\\', '/');
1081 1081
 			}
1082 1082
 		}
1083 1083
 
1084
-		$path = preg_replace('/^' . preg_quote(_XE_PATH_, '/') . '/', '', $path);
1084
+		$path = preg_replace('/^'.preg_quote(_XE_PATH_, '/').'/', '', $path);
1085 1085
 
1086 1086
 		return $path;
1087 1087
 	}
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 	 */
1105 1105
 	function _replaceVar($php)
1106 1106
 	{
1107
-		if(!strlen($php))
1107
+		if (!strlen($php))
1108 1108
 		{
1109 1109
 			return '';
1110 1110
 		}
@@ -1120,13 +1120,13 @@  discard block
 block discarded – undo
1120 1120
 		$dirSkins = '(layouts\/default|layouts\/user_layout|layouts\/xedition|layouts\/xedition\/demo|m\.layouts\/colorCode|m\.layouts\/default|m\.layouts\/simpleGray|modules\/board\/m\.skins\/default|modules\/board\/m\.skins\/simpleGray|modules\/board\/skins\/default|modules\/board\/skins\/xedition|modules\/communication\/m\.skins\/default|modules\/communication\/skins\/default|modules\/editor\/skins\/ckeditor|modules\/editor\/skins\/xpresseditor|modules\/integration_search\/skins\/default|modules\/layout\/faceoff|modules\/member\/m\.skins\/default|modules\/member\/skins\/default|modules\/message\/m\.skins\/default|modules\/message\/skins\/default|modules\/message\/skins\/xedition|modules\/page\/m\.skins\/default|modules\/page\/skins\/default|modules\/poll\/skins\/default|modules\/poll\/skins\/simple|widgets\/content\/skins\/default|widgets\/counter_status\/skins\/default|widgets\/language_select\/skins\/default|widgets\/login_info\/skins\/default|widgets\/mcontent\/skins\/default|widgetstyles\/simple)';
1121 1121
 
1122 1122
 		// 'tpl'
1123
-		if(preg_match('/^(\.\/)?(modules\/' . $dirTpl . '|common)\/tpl\//', $absPath))
1123
+		if (preg_match('/^(\.\/)?(modules\/'.$dirTpl.'|common)\/tpl\//', $absPath))
1124 1124
 		{
1125 1125
 			return true;
1126 1126
 		}
1127 1127
 
1128 1128
 		// skin, layout
1129
-		if(preg_match('/^(\.\/)?(' . $dirSkin . '\//', $absPath))
1129
+		if (preg_match('/^(\.\/)?('.$dirSkin.'\//', $absPath))
1130 1130
 		{
1131 1131
 			return true;
1132 1132
 		}
Please login to merge, or discard this patch.
Braces   +31 added lines, -48 removed lines patch added patch discarded remove patch
@@ -113,8 +113,7 @@  discard block
 block discarded – undo
113 113
 			if(!isset($GLOBALS['__TemplateHandlerCalled__']))
114 114
 			{
115 115
 				$GLOBALS['__TemplateHandlerCalled__'] = 1;
116
-			}
117
-			else
116
+			} else
118 117
 			{
119 118
 				$GLOBALS['__TemplateHandlerCalled__']++;
120 119
 			}
@@ -219,8 +218,7 @@  discard block
 block discarded – undo
219 218
 		{
220 219
 			$cache_key = 'template:' . $this->file;
221 220
 			$buff = $oCacheHandler->get($cache_key, $latest_mtime);
222
-		}
223
-		else
221
+		} else
224 222
 		{
225 223
 			if(is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file))
226 224
 			{
@@ -234,8 +232,7 @@  discard block
 block discarded – undo
234 232
 			if($oCacheHandler->isSupport())
235 233
 			{
236 234
 				$oCacheHandler->put($cache_key, $buff);
237
-			}
238
-			else
235
+			} else
239 236
 			{
240 237
 				FileHandler::writeFile($this->compiled_file, $buff);
241 238
 			}
@@ -320,7 +317,9 @@  discard block
 block discarded – undo
320 317
 			}
321 318
 		}
322 319
 
323
-		if($this->config->autoescape === 'on') $this->safeguard = true;
320
+		if($this->config->autoescape === 'on') {
321
+			$this->safeguard = true;
322
+		}
324 323
 
325 324
 		// replace comments
326 325
 		$buff = preg_replace('@<!--//.*?-->@s', '', $buff);
@@ -379,8 +378,7 @@  discard block
 block discarded – undo
379 378
 				{
380 379
 					$path = str_replace('@', '', $m[1]);
381 380
 					$path = './files/ruleset/' . $path . '.xml';
382
-				}
383
-				else if(strpos($m[1], '#') !== FALSE)
381
+				} else if(strpos($m[1], '#') !== FALSE)
384 382
 				{
385 383
 					$fileName = str_replace('#', '', $m[1]);
386 384
 					$fileName = str_replace('<?php echo ', '', $fileName);
@@ -392,8 +390,7 @@  discard block
 block discarded – undo
392 390
 					list($rulsetFile) = explode('.', $fileName);
393 391
 					$autoPath = $module_path . '/ruleset/' . $rulsetFile . '.xml';
394 392
 					$m[1] = $rulsetFile;
395
-				}
396
-				else if(preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm))
393
+				} else if(preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm))
397 394
 				{
398 395
 					$module_path = $mm[1];
399 396
 					$path = $module_path . '/ruleset/' . $m[1] . '.xml';
@@ -423,10 +420,10 @@  discard block
 block discarded – undo
423 420
 		if(!preg_match('/no-error-return-url="true"/i', $matches[1]))
424 421
 		{
425 422
 			preg_match('/<input[^>]*name="error_return_url"[^>]*>/is', $matches[2], $m3);
426
-			if(!$m3[0])
427
-				$matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />' . $matches[2];
428
-		}
429
-		else
423
+			if(!$m3[0]) {
424
+							$matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />' . $matches[2];
425
+			}
426
+		} else
430 427
 		{
431 428
 			$matches[1] = preg_replace('/no-error-return-url="true"/i', '', $matches[1]);
432 429
 		}
@@ -471,13 +468,11 @@  discard block
 block discarded – undo
471 468
 				{
472 469
 				    throw new Exception("Error Parsing Template - {$error_info['message']} in template file {$this->file}");
473 470
 				}
474
-			}
475
-			else
471
+			} else
476 472
 			{
477 473
 				include(substr($buff, 7));
478 474
 			}
479
-		}
480
-		else
475
+		} else
481 476
 		{
482 477
 			$eval_str = "?>" . $buff;
483 478
 			@eval($eval_str);
@@ -603,12 +598,10 @@  discard block
 block discarded – undo
603 598
 									$expr_m[2] .= '=>' . trim($expr_m[3]);
604 599
 								}
605 600
 								$nodes[$idx - 1] .= "<?php if({$expr_m[1]}&&count({$expr_m[1]}))foreach({$expr_m[1]} as {$expr_m[2]}){ ?>";
606
-							}
607
-							elseif($expr_m[4])
601
+							} elseif($expr_m[4])
608 602
 							{
609 603
 								$nodes[$idx - 1] .= "<?php for({$expr_m[4]}){ ?>";
610
-							}
611
-							elseif($expr_m[5])
604
+							} elseif($expr_m[5])
612 605
 							{
613 606
 								$nodes[$idx - 1] .= "<?php while({$expr_m[5]}={$expr_m[6]}){ ?>";
614 607
 							}
@@ -623,8 +616,7 @@  discard block
 block discarded – undo
623 616
 				if($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag]))
624 617
 				{
625 618
 					$nodes[$idx + 1] = $close_php . $nodes[$idx + 1];
626
-				}
627
-				else
619
+				} else
628 620
 				{
629 621
 					$depth = 1;
630 622
 					for($i = $idx + 2; $i < $node_len; $i+=2)
@@ -633,8 +625,7 @@  discard block
 block discarded – undo
633 625
 						if(strpos($nd, $tag) === 1)
634 626
 						{
635 627
 							$depth++;
636
-						}
637
-						elseif(strpos($nd, '/' . $tag) === 1)
628
+						} elseif(strpos($nd, '/' . $tag) === 1)
638 629
 						{
639 630
 							$depth--;
640 631
 							if(!$depth)
@@ -697,8 +688,7 @@  discard block
 block discarded – undo
697 688
 			{
698 689
 				$m[1] = $this->_replaceVar(substr($m[1], 1));
699 690
 				return "<?php {$m[1]} ?>";
700
-			}
701
-			else
691
+			} else
702 692
 			{
703 693
 				// Get escape options.
704 694
 				foreach ($this->ignoreEscape as $key => $value)
@@ -715,8 +705,7 @@  discard block
 block discarded – undo
715 705
 				{
716 706
 					$m[1] = $mm[1];
717 707
 					$filters = array_map('trim', explode_with_escape('|', substr($mm[2], 1)));
718
-				}
719
-				else
708
+				} else
720 709
 				{
721 710
 					$filters = array();
722 711
 				}
@@ -735,13 +724,11 @@  discard block
 block discarded – undo
735 724
 						if (!self::_isVar($filter_option) && !preg_match("/^'.*'$/", $filter_option) && !preg_match('/^".*"$/', $filter_option))
736 725
 						{
737 726
 							$filter_option = "'" . escape_sqstr($filter_option) . "'";
738
-						}
739
-						else
727
+						} else
740 728
 						{
741 729
 							$filter_option = self::_replaceVar($filter_option);
742 730
 						}
743
-					}
744
-					else
731
+					} else
745 732
 					{
746 733
 						$filter_option = null;
747 734
 					}
@@ -817,8 +804,7 @@  discard block
 block discarded – undo
817 804
 							{
818 805
 								$filter_option = $this->_applyEscapeOption($filter_option, 'autoescape');
819 806
 								$var = "'<a href=\"' . {$filter_option} . '\">' . {$var} . '</a>'";
820
-							}
821
-							else
807
+							} else
822 808
 							{
823 809
 								$var = "'<a href=\"' . {$var} . '\">' . {$var} . '</a>'";
824 810
 							}
@@ -850,8 +836,7 @@  discard block
 block discarded – undo
850 836
 					}
851 837
 				}
852 838
 				$attr['target'] = $m[5];
853
-			}
854
-			else
839
+			} else
855 840
 			{
856 841
 				if(!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm))
857 842
 				{
@@ -930,8 +915,7 @@  discard block
 block discarded – undo
930 915
 							if($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang')
931 916
 							{
932 917
 								$result = "Context::loadLang('{$relativeDir}');";
933
-							}
934
-							else
918
+							} else
935 919
 							{
936 920
 								$result = "require_once('./classes/xml/XmlJsFilter.class.php');\$__xmlFilter=new XmlJsFilter('{$relativeDir}','{$pathinfo['basename']}');\$__xmlFilter->compile();";
937 921
 							}
@@ -940,8 +924,7 @@  discard block
 block discarded – undo
940 924
 							if($doUnload)
941 925
 							{
942 926
 								$result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}');";
943
-							}
944
-							else
927
+							} else
945 928
 							{
946 929
 								$metafile = $attr['target'];
947 930
 								$result = "\$__tmp=array('{$attr['target']}','{$attr['type']}','{$attr['targetie']}','{$attr['index']}');Context::loadFile(\$__tmp);unset(\$__tmp);";
@@ -951,8 +934,7 @@  discard block
 block discarded – undo
951 934
 							if($doUnload)
952 935
 							{
953 936
 								$result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}','{$attr['media']}');";
954
-							}
955
-							else
937
+							} else
956 938
 							{
957 939
 								$metafile = $attr['target'];
958 940
 								$result = "\$__tmp=array('{$attr['target']}','{$attr['media']}','{$attr['targetie']}','{$attr['index']}');Context::loadFile(\$__tmp);unset(\$__tmp);";
@@ -1004,8 +986,7 @@  discard block
 block discarded – undo
1004 986
 				if($mm[1] == 'switch')
1005 987
 				{
1006 988
 					$m[9] = '';
1007
-				}
1008
-				elseif($mm[1] == 'foreach')
989
+				} elseif($mm[1] == 'foreach')
1009 990
 				{
1010 991
 					$var = preg_replace('/^\s*\(\s*(.+?) .*$/', '$1', $m[8]);
1011 992
 					$precheck = "if({$var}&&count({$var}))";
@@ -1113,7 +1094,9 @@  discard block
 block discarded – undo
1113 1094
 
1114 1095
 	function isSafeguard()
1115 1096
 	{
1116
-		if ($this->dbinfo->safeguard === 'Y') return true;
1097
+		if ($this->dbinfo->safeguard === 'Y') {
1098
+			return true;
1099
+		}
1117 1100
 
1118 1101
 		$absPath = str_replace(_XE_PATH_, '', $this->path);
1119 1102
 		$dirTpl = '(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)';
Please login to merge, or discard this patch.