diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2008-08-01 14:35:11 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2008-08-01 14:35:11 +0000 |
commit | 00fa69cab9488634716732c5cfd2ad745c33cf85 (patch) | |
tree | 05783aee7b35b22d86184a77e2443e36e1e38a7b /phpBB | |
parent | 2389388c4629b9c1fecc72e8c2007522f9a18721 (diff) | |
download | forums-00fa69cab9488634716732c5cfd2ad745c33cf85.tar forums-00fa69cab9488634716732c5cfd2ad745c33cf85.tar.gz forums-00fa69cab9488634716732c5cfd2ad745c33cf85.tar.bz2 forums-00fa69cab9488634716732c5cfd2ad745c33cf85.tar.xz forums-00fa69cab9488634716732c5cfd2ad745c33cf85.zip |
change conditional enclosements in template engine
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8739 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/functions_template.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index 1e7fbaa8e6..436c8692b4 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -515,11 +515,64 @@ class template_compile } $token = "sizeof($varref)"; } + else if (!empty($token)) + { + $token = '(' . $token . ')'; + /** + * If we need to really secure the usage, or force specific types on specific operations... the following would be the code + + if (!isset($tokens[$i - 1])) + { + unset($tokens[$i]); + break; + } + + $prev_token = trim($tokens[$i - 1]); + + switch ($prev_token) + { + // Integer + case '<': + case '>': + case '<=': + case '>=': + case '%': + $token = ( ((double) $token) != 0) ? (double) $token : (int) $token; + break; + + case '==': + case '!=': + $int_token = (((double) $token) != 0) ? (double) $token : (int) $token; + if ($int_token && $int_token == $token) + { + $token = $int_token; + break; + } + + // It is a string... + $token = '(' . $token . ')'; + break; + + case '!': + case '||': + case '&&': + default: + unset($tokens[$i]); + break; + break; + } + */ + } break; } } + // If there are no valid tokens left or only control/compare characters left, we do skip this statement + if (!sizeof($tokens) || str_replace(array(' ', '=', '!', '<', '>', '&', '|', '%', '(', ')'), '', implode('', $tokens)) == '') + { + $tokens = array('false'); + } return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { '); } |