示例#1
0
 /**
  * isDefault 
  * 
  * @access public
  * @return bool   false if the user is authenticated, true if not (default user)
  */
 public function isDefault()
 {
     $session =& Framework_Session::singleton();
     if (is_null($session->email)) {
         return true;
     }
     // Check timeout
     $time = time();
     $lastActionTime = $session->lastActionTime;
     $timeLimit = (int) Framework::$site->config->inactiveTimeout;
     $this->recordio("timeout info: time: {$time}, lastActionTime: {$lastActionTime}, timeLimit: {$timeLimit}");
     if ($time - $lastActionTime > $timeLimit) {
         header('Location: ./?module=Login&event=logoutInactive');
         return false;
     }
     // Authenticate
     $encryptedPass = $session->password;
     $crypt = new Crypt_Blowfish((string) Framework::$site->config->mcryptKey);
     $plainPass = $crypt->decrypt($encryptedPass);
     if ($this->authenticate($session->email, $plainPass)) {
         $session->lastActionTime = $time;
         return false;
     }
     return true;
 }
示例#2
0
 /**
  * singleton
  *
  * Implementation of the singleton pattern. Returns a sincle instance
  * of the session class.
  *
  * @author Joe Stump <*****@*****.**>
  * @return mixed Instance of session
  */
 public static function singleton()
 {
     if (!isset(self::$instance)) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
示例#3
0
 /**
  * __construct
  *
  * @access      public
  * @return      void
  */
 public function __construct()
 {
     parent::__construct();
     if (!is_null($this->db)) {
         $this->user = Framework_User::singleton();
     }
     $this->session = Framework_Session::singleton();
 }
示例#4
0
文件: User.php 项目: shupp/Framework
 /**
  * singleton
  *
  * @access public
  * @return mixed PEAR_Error on failure, user class on success
  * @static
  */
 public static function singleton()
 {
     static $user = null;
     $session = Framework_Session::singleton();
     if (is_null($user) || !is_null($user) && $user->userID != $session->userID) {
         if (!isset(Framework::$site->config->user->userClass)) {
             $file = null;
             $class = 'Framework_User';
         } else {
             $file = 'Framework/User/' . Framework::$site->config->user->userClass . '.php';
             $class = 'Framework_User_' . Framework::$site->config->user->userClass;
         }
         if (!is_null($file)) {
             if (!(include_once $file)) {
                 throw new Framework_Exception('Could not load class file: ' . $file);
             }
         }
         if (class_exists($class)) {
             $user = new $class();
         } else {
             throw new Framework_Exception('Unable to load class: ' . Framework::$site->userClass);
         }
     }
     return $user;
 }
示例#5
0
文件: Web.php 项目: shupp/Framework
 /**
  * __construct
  *
  * @access      public
  * @return      void
  */
 public function __construct()
 {
     parent::__construct();
     $this->user = Framework_User::singleton();
     $this->session = Framework_Session::singleton();
 }