Пример #1
0
    public static function init(){
        ob_start();

        self::$request = new Request();
        Router::init();
        Router::route();
    }
Пример #2
0
 private function init()
 {
     //get user requested route
     if (isset($_GET['node'])) {
         //define route without parameters (helps with showing base URI request)
         $route = $_GET['node'];
         self::$route = $route;
         //break requested route into chunks in array
         $route_chunks = explode("/", $route);
         //define controller
         $controller = $route_chunks[0];
         self::$controller = $controller;
         //define controller directory
         $controller_dir = CONTROLLER_DIR . $controller;
         self::$controller_dir = $controller_dir;
         //define format
         if (!empty($route_chunks[1])) {
             $format = $route_chunks[1];
             self::$format = $format;
         }
         //define parameters - get full url etc and extract all strings after &..
         global $settings;
         $request_uri = $settings['request_uri'];
         //break requested route into chunks in array
         $route_params = explode("&", $request_uri);
         //remove first value from array & return $route_params as just parameters
         $params_shift = array_shift($route_params);
         //update $params array
         foreach ($route_params as $val) {
             $param_chunks = explode("=", $val);
             $params[$param_chunks[0]] = $param_chunks[1];
         }
         self::$params = $params;
     }
 }
Пример #3
0
 /**
  * Change the router state according to the error Code
  * @param string $errorRouteId
  * @param \Exception $error
  * @throws Exception
  * @throws \Exception
  */
 public function route($errorCode, $error)
 {
     // Router knows a route for this error code
     if (isset($this->routeId[$errorCode])) {
         $errorRouteId = $this->routeId[$errorCode];
     } else {
         $errorRouteId = null;
     }
     if ($this->_router->ruleExists($errorRouteId)) {
         // There is a specific route for this error code
         $errorRoute = $errorRouteId;
     } elseif ($this->_router->ruleExists(self::ROUTE_ALL_ERROR)) {
         // There is a default route for all errors
         $errorRoute = self::ROUTE_ALL_ERROR;
     } else {
         // No route for error, do nothing
         $errorRoute = null;
     }
     if ($errorRoute !== null) {
         try {
             // Prepare redirecting in the router
             $this->_router->route($this->_router->getPrefix() . '/' . $errorRoute);
             $this->_router->setVariable('err', $error);
         } catch (\Exception $e) {
             // The router is unable to route the error
             throw new Exception('Unable to handle error ' . $e, 0, $e);
         }
     } else {
         // There is no error route for this error code, just transfert the exception
         throw $error;
     }
 }
Пример #4
0
 /**
  * @covers Zepto\Router::route()
  * @expectedException InvalidArgumentException
  */
 public function testRouteWithInvalidHttpMethod()
 {
     $this->router->route(new \Zepto\Route('/test', function () {
         return 'New test route';
     }), 'NO_SUCH_METHOD');
     $routes = $this->router->routes();
     $this->assertArrayNotHasKey('NO_SUCH_METHOD', $routes);
 }
Пример #5
0
 function dispatch()
 {
     $router = new Router(Request::instance());
     $array = $router->route();
     extract($array);
     // instantiates the controller and runs the action (method) we got from above
     $controller = new $controller();
     $controller->{$action}();
 }
Пример #6
0
 /**
  * Protected constructor to prevent creating a new instance of the
  * *Services* via the `new` operator from outside of this class.
  */
 protected function __construct()
 {
     parent::__construct();
     $this->config = new Config();
     $this->input = new Input($this->config->get('config'));
     $this->output = new Output($this->config->get('mimes'));
     $router = new Router($this->config->get('routes'));
     $this->route = $router->route($this->input->uri());
 }
Пример #7
0
 public function testManyActionParams()
 {
     $uri = '/test/test/param1/param2/param3/param4/param5/param6';
     ob_start();
     $router = new Router($uri, $this->path);
     $router->route();
     $response = ob_get_clean();
     $this->assertEquals('test', $response);
 }
