Exemplo n.º 1
0
 protected function OnOutput()
 {
     $vars = array('title' => $this->title, 'content' => $this->content, 'menu' => $this->menu, 'errors' => $this->errors, 'data' => $this->data);
     $page = $this->Template('admin', $vars);
     if (JL::ex('ajax', 1)) {
         $page = '';
     }
     echo $page;
 }
Exemplo n.º 2
0
 protected function OnOutput()
 {
     $vars = array('title' => $this->title, 'content' => $this->content, 'menu' => $this->menu, 'errors' => $this->errors, 'data' => $this->data);
     if (JL::ex('type', 'ajax') || JL::ex('type', 'form')) {
         $page = '';
     } else {
         $page = $this->Template('main', $vars);
     }
     echo $page;
 }
Exemplo n.º 3
0
 public static function Registration($data)
 {
     global $DB;
     $data['status'] = isset($data['status']) ? 1 : 0;
     $salt = JL::Random(32);
     $new_pwd = JL::Random(10);
     $password = sha1(sha1($new_pwd . $salt) . SECRET_KEY);
     $data['salt'] = $salt;
     $data['password'] = $password;
     try {
         $sth = $DB->prepare('INSERT INTO users (`name`, role, email, phone, skype, status, salt, password)
                                   VALUES (:name, :role, :email, :phone, :skype, :status, :salt, :password)');
         $sth->execute($data);
     } catch (PDOException $e) {
         die('We have a problems! Notify administrators this issue. Code 101');
     }
     $msg = "You are logged in Ankorinvest.\n\r\nYour login: {$data['email']} \n\r\nYour password: {$new_pwd}";
     Mail::send($data['email'], 'New password', $msg, 'Ankorinvest');
 }
Exemplo n.º 4
0
 /**
  * Авторизация
  *
  * @param $login
  * @param $password
  * @return bool
  */
 public static function Login($login, $password)
 {
     global $DB;
     $STH = $DB->prepare('SELECT * from `users` WHERE `email` = :login');
     $STH->execute(array(':login' => $login));
     $user = $STH->fetch();
     if (!$user) {
         return 'Incorrect user';
     }
     $must_be = sha1(sha1($password . $user['salt']) . SECRET_KEY);
     if ($user['password'] != $must_be) {
         return 'Incorrect user';
     }
     $hash = sha1(JL::Random(20));
     $data = array('hash' => $hash, 'time' => time(), 'ip' => $_SERVER['REMOTE_ADDR']);
     $STH = $DB->prepare("UPDATE `users` SET `hash` = :hash, `last_login` = :time, `ip` = :ip");
     $STH->execute($data);
     setcookie("id", $user['id'], time() + 60 * 60 * 24);
     setcookie("hash", $hash, time() + 60 * 60 * 24);
     $_SESSION['user']['name'] = $user['name'];
     $_SESSION['user']['avatar'] = $user['name'];
     $_SESSION['user']['role'] = $user['role'];
     return true;
 }
Exemplo n.º 5
0
 public function actionLogout()
 {
     Auth::Logout();
     JL::redirect('/');
 }
Exemplo n.º 6
0
 public function actionLogout()
 {
     Auth::Logout('c_admin_index');
     JL::redirect('/');
 }