示例#1
0
 public function __construct()
 {
     $lang = cookie::get('jq_session_language');
     Translator::setLang($lang ?: 'ru');
     $const_data = constData::load(BASEDIR . '/caru/config.php');
     $request = coreInput::getCleanInput();
     $output = coreOutput::getInstance();
     $output->assign('SERVER_URL', SERVER_URL);
     $output->assign('SITE_PATH', SITE_PATH);
     $output->assign('erp_flag', defined('SECTIONS') && SECTIONS == 'erp');
     $output->assign('const_data', $const_data);
     $output->assign('cache', cache::getInstance());
     $output->assign('language', Translator::getLang());
     $output->setDir(BASEDIR . '/caru/');
     $postfix = !defined('SECTIONS') || SECTIONS != 'terminal' ? "/" : "/terminal";
     $output->setDir(BASEDIR . '/caru/', $postfix);
     $output->setTemplate('blank');
     $this->section = isset($request['section']) ? $request['section'] : null;
     $this->act = isset($request['act']) ? $request['act'] : null;
     //-----------------
     // Авторизация
     //-----------------
     /*
     // для обратной совместимости с логином CashAssist
     if($this->act=='ext_login') {
     	if(empty($request['login']) || empty($request['pass']))
     		die(0);
     	die($this->externalLogin($request['login'],$request['pass']));
     }
     */
     $session = user_bo::session();
     if (!$session) {
         // #36015
         $backurl = filter_input(INPUT_SERVER, 'REQUEST_URI') ? filter_input(INPUT_SERVER, 'REQUEST_URI') : '';
         $output->setTemplate('login');
         $output->toTemplate('backurl', $backurl);
         $output->display();
         return false;
     }
     // удаленным - нет
     if (in_array('deleted', user_bo::getSessionUserGroups())) {
         header('HTTP/1.1 403 Forbidden, please log in');
         LogErrors::add("\n-------BEGIN-----\n" . "\n{$_SERVER['REQUEST_URI']}\n" . 'Case 3 (deleted). s_user: '******'session_false.log');
         user_bo::logout();
         $output->setTemplate('login');
         $output->display();
         return false;
     }
     if (!$this->checkAccess()) {
         LogErrors::add("\n-------BEGIN-----\n" . "\n{$_SERVER['REQUEST_URI']}\n" . 'Case 5 (no access). s_user: '******'session_false.log');
         header('HTTP/1.1 403 Forbidden, please log in');
         return false;
     }
     if ($this->section && $this->act) {
         $output->setTemplate($this->section . "/" . $this->act);
     }
     //-----------------
     // Подключаем контроллер
     //-----------------
     try {
         if (class_exists($this->section . "_controller")) {
             $cont_class = $this->section . "_controller";
             $cont = new $cont_class($this);
         } else {
             $cont = new Controller($this);
         }
         if ($this->act && is_callable(array($cont, $this->act))) {
             call_user_func(array($cont, $this->act));
         }
     } catch (Exception $e) {
         $output->setTemplate('_error');
         $output->assign('exeption', $e);
     }
     $user = user_bo::getSessionUser();
     $sections = $this->getAllowedSections();
     $user['groups'] = user_bo::getSessionUserGroups();
     $output->assign('sections', $sections);
     $output->assign('user', $user);
     $output->assign('section', $this->section ? $sections[$this->section] : null);
     $output->assign('act', $this->act);
     $output->assign('title', $this->act ? $sections[$this->section]['items'][$this->act] : null);
     $output->display();
     return true;
 }