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
Pull Request — develop (#2403)
by
unknown
07:20
created
classes/template/TemplateHandler.class.php 1 patch
Spacing   +149 added lines, -149 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,18 +33,18 @@  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
-			'functions' => function ($m) {
40
+			'functions' => function($m) {
41 41
 				$list = array(
42 42
 					'htmlspecialchars',
43 43
 					'nl2br',
44 44
 				);
45
-				return preg_match('/^(' . implode('|', $list) . ')\(/', $m[1]);
45
+				return preg_match('/^('.implode('|', $list).')\(/', $m[1]);
46 46
 			},
47
-			'lang' => function ($m) {
47
+			'lang' => function($m) {
48 48
 				// 다국어
49 49
 				return preg_match('/^\$lang\-\>/', trim($m[1]));
50 50
 			}
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	{
62 62
 		static $oTemplate = NULL;
63 63
 
64
-		if(__DEBUG__ == 3)
64
+		if (__DEBUG__ == 3)
65 65
 		{
66
-			if(!isset($GLOBALS['__TemplateHandlerCalled__']))
66
+			if (!isset($GLOBALS['__TemplateHandlerCalled__']))
67 67
 			{
68 68
 				$GLOBALS['__TemplateHandlerCalled__'] = 1;
69 69
 			}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 			}
74 74
 		}
75 75
 
76
-		if(!$oTemplate)
76
+		if (!$oTemplate)
77 77
 		{
78 78
 			$oTemplate = new TemplateHandler();
79 79
 		}
@@ -91,23 +91,23 @@  discard block
 block discarded – undo
91 91
 	protected function init($tpl_path, $tpl_filename, $tpl_file = '')
92 92
 	{
93 93
 		// verify arguments
94
-		if(substr($tpl_path, -1) != '/')
94
+		if (substr($tpl_path, -1) != '/')
95 95
 		{
96 96
 			$tpl_path .= '/';
97 97
 		}
98
-		if(!is_dir($tpl_path))
98
+		if (!is_dir($tpl_path))
99 99
 		{
100 100
 			return;
101 101
 		}
102
-		if(!file_exists($tpl_path . $tpl_filename) && file_exists($tpl_path . $tpl_filename . '.html'))
102
+		if (!file_exists($tpl_path.$tpl_filename) && file_exists($tpl_path.$tpl_filename.'.html'))
103 103
 		{
104 104
 			$tpl_filename .= '.html';
105 105
 		}
106 106
 
107 107
 		// create tpl_file variable
108
-		if(!$tpl_file)
108
+		if (!$tpl_file)
109 109
 		{
110
-			$tpl_file = $tpl_path . $tpl_filename;
110
+			$tpl_file = $tpl_path.$tpl_filename;
111 111
 		}
112 112
 
113 113
 		// set template file infos.
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
 		$this->filename = $tpl_filename;
116 116
 		$this->file = $tpl_file;
117 117
 
118
-		$this->web_path = $this->xe_path . '/' . ltrim(preg_replace('@^' . preg_quote(_XE_PATH_, '@') . '|\./@', '', $this->path), '/');
118
+		$this->web_path = $this->xe_path.'/'.ltrim(preg_replace('@^'.preg_quote(_XE_PATH_, '@').'|\./@', '', $this->path), '/');
119 119
 
120 120
 		// get compiled file name
121
-		$hash = md5($this->file . __XE_VERSION__);
121
+		$hash = md5($this->file.__XE_VERSION__);
122 122
 		$this->compiled_file = "{$this->compiled_path}{$hash}.compiled.php";
123 123
 
124 124
 		$this->autoescape = $this->isAutoescape();
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$buff = false;
142 142
 
143 143
 		// store the starting time for debug information
144
-		if(__DEBUG__ == 3)
144
+		if (__DEBUG__ == 3)
145 145
 		{
146 146
 			$start = getMicroTime();
147 147
 		}
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 		$this->init($tpl_path, $tpl_filename, $tpl_file);
151 151
 
152 152
 		// if target file does not exist exit
153
-		if(!$this->file || !file_exists($this->file))
153
+		if (!$this->file || !file_exists($this->file))
154 154
 		{
155 155
 			return "Err : '{$this->file}' template file does not exists.";
156 156
 		}
157 157
 
158 158
 		// for backward compatibility
159
-		if(is_null(self::$rootTpl))
159
+		if (is_null(self::$rootTpl))
160 160
 		{
161 161
 			self::$rootTpl = $this->file;
162 162
 		}
@@ -168,23 +168,23 @@  discard block
 block discarded – undo
168 168
 		$oCacheHandler = CacheHandler::getInstance('template');
169 169
 
170 170
 		// get cached buff
171
-		if($oCacheHandler->isSupport())
171
+		if ($oCacheHandler->isSupport())
172 172
 		{
173
-			$cache_key = 'template:' . $this->file;
173
+			$cache_key = 'template:'.$this->file;
174 174
 			$buff = $oCacheHandler->get($cache_key, $latest_mtime);
175 175
 		}
176 176
 		else
177 177
 		{
178
-			if(is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file))
178
+			if (is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file))
179 179
 			{
180
-				$buff = 'file://' . $this->compiled_file;
180
+				$buff = 'file://'.$this->compiled_file;
181 181
 			}
182 182
 		}
183 183
 
184
-		if($buff === FALSE)
184
+		if ($buff === FALSE)
185 185
 		{
186 186
 			$buff = $this->parse();
187
-			if($oCacheHandler->isSupport())
187
+			if ($oCacheHandler->isSupport())
188 188
 			{
189 189
 				$oCacheHandler->put($cache_key, $buff);
190 190
 			}
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
 
197 197
 		$output = $this->_fetch($buff);
198 198
 
199
-		if($__templatehandler_root_tpl == $this->file)
199
+		if ($__templatehandler_root_tpl == $this->file)
200 200
 		{
201 201
 			$__templatehandler_root_tpl = null;
202 202
 		}
203 203
 
204 204
 		// store the ending time for debug information
205
-		if(__DEBUG__ == 3)
205
+		if (__DEBUG__ == 3)
206 206
 		{
207 207
 			$GLOBALS['__template_elapsed__'] += getMicroTime() - $start;
208 208
 		}
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		$this->init($tpl_path, $tpl_filename, null);
222 222
 
223 223
 		// if target file does not exist exit
224
-		if(!$this->file || !file_exists($this->file))
224
+		if (!$this->file || !file_exists($this->file))
225 225
 		{
226 226
 			Context::close();
227 227
 			exit("Cannot find the template file: '{$this->file}'");
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	protected function parse($buff = null)
239 239
 	{
240
-		if(is_null($buff))
240
+		if (is_null($buff))
241 241
 		{
242
-			if(!is_readable($this->file))
242
+			if (!is_readable($this->file))
243 243
 			{
244 244
 				return;
245 245
 			}
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		}
250 250
 
251 251
 		// HTML tags to skip
252
-		if(is_null($this->skipTags))
252
+		if (is_null($this->skipTags))
253 253
 		{
254 254
 			$this->skipTags = array('marquee');
255 255
 		}
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
 		$this->config = new stdClass();
260 260
 		$this->config->autoescape = null;
261 261
 
262
-		if(preg_match('/\<config( [^\>\/]+)/', $buff, $config_match))
262
+		if (preg_match('/\<config( [^\>\/]+)/', $buff, $config_match))
263 263
 		{
264
-			if(preg_match_all('@ (?<name>\w+)="(?<value>[^"]+)"@', $config_match[1], $config_matches, PREG_SET_ORDER))
264
+			if (preg_match_all('@ (?<name>\w+)="(?<value>[^"]+)"@', $config_match[1], $config_matches, PREG_SET_ORDER))
265 265
 			{
266
-				foreach($config_matches as $config_match)
266
+				foreach ($config_matches as $config_match)
267 267
 				{
268
-					if($config_match['name'] === 'autoescape')
268
+					if ($config_match['name'] === 'autoescape')
269 269
 					{
270 270
 						$this->config->autoescape = $config_match['value'];
271 271
 					}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			}
274 274
 		}
275 275
 
276
-		if($this->config->autoescape === 'on') $this->autoescape = true;
276
+		if ($this->config->autoescape === 'on') $this->autoescape = true;
277 277
 
278 278
 		// replace comments
279 279
 		$buff = preg_replace('@<!--//.*?-->@s', '', $buff);
@@ -292,13 +292,13 @@  discard block
 block discarded – undo
292 292
 
293 293
 		// form auto generation
294 294
 		$temp = preg_replace_callback('/(<form(?:<\?php.+?\?>|[^<>]+)*?>)(.*?)(<\/form>)/is', array($this, '_compileFormAuthGeneration'), $buff);
295
-		if($temp)
295
+		if ($temp)
296 296
 		{
297 297
 			$buff = $temp;
298 298
 		}
299 299
 
300 300
 		// prevent from calling directly before writing into file
301
-		$buff = '<?php if(!defined("__XE__"))exit;?>' . $buff;
301
+		$buff = '<?php if(!defined("__XE__"))exit;?>'.$buff;
302 302
 
303 303
 		// remove php script reopening
304 304
 		$buff = preg_replace(array('/(\n|\r\n)+/', '/(;)?( )*\?\>\<\?php([\n\t ]+)?/'), array("\n", ";\n"), $buff);
@@ -321,40 +321,40 @@  discard block
 block discarded – undo
321 321
 	private function _compileFormAuthGeneration($matches)
322 322
 	{
323 323
 		// form ruleset attribute move to hidden tag
324
-		if($matches[1])
324
+		if ($matches[1])
325 325
 		{
326 326
 			preg_match('/ruleset="([^"]*?)"/is', $matches[1], $m);
327
-			if($m[0])
327
+			if ($m[0])
328 328
 			{
329
-				$matches[1] = preg_replace('/' . addcslashes($m[0], '?$') . '/i', '', $matches[1]);
329
+				$matches[1] = preg_replace('/'.addcslashes($m[0], '?$').'/i', '', $matches[1]);
330 330
 
331
-				if(strpos($m[1], '@') !== FALSE)
331
+				if (strpos($m[1], '@') !== FALSE)
332 332
 				{
333 333
 					$path = str_replace('@', '', $m[1]);
334
-					$path = './files/ruleset/' . $path . '.xml';
334
+					$path = './files/ruleset/'.$path.'.xml';
335 335
 				}
336
-				else if(strpos($m[1], '#') !== FALSE)
336
+				else if (strpos($m[1], '#') !== FALSE)
337 337
 				{
338 338
 					$fileName = str_replace('#', '', $m[1]);
339 339
 					$fileName = str_replace('<?php echo ', '', $fileName);
340 340
 					$fileName = str_replace(' ?>', '', $fileName);
341
-					$path = '#./files/ruleset/' . $fileName . '.xml';
341
+					$path = '#./files/ruleset/'.$fileName.'.xml';
342 342
 
343 343
 					preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm);
344 344
 					$module_path = $mm[1];
345 345
 					list($rulsetFile) = explode('.', $fileName);
346
-					$autoPath = $module_path . '/ruleset/' . $rulsetFile . '.xml';
346
+					$autoPath = $module_path.'/ruleset/'.$rulsetFile.'.xml';
347 347
 					$m[1] = $rulsetFile;
348 348
 				}
349
-				else if(preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm))
349
+				else if (preg_match('@(?:^|\.?/)(modules/[\w-]+)@', $this->path, $mm))
350 350
 				{
351 351
 					$module_path = $mm[1];
352
-					$path = $module_path . '/ruleset/' . $m[1] . '.xml';
352
+					$path = $module_path.'/ruleset/'.$m[1].'.xml';
353 353
 				}
354 354
 
355
-				$matches[2] = '<input type="hidden" name="ruleset" value="' . $m[1] . '" />' . $matches[2];
355
+				$matches[2] = '<input type="hidden" name="ruleset" value="'.$m[1].'" />'.$matches[2];
356 356
 				//assign to addJsFile method for js dynamic recache
357
-				$matches[1] = '<?php Context::addJsFile("' . $path . '", FALSE, "", 0, "body", TRUE, "' . $autoPath . '") ?' . '>' . $matches[1];
357
+				$matches[1] = '<?php Context::addJsFile("'.$path.'", FALSE, "", 0, "body", TRUE, "'.$autoPath.'") ?'.'>'.$matches[1];
358 358
 			}
359 359
 		}
360 360
 
@@ -362,22 +362,22 @@  discard block
 block discarded – undo
362 362
 		preg_match_all('/<input[^>]* name="(act|mid|vid)"/is', $matches[2], $m2);
363 363
 		$checkVar = array('act', 'mid', 'vid');
364 364
 		$resultArray = array_diff($checkVar, $m2[1]);
365
-		if(is_array($resultArray))
365
+		if (is_array($resultArray))
366 366
 		{
367 367
 			$generatedHidden = '';
368
-			foreach($resultArray AS $key => $value)
368
+			foreach ($resultArray AS $key => $value)
369 369
 			{
370
-				$generatedHidden .= '<input type="hidden" name="' . $value . '" value="<?php echo $__Context->' . $value . ' ?>" />';
370
+				$generatedHidden .= '<input type="hidden" name="'.$value.'" value="<?php echo $__Context->'.$value.' ?>" />';
371 371
 			}
372
-			$matches[2] = $generatedHidden . $matches[2];
372
+			$matches[2] = $generatedHidden.$matches[2];
373 373
 		}
374 374
 
375 375
 		// return url generate
376
-		if(!preg_match('/no-error-return-url="true"/i', $matches[1]))
376
+		if (!preg_match('/no-error-return-url="true"/i', $matches[1]))
377 377
 		{
378 378
 			preg_match('/<input[^>]*name="error_return_url"[^>]*>/is', $matches[2], $m3);
379
-			if(!$m3[0])
380
-				$matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />' . $matches[2];
379
+			if (!$m3[0])
380
+				$matches[2] = '<input type="hidden" name="error_return_url" value="<?php echo htmlspecialchars(getRequestUriByServerEnviroment(), ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" />'.$matches[2];
381 381
 		}
382 382
 		else
383 383
 		{
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 */
396 396
 	private function _fetch($buff)
397 397
 	{
398
-		if(!$buff)
398
+		if (!$buff)
399 399
 		{
400 400
 			return;
401 401
 		}
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 		$__Context = &$GLOBALS['__Context__'];
404 404
 		$__Context->tpl_path = $this->path;
405 405
 
406
-		if($_SESSION['is_logged'])
406
+		if ($_SESSION['is_logged'])
407 407
 		{
408 408
 			$__Context->logged_info = Context::get('logged_info');
409 409
 		}
410 410
 
411 411
 		$level = ob_get_level();
412 412
 		ob_start();
413
-		if(substr($buff, 0, 7) == 'file://')
413
+		if (substr($buff, 0, 7) == 'file://')
414 414
 		{
415
-			if(__DEBUG__)
415
+			if (__DEBUG__)
416 416
 			{
417 417
 				//load cache file from disk
418 418
 				$eval_str = FileHandler::readFile(substr($buff, 7));
419
-				$eval_str_buffed = "?>" . $eval_str;
419
+				$eval_str_buffed = "?>".$eval_str;
420 420
 				@eval($eval_str_buffed);
421 421
 				$error_info = error_get_last();
422 422
 				//parse error
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		}
433 433
 		else
434 434
 		{
435
-			$eval_str = "?>" . $buff;
435
+			$eval_str = "?>".$buff;
436 436
 			@eval($eval_str);
437 437
 			$error_info = error_get_last();
438 438
 			//parse error
@@ -461,31 +461,31 @@  discard block
 block discarded – undo
461 461
 	private function _replacePath($match)
462 462
 	{
463 463
 		//return origin conde when src value started '${'.
464
-		if(preg_match('@^\${@', $match[1]))
464
+		if (preg_match('@^\${@', $match[1]))
465 465
 		{
466 466
 			return $match[0];
467 467
 		}
468 468
 
469 469
 		//return origin code when src value include variable.
470
-		if(preg_match('@^[\'|"]\s*\.\s*\$@', $match[1]))
470
+		if (preg_match('@^[\'|"]\s*\.\s*\$@', $match[1]))
471 471
 		{
472 472
 			return $match[0];
473 473
 		}
474 474
 
475 475
 		$src = preg_replace('@^(\./)+@', '', trim($match[1]));
476 476
 
477
-		$src = $this->web_path . $src;
477
+		$src = $this->web_path.$src;
478 478
 		$src = str_replace('/./', '/', $src);
479 479
 
480 480
 		// for backward compatibility
481 481
 		$src = preg_replace('@/((?:[\w-]+/)+)\1@', '/\1', $src);
482 482
 
483
-		while(($tmp = preg_replace('@[^/]+/\.\./@', '', $src, 1)) !== $src)
483
+		while (($tmp = preg_replace('@[^/]+/\.\./@', '', $src, 1)) !== $src)
484 484
 		{
485 485
 			$src = $tmp;
486 486
 		}
487 487
 
488
-		return substr($match[0], 0, -strlen($match[1]) - 6) . "src=\"{$src}\"";
488
+		return substr($match[0], 0, -strlen($match[1]) - 6)."src=\"{$src}\"";
489 489
 	}
490 490
 
491 491
 	/**
@@ -495,19 +495,19 @@  discard block
 block discarded – undo
495 495
 	 */
496 496
 	private function _parseInline($buff)
497 497
 	{
498
-		if(!preg_match_all('/<([a-zA-Z]+\d?)(?:\s)/', $buff, $match))
498
+		if (!preg_match_all('/<([a-zA-Z]+\d?)(?:\s)/', $buff, $match))
499 499
 		{
500 500
 			return $buff;
501 501
 		}
502 502
 
503 503
 		$tags = array_diff(array_unique($match[1]), $this->skipTags);
504 504
 
505
-		if(!count($tags))
505
+		if (!count($tags))
506 506
 		{
507 507
 			return $buff;
508 508
 		}
509 509
 
510
-		$tags = '(?:' . implode('|', $tags) . ')';
510
+		$tags = '(?:'.implode('|', $tags).')';
511 511
 		$split_regex = "@(<(?>/?{$tags})(?>[^<>\{\}\"']+|<!--.*?-->|{[^}]+}|\".*?\"|'.*?'|.)*?>)@s";
512 512
 
513 513
 		$nodes = preg_split($split_regex, $buff, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -515,14 +515,14 @@  discard block
 block discarded – undo
515 515
 		// list of self closing tags
516 516
 		$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);
517 517
 
518
-		for($idx = 1, $node_len = count($nodes); $idx < $node_len; $idx+=2)
518
+		for ($idx = 1, $node_len = count($nodes); $idx < $node_len; $idx += 2)
519 519
 		{
520
-			if(!($node = $nodes[$idx]))
520
+			if (!($node = $nodes[$idx]))
521 521
 			{
522 522
 				continue;
523 523
 			}
524 524
 
525
-			if(preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches))
525
+			if (preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches))
526 526
 			{
527 527
 				// this tag
528 528
 				$tag = substr($node, 1, strpos($node, ' ') - 1);
@@ -531,37 +531,37 @@  discard block
 block discarded – undo
531 531
 				$closing = 0;
532 532
 
533 533
 				// process opening tag
534
-				foreach($matches[1] as $n => $stmt)
534
+				foreach ($matches[1] as $n => $stmt)
535 535
 				{
536 536
 					$expr = $matches[2][$n];
537 537
 					$expr = $this->_replaceVar($expr);
538 538
 					$closing++;
539 539
 
540
-					switch($stmt)
540
+					switch ($stmt)
541 541
 					{
542 542
 						case 'cond':
543 543
 							$nodes[$idx - 1] .= "<?php if({$expr}){ ?>";
544 544
 							break;
545 545
 						case 'loop':
546
-							if(!preg_match('@^(?:(.+?)=>(.+?)(?:,(.+?))?|(.*?;.*?;.*?)|(.+?)\s*=\s*(.+?))$@', $expr, $expr_m))
546
+							if (!preg_match('@^(?:(.+?)=>(.+?)(?:,(.+?))?|(.*?;.*?;.*?)|(.+?)\s*=\s*(.+?))$@', $expr, $expr_m))
547 547
 							{
548 548
 								break;
549 549
 							}
550
-							if($expr_m[1])
550
+							if ($expr_m[1])
551 551
 							{
552 552
 								$expr_m[1] = trim($expr_m[1]);
553 553
 								$expr_m[2] = trim($expr_m[2]);
554
-								if($expr_m[3])
554
+								if ($expr_m[3])
555 555
 								{
556
-									$expr_m[2] .= '=>' . trim($expr_m[3]);
556
+									$expr_m[2] .= '=>'.trim($expr_m[3]);
557 557
 								}
558 558
 								$nodes[$idx - 1] .= "<?php if({$expr_m[1]}&&count({$expr_m[1]}))foreach({$expr_m[1]} as {$expr_m[2]}){ ?>";
559 559
 							}
560
-							elseif($expr_m[4])
560
+							elseif ($expr_m[4])
561 561
 							{
562 562
 								$nodes[$idx - 1] .= "<?php for({$expr_m[4]}){ ?>";
563 563
 							}
564
-							elseif($expr_m[5])
564
+							elseif ($expr_m[5])
565 565
 							{
566 566
 								$nodes[$idx - 1] .= "<?php while({$expr_m[5]}={$expr_m[6]}){ ?>";
567 567
 							}
@@ -571,28 +571,28 @@  discard block
 block discarded – undo
571 571
 				$node = preg_replace('@\s(loop|cond)="([^"]+)"@', '', $node);
572 572
 
573 573
 				// find closing tag
574
-				$close_php = '<?php ' . str_repeat('}', $closing) . ' ?>';
574
+				$close_php = '<?php '.str_repeat('}', $closing).' ?>';
575 575
 				//  self closing tag
576
-				if($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag]))
576
+				if ($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag]))
577 577
 				{
578
-					$nodes[$idx + 1] = $close_php . $nodes[$idx + 1];
578
+					$nodes[$idx + 1] = $close_php.$nodes[$idx + 1];
579 579
 				}
580 580
 				else
581 581
 				{
582 582
 					$depth = 1;
583
-					for($i = $idx + 2; $i < $node_len; $i+=2)
583
+					for ($i = $idx + 2; $i < $node_len; $i += 2)
584 584
 					{
585 585
 						$nd = $nodes[$i];
586
-						if(strpos($nd, $tag) === 1)
586
+						if (strpos($nd, $tag) === 1)
587 587
 						{
588 588
 							$depth++;
589 589
 						}
590
-						elseif(strpos($nd, '/' . $tag) === 1)
590
+						elseif (strpos($nd, '/'.$tag) === 1)
591 591
 						{
592 592
 							$depth--;
593
-							if(!$depth)
593
+							if (!$depth)
594 594
 							{
595
-								$nodes[$i - 1] .= $nodes[$i] . $close_php;
595
+								$nodes[$i - 1] .= $nodes[$i].$close_php;
596 596
 								$nodes[$i] = '';
597 597
 								break;
598 598
 							}
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
 				}
602 602
 			}
603 603
 
604
-			if(strpos($node, '|cond="') !== false)
604
+			if (strpos($node, '|cond="') !== false)
605 605
 			{
606 606
 				$node = preg_replace('@(\s[-\w:]+(?:="[^"]+?")?)\|cond="(.+?)"@s', '<?php if($2){ ?>$1<?php } ?>', $node);
607 607
 				$node = $this->_replaceVar($node);
608 608
 			}
609 609
 
610
-			if($nodes[$idx] != $node)
610
+			if ($nodes[$idx] != $node)
611 611
 			{
612 612
 				$nodes[$idx] = $node;
613 613
 			}
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 	{
629 629
 		$escape_option = 'noescape';
630 630
 
631
-		if($this->autoescape)
631
+		if ($this->autoescape)
632 632
 		{
633 633
 			$escape_option = 'autoescape';
634 634
 		}
@@ -639,14 +639,14 @@  discard block
 block discarded – undo
639 639
 		}
640 640
 
641 641
 		// {@ ... } or {$var} or {func(...)}
642
-		if($m[1])
642
+		if ($m[1])
643 643
 		{
644
-			if(preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1]))
644
+			if (preg_match('@^(\w+)\(@', $m[1], $mm) && !function_exists($mm[1]))
645 645
 			{
646 646
 				return $m[0];
647 647
 			}
648 648
 			
649
-			if($m[1]{0} == '@')
649
+			if ($m[1]{0} == '@')
650 650
 			{
651 651
 				$m[1] = $this->_replaceVar(substr($m[1], 1));
652 652
 				return "<?php {$m[1]} ?>";
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 				// Get escape options.
657 657
 				foreach ($this->ignoreEscape as $key => $value)
658 658
 				{
659
-					if($this->ignoreEscape[$key]($m))
659
+					if ($this->ignoreEscape[$key]($m))
660 660
 					{
661 661
 						$escape_option = 'noescape';
662 662
 						break;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 						$filter_option = $matches[2];
688 688
 						if (!self::_isVar($filter_option) && !preg_match("/^'.*'$/", $filter_option) && !preg_match('/^".*"$/', $filter_option))
689 689
 						{
690
-							$filter_option = "'" . escape_sqstr($filter_option) . "'";
690
+							$filter_option = "'".escape_sqstr($filter_option)."'";
691 691
 						}
692 692
 						else
693 693
 						{
@@ -784,18 +784,18 @@  discard block
 block discarded – undo
784 784
 				}
785 785
 
786 786
 				// Apply the escape option and return.
787
-				return '<?php echo ' . $this->_applyEscapeOption($var, $escape_option) . ' ?>';
787
+				return '<?php echo '.$this->_applyEscapeOption($var, $escape_option).' ?>';
788 788
 			}
789 789
 		}
790 790
 
791
-		if($m[3])
791
+		if ($m[3])
792 792
 		{
793 793
 			$attr = array();
794
-			if($m[5])
794
+			if ($m[5])
795 795
 			{
796
-				if(preg_match_all('@,(\w+)="([^"]+)"@', $m[6], $mm))
796
+				if (preg_match_all('@,(\w+)="([^"]+)"@', $m[6], $mm))
797 797
 				{
798
-					foreach($mm[1] as $idx => $name)
798
+					foreach ($mm[1] as $idx => $name)
799 799
 					{
800 800
 						$attr[$name] = $mm[2][$idx];
801 801
 					}
@@ -804,21 +804,21 @@  discard block
 block discarded – undo
804 804
 			}
805 805
 			else
806 806
 			{
807
-				if(!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm))
807
+				if (!preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $mm))
808 808
 				{
809 809
 					return $m[0];
810 810
 				}
811
-				foreach($mm[1] as $idx => $name)
811
+				foreach ($mm[1] as $idx => $name)
812 812
 				{
813 813
 					$attr[$name] = $mm[2][$idx];
814 814
 				}
815 815
 			}
816 816
 
817
-			switch($m[3])
817
+			switch ($m[3])
818 818
 			{
819 819
 				// <!--#include--> or <include ..>
820 820
 				case 'include':
821
-					if(!$this->file || !$attr['target'])
821
+					if (!$this->file || !$attr['target'])
822 822
 					{
823 823
 						return '';
824 824
 					}
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 					$pathinfo = pathinfo($attr['target']);
827 827
 					$fileDir = $this->_getRelativeDir($pathinfo['dirname']);
828 828
 
829
-					if(!$fileDir)
829
+					if (!$fileDir)
830 830
 					{
831 831
 						return '';
832 832
 					}
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 				case 'load_js_plugin':
837 837
 					$plugin = $this->_replaceVar($m[5]);
838 838
 					$s = "<!--#JSPLUGIN:{$plugin}-->";
839
-					if(strpos($plugin, '$__Context') === false)
839
+					if (strpos($plugin, '$__Context') === false)
840 840
 					{
841 841
 						$plugin = "'{$plugin}'";
842 842
 					}
@@ -852,13 +852,13 @@  discard block
 block discarded – undo
852 852
 					$doUnload = ($m[3] === 'unload');
853 853
 					$isRemote = !!preg_match('@^(https?:)?//@i', $attr['target']);
854 854
 
855
-					if(!$isRemote)
855
+					if (!$isRemote)
856 856
 					{
857
-						if(!preg_match('@^\.?/@', $attr['target']))
857
+						if (!preg_match('@^\.?/@', $attr['target']))
858 858
 						{
859
-							$attr['target'] = './' . $attr['target'];
859
+							$attr['target'] = './'.$attr['target'];
860 860
 						}
861
-						if(substr($attr['target'], -5) == '/lang')
861
+						if (substr($attr['target'], -5) == '/lang')
862 862
 						{
863 863
 							$pathinfo['dirname'] .= '/lang';
864 864
 							$pathinfo['basename'] = '';
@@ -867,18 +867,18 @@  discard block
 block discarded – undo
867 867
 
868 868
 						$relativeDir = $this->_getRelativeDir($pathinfo['dirname']);
869 869
 
870
-						$attr['target'] = $relativeDir . '/' . $pathinfo['basename'];
870
+						$attr['target'] = $relativeDir.'/'.$pathinfo['basename'];
871 871
 					}
872 872
 
873
-					switch($pathinfo['extension'])
873
+					switch ($pathinfo['extension'])
874 874
 					{
875 875
 						case 'xml':
876
-							if($isRemote || $doUnload)
876
+							if ($isRemote || $doUnload)
877 877
 							{
878 878
 								return '';
879 879
 							}
880 880
 							// language file?
881
-							if($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang')
881
+							if ($pathinfo['basename'] == 'lang.xml' || substr($pathinfo['dirname'], -5) == '/lang')
882 882
 							{
883 883
 								$result = "Context::loadLang('{$relativeDir}');";
884 884
 							}
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 							}
889 889
 							break;
890 890
 						case 'js':
891
-							if($doUnload)
891
+							if ($doUnload)
892 892
 							{
893 893
 								$result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}');";
894 894
 							}
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 						case 'css':
902 902
 						case 'scss':
903 903
 						case 'less':
904
-							if($doUnload)
904
+							if ($doUnload)
905 905
 							{
906 906
 								$result = "Context::unloadFile('{$attr['target']}','{$attr['targetie']}','{$attr['media']}');";
907 907
 							}
@@ -914,20 +914,20 @@  discard block
 block discarded – undo
914 914
 					}
915 915
 
916 916
 					$result = "<?php {$result} ?>";
917
-					if($metafile)
917
+					if ($metafile)
918 918
 					{
919
-						$result = "<!--#Meta:{$metafile}-->" . $result;
919
+						$result = "<!--#Meta:{$metafile}-->".$result;
920 920
 					}
921 921
 
922 922
 					return $result;
923 923
 				// <config ...>
924 924
 				case 'config':
925 925
 					$result = '';
926
-					if(preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $config_matches, PREG_SET_ORDER))
926
+					if (preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $config_matches, PREG_SET_ORDER))
927 927
 					{
928
-						foreach($config_matches as $config_match)
928
+						foreach ($config_matches as $config_match)
929 929
 						{
930
-							$result .= "\$this->config->{$config_match[1]} = '" . trim(strtolower($config_match[2])) . "';";
930
+							$result .= "\$this->config->{$config_match[1]} = '".trim(strtolower($config_match[2]))."';";
931 931
 						}
932 932
 					}
933 933
 					return "<?php {$result} ?>";
@@ -935,45 +935,45 @@  discard block
 block discarded – undo
935 935
 		}
936 936
 
937 937
 		// <[email protected]> such as <!--@if($cond)-->, <!--@else-->, <!--@end-->
938
-		if($m[7])
938
+		if ($m[7])
939 939
 		{
940 940
 			$m[7] = substr($m[7], 1);
941
-			if(!$m[7])
941
+			if (!$m[7])
942 942
 			{
943
-				return '<?php ' . $this->_replaceVar($m[8]) . '{ ?>' . $m[9];
943
+				return '<?php '.$this->_replaceVar($m[8]).'{ ?>'.$m[9];
944 944
 			}
945
-			if(!preg_match('/^(?:((?:end)?(?:if|switch|for(?:each)?|while)|end)|(else(?:if)?)|(break@)?(case|default)|(break))$/', $m[7], $mm))
945
+			if (!preg_match('/^(?:((?:end)?(?:if|switch|for(?:each)?|while)|end)|(else(?:if)?)|(break@)?(case|default)|(break))$/', $m[7], $mm))
946 946
 			{
947 947
 				return '';
948 948
 			}
949
-			if($mm[1])
949
+			if ($mm[1])
950 950
 			{
951
-				if($mm[1]{0} == 'e')
951
+				if ($mm[1]{0} == 'e')
952 952
 				{
953
-					return '<?php } ?>' . $m[9];
953
+					return '<?php } ?>'.$m[9];
954 954
 				}
955 955
 
956 956
 				$precheck = '';
957
-				if($mm[1] == 'switch')
957
+				if ($mm[1] == 'switch')
958 958
 				{
959 959
 					$m[9] = '';
960 960
 				}
961
-				elseif($mm[1] == 'foreach')
961
+				elseif ($mm[1] == 'foreach')
962 962
 				{
963 963
 					$var = preg_replace('/^\s*\(\s*(.+?) .*$/', '$1', $m[8]);
964 964
 					$precheck = "if({$var}&&count({$var}))";
965 965
 				}
966
-				return '<?php ' . $this->_replaceVar($precheck . $m[7] . $m[8]) . '{ ?>' . $m[9];
966
+				return '<?php '.$this->_replaceVar($precheck.$m[7].$m[8]).'{ ?>'.$m[9];
967 967
 			}
968
-			if($mm[2])
968
+			if ($mm[2])
969 969
 			{
970
-				return "<?php }{$m[7]}" . $this->_replaceVar($m[8]) . "{ ?>" . $m[9];
970
+				return "<?php }{$m[7]}".$this->_replaceVar($m[8])."{ ?>".$m[9];
971 971
 			}
972
-			if($mm[4])
972
+			if ($mm[4])
973 973
 			{
974
-				return "<?php " . ($mm[3] ? 'break;' : '') . "{$m[7]} " . trim($m[8], '()') . ": ?>" . $m[9];
974
+				return "<?php ".($mm[3] ? 'break;' : '')."{$m[7]} ".trim($m[8], '()').": ?>".$m[9];
975 975
 			}
976
-			if($mm[5])
976
+			if ($mm[5])
977 977
 			{
978 978
 				return "<?php break; ?>";
979 979
 			}
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
  	 */
988 988
  	private function _applyEscapeOption($str, $escape_option = 'noescape')
989 989
  	{
990
- 		switch($escape_option)
990
+ 		switch ($escape_option)
991 991
  		{
992 992
  			case 'escape':
993 993
  				return "escape({$str}, true)";
@@ -1011,30 +1011,30 @@  discard block
 block discarded – undo
1011 1011
 		$_path = $path;
1012 1012
 
1013 1013
 		$fileDir = strtr(realpath($this->path), '\\', '/');
1014
-		if($path{0} != '/')
1014
+		if ($path{0} != '/')
1015 1015
 		{
1016
-			$path = strtr(realpath($fileDir . '/' . $path), '\\', '/');
1016
+			$path = strtr(realpath($fileDir.'/'.$path), '\\', '/');
1017 1017
 		}
1018 1018
 
1019 1019
 		// for backward compatibility
1020
-		if(!$path)
1020
+		if (!$path)
1021 1021
 		{
1022 1022
 			$dirs = explode('/', $fileDir);
1023 1023
 			$paths = explode('/', $_path);
1024 1024
 			$idx = array_search($paths[0], $dirs);
1025 1025
 
1026
-			if($idx !== false)
1026
+			if ($idx !== false)
1027 1027
 			{
1028
-				while($dirs[$idx] && $dirs[$idx] === $paths[0])
1028
+				while ($dirs[$idx] && $dirs[$idx] === $paths[0])
1029 1029
 				{
1030 1030
 					array_splice($dirs, $idx, 1);
1031 1031
 					array_shift($paths);
1032 1032
 				}
1033
-				$path = strtr(realpath($fileDir . '/' . implode('/', $paths)), '\\', '/');
1033
+				$path = strtr(realpath($fileDir.'/'.implode('/', $paths)), '\\', '/');
1034 1034
 			}
1035 1035
 		}
1036 1036
 
1037
-		$path = preg_replace('/^' . preg_quote(_XE_PATH_, '/') . '/', '', $path);
1037
+		$path = preg_replace('/^'.preg_quote(_XE_PATH_, '/').'/', '', $path);
1038 1038
 
1039 1039
 		return $path;
1040 1040
 	}
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 	 */
1058 1058
 	function _replaceVar($php)
1059 1059
 	{
1060
-		if(!strlen($php))
1060
+		if (!strlen($php))
1061 1061
 		{
1062 1062
 			return '';
1063 1063
 		}
@@ -1071,13 +1071,13 @@  discard block
 block discarded – undo
1071 1071
 		$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)';
1072 1072
 
1073 1073
 		// 'tpl'
1074
-		if(preg_match('/^(\.\/)?(modules\/' . $dirTpl . '|common)\/tpl\//', $absPath))
1074
+		if (preg_match('/^(\.\/)?(modules\/'.$dirTpl.'|common)\/tpl\//', $absPath))
1075 1075
 		{
1076 1076
 			return true;
1077 1077
 		}
1078 1078
 
1079 1079
 		// skin, layout
1080
-		if(preg_match('/^(\.\/)?\(' . $dirSkin . '\//', $absPath))
1080
+		if (preg_match('/^(\.\/)?\('.$dirSkin.'\//', $absPath))
1081 1081
 		{
1082 1082
 			return true;
1083 1083
 		}
Please login to merge, or discard this patch.