public function __construct($page)
 {
     parent::__construct();
     $this->_checkSiteStatus();
     $this->data['page'] = $page;
     $this->data['title'] = $this->_generateTitle($page);
     $login_user = $this->_checkForLoginAttempt();
     // Log them in
     $success = is_array($login_user) && array_key_exists('success', $login_user) && $login_user['success'];
     if ($success) {
         $this->_getUserRoles($login_user['data']->id);
         // Get roles since the constructor didn't ($_SESSION['user_id'] wasn't set)
         $_SESSION['logged_in'] = TRUE;
         $_SESSION['user_id'] = $login_user['data']->id;
         $_SESSION['username'] = $login_user['data']->username;
         $_SESSION['email_verified'] = $login_user['data']->email_verified;
     } else {
         if ($login_user !== null) {
             $this->data['login_failed'] = TRUE;
         }
     }
     // If logged in
     if (isset($_SESSION['logged_in'])) {
         $this->data['logged_in'] = TRUE;
         $this->data['username'] = $_SESSION['username'];
         $this->data['email_verified'] = $_SESSION['email_verified'];
         // Check if banned
         $ban_record = $this->user_ban_model->getActiveByUserId($_SESSION['user_id']);
         if ($ban_record !== FALSE) {
             $this->data['banned'] = TRUE;
             $this->data['ban'] = array('title' => 'Account Frozen', 'message' => "We're sorry but this account is banned", 'reason' => $ban_record->reason);
         }
     }
 }
 public function __construct($page)
 {
     parent::__construct();
     $this->data['page'] = $page;
     // Check if they have access
     if (isset($_SESSION['user_id'])) {
         if (!$this->roles->hasPermission($this->userRoles, PERMISSION_VIEW_ADMIN_PANEL)) {
             show_error('You do not have access to this area');
         }
     } else {
         if ($page != 'admin_login' && $page != 'admin_pwreset') {
             redirect('/admin', 200);
         }
     }
 }