d529178672
8.09.2006 - Build 17 (Haiku): - Moved stylesheets into .css files. - Added javascript tooltips for the class info when creating a new character. - Changed doquery() format - rewrote all calls to this function to match the new format. - Various changes to the structure of lib.php. - Implemented Anman's increased attack and defense spells (Blessed Strike & Stone Skin). - Fixed class display in profile view. - Began admin control panel. - Various little bitty fixes. - You can no longer gamble 0 gold. - Added new level stat type: life. - Monsters can now do excellent hits, and you can now dodge monsters. - Removed several columns from controlrow that are no longer used.
31 lines
1.2 KiB
PHP
31 lines
1.2 KiB
PHP
<?php // cookies.php :: Handles cookies. (Mmm, tasty!)
|
|
|
|
function checkcookies() {
|
|
|
|
include('config.php');
|
|
|
|
$row = false;
|
|
|
|
if (isset($_COOKIE["scourge"])) {
|
|
|
|
// COOKIE FORMAT:
|
|
// {ID} {USERNAME} {PASSWORDHASH} {REMEMBERME}
|
|
$theuser = explode(" ",$_COOKIE["scourge"]);
|
|
if (!is_numeric($theuser[0])) { err("Invalid cookie data (Error 0). Please clear cookies and log in again."); }
|
|
$row = dorow(doquery("SELECT * FROM <<accounts>> WHERE username='$theuser[1]' LIMIT 1"));
|
|
if ($row == false) { err("Invalid cookie data (Error 1). Please clear cookies and log in again."); }
|
|
if ($row["id"] != $theuser[0]) { err("Invalid cookie data (Error 2). Please clear cookies and log in again."); }
|
|
if (md5($row["password"] . "--" . $dbsettings["secretword"]) !== $theuser[2]) { err("Invalid cookie data (Error 3). Please clear cookies and log in again."); }
|
|
|
|
// If we've gotten this far, cookie should be valid, so write a new one.
|
|
$newcookie = implode(" ",$theuser);
|
|
if ($theuser[3] == 1) { $expiretime = time()+31536000; } else { $expiretime = 0; }
|
|
setcookie ("scourge", $newcookie, $expiretime, "/", "", 0);
|
|
|
|
}
|
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
?>
|