Пример #8
0
 /**
  * This method is only here as a legacy decorator, use url::to.
  *
  * @return \League\URL\URLInterface
  *
  * @deprecated
  */
 public static function route($data)
 {
     $arguments = array_slice(func_get_args(), 1);
     if (!$arguments) {
         $arguments = array();
     }
     $route = \Router::route($data);
     array_unshift($arguments, $route);
     return static::getFacadeRoot()->resolve($arguments);
 }
Пример #9
0
    public function render()
    {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
        Application::loadLibrary('olmi/request');
        Application::loadLibrary('core/router');
        $url = ltrim($_SERVER['REQUEST_URI'], '/');
        $user_session = Application::getUserSession();
        $user_logged = $user_session->getUserAccount();
        Router::setDefaultModuleName($user_logged ? 'profile' : 'login');
        Router::route($url);
        $page = Application::getPage();
        $page = Application::getPage();
        $page->setTitle('OCS');
        $page->addMeta(array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1'));
        $page->addMeta(array('charset' => 'utf-8'));
        $page->addStylesheet(coreResourceLibrary::getStaticPath('/bootstrap/css/bootstrap.min.css'));
        $page->addStylesheet(coreResourceLibrary::getStaticPath('/bootstrap/css/bootstrap-theme.min.css'));
        $page->addStylesheet(coreResourceLibrary::getStaticPath('jquery-ui/jquery-ui-bootstrap.css'));
        $page->addStylesheet(coreResourceLibrary::getStaticPath('/css/admin.css'));
        $page->addScript(coreResourceLibrary::getStaticPath('/js/jquery-1.11.3.min.js'));
        $page->addScript(coreResourceLibrary::getStaticPath('/jquery-ui/jquery-ui.min.js'));
        $page->addScript(coreResourceLibrary::getStaticPath('/bootstrap/js/bootstrap.min.js'));
        $page->addScript(coreResourceLibrary::getStaticPath('/js/application.js'));
        $page->addLiteral('
				<script type="text/javascript">
					jQuery(document).ready(function(){
						App.init();
					});
				</script>
			
			');
        $smarty = Application::getSmarty();
        $module_name = Router::getModuleName();
        $module_params = Router::getModuleParams();
        if ($module_name) {
            $module = Application::getResourceInstance('module', $module_name);
            if (coreAccessControlLibrary::accessAllowed($user_logged, $module)) {
                $content = call_user_func(array($module, 'run'), $module_params);
            } else {
                Application::stackError(Application::gettext('You have no permission to login'));
                $user_session->logout();
                Redirector::redirect(Application::getSeoUrl('/login?back=' . Router::getSourceUrl()));
            }
        } else {
            $content = Application::runModule('page404');
        }
        $smarty->assign('content', $content);
        $html_head = $page->getHtmlHead();
        $smarty->assign('html_head', $html_head);
        /*$smarty->assign('header', Application::getBlock('header'));
        		$smarty->assign('footer', Application::getBlock('footer'));*/
        $template_path = coreResourceLibrary::getTemplatePath('index');
        $smarty->display($template_path);
    }
Пример #10
0
 /**
  * Dispatcher for CGI mode.
  */
 public static function handleCGI()
 {
     require APP_PATH . 'controller/Base.php';
     Router::responseFrontEndFiles('static');
     $oController = Router::route($_SERVER['REQUEST_URI'], APP_PATH);
     $oController->before();
     $aData = $oController->handle();
     $sOutputType = $oController->getOutputType();
     Output::handle($aData, $sOutputType);
     $oController->after();
 }
Пример #11
0
 public function run($config)
 {
     self::register('db', $config['db'], false);
     self::$_loader = new Autoloader();
     self::$_loader->register();
     $session = new Session();
     $session->start();
     $url = substr($_SERVER['REQUEST_URI'], 1);
     if ($url != '') {
         $router = new Router(self::$_loader, 'App');
         $router->route();
     }
 }
Пример #12
0
/**
 * The request router looks at the URI path, tries to load it from /assets,
 * then tries to route the request through the Router if it's a model.
 * If it's not a model, the PageEngine tries to render the template file.
 */
function routeRequest()
{
    $path = getPath();
    if (!$path) {
        return PageEngine::renderPage('index');
    }
    if (File::find("assets/{$path}")) {
        File::render("assets/{$path}");
    }
    try {
        $router = new Router();
        return $router->route($path);
    } catch (ModelExistenceException $e) {
        return PageEngine::renderPage($path);
    }
}
Пример #13
0
 public function handle()
 {
     $request = $this->configuration->getRequest();
     $response = $this->configuration->getResponse();
     $request = Router::route($request);
     $mainController = $this->configuration->getController();
     if (is_null($mainController)) {
         $response->set('Not found');
         $response->setStatus(404, 'Not Found');
         return $response->render();
     }
     $returnValue = $mainController->handle();
     if (!is_null($returnValue)) {
         $response->add($returnValue);
     }
     return $response->render();
 }
Пример #14
0
 /**
  * return the first matching routes with matching additionnal param if any,
  * return false if no match 
  *
  * @return mixed the first matching Route or false if no match
  */
 function route()
 {
     $routes = $this->_routes->getRoutes();
     foreach ($routes as $route) {
         $options = $route->match($this->_url);
         if (is_array($options)) {
             if ($route->isKnownLocation()) {
                 return $route;
             } else {
                 $simplified_url = $route->simplify($this->_url);
                 $location = $route->getLocation();
                 $router = new Router($simplified_url, $location);
                 return $router->route();
             }
         }
     }
     return false;
 }
 /**
  * route Handles incoming requests. 
  * 
  * @access public
  * @return void
  */
 public function route()
 {
     global $logger;
     try {
         // TODO : Refactor Code :
         // $url    = URLParser::parse();
         // $route  = RouteMapper::getRoute($url['route']);
         // $router = new Router();
         // $router->route($route);
         $urlInterpreter = new UrlInterpreter();
         $command = $urlInterpreter->getCommand();
         $router = new Router($command);
         $logger->debug('Routing to : ' . $command->getControllerName());
         $router->route();
     } catch (Exception $e) {
         throw new RouteNotFoundException();
     }
 }
Пример #16
0
    public static function Run() {
        Core::Init();
        
        // login as admin
        //Authorization::makeAuth(array("admin","123"));

        //l(API::parseStylesFile(CUSTOMPATH.DS."Users".DS."Users.views"));

        if( isset( $_POST["ajax"] ) ) Ajax::Run( $_POST );
        else{
            $url = array_keys($_GET);
            if(!isset($url[0]))$url[0] = "";
            $urlArray = explode("/",  substr($url[0],1));
            $urlArray = array_filter($urlArray);
            Router::route( $urlArray );
        }
        
        
    }
Пример #17
0
/**
 * @param $isHashHost Boolean Is this host a router
 * @param $hostNumber Number How many host there
 * @param $packImages Boolean make a zip pack for images?
 */
function main($isHashHost, $hostNumber, $packImages)
{
    $url = isset($_GET['url']) ? $_GET['url'] : '';
    # URL given
    if ($url) {
        # it's an image url
        if (Input::isImageUrl($url)) {
            Output::redirect($url);
        } elseif ($isHashHost) {
            Router::route($url, $hostNumber);
        } else {
            $mc = new mc();
            Input::loadMemcached($mc);
            Output::loadMemcached($mc);
            Handler::loadMemcached($mc);
            Handler::handle($url, $packImages);
        }
    } else {
        exit_script('Hello Tumblr!');
    }
}
Пример #18
0
 function route($method, $uri)
 {
     if (substr($uri, 0, strlen("/public/")) == "/public/") {
         // serve static files
         $this->serve_static($uri);
     } else {
         // dynamic content
         header('Content-Type: text/html; charset=utf-8');
         $route = Router::route($method, $uri);
         if (is_numeric($route) and $route == 404) {
             echo 404;
         } else {
             // if it's in format "controller#action"
             if (is_string($route)) {
                 Router::extract_params($method, $uri);
                 $parts = explode('#', $route);
                 $controller = $parts[0] . "Controller";
                 $action = $parts[1];
                 // create a new controller instance
                 $instance = new $controller();
                 // inject some config variables
                 $instance->url_prefix = self::$url_prefix;
                 $instance->public_folder = $this->public_folder;
                 // execute before callback
                 $instance->before_action();
                 $result = $instance->{$action}();
                 if ($result === null) {
                     // render template
                     echo Renderer::render_view($instance, $parts[0], $action);
                 } else {
                     // render what returned
                     echo $result;
                 }
                 // execute after callback
                 $instance->after_action();
             }
         }
     }
 }
Пример #19
0
    } else {
        die('Awkward path mate.');
    }
    $rel_uri = ltrim($uri, '/');
    // Re-assign $_GET array
    parse_str($_SERVER['QUERY_STRING'], $_GET);
    $_SERVER['REQUEST_METHOD'] = 'GET';
} else {
    // Create path from URI
    $uri = $_SERVER['REQUEST_URI'];
    if (strncmp($uri, '/', 1) === 0) {
        $uri = explode('?', $uri, 2);
        $_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : '';
        $uri = rawurldecode($uri[0]);
    } else {
        die('Awkward path mate.');
    }
    // Re-assign $_GET array
    parse_str($_SERVER['QUERY_STRING'], $_GET);
    // Get the requested controller. Assign the default controller
    // from the config file if no controller is requested.
    $rel_uri = ltrim(substr($uri, strlen($_SERVER['SCRIPT_NAME']) - strlen('/index.php')), '/');
}
if (empty($rel_uri)) {
    $rel_uri = trim(Config::instance()->item('site', 'default_controller'));
    if (!$rel_uri) {
        die('No controller specified');
    }
}
Router::route($rel_uri);
Пример #20
0
<?php

