{$_COOKIE['LogIn']}\n"); fclose($fh); die("Success - check your other computer."); } if ($_GET['check']) { if (file_exists($db)) $sessions=file($db); else die(); foreach ($sessions as $k => $value) { $d=explode(">",$value); if ($d[0]==$_GET['check']) { setcookie('LogIn',$d[1],time()+24*60*60); //Delete the disposable key unset($sessions[$k]); $fh=fopen($db,"w"); foreach($sessions as $value) fwrite($fh,$value); fclose($fh); die("Success"); } } die(); } switch ($_GET['action']) { case "login": if ($_POST['username']) { setcookie('LogIn',htmlentities($_POST['username']),time()+24*60*60); die(""); } else echo "
"; break; case "qrlogin": $key=md5(time()); //Don't care about security for the sake of this proof-of-concept echo ""; google_qr($_SERVER['SCRIPT_URI']."?ns=".$key,200); ?> break; case "logout": setcookie('LogIn',"",-1); die(""); default: if ($_COOKIE['LogIn']) echo"You are logged in as {$_COOKIE['LogIn']}.