Example #1
0
 public static function dispatch()
 {
     $url = new Url();
     $uri = $url->getPath();
     foreach (array_reverse(self::$routes, true) as $route => $class) {
         if (preg_match("~^{$route}\$~", $uri, $params)) {
             Router::$current = $class;
             $return = call_user_func_array(array('Controller', 'dispatch'), array_merge(array($class), array_slice($params, 1)));
             if (!(false === $return)) {
                 $vars = get_class_vars($class);
                 $type = 'text/html';
                 if (isset($vars['type'])) {
                     $type = $vars['type'];
                 }
                 # PHP >= 5.3
                 # if ( isset($class::$type) )
                 #     $type = $class::$type;
                 //Response::setHeader('Content-Type', 'application/xhtml+xml');
                 Response::setHeader('Content-Type', "{$type};charset=UTF-8");
                 Response::setBody($class, $return);
                 return;
             }
             Router::$current = null;
         }
     }
     if (Response::getHttpResponseCode() == 200) {
         $class = 'Error404';
         $return = Controller::dispatch($class);
         Response::setHeader('Content-Type', 'text/html;charset=UTF-8');
         Response::setBody($class, $return);
         //Response::setHeader('HTTP/1.0 404 Not Found');
         //Response::setHttpResponseCode(404);
         //Response::setBody('404', 'Error 404');
     }
 }
Example #2
0
 public function dispatch()
 {
     // Searches routes array matching the url path
     foreach ($this->routes as $key => $value) {
         // convert route params into valid regex
         $regex = preg_replace('<@(\\w+)>', '(?<$1>[\\w-]+)', $key);
         $match = preg_match("<^{$regex}\$>", $this->path, $matches);
         if ($match) {
             break;
         }
     }
     // If match, evaluate the route, otherwise use default route
     if ($match) {
         $route = preg_replace_callback('|@([\\w\\d-]+)|', function ($keys) use(&$matches) {
             return @$matches[$keys[1]];
         }, $value);
     } else {
         $route = 'error/404';
     }
     // Split parts (file, class, action)
     $parts = explode('->', $route);
     $controller_file = $parts[0];
     $controller_action = (count($parts) > 1 ? $parts[1] : 'index') . 'Action';
     $controller_class = basename($parts[0]);
     // Parameters
     $params = array_merge($matches, $_GET);
     // Dispatch controller
     require "{$controller_file}.php";
     Controller::dispatch($controller_class, $controller_action, $params);
 }
Example #3
0
 public function post()
 {
     $return = @file_put_contents('application.ini', Controller::dispatch('Helpers_Config', $this->config));
     if (false === $return) {
         return '/admin/configuracion?error=1';
     }
     return '/admin/configuracion?edited=1';
 }
Example #4
0
 /**
  * Dispatch request
  */
 public static function dispatch()
 {
     $uri = preg_replace('/^\\/( ?=. )|( ?<=. )\\/$/', '', $_SERVER['PATH_INFO'] ?: '/');
     $options = null;
     foreach (self::$routes as $route) {
         if ($options = $route->match($uri)) {
             break;
         }
     }
     if (!$options) {
         throw new Router\Exception('No route matches');
     }
     foreach ($options as $param => $value) {
         $_REQUEST[$param] = $value;
     }
     \Controller::dispatch($options['controller'], $options['action']);
 }
<?php

error_reporting(E_ALL);
require 'config.php';
$controller = new Controller();
$controller->dispatch($_GET['perform']);
Example #6
0
<?php

// $Id$
/**
 * Initialization page
 * @author Ryan McCue <*****@*****.**>
 * @package Lilina
 * @version 1.0
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
/** */
define('LILINA_PATH', dirname(__FILE__));
define('LILINA_INCPATH', LILINA_PATH . '/inc');
$settings = array();
require_once LILINA_INCPATH . '/core/install-functions.php';
lilina_check_installed();
require_once LILINA_INCPATH . '/core/conf.php';
lilina_level_playing_field();
require_once LILINA_INCPATH . '/core/plugin-functions.php';
$timer_start = lilina_timer_start();
require_once LILINA_INCPATH . '/core/version.php';
Locale::load_default_textdomain();
require_once LILINA_INCPATH . '/core/feed-functions.php';
require_once LILINA_INCPATH . '/core/file-functions.php';
require_once LILINA_INCPATH . '/core/skin.php';
do_action('init');
//Templates::load();
Controller::dispatch();
<?php

require_once 'Controller.php';
require_once 'RouterRegex.php';
$router = new RouterRegex();
$router->addRoute("/:controller/:action/alnum:user/int:photoId/in/regex:(?P<groupType>([a-z]+?))-(?P<groupId>([0-9]+?))");
$router->addRoute("/error", array('controller' => 'error', 'action' => 'showError'));
$controller = new Controller();
$controller->setRouter($router);
$controller->dispatch('/photos/getPhoto/dshafik/5584010786/in/set-72157626290864145');
$controller->dispatch('/users/dshafik');
Example #8
0
<?php

/*
 * Copyright(c) 2009 limitlink,Inc. All Rights Reserved.
 * http://limitlink.jp/
 * 文字コード UTF-8
 */