require_once LIBPATH . '/Router.php';
$url = $_SERVER['REQUEST_URI'];
$router = new Router("/pf");
$router->route($url);
Пример #21
0
$eventManager = new EventManager();
Settings::setProtected('eventManager', $eventManager);
// Initialize transcript controller
// --------------------------------------------------
Transcript::setEventManager($eventManager);
Transcript::register('load', array('TranscriptController', 'load'));
Transcript::register('save', array('TranscriptController', 'save'));
Transcript::register('diff', array('TranscriptController', 'diff'));
// Initialize workflow controller
// --------------------------------------------------
Workflow::register('callback', array('WorkflowController', 'parse'));
// Initialize notifications controller
// --------------------------------------------------
$notifications = Settings::getProtected('notifications');
$notificationsList = array();
foreach ($notifications as $key => $value) {
    // Get an array of just the keys
    array_push($notificationsList, $key);
}
$notify = new NotificationManager();
$notify->setEventManager($eventManager);
$notify->registerNotifications($notificationsList, array('NotificationController', 'send'));
Settings::setProtected('notify', $notify);
// Parse the routes
// --------------------------------------------------
// The \.?([^/]*)?/? at the end allows us to add .json, etc. for other formats
// Create the routes we want to use
$routes = array('#^/?$#' => 'SystemPageController::index', '#^/login/?$#' => 'SystemPageController::login', '#^/logout/?$#' => 'SystemPageController::logout', '#^/signup(\\.[^/]+)?/?$#' => 'SystemPageController::signup', '#^/signup/activate/(.*)(\\.[^/]+)?/?$#' => 'SystemPageController::activate', '#^/messages/?$#' => 'SystemPageController::message', '#^/install/?$#' => 'SystemPageController::install', '#^/test/(.*)/?$#' => 'SystemPageController::test', '#^/(users)/([^/]+)/projects/([^/]+)/items/get(\\.[^/]+)?/?#' => 'ItemPageController::getNewItem', '#^/(users)/([^/]+)/projects/([^/]+)/items/([^/.]+)/transcript(\\.[^/]+)?/?#' => 'ItemPageController::transcript', '#^/(users)/([^/]+)/projects/([^/]+)/items/([^/.]+)/delete(\\.[^/]+)?/?#' => 'ItemPageController::deleteItem', '#^/(users)/([^/]+)/projects/([^/]+)/items/([^/.]+)/(proof|review)(\\.[^/]+)?/?#' => 'ItemPageController::itemProof', '#^/(users)/([^/]+)/projects/([^/]+)/items/([^/.]+)/(proof|review|edit)(\\.[^/]+)?/?#' => 'ItemPageController::itemProof', '#^/(users)/([^/]+)/projects/([^/]+)/items/([^/.]+)(\\.[^/]+)?/?#' => 'ItemPageController::item', '#^/(users)/([^/]+)/projects/([^/]+)/items(\\.[^/]+)?/?#' => 'ItemPageController::items', '#^/(users)/([^/]+)/projects/([^/]+)/transcript/split(\\.[^/]+)?/?#' => 'ProjectPageController::splitTranscript', '#^/(users)/([^/]+)/projects/([^/]+)/transcript(\\.[^/]+)?/?#' => 'ProjectPageController::transcript', '#^/(users)/([^/]+)/projects/([^/]+)/membership/leave(\\.[^/]+)?/?#' => 'ProjectPageController::membershipLeave', '#^/(users)/([^/]+)/projects/([^/]+)/membership(\\.[^/]+)?/?#' => 'ProjectPageController::membership', '#^/(users)/([^/]+)/projects/([^/]+)/admin(\\.[^/]+)?/?#' => 'ProjectPageController::admin', '#^/(users)/([^/]+)/projects/([^/]+)/upload(\\.[^/]+)?/?#' => 'ProjectPageController::upload', '#^/(users)/([^/]+)/projects/([^/]+)/import(\\.[^/]+)?/?#' => 'ProjectPageController::import', '#^/(users)/([^/]+)/projects/new-project(\\.[^/]+)?/?#' => 'ProjectPageController::newProject', '#^/(users)/([^/]+)/projects/([^/.]+)(\\.[^/]+)?/?#' => 'ProjectPageController::projectPage', '#^/(users)/([^/]+)/projects(\\.[^/]+)?/?#' => 'ProjectPageController::projects', '#^/users/([^/]+)/dashboard(\\.[^/]+)?/?#' => 'UserPageController::userDashboard', '#^/users/([^/]+)/settings(\\.[^/]+)?/?#' => 'UserPageController::userSettings', '#^/users/([^/.]+)(\\.[^/]+)?/?#' => 'UserPageController::userPage', '#^/users(\\.[^/]+)?/?#' => 'UserPageController::users', '#^/projects/([^/]+)/items/get(\\.[^/]+)?/?#' => 'ItemPageController::getNewItem', '#^/projects/([^/]+)/items/([^/.]+)/transcript(\\.[^/]+)?/?#' => 'ItemPageController::transcript', '#^/projects/([^/]+)/items/([^/.]+)/delete(\\.[^/]+)?/?#' => 'ItemPageController::deleteItem', '#^/projects/([^/]+)/items/([^/.]+)/(proof|review)/(\\.[^/]+)/?#' => 'ItemPageController::itemProof', '#^/projects/([^/]+)/items/([^/.]+)/(proof|review|edit)(\\.[^/]+)?/?#' => 'ItemPageController::itemProof', '#^/projects/([^/]+)/items/([^/.]+)(\\.[^/]+)?/?#' => 'ItemPageController::item', '#^/projects/([^/]+)/items(\\.[^/]+)?/?#' => 'ItemPageController::items', '#^/projects/([^/]+)/transcript/split(\\.[^/]+)?/?#' => 'ProjectPageController::splitTranscript', '#^/projects/([^/]+)/transcript(\\.[^/]+)?/?#' => 'ProjectPageController::transcript', '#^/projects/([^/]+)/membership/leave(\\.[^/]+)?/?#' => 'ProjectPageController::membershipLeave', '#^/projects/([^/]+)/membership(\\.[^/]+)?/?#' => 'ProjectPageController::membership', '#^/projects/([^/]+)/admin(\\.[^/]+)?/?#' => 'ProjectPageController::admin', '#^/projects/([^/]+)/upload(\\.[^/]+)?/?#' => 'ProjectPageController::upload', '#^/projects/([^/]+)/import(\\.[^/]+)?/?#' => 'ProjectPageController::import', '#^/projects/new-project(\\.[^/]+)?/?#' => 'ProjectPageController::newProject', '#^/projects/([^/.]+)(\\.[^/]+)?/?#' => 'ProjectPageController::projectPage', '#^/projects(\\.[^/]+)?/?#' => 'ProjectPageController::projects', '#^/admin(\\.[^/]+)?/?$#' => 'AdminPageController::admin');
$router = new Router('SystemPageController::fileNotFound');
$router->route($routes);
Пример #22
0
<?php

