Пример #1
0
 public static final function clearCookie()
 {
     Q::cookie('l', null, 0);
     self::$cookie = false;
 }
Пример #2
0
 /**
  * Requires HTTP Authentication. Execution dies after authentication fails.
  *
  * @param string $message Message displayed to the user
  * @param array $creds An associative array of username => sha1(password) pairs.
  * @param callback $failure A callback method that is called if authentication fails.
  */
 public static function requireHTTPAuth($message, $creds, $failure = null)
 {
     //if(isset($_COOKIE['auth'])) return true;
     if (isset($_SERVER['PHP_AUTH_USER'])) {
         if (isset($creds[$_SERVER['PHP_AUTH_USER']]) && sha1($_SERVER['PHP_AUTH_PW']) == $creds[$_SERVER['PHP_AUTH_USER']]) {
             Q::cookie('auth', 1, 10000000);
             return true;
         } else {
             header("WWW-Authenticate: Basic realm=\"{$message}\"", null, 401);
             if ($failure) {
                 call_user_func($failure);
             }
             die;
         }
     } else {
         header("WWW-Authenticate: Basic realm=\"{$message}\"", null, 401);
         die('Forbidden');
     }
 }