authentication.inc 476 Bytes
Newer Older
Dries's avatar
Dries committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<?

if ((isset($aid)) && (isset($pwd)) && ($op == "login")) {
  $admin = base64_encode("$aid:$pwd");
  setcookie("admin","$admin",time()+2592000); // 1 mo is 2592000
}

if (isset($admin)) {
  $admin = base64_decode($admin);
  $admin = explode(":", $admin);
  $aid = "$admin[0]";
  $pwd = "$admin[1]";
  dbconnect();
  if (mysql_num_rows(mysql_query("SELECT * FROM authors WHERE aid = '$aid' AND pwd = '$pwd'")) == 1) $admin = 1;
  else $admin = 0;
} else {
  $admin = 0;
}

?>