/**
  *
  */
 public function before()
 {
     $is_guest = \Registry::getCurrentUser()->isGuest();
     // Дополнительные функции
     $this->InitEnvironment();
     if (!Request::current()->is_ajax()) {
         // Add Google Font
         Assets::css('Google_Font', 'https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic&subset=latin,cyrillic-ext,cyrillic');
         /*ADD google maps JS*/
         Assets::js('google_maps_api', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&libraries=drawing&places&geometry');
         Assets::js('jQuery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js');
         Assets::css('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', ['media' => 'screen']);
         Assets::js('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js');
         //GMAP Plugin js
         Assets::js('cluster', base_UI . 'js/plugins/gmap/marker.js');
         Assets::js('gmap', base_UI . 'js/plugins/gmap/gmaps.js');
         /*Базовые стили шаблона*/
         //Global Assets
         Assets::js('globalJS', base_UI . 'js/pages/global.js');
         Assets::css('awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css');
         Assets::css('stl', base_UI . 'css/style.css');
         /*BootBox Js file*/
         Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js');
         /*Login Js file*/
         Assets::js('LoginJs', base_UI . 'js/Auth/login.js');
         /*Register Js file*/
         Assets::js('RegisterJs', base_UI . 'js/Auth/register.js');
         //Zopim Helper js
         Assets::js('zopim', base_UI . 'js/index/zopim.js');
         //MAP js
         Assets::js('map1', base_UI . 'js/map/map.js');
         Assets::js('map2', base_UI . 'js/pages/map.js');
         Assets::js('map3', base_UI . 'js/map/catalog.js');
         $this->template = \smarty\View::init();
         $this->renderULogin();
         if (!$is_guest) {
             $access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
             $user_id = \Registry::getCurrentUser()->iduser;
             $this->template->assign(['current_user' => \Registry::getCurrentUser(), 'isAdmin' => $access->get(\Auth\Access::User_Is_Admin), 'isModerator' => $access->get(\Auth\Access::User_Is_Moderator)]);
         } else {
             $this->template->assign(['current_user' => \Registry::getCurrentUser()]);
         }
         $this->template->assign(['localis' => $this->localis, 'local' => $this->i18n]);
     } else {
         $this->setJSONHeader();
         // Mobile API
         if (!isset($_POST)) {
             $error = array('status' => 'error', 'message' => 'No Data', 'code' => '2');
             echo json_encode($error);
             return;
         }
         /** @var $dbSession UserSession */
         if ($_POST['token']) {
             $condition = (new \DBCriteria())->addColumnCondition(['token' => $_POST['token']])->addCondition('`expired`>=UNIX_TIMESTAMP(NOW())');
             /** @var $dbSession UserSession */
             $sessionData = UserSession::model()->with('user')->find($condition);
             \Registry::setCurrentUser($sessionData->user);
         }
     }
 }
Exemple #2
0
 /**
  *
  */
 public function before()
 {
     if (\Registry::getCurrentUser()->isGuest()) {
         if ($this->request->controller() != 'Main' && $this->request->action() != 'login') {
             #todo Fix it!
             if (!\Request::current()->is_ajax()) {
                 \HTTP::redirect(\Route::get('SystemRoute')->uri(['controller' => 'Main', 'action' => 'login']), 302);
             }
         }
     }
     if (!Request::current()->is_ajax()) {
         // Add Google Font
         Assets::css('Google_Font', 'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,300italic,400italic,700italic|Lustria');
         Assets::js('jQuery', base_UI . 'libs/jquery-2.1.1.js');
         Assets::css('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', ['media' => 'screen']);
         Assets::js('bootstrap', 'http:////netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js');
         Assets::css('font-awesome', 'http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css', ['media' => 'screen']);
         /*Базовые стили шаблона*/
         Assets::css('stl', base_UI . 'AdminLTE/css/style.css');
         Assets::css('lightbox', base_UI . 'libs/lightbox/css/lightbox.css');
         /*BootBox Js file*/
         Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js');
         /*Login Js file*/
         Assets::js('LoginJs', base_UI . 'js/Auth/login.js');
         /*Register Js file*/
         Assets::js('RegisterJs', base_UI . 'js/Auth/register.js');
         //uLogin js
         Assets::js('uLogin', 'http://ulogin.ru/js/ulogin.js');
         //Add notification plugin
         Assets::js('notification', base_UI . 'libs/bootstrap/msg/bootstrap-msg.js');
         Assets::css('notification', base_UI . 'libs/bootstrap/msg/bootstrap-msg.css');
         Assets::css('AdminLTE', base_UI . 'AdminLTE/css/AdminLTE.css');
         Assets::js('AdminLTE_App', base_UI . 'AdminLTE/js/AdminLTE/app.js');
         $this->template = \Smarty\View::init();
         if (!Request::current()->is_ajax()) {
             $access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
             $this->template->assign(['current_user' => \Registry::getCurrentUser(), 'isAdmin' => $access->get(\Auth\Access::User_Is_Admin), 'isModerator' => $access->get(\Auth\Access::User_Is_Moderator)]);
         }
     }
 }
Exemple #3
0
 public function action_GetJson()
 {
     $data = User::model()->findAll();
     $access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
     if ($access->get(\Auth\Access::User_Is_Admin)) {
         $aoColumnsData = [];
         /** @var $item User */
         foreach ($data as $item) {
             $currentUserAccess = new \Auth\Access($item->access_level);
             $tmp = ['id' => $item->iduser, 'fio' => $item->first_name, 'email' => $item->email, 'Access' => $currentUserAccess->get(\Auth\Access::User_Login) ? 'Yes' : 'No'];
             $aoColumnsData[] = $tmp;
         }
         $this->response->body(json_encode(['aaData' => $aoColumnsData]));
     } else {
         throw new \HTTP_Exception_403('Admin Only');
     }
 }
Exemple #4
0
 /**
  * @param $mail
  * @param $pass
  * @return bool|int
  */
 public static function createSession($mail, $pass)
 {
     /** @var $userInfo User */
     if (!($userInfo = User::model()->findByAttributes(['email' => $mail]))) {
         return -1;
     }
     //$pass = Protect::Crypt($pass.\Cookie::$salt,$userInfo->salt);
     $pass = Protect::Crypt($pass . $userInfo->salt, $userInfo->salt);
     //Если пароли не совпадают
     if ($pass != $userInfo->pass) {
         return -2;
     }
     $access = new \Auth\Access($userInfo->access_level);
     $isAdmin = $access->get(\Auth\Access::User_Is_Admin);
     $isModerator = $access->get(\Auth\Access::User_Is_Moderator);
     //Если юзверю не разрешено логинится
     /*if( !$isAdmin && !$isModerator  )
     		{
     			return -3;
     		}*/
     return self::startSession($userInfo);
 }
Exemple #5
0
 public function action_GetJson()
 {
     $data = \Model\UserPayment::model()->with('iduser0', 'iduserCredit')->findAll();
     $access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
     if ($access->get(\Auth\Access::User_Is_Admin)) {
         $aoColumnsData = [];
         if (!$data) {
             $this->response->body(json_encode(['aaData' => $aoColumnsData]));
             return;
         }
         /** @var $item User */
         foreach ($data as $key => $item) {
             $tmp = ['id' => $item->iduser_payment, 'price' => $item->price, 'date' => date("Y-m-d H:i", $item->date_pay), 'remaining' => $item->iduserCredit->price_remaining, 'user' => $item->iduser0->first_name . " " . $item->iduser0->last_name];
             $aoColumnsData[] = $tmp;
         }
         $this->response->body(json_encode(['aaData' => $aoColumnsData]));
     } else {
         throw new \HTTP_Exception_403('Admin Only');
     }
 }
Exemple #6
0
 public function action_GetJson()
 {
     $data = \Model\Pages::model()->with('idpageType')->findAll();
     $access = new \Auth\Access(\Registry::getCurrentUser()->access_level);
     if ($access->get(\Auth\Access::User_Is_Admin)) {
         $aoColumnsData = [];
         if (!$data) {
             $this->response->body(json_encode(['aaData' => $aoColumnsData]));
             return;
         }
         /** @var $item User */
         foreach ($data as $key => $item) {
             $tmp = ['id' => $item->idpages, 'title' => $item->title, 'description' => $item->description, 'type' => $item->idpageType->name];
             $aoColumnsData[] = $tmp;
         }
         $this->response->body(json_encode(['aaData' => $aoColumnsData]));
     } else {
         throw new \HTTP_Exception_403('Admin Only');
     }
 }