예제 #1
0
파일: ClassLogin.php 프로젝트: s9271/SEW3
 public function getUserByAuthKey($go_home = false, $go_guard = false)
 {
     // sprawdzanie czy istnieje wgl sesja
     if (!$this->is_session_auth) {
         $this->goToLoginPage();
         return;
     }
     // pobieranie uzytkownika
     if (!($user = ClassUser::getUserByAuthKey($this->is_session_auth))) {
         $this->goToLoginPage();
         return;
     }
     // sprawdzanie czy user loguje sie z poprawnego ip
     if ($user['guard_ip'] != $_SERVER['REMOTE_ADDR']) {
         $this->goToLoginPage();
         return;
     }
     // sprawdzanie czy user jest zalogowany
     if ($user['is_logged'] != '1') {
         $this->goToLoginPage();
         return;
     }
     $this->auth_user = $user;
     // sprawdzanie czy czas nieaktywnosci juz minal
     $date_refresh = new DateTime($user['date_refresh']);
     $date_now = new DateTime("now");
     $date_now->sub(new DateInterval('PT' . ClassAuth::$session_time));
     if ($date_refresh < $date_now) {
         $this->logout();
         return;
     }
     $page_action = ClassTools::getValue('page_action');
     // sprawdzanie czy ip jest zweryfikowany
     if (($go_home || $page_action == 'guard') && $user['verified'] == '1') {
         $this->goToHomePage();
         return;
     }
     // sprawdzanie czy ip jest zweryfikowany
     if ($go_guard && $user['verified'] == '0' && $page_action != 'guard') {
         $this->goToGuardPage();
         return;
     }
     // sprawdzanie czy jest sie na stronie dla logowanych
     if ($page_action == 'login' || $page_action == 'haslo') {
         $this->goToHomePage();
         return;
     }
     // przy kazdym wejsciu na strone aktualizuje date ostatniwgo wejscia uzytkonika
     $this->sqlUpdateLoginDateRefresh();
     return;
 }