require 'includes/classes/Messenger.php';
$hades = new Messenger();
require 'includes/init.php';
$response = new ResponseObject();
$router = new Router();
$response = $router->route($response);
$view = new View($response);
$view->generateView();
//$hades->printLog();
Пример #23
0
<?php

require_once "./vendor/autoload.php";
require_once "bootstrap.php";
$class = Router::route();
#get the configuration file for the app
$file = file_get_contents("./etc/config.json");
$config = json_decode($file, true);
if ($class) {
    error_log("Route to {$class}");
    $server = new $class($entityManager, $config);
}
Пример #24
0
<?php

/***
 * init.php - application startup
 */
// load configuration info
require_once APP_PATH . 'config.php';
// load core libraries
require_once APP_PATH . 'core.php';
// ... any other files to initialize the app go here
// if REDIRECT_URL doesn't exist, then the index.php page was requested
// directly. Display the default home page view.
try {
    Router::route($_SERVER['REDIRECT_URL']);
} catch (exception $e) {
    // routing failed
    echo '<p>The requested page or resource could not be found.</p>';
    if (DEBUG_MODE) {
        echo '<p>' . $e->getMessage() . '</p>';
    }
}
Пример #25
0
require_once __DIR__ . '/../../src/HTTPException.php';
$router = new Router();
$router->on('get', function ($request, $services) {
    session_start();
    $stmt = $services['pdo']->prepare('
			SELECT 
				`id`, 
				`username`, 
				UNIX_TIMESTAMP(`created`) AS `created`,
				`admin`
			FROM `User` 
			WHERE `id` = (
				SELECT `ownerID` 
				FROM `Session` 
				WHERE `id` = :sessionID 
					AND `active` = 1
				LIMIT 1)');
    $stmt->bindValue('sessionID', session_id(), PDO::PARAM_STR);
    $stmt->execute();
    $result = $stmt->fetch(PDO::FETCH_ASSOC);
    if ($result) {
        $result['id'] = intval($result['id']);
        $result['created'] = intval($result['created']);
        $result['admin'] = $result['admin'] !== '0';
        return $result;
    } else {
        throw new UnauthorizedException();
    }
});
$router->route();
Пример #26
0
<?php

require "config.php";
require "libraries/router.php";
require "libraries/template.php";
require "kernel/general.php";
Router::route();
if (file_exists(ROUTE_CONTROLLER_PATH)) {
    require ROUTE_CONTROLLER_PATH;
} else {
    throw new Exception('00404');
}
$class = ROUTE_MODULE;
$controller = new $class();
if (!empty(Router::$action)) {
    $action_method = 'action_' . Router::$action;
    if (method_exists($controller, $action_method)) {
        $controller->{$action_method}();
    } else {
        throw new Exception('00404');
    }
} else {
    if (method_exists($controller, 'action_default')) {
        $controller->action_default();
    } else {
        throw new Exception('00404');
    }
}
Пример #27
0
 /**
  * Runs the application by retrieving and calling the method for the current action.
  *
  * @author Yorick Peterse
  * @return void
  */
 public function run()
 {
     if (empty($this->mappings)) {
         throw new Exception\MappingException("No methods have been mapped to any URL");
     }
     // Set the PATH_INFO based on the CLI arguments.
     if (defined('KOI_DEBUG') != TRUE and PHP_SAPI === 'cli') {
         $_SERVER['PATH_INFO'] = CLI::uri();
     }
     // Route the call
     $result = Router::route($this->mappings);
     if ($result === FALSE) {
         throw new Exception\MappingException("No methods have been bound to {$_SERVER['PATH_INFO']}");
     }
     $this->render($result['body'], $result['status'], $result['content_type']);
 }
Пример #28
0
namespace Blog;

$get = array_keys($_GET);
$route = array_shift($get);
/** Autoloader */
spl_autoload_register(function ($class) {
    $path = str_replace(__NAMESPACE__ . '\\', '', $class);
    $path = str_replace('\\', '/', $path);
    require_once $path . '.php';
});
Model::init();
//Router::route('install', ['Blog\AbstractController', 'install']);
//
Router::route('posts', ['Blog\\Controller\\Front', 'posts']);
//Router::route('edit/post/(\d+)', ['Blog\Controller\Front', 'form']);
//Router::route('delete/post/(\d+)', ['Blog\Controller\Front', 'delete']);
//Router::route('edit/post/', ['Blog\Controller\Front', 'form']);
//Router::route('new/post', ['Blog\Controller\Front', 'form']);
//
//Router::route('users', ['Blog\Controller\User', 'index']);
//Router::route('delete/user/(\d+)', ['Blog\Controller\User', 'delete']);
//Router::route('new/user', ['Blog\Controller\User', 'form']);
//Router::route('edit/user/', ['Blog\Controller\User', 'form']);
//Router::route('edit/user/(\d+)', ['Blog\Controller\User', 'form']);
Router::route('([a-z]+)/(index)');
Router::route('([a-z]+)/(single)/(\\d*)');
Router::route('([a-z]+)/(delete)/(\\d+)');
Router::route('([a-z]+)/(insert)');
Router::route('([a-z]+)/(edit)/(\\d*)');
Router::route('([a-z]+)/(save)/(\\d*)');
Router::execute($_SERVER['QUERY_STRING']);
Пример #29
0
<?php

session_start();
/*
 *  File name: index.php
 *  Created by: Sander van Mook
 *  Contact: sandervanmook84@gmail.com
 * 
 *  Purpose of this file:
 * - Handle all requests to this website
 * - Include all files needed to use this site
 */
// Load the config file
require_once 'sys/config.php';
// Direct requests to the router
$router = new Router();
$router->route($_GET, $_POST);
Пример #30
0
include './config/autoloader.php';
?>
<!doctype html>
<html class='admin-page'>
<head>
	<meta name='viewport' content='width=device-width,initial-scale=1' >
	<link href='/reset.css' rel='stylesheet'/>
	<link href='/main.css' rel='stylesheet'/>
  <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?autoload=true&amp;skin=sunburst&amp;lang=css" defer="defer"></script>
</head>
<body>
	<div class='container'>
		<div class='inner-container'>
			<?php 
$router = new Router();
$router->route('/admin.php/edit/:articleid', 'admin\\edit\\EditArticleHandler');
$router->route('/admin.php/create', 'admin\\create\\CreateArticleHandler');
$router->route('/admin.php', 'admin\\ShowArticlesHandler');
$router->route('/admin.php/cancel-edit/:articleid', 'admin\\CancelEditHandler');
$router->route('/admin.php/create/:articleid', 'CreateArticleHandler');
$router->route('/admin.php/create/preview/:articleid', 'admin\\create\\preview\\CreatePreviewArticleHandler');
$router->route('/admin.php/edit/preview/:articleid', 'admin\\edit\\preview\\EditPreviewArticleHandler');
$router->setDefaultHandlerClass('admin\\ShowArticlesHandler');
$router->dispatch();
?>
		</div>
	</div>
</body>
</html>