1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<? function checkcookies() { // I used a global. Shoot me. global $admin;
$admin=FALSE; $ok=FALSE;
if (!empty($_COOKIE["userid"])&&!empty($_COOKIE["userpass"])) { $result=doquery("select password, admin from user where id = ".$_COOKIE["userid"]." and enabled=1"); if (mysql_num_rows($result)==1) { $row=mysql_fetch_assoc($result); if ($row["password"]==$_COOKIE["userpass"]) { $ok=TRUE; if ($row["admin"]==1) $admin=TRUE; doquery("update user set lastvisit=now() where id = ".$_COOKIE["userid"]); } } } if (!$ok) { setcookie("userid"); setcookie("userpass"); setcookie("username"); header("Location: login.php"); die(); } }
?>
|