ID: 10446
Updated by: kalowsky
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Scripting Engine problem
Operating system:
PHP Version: 4.0.4pl1
Assigned To:
Comments:
your if statement is incorrect.
Previous Comments:
---------------------------------------------------------------------------
[2001-04-22 16:39:25] [EMAIL PROTECTED]
Apache/1.3.19
In the switch block, the following code generates an invalid server response:
case "":
if($var) {
echo "FALSE";
return $ret;
} echo "TRUE";
else {
return !$ret;
}
included file named parse.php, an advanced template parser, contains the following
function:
Typical input to the function would be:
iftest("if", "cats")
iftest("else");
iftest("ifnot", "cats!=4")
iftest("elseif", "homepage==domain+'index.php'")
the dehash function parses variables as they are passed to the template. e.g.,
homepage=>'http://www.php.net/index.php', domain=>'http://www.php.net/', so the last
example would return true.
function iftest($func,$arg) {
global $var_hash;
$var="";
$op="";
$val="";
$i=0;
if($func=="else") {
return TRUE;
}
do {
$var.=$arg[$i++];
}
while($i<strlen($arg)&&$arg[$i]!="="&&$arg[$i]!="!"&&$arg[$i]!="<"&&$arg[$i]!=">");
if($i<strlen($arg)) {
do {
$op.=$arg[$i++];
}
while(($arg[$i]=="="||$arg[$i]=="!"||$arg[$i]=="<"||$arg[$i]==">")&&$i<strlen($arg));
}
if($i<strlen($arg)) {
do {
$val.=$arg[$i++];
} while($i<strlen($arg));
}
if($val[0]=='"'||$val[0]=="'") {
$val=substr($val, 1, strlen($val)-2);
}
$var=dehash($var);
if($func=="if"||$func=="elseif") {
$ret=TRUE;
}
elseif($func=="ifnot"||$func="elseifnot") {
$ret=FALSE;
}
switch($op) {
case "==":
if($var==$val)
return $ret;
else
return !$ret;
break;
case "!=":
if($var!=$val)
return $ret;
else
return !$ret;
break;
case ">=":
if($var>=$val)
return $ret;
else
return !$ret;
break;
case "<=":
if($var<=$val)
return $ret;
else
return !$ret;
break;
case ">":
if($var>$val)
return $ret;
else
return !$ret;
break;
case "<":
if($var<$val)
return $ret;
else
return !$ret;
break;
case "":
if($var) {
echo "FALSE";
return $ret;
} echo "TRUE";
else {
return !$ret;
}
break;
default:
return FALSE;
}
return FALSE;
}
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=10446&edit=2
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]