0f3f0dc8ed
09.03.2006 - Build 18 (Joe Camel): - Fixed function redeclaration with Blessed Strike & Stone Skin spells. - When you're all alone, you no longer have a little blue "undefined" orb to keep you company. - Changing worlds after a quest now gives you the world's starting town to avoid panel errors. - Minor optimization fix for item building. - Unique items no longer drop with prefixes/suffixes, and you can no longer buy unique items. - Removed alphanumeric requirement for passwords. - hpleech(monster) now properly accounts for difficulty multiplier when checking against the monster's maxhp. - Added Deposit/Withdraw All links to the Bank. - Fixed PVP and Post office bugs related to the new doquery syntax. - Fixed single-quote bugs in mymail(). - Removed verbiage from the levelup template that was no longer necessary. - Fixed some more verbiage in the registration message that was also no longer necessary. - Added admin-definable cookie name and cookie domain to controlrow.
32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php // cookies.php :: Handles cookies. (Mmm, tasty!)
|
|
|
|
function checkcookies() {
|
|
|
|
include('config.php');
|
|
global $controlrow;
|
|
|
|
$row = false;
|
|
|
|
if (isset($_COOKIE[$controlrow["cookiename"]])) {
|
|
|
|
// COOKIE FORMAT:
|
|
// {ID} {USERNAME} {PASSWORDHASH} {REMEMBERME}
|
|
$theuser = explode(" ",$_COOKIE[$controlrow["cookiename"]]);
|
|
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 ($controlrow["cookiename"], $newcookie, $expiretime, "/", $controlrow["cookiedomain"], 0);
|
|
|
|
}
|
|
|
|
return $row;
|
|
|
|
}
|
|
|
|
?>
|