示例#1
0
 public function __construct()
 {
     @session_start();
     self::$db = \DatabaseModel::getInstance();
     $this->post_data = filter_input_array(INPUT_POST);
     if ($this->post_data) {
         $this->csrfCheck();
         $this->post_data = $this->validateInput($this->post_data);
     }
     $get_data = filter_input_array(INPUT_GET);
     if ($get_data) {
         $get_data = $this->validateInput();
     }
 }
示例#2
0
 /**
  * metoda pro zjisteni, zda prihlasovany uzivatel ma pravo na vstup do admina
  * @param    array   $credentials vyplnene udaje v prihlasovacim formulari
  */
 public function authenticate(array $credentials)
 {
     self::$db = \DatabaseModel::getInstance();
     $username = $credentials['username'];
     $password = $credentials['password'];
     $row = self::$db->getUser($username);
     if ($row) {
         $password_is_correct = password_verify($password, $row['password']);
         if ($password_is_correct !== true) {
             throw new Exception('Špatně zadané heslo');
         } else {
             $_SESSION['username'] = $row['username'];
             $_SESSION['rights'] = $row['rights_level'];
         }
     } else {
         throw new Exception('Špatně zadané jméno');
     }
 }
示例#3
0
 public function __construct()
 {
     @session_start();
     self::$db = \DatabaseModel::getInstance();
     $this->user = new \User();
     $is_logged_in = $this->user->isLoggedIn();
     if ($is_logged_in === false) {
         $this->redirect('/admin/prihlaseni/login');
     }
     $this->post_data = filter_input_array(INPUT_POST);
     if ($this->post_data) {
         $csrfCheck = $this->csrfCheck();
         if ($csrfCheck === false) {
             $this->info = $_SESSION['info'] = "Akce se nepovedla, prosím obnovte stránku a zkuste to znovu.";
             $this->redirect('/admin/');
         }
         $this->post_data = $this->validateInput($this->post_data);
     }
 }
示例#4
0
 public function __construct()
 {
     self::$db = \DatabaseModel::getInstance();
 }