예제 #1
0
 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('/');
         }
     }
 }
예제 #2
0
 public static function run()
 {
     Route::run();
 }
예제 #3
0
파일: index.php 프로젝트: bkb24/mvc
<?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)) {
예제 #4
0
파일: routes.php 프로젝트: bkb24/mvc
<?php

use lib\Route;
Route::get(array('route' => '/', 'uses' => 'Home.index'));