コード例 #1
0
 private static function login($password)
 {
     global $session;
     if (!isset($password) || $password == "") {
         header('HTTP/1.1 401 Unauthorized');
         throw new Exception("Password required.");
     }
     if (LoginAttemptService::atLoginLimit($_SERVER['REMOTE_ADDR'])) {
         header('HTTP/1.1 401 Unauthorized');
         throw new Exception("Too many login attempts.");
     }
     try {
         $session->setUser(GuestService::getInstance()->getUserData($password));
     } catch (Exception $e) {
         LoginAttemptService::addLoginAttempt($_SERVER['REMOTE_ADDR']);
         header('HTTP/1.1 401 Unauthorized');
         throw new Exception("Unknown password.");
     }
     LoginAttemptService::markLoginSuccessful($_SERVER['REMOTE_ADDR']);
     $clientShareableUser = clone $session->user;
     $clientShareableUser->id = $session->session_id;
     if ($session->user->rsvp->dueDate->getTimestamp() > time()) {
         $clientShareableUser->rsvp->dueDate = "Please be sure to RSVP by " . date("M jS", $clientShareableUser->rsvp->dueDate->getTimestamp() - 1);
     } else {
         $clientShareableUser->rsvp->dueDate = "Please be sure to RSVP as soon as possible";
     }
     return array("user" => $clientShareableUser);
 }
コード例 #2
0
 public static function init()
 {
     self::$loginAttemptsFolderLocation = $_SERVER['DOCUMENT_ROOT'] . "/shalomshanti/loginAttempts/";
 }