示例#1
0
文件: util.php 项目: nham/pungent
function hash_valid($db, $hash) {
  $query = $db->query("SELECT uid FROM hashez WHERE hash='$hash'");
  
  if($query !== FALSE) {
    if(($fetch = $query->fetch(PDO::FETCH_NUM)) !== FALSE) {
      return current($fetch);
    } else {
      // if the cookie was invalid, unset it
      unset_auth_cookie();
      return "invalid";
    }
  } else {
    return "error";
  }
}
示例#2
0
文件: index.php 项目: nham/pungent
function logout() {
  $db = $GLOBALS['db'];
  $stm = $db->prepare("DELETE FROM hashez WHERE hash = :hash");
  $stm->execute(array(':hash' => $_COOKIE['user']));
  unset_auth_cookie();
  goToApp();
}