/** * Register Cookie Alert * * @param cfg configuration */ function init($cfg) { //load assets View::jslib("cookiealert.js", "pe.cookiealert.init(" . json_encode($cfg) . ");"); View::css("cookiealert.css"); return true; }
private function loadNavigation() { $arr = array('NAME' => $_SERVER['PHP_AUTH_USER']); $arr['NODES'] = View::load(array('engine', 'adminNavigationNode'), array('HREF' => '/' . __CLASS__, 'alias' => 'Статистика', 'img' => View::img('chart', 'icons'))); $files = Engine::loadControllers(); $permissions = Users::getAdminPermissions($_SERVER['PHP_AUTH_USER']); if (count($permissions) == 1 && empty($permissions[0]['controller'])) { $permissions = false; } foreach ($files as $row) { if ($permissions && !in_array($row['name'], $permissions)) { continue; } if (strstr($row['name'], strtolower(__CLASS__))) { $row['name'] = 'admin'; } $row['HREF'] = '/' . __CLASS__ . '/' . $row['name']; $row['img'] = View::img($row['img'], 'icons'); $arr['NODES'] .= View::load(array('engine', 'adminNavigationNode'), $row); } View::setTitle('Страница статистики'); View::css('engine'); View::css('admin'); View::js('engine'); View::js('admin'); View::loadContent('adminNavigation', $arr, 'engine'); }
/** * Register MultiServer * * @param cfg not used */ public function init($cfg) { //! check whether we are enabled //if(empty($cfg['type'])) // return false; View::jslib("multiserver.js"); View::css("multiserver.css"); }
function index() { View::setTitle('Авторизация'); View::css('engine'); View::css(); View::loadContent('loginForm'); View::render(); }
/** * Initialization hook * * @return true on success */ function init($cfg) { //! if user is not logged in or does not have the necessary //! priviledge then do not register this service if (!Core::$user->has("siteadm|webadm")) { return false; } //! load configuration into properties if (!empty($cfg['expert'])) { $this->expert = true; } if (!empty($cfg['pagehistory'])) { $this->revert = true; } if (isset($cfg['purge'])) { $this->purge = intval($cfg['purge']); } if ($this->purge < 3) { $this->purge = 8; } if ($this->purge > 999) { $this->purge = 999; } if (!empty($cfg['metas'])) { $this->metas = str_getcsv($cfg['metas'], ','); } else { $this->metas = ["description", "keywords"]; } //! add menu if (Core::$user->has("siteadm")) { //! two level menu for site adminsitrators View::menu(L("Contents") . "@siteadm|webadm", [L("Pages") . "@siteadm|webadm" => "cms/pages", L("Layouts") . "@siteadm" => "cms/layouts"]); } else { //! simple link for web administrators View::menu(L("Contents") . "@webadm", "cms/pages"); } //! disable caching for all cms related applications //! also load the stylesheet for them if (Core::$core->app == "cms") { Core::$core->nocache = true; View::css("cms.css"); } }
<?php /** * PHP Portal Engine v3.0.0 * https://github.com/bztsrc/phppe3/ * * Copyright LGPL 2016 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * <http://www.gnu.org/licenses/> * * @file vendor/phppe/spectrum/init.php * @author bzt * @date 23 May 2016 * @brief */ namespace PHPPE; View::css("spectrum.css"); View::jslib("spectrum.js");
static function renderError($msg) { self::setTitle('Ошибка'); View::css('engine'); self::loadContent('error', array('ERROR_DESC' => $msg), 'engine'); self::render(true); }
static function start() { try { Session::start(); //загрузка параметров движка Settings::$ENGINE = Engine::loadSettings(); //проверка закрыт сайт или нет if (Settings::$ENGINE['site'] == 0) { View::renderClosed('Извините, доступ на сайт закрыт'); } View::$template = Settings::$ENGINE['template']; Controller::$lang = Settings::$ENGINE['default_lang']; $route = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); //считываем из сессии id пользователя (-1 назначаем неавторизованным пользователям) $user_id = -1; if (isset($_SESSION['uid']) && !empty($_SESSION['uid']) && is_numeric($_SESSION['uid'])) { $user_id = $_SESSION['uid']; } /*$pwd = "ruh"; $hash = Crypt::password_hash($pwd); if(Crypt::password_verify($pwd,$hash)) echo "true"; else echo "false"; exit;*/ /*print_r(AclModel::getRoles()); exit;*/ //проверяем, не был ли передан тип запроса (например при ajax запросе) $request_type = null; if (isset($_POST["request_type"]) && is_numeric($_POST["request_type"])) { $request_type = $_POST["request_type"]; ini_set('display_errors', 0); } else { $page = PageManager::findPage($route == '/' ? '/main' : $route); if (!$page) { throw new Exception404(); } View::setTitle($page['title']); View::css(explode('|', $page['css'])); View::js(explode('|', $page['js'])); //TODO: замутить парсер META $args = json_decode($page['content'], true); foreach ($args as $key => $val) { $class = new $args[$key]['c'](); View::$args[$key] = $class->{$args}[$key]['m'](!empty($args[$key]['a']) ? $args[$key]['a'] : null); } //print_r(View::$args); View::render('index', Settings::$ENGINE['template']); } //Если страницы не были найдены, то обращаемся напрямую к контроллеру $routes = explode('/', $route); array_shift($routes); if ($routes) { //задаем контроллер и его метод по умолчанию $controller_name = Settings::$DEFAULT_CONTROLLER; $action = 'index'; //распарсиваем адресную строку //определяем имя контроллера if (!empty($routes[0])) { $controller_name = $routes[0]; } //его метод if (!empty($routes[1])) { $action = $routes[1]; } //все остальные параметры адресной строки преобразуем в аргументы $i = 2; $arg = array(); while (!empty($routes[$i])) { $arg[] = $routes[$i++]; } //создаем объект для работы контроллером if (!class_exists($controller_name)) { throw new Exception404(); } $controller = new $controller_name(); //проверяем, если это пост запрос c request_type, обрабатываем его соответственно if ($request_type != null) { //проверяем, есть ли данный метод у контроллера if (method_exists($controller_name, $action)) { //если метод есть, то //запускаем главную функцию обработки запроса $res = $controller->{$action}(isset($arg) ? $arg : NULL); //выводим результат echo json_encode(array('answer' => $res)); } else { //если функция не видна, то выдаем сответствующюю инфу echo json_encode(array("error" => 'Не найдена функция для обработки запроса (' . $controller_name . '::' . $action . ')!')); } exit; } //если это не запрос, просто вызываем метод $controller->{$action}(isset($arg) ? $arg : NULL); unset($routes); } else { throw new Exception404(); } } catch (mysqli_sql_exception $e) { if (Settings::$DEBUG) { echo '<br>DEBUG: mysqli_sql_exception: ' . $e->getMessage() . ' => ' . $e->getCode() . '<br>'; } Log::writeLog($e->getMessage() . ' ' . $e->getCode()); } catch (Exception404 $e) { // Здесь сделаем так, что бы 404 выдавалось в контент или куда-то еще, что бы не нарушать целостность сайта // View::render404(); echo '404'; } catch (Exception $e) { if (Settings::$DEBUG) { echo '<br>DEBUG: Exception: ' . $e->getMessage() . ' => ' . $e->getCode() . '<br>'; } } //// проверка на запрещенные или разрешенные IP-адреса // if(Settings::$ENGINE['checkIP'] > 0) // { // $ip = Engine::checkIp($_SERVER['REMOTE_ADDR']); // // if($ip && Settings::$ENGINE['checkIP'] == 1) // View::renderClosed($ip['reason'], $ip['date']); // else // if(!$ip && Settings::$ENGINE['checkIP'] == 2) // View::renderClosed('Доступ к сайту с Вашего IP-адреса запрещен'); // } // // /** // * проверка на запрещенные или разрешенные ОС, браузеры или их версии // * TODO: тут, по-хороошему, нужно поближе рассмотреть этот мехвнизм, обточить // */ // if(Settings::$ENGINE['checkFStuff'] > 0) // { // $r = Engine::checkForbiddenStuff(self::getUserBrowser()); // if($r && Settings::$ENGINE['checkFStuff'] == 1) // View::renderClosed($r); // else // if(!$r && Settings::$ENGINE['checkFStuff'] == 2) // View::renderClosed('Сайт не поддерживает работу с Вашими устройствами'); // } // // //// проверка включена ли мультиязычность или нет, по умолчанию используется только русский язык // if(Settings::$ENGINE['multiLang']) // if(!empty($_COOKIE['lang'])) // Controller::$lang = $_COOKIE['lang']; }
/** * PHP Portal Engine v3.0.0 * https://github.com/bztsrc/phppe3/ * * Copyright LGPL 2016 bzt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * <http://www.gnu.org/licenses/> * * @file vendor/phppe/bootstrap/init.php * @author bzt * @date 1 Jan 2016 * @brief Bootstrap integration in PHPPE */ namespace PHPPE; //load style sheests View::css("bootstrap.min.css"); View::css("bootstrap-theme.min.css"); //load JavaScript View::jslib("bootstrap.min.js", "", 1);
* * Copyright LGPL 2016 bzt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * <http://www.gnu.org/licenses/> * * @file vendor/phppe/bootstrapcdn/init.php * @author bzt * @date 1 Jan 2016 * @brief Bootstrap CDN integration in PHPPE */ namespace PHPPE; if (!Core::isInst("bootstrap")) { //load style sheests View::css("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"); View::css("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"); //load JavaScript View::jslib("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js", "", 1); //register ourself as bootstrap too Core::lib("bootstrap", "PHPPE\\Extension"); }