1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-26 21:15:21 +02:00

change conditional enclosements in template engine

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8739 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2008-08-01 14:35:11 +00:00
parent 2389388c46
commit 00fa69cab9

View File

@ -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) . ') { ');
}