Exemple #1
0
 public function __construct()
 {
     $this->_model = new \models\pick();
     $session = \helpers\session::id();
     if (!$this->_model->get_session($session)) {
         url::redirect('login');
     } else {
         $this->user_id = $this->_model->get_session($session);
     }
 }
Exemple #2
0
 public function __construct()
 {
     $this->_model = new \models\admin\orders();
     $session = \helpers\session::id();
     if (!$this->_model->get_session($session)) {
         url::redirect('admin/login');
     }
     $this->_acl = new \helpers\acl();
     $this->_rights = $this->_acl->is_allow();
     if (json_decode($this->_rights[0]->pages)->{'orders'}->acl_level == 0) {
         url::redirect('admin/login');
     }
 }
Exemple #3
0
 public function __construct()
 {
     $this->_model = new \models\admin\permissions();
     $session = \helpers\session::id();
     if (!$this->_model->get_session($session)) {
         url::redirect('admin/login');
     }
     $this->_acl = new \helpers\acl();
     $this->_rights = $this->_acl->is_allow();
     if (json_decode($this->_rights[0]->pages)->{'permissions'} != 1) {
         url::redirect('admin/login');
     }
     \helpers\session::pull('url');
 }
Exemple #4
0
 public function login()
 {
     $session = \helpers\session::id();
     if ($this->_model->get_session($session)) {
         url::redirect('');
     }
     $data['title'] = 'Вход';
     if (!empty($_POST)) {
         //print_r($_POST);
         //exit;
         if (!isset($_POST['captcha']) || empty($_POST['captcha'])) {
             $error[] = 'Введите данные с каринки';
         } else {
             $captcha = new \helpers\raincaptcha();
             if (!$captcha->checkAnswer($_POST['captcha'])) {
                 $error[] = 'Некорректные цифры с картинки';
             }
         }
         if (!isset($_POST['login']) || empty($_POST['login'])) {
             $error[] = 'Введите логин';
         } else {
             $username = $_POST['login'];
         }
         if (!isset($_POST['password']) || empty($_POST['password'])) {
             $error[] = 'Введите пароль';
         } else {
             $password = $_POST['password'];
         }
         if (\helpers\password::verify($password, $this->_model->getLogin($username)) == 0) {
             $error[] = 'Неверные логин или пароль';
         }
         if (!$error) {
             $data = array('session' => $session);
             $where = array('login' => $username);
             $this->_model->setSession($data, $where);
             url::redirect('');
         }
     }
     view::rendertemplate('header', $data);
     view::render('login', $data, $error);
     view::rendertemplate('footer');
 }
Exemple #5
0
 public function login()
 {
     $session = \helpers\session::id();
     if ($this->_model->get_session($session)) {
         url::redirect('admin');
     }
     $data['title'] = 'Админка';
     if (!empty($_POST)) {
         $username = $_POST['login'];
         $password = $_POST['password'];
         if (\helpers\password::verify($password, $this->_model->getLogin($username)) == 0) {
             $error[] = 'Неверные логин или пароль';
         } else {
             $data = array('session' => $session);
             $where = array('login' => $username);
             $this->_model->setSession($data, $where);
             url::redirect('admin');
         }
     }
     view::rendertemplate('header', $data);
     view::render('admin/login', $data, $error);
     view::rendertemplate('footer');
 }
Exemple #6
0
 /**
  * create a new instance of the database helper
  */
 public function __construct()
 {
     //connect to PDO here.
     $this->_db = \helpers\database::get();
     $this->sessionId = \helpers\session::id();
 }