|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-11 02:17 UTC] webmaster at ckeren dot com
Below is the short script that produce quite stupid logics :)
//*************** start here
$header = "<html><head><title>BUGS</title></head><body><center><br><br><br><br>";
$min = 4;
$log = "<br><form action=\"$PHP_SELF\" method=post><table border=0 cellspacing=1 cellpadding=3>";
$log .= "<tr><td class=login colspan=2>Username<br><input type=text name=\"mumzu\" size=25 maxlength=20></td></tr>";
$log .= "<tr><td class=login colspan=2>Password<br><input type=password name=\"mumzp\" size=16 maxlength=20> <input align=\"texttop\" type=submit value=\"Log In\" class=\"submit\"></td></tr>";
$log .= "<tr><td valign=top><input type=\"radio\" name=\"mumzr\" value=\"1\"></td><td width=150><font class=option>Keep me loged-in into this MUMZ unless I logout.</font></td></tr>";
$log .= "<tr><td valign=top><input type=\"radio\" name=\"mumzr\" value=\"0\" checked></td><td width=150><font class=option>Do nothing.</font></td></tr></table></form><br><br>";
if((isset($HTTP_POST_VARS["mumzu"]) && isset($HTTP_POST_VARS["mumzp"]) && isset($HTTP_POST_VARS["mumzr"])) || (isset($HTTP_COOKIE_VARS["mumzu"]) && isset($HTTP_COOKIE_VARS["mumzp"]) && isset($HTTP_COOKIE_VARS["mumzr"])))
{
if(!isset($p))
{
$m = 30;
$lifetime = time() + ($m * 60);
setcookie("mumzu", $mumzu, $lifetime);
setcookie("mumzp", $mumzp, $lifetime);
setcookie("mumzr", $mumzr, $lifetime);
echo $header;
echo "this is <b>Restricted area</b><br><br>click <a href=\"$PHP_SELF?p=logout\">here</a> to logout";
}
else if(isset($p) && $p == "logout")
{
setcookie("mumzu");
setcookie("mumzp");
setcookie("mumzr");
echo $header;
echo "<font color=\"#FF0000\">Here is the bug: the 3 variabels mumzu, mumzp, mumzr suppoused to be disapeared after clicking the link below.<br>And logically since there is no any existing variables it suppoused to display login form instead <b>restricted area</b> again</font><br><br>";
echo "you have been loged out click <a href=\"$PHP_SELF\">here</a> to login again";
}
else
{
setcookie("mumzu");
setcookie("mumzp");
setcookie("mumzr");
echo $header;
echo "Bad username or password";
echo $log;
}
}
else
echo $header.$log;
if(isset($mumzu))
echo "<br><br>username: \"$mumzu\" , pass: \"$mumzp\", cookie mumzp: ".@$HTTP_COOKIE_VARS["mumzp"];
echo "</center></body></html>";
//***************End of Line
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 09:00:02 2025 UTC |
ok here is the simpler script, please try it and you'll see very clearly where the bug is. It should work but logically it doesn't. That is because php doesn't flush the variables after loading a new page which normally it should. Instead it passess the variables with an empty string MAGICALY. ********************* Start of line $header = "<html><head><title>BUGS</title></head><body><center><br><br><br><br>"; $log = "<br><form action=\"$PHP_SELF\" method=post>Username: <input type=text name=\"user\" size=25 maxlength=20><input type=submit></form>"; if((isset($HTTP_POST_VARS["user"]) || isset($HTTP_COOKIE_VARS["user"]))) { if(!isset($p)) { $m = 30; //m variable represent minutes $lifetime = time() + ($m * 60); //lifetime variable represent the setcookie("user", $user, $lifetime); //set the user variable value into cookie echo $header; //Just to print html header //Print contents of restricted area echo "this is <b>Restricted area</b><br><br>click <a href=\"$PHP_SELF?p=logout\">here</a> to logout"; } else if(isset($p) && $p == "logout") { setcookie("user"); //delete user cookie echo $header; echo "<font color=\"#FF0000\">Here is the bug: the variable user suppoused to be disapeared after clicking the link below.<br>And logically since there is no any existing variables it suppoused to display login form instead <b>restricted area</b></font><br><br>"; echo "you have been loged out click <a href=\"$PHP_SELF\">here</a> to login again"; } else { setcookie("user"); //delete user cookie echo $header; echo "Bad username or password"; echo $log; } } else echo $header.$log; if(isset($user)) echo "<br><br>username: \"$user\" , cookie user: ".@$HTTP_COOKIE_VARS["user"]; echo "</center></body></html>"; ********************* End of line