Nieuw lid |
|
Een fout
Invalid cookie data (Error 1). Please clear cookies and log in again.
Invalid cookie data (Error 1). Please clear cookies and log in again .
cookies
<?php // cookies.php :: Handles cookies. (Mmm, tasty!)
function checkcookies() {
include('config.php');
$row = false;
if (isset($_COOKIE["dkgame"])) {
// COOKIE FORMAT:
// {ID} {USERNAME} {PASSWORDHASH} {REMEMBERME}
$theuser = explode(" ",$_COOKIE["dkgame"]);
$query = doquery("SELECT * FROM {{table}} WHERE username='$theuser[1]'", "users");
if (mysql_num_rows($query) != 1) { die("Invalid cookie data (Error 1). Please clear cookies and log in again."); }
$row = mysql_fetch_array($query);
if ($row["id"] != $theuser[0]) { die("Invalid cookie data (Error 2). Please clear cookies and log in again."); }
if (md5($row["password"] . "--" . $dbsettings["secretword"]) !== $theuser[2]) { die("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 ("dkgame", $newcookie, $expiretime, "/", "", 0);
$onlinequery = doquery("UPDATE {{table}} SET onlinetime=NOW() WHERE id='$theuser[0]' LIMIT 1", "users");
}
return $row;
}
?>
<?php // cookies.php :: Handles cookies. (Mmm, tasty!) function checkcookies() { include('config.php'); $row = false; if (isset($_COOKIE["dkgame"])) { // COOKIE FORMAT: // {ID} {USERNAME} {PASSWORDHASH} {REMEMBERME} $theuser = explode(" ",$_COOKIE["dkgame"]); $query = doquery("SELECT * FROM {{table}} WHERE username='$theuser[1]'", "users"); if (mysql_num_rows($query) != 1) { die("Invalid cookie data (Error 1). Please clear cookies and log in again."); } if ($row["id"] != $theuser[0]) { die("Invalid cookie data (Error 2). Please clear cookies and log in again."); } if (md5($row["password"] . "--" . $dbsettings["secretword"]) !== $theuser[2]) { die("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 ("dkgame", $newcookie, $expiretime, "/", "", 0); $onlinequery = doquery("UPDATE {{table}} SET onlinetime=NOW() WHERE id='$theuser[0]' LIMIT 1", "users"); } return $row; } ?>
config:
<?php // config.php :: Low-level app/database variables.
$dbsettings = Array(
"server" => "localhost", // MySQL server name. (Default: localhost)
"user" => "sanniiie", // MySQL username.
"pass" => "********", // MySQL password.
"name" => "sanniiie_03", // MySQL database name.
"prefix" => "dk", // Prefix for table names. (Default: dk)
"secretword" => ""); // Secret word used when hashing information for cookies.
?>
<?php // config.php :: Low-level app/database variables. "server" => "localhost", // MySQL server name. (Default: localhost) "user" => "sanniiie", // MySQL username. "pass" => "********", // MySQL password. "name" => "sanniiie_03", // MySQL database name. "prefix" => "dk", // Prefix for table names. (Default: dk) "secretword" => ""); // Secret word used when hashing information for cookies. ?>
Wat heb ik fout gedaan? Waarschijnlijk komt het door het secretword wie kan me helpen?
|