require dirname(__FILE__) . '/controller.php';
$controller = new Controller();
$hash = $controller->dispatch();
$view = new ApplicationView($hash);
$helper = new Helper();
Example #9
0
 /**
  * run
  * @access public
  * @return void
  */
 public function run()
 {
     // set up core components;
     $this->setup();
     View::assignLanguage();
     // use controller to dispatch
     Controller::dispatch($this->mDefaultController, $this->mCore);
     // use view
     View::display();
     if ($this->mCache) {
         $this->mCache->save();
     }
     $this->execTime();
 }
Example #10
0
 /**
  * Executes command and returns the response created by the response factory.
  *
  * @param mixed $command
  * @return mixed|HttpResponse
  */
 protected function dispatch($command)
 {
     try {
         $data = parent::dispatch($command);
         return $this->responseFactory->create($data);
     } catch (Exception $e) {
         Log::debug($e->getMessage() . ': ' . $e->getTraceAsString());
         return $this->responseFactory->create($e);
     }
 }
Example #11
0
<?php

// $Id: index.php 424 2009-06-26 10:54:53Z cubegames $
/**
 * Initialization page
 * @author Ryan McCue <*****@*****.**>
 * @package Lilina
 * @version 1.0
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
/** */
define('LILINA_PATH', dirname(__FILE__));
define('LILINA_INCPATH', LILINA_PATH . '/inc');
$settings = array();
error_reporting(E_ALL);
require_once LILINA_INCPATH . '/core/install-functions.php';
lilina_check_installed();
require_once LILINA_INCPATH . '/core/conf.php';
lilina_level_playing_field();
require_once LILINA_INCPATH . '/core/plugin-functions.php';
$timer_start = lilina_timer_start();
require_once LILINA_INCPATH . '/core/version.php';
Locale::load_default_textdomain();
require_once LILINA_INCPATH . '/core/feed-functions.php';
require_once LILINA_INCPATH . '/core/file-functions.php';
require_once LILINA_INCPATH . '/core/skin.php';
do_action('init');
//Templates::load();
$controller = new Controller();
$controller->dispatch();
Example #12
0
<?php

include $_SERVER['ROOT_DIR'] . '/autoload.php';
i18n::register();
Session::init();
Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?'));
Example #13
0
            case "about":
                $title = "À propos | ExifCool";
                $meta_title = "À propos de l'application | ExifCool";
                $meta_description = "Détails techniques sur la mise en place de l'application.";
                $meta_image = $_SERVER['SERVER_NAME'] . "/ExifCool/ui/images/photographer.jpg";
                $meta_url = $_SERVER['SERVER_NAME'] . "/ExifCool" . $_SERVER['REQUEST_URI'];
                break;
            case "detail":
                $title = $_GET['t'];
                $meta_title = $_GET['t'];
                $meta_description = "Une photo disponible sur ExifCool";
                $meta_image = $_SERVER['SERVER_NAME'] . "/ExifCool/ui/images/photos/" . $_GET['q'];
                $meta_url = $_SERVER['SERVER_NAME'] . "/ExifCool" . $_SERVER['REQUEST_URI'];
                break;
        }
    } else {
        $ctrl = new Controller();
        $res = $ctrl->dispatch();
        $title = "Accueil | ExifCool";
        $meta_title = "Galerie d'images | ExifCool";
        $meta_description = "Une galerie d'images pour le module UMDN3C";
        $meta_image = $_SERVER['SERVER_NAME'] . "/ExifCool/ui/images/photographer.jpg";
        $meta_url = $_SERVER['SERVER_NAME'] . "/ExifCool";
    }
    require_once "includes/header.html";
    echo $res;
    require_once "includes/footer.html";
} catch (Exception $e) {
    header('Content-Type: text/html; charset=utf-8');
    echo $e->getMessage();
}
Example #14
0
    }
    function setReturnCode($code, $text)
    {
        header("HTTP/1.0 " . $code . " " . $text);
    }
}
$output = new Output();
$method = $_SERVER["REQUEST_METHOD"];
if ($method == "GET") {
    if (strlen($security_token_read) > 0) {
        if (!isset($_SERVER["HTTP_X_AUTH_TOKEN"]) || $_SERVER["HTTP_X_AUTH_TOKEN"] != $security_token_read) {
            $output->setReturnCode(401, "Not authorized");
            die("Not authorized\n");
        }
    }
} else {
    if (strlen($security_token_write) > 0) {
        if (!isset($_SERVER["HTTP_X_AUTH_TOKEN"]) || $_SERVER["HTTP_X_AUTH_TOKEN"] != $security_token_write) {
            $output->setReturnCode(401, "Not authorized");
            die("Not authorized\n");
        }
    }
}
$controller = new Controller($host_d_path, $reload_command, $lease_file);
$controller->setOutput($output);
$request = $_SERVER["REQUEST_URI"];
if (strlen($_SERVER["QUERY_STRING"]) > 0) {
    $request = substr($request, 0, strlen($_SERVER["REQUEST_URI"]) - strlen($_SERVER["QUERY_STRING"]) - 1);
}
$controller->dispatch($method, $request, file_get_contents('php://input'), $_GET);