function __construct() { $visitor = new Visitor(); $visitor->add(Helper::getIP(), Helper::getBrowser()); $page = new Page(); if (isset($_GET['adress']) && !isset($_POST)) { $page->register($_GET['adress']); Route::get($_GET['adress']); } else { if (isset($_GET['adress']) && isset($_POST)) { $page->register($_GET['adress']); Route::get($_GET['adress'], $_POST); } else { $page->register('/'); Route::get('/'); } } }
public static function run() { Route::run(); }
<?php session_start(); $public = strpos($_SERVER['REQUEST_URI'], "public"); $dir = substr($_SERVER['REQUEST_URI'], 0, $public); $dir = str_replace("/", "", $dir); $GLOBALS['dir'] = $dir; require $_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/autoload.php"; require $_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/routes.php"; use lib\Route; use lib\Auth; $route = Route::matchRoute(); if ($route === false) { require $_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/views/404.php"; die('match route'); } $ctrl = "controllers\\" . $route['controller'] . "Controller"; if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/" . $ctrl . ".php")) { require $_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/views/404.php"; die('not such controller!'); } $a = new $ctrl(); $params = $route['params']; if (method_exists($a, $route['action']) === false) { require $_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/views/404.php"; die('not such action in the controller!'); } $view = call_user_func_array(array($a, $route['action']), $params); if (is_object($view)) { $view_path = file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/views/" . $view->view_file . ".php"); if (isset($view->data)) {
<?php use lib\Route; Route::get(array('route' => '/', 'uses' => 'Home.index'));