Exemplo n.º 1
0
 /**
  * check login state
  * @return bool
  */
 public static function isLoggedIn(\Base $f3)
 {
     $ip_db = sprintf("%u", ip2long($_SERVER['REMOTE_ADDR']));
     /*
     Session mask (bit-wise)
     
     - admin			   128
     - super mod			64
     - story mod 		32
     - lector			16
     - author (trusted)	 8
     - author (regular)	 4
     - user (trusted)	 2
     - user (active)		 1
     - guest				 0
     */
     if ($f3->exists('SESSION.session_id')) {
         $session_id = $f3->get('SESSION.session_id');
     } elseif (isset($_COOKIE['session_id'])) {
         $session_id = $_COOKIE['session_id'];
         $f3->set('SESSION.session_id', $session_id);
     } else {
         $session_id = \Model\Auth::instance()->createSession($ip_db);
     }
     //		echo "<br>old: ".$_SESSION['session_id'];
     if (isset($session_id) && ($user = \Model\Auth::instance()->validateSession($session_id, $ip_db)) and $user['userID'] > 0) {
         $_SESSION['groups'] = $user['groups'];
         $_SESSION['admin_active'] = $user['admin_active'];
         $_SESSION['userID'] = $user['userID'];
         $_SESSION['username'] = $user['nickname'];
         $_SESSION['mail'] = array($user['mail'], $user['unread']);
         $_SESSION['tpl'] = ["default", 1];
         return TRUE;
     } else {
         //getStats();
         //
         $_SESSION['groups'] = bindec('0');
         $_SESSION['admin_active'] = FALSE;
         $_SESSION['userID'] = FALSE;
         $_SESSION['username'] = "******";
         $_SESSION['mail'] = FALSE;
         $_SESSION['tpl'] = ["default", 1];
         return FALSE;
     }
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $this->modelAuth = ModelAuth::singleton();
     // TODO: translations and localization
     $this->lang = "en";
 }