From 13f7d9273945374c6491d37dc269aca5482757ee Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Wed, 23 Apr 2003 20:55:48 +0000 Subject: [PATCH] hhmmm, was slap bang in the middle of working on this ;) Excess slashing(?) .. keep an eye out for errors ... fixed static lang preg git-svn-id: file:///svn/phpbb/trunk@3933 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 542ae39435..899f727333 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -271,6 +271,11 @@ class Template { global $config; + // Remove any "loose" php ... we want to give admins the ability + // to switch on/off PHP for a given template. Allowing unchecked + // php is a no-no + $code = preg_replace('#\<\?php(.*?)\?\>#is', '', $code); + // Pull out all block/statement level elements and seperate // plain text preg_match_all('#(.*?)#s', $code, $matches); @@ -292,7 +297,6 @@ class Template $this->compile_var_tags($text_blocks[$i]); } - $compile_blocks = array(); for ($curr_tb = 0; $curr_tb < count($text_blocks); $curr_tb++) @@ -371,9 +375,12 @@ class Template $template_php .= (!$no_echo) ? ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : '') : ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : ''); } + // There will be a number of occassions where we switch into and out of + // PHP mode instantaneously. Rather than "burden" the parser with this + // we'll strip out such occurences, minimising such switching $template_php = str_replace(' ?>_tpldata[\'.\'][0][\'L_\\1\'])) ? \$this->_tpldata[\'.\'][0][\'L_\\1\'] : \'' . ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '') . '\'); ?>'" , $text_blocks); + $text_blocks = preg_replace('#\{L_([A-Z0-9\-_]*?)\}#e', "'_tpldata[\'.\'][0][\'L_\\1\'])) ? \$this->_tpldata[\'.\'][0][\'L_\\1\'] : \'' . ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '') . '\'); ?>'" , $text_blocks); } $text_blocks = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "_tpldata['.'][0]['\\1']; ?>", $text_blocks);