public function init() { $token = isset($_SESSION['token']) ? $_SESSION['token'] : $_COOKIE['token']; $personal_id = isset($_SESSION['person']) ? $_SESSION['person'] : $_COOKIE['person']; $user_ip = system::getInstance()->getRealIp(); // data 1st raw check before sql is used if (strlen($token) == 32 && (filter_var($personal_id, FILTER_VALIDATE_EMAIL) || strlen($personal_id) > 0 && system::getInstance()->isLatinOrNumeric($personal_id))) { $query = "SELECT * FROM\r\n " . property::getInstance()->get('db_prefix') . "_user a,\r\n " . property::getInstance()->get('db_prefix') . "_user_access_level b,\r\n " . property::getInstance()->get('db_prefix') . "_user_custom c\r\n WHERE (a.email = ? OR a.login = ?) AND a.token = ? AND a.token_ip = ? AND a.aprove = 0 AND a.access_level = b.group_id AND a.id = c.id"; $stmt = database::getInstance()->con()->prepare($query); $stmt->bindParam(1, $personal_id, \PDO::PARAM_STR); $stmt->bindParam(2, $personal_id, \PDO::PARAM_STR); $stmt->bindParam(3, $token, \PDO::PARAM_STR, 32); $stmt->bindParam(4, $user_ip, \PDO::PARAM_STR); $stmt->execute(); if ($stmt->rowCount() == 1) { $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt = null; if (time() - $result[0]['token_start'] < property::getInstance()->get('token_time')) { $this->userindex = $result[0]['id']; foreach ($result[0] as $column_index => $column_data) { $this->userdata[$this->userindex][$column_index] = $column_data; } // set template variables template::getInstance()->set(template::TYPE_USER, 'id', $this->userindex); template::getInstance()->set(template::TYPE_USER, 'name', $this->userdata[$this->userindex]['nick']); template::getInstance()->set(template::TYPE_USER, 'admin', permission::getInstance()->have('global/owner')); template::getInstance()->set(template::TYPE_USER, 'admin_panel', permission::getInstance()->have('admin/main')); template::getInstance()->set(template::TYPE_USER, 'news_add', extension::getInstance()->getConfig('enable_useradd', 'news', extension::TYPE_COMPONENT, 'bol')); template::getInstance()->set(template::TYPE_USER, 'balance', $this->userdata[$this->userindex]['balance']); } } } }
public function make() { if (!property::getInstance()->get('maintenance')) { // is not a maintenance mod return; } if (permission::getInstance()->have('admin/main')) { // not show for admin return; } $login_form = extension::getInstance()->call(extension::TYPE_COMPONENT, 'user')->viewLogin(); // call to login view & worker $tpl = template::getInstance()->twigRender('maintenance.tpl', array('login_form' => $login_form)); // render with login form template::getInstance()->justPrint($tpl, array()); }
protected function twigLoader() { $twig_cache = root . '/cache/'; $tpl_name = $this->getIfaceTemplate(); switch (loader) { case 'front': case 'api': $twig_cache .= user::getInstance()->get('id') < 1 ? 'guest' : 'uid' . user::getInstance()->get('id'); break; case 'back': $twig_cache .= 'admintmp'; break; case 'install': $twig_cache .= 'installtmp'; break; } $template_path_root = root . '/' . property::getInstance()->get('tpl_dir') . '/' . $tpl_name; if (!file_exists($template_path_root)) { // mb default template is available ? if (file_exists(root . '/' . property::getInstance()->get('tpl_dir') . '/default') && in_array(loader, array('front', 'api'))) { property::getInstance()->set('tpl_name', 'default'); $template_path_root = root . '/' . property::getInstance()->get('tpl_dir') . '/default'; } else { exit("Template " . $tpl_name . " is not founded! Exit"); } logger::getInstance()->log(logger::LEVEL_ERR, 'Template ' . $tpl_name . ' is not founded. Use default template.'); } require_once root . "/resource/Twig/Autoloader.php"; \Twig_Autoloader::register(); $this->twig_file = new \Twig_Environment(new \Twig_Loader_Filesystem($template_path_root), array('cache' => $twig_cache, 'charset' => 'utf-8', 'autoescape' => false, 'strict_variables' => false)); if (loader == 'install' || permission::getInstance()->have('global/owner')) { // auto rebuild cache for owner $this->twig_file->enableAutoReload(); } $this->twig_string = new \Twig_Environment(new \Twig_Loader_String()); }