/** * Определение контроллера и экшена */ private static function prepareController() { self::prepareRequest(); if (!($furl = \Controller\Router::findRule(self::$_path))) { $furl = explode('/', preg_replace('#\\/{1,}#', '/', self::$_path)); } self::$_controller = (isset($furl[1]) and $furl[1]) ? ucfirst(mb_strtolower($furl[1])) : 'Index'; self::$_action = (isset($furl[2]) and $furl[2]) ? ucfirst(mb_strtolower($furl[2])) : 'Index'; unset($furl[0], $furl[1], $furl[2]); self::$_furl = array_values($furl); }
use View\Page; use View\Pages\Banned; use View\Pages\FourOhFour; define("START_TIME", microtime(true)); require_once 'inc/config.php'; require_once 'inc/globals.php'; try { // Page router try { if (Site::backupInProgress() && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') { die((new Page("Backup in Progress", "<h2>Backing Up</h2><div class='centertext'>Please come back later.</div>"))->display()); } if (Site::isBanned()) { die((new Banned())->display()); } Router::route(strtok($_SERVER["REQUEST_URI"], '?')); } catch (NotFoundException $ex) { echo (new FourOhFour($ex->getMessage()))->display(); } catch (PermissionException $ex) { die((new FancyPage("/b/ stats: ACCESS DENIED", Site::parseHtmlFragment('accessDenied.html', ['__privilege__', '__required__'], [$ex->has, $ex->required]), 0))->display()); } catch (PDOException $ex) { $page = new Page("Database Error", ""); $page->appendToBody(div('There was an error with the database.<br>' . 'It may be misconfigured.', 'centertext') . div($ex->getMessage() . nl2br($ex->getTraceAsString()), 'centertext')); header("HTTP/1.0 500 Internal Server Error"); echo $page->display(); } catch (Exception $ex) { $page = new FancyPage("Error", "", 0); $page->setBody("<h1>Error</h1>" . "<div class='centertext'>" . "Your request could not be processed. The following error was encountered: " . "<br>" . $ex->getMessage() . " at " . $ex->getFile() . ":" . $ex->getLine() . "</div>"); echo $page->display(); } } catch (Throwable $err) {
* Copyright (C) 2008-2009 Gabriel Sobrinho <*****@*****.**> * * This file is part of Core PHP Framework. * * Core PHP Framework 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. * * Core PHP Framework 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. * * You should have received a copy of the GNU Lesser General Public License * along with Core PHP Framework. If not, see <http://www.gnu.org/licenses/>. * * @package Core * @subpackage Application * @copyright 2008-2009 Gabriel Sobrinho <*****@*****.**> * @license http://opensource.org/licenses/lgpl-3.0.html GNU Lesser General Public License version 3 (LGPLv3) * @version 0.1 */ use Controller\Router; // Admin route Router::module('admin', function ($admin) { $admin->connect('/', array('controller' => 'dashboard')); }); // Root route Router::connect('/');