Esempio n. 1
0
 public static function go()
 {
     try {
         Glue::stick(array('/' => 'filethis_handler_main'));
     } catch (Exception $e) {
         header('HTTP/1.1 404 Not Found');
         die($e->getMessage());
     }
 }
Esempio n. 2
0
<?php

if (getenv('OBF_LIBDIR')) {
    define('OBF_LIBDIR', getenv('OBF_LIBDIR'));
}
if (!defined('OBF_LIBDIR')) {
    die('Shit is all f****d up and bullshit: missing libdir.');
}
require_once OBF_LIBDIR . 'obfind.php';
OBFind::init();
try {
    Glue::stick(array('/' => 'obfind_handler_home', '/sms' => 'obfind_handler_sms'), '_obfind');
} catch (OBFindException $e) {
} catch (Exception $e) {
    header('HTTP/1.1 404 Not Found');
    die($e->getMessage());
}
Esempio n. 3
0
File: router.php Progetto: tdt/start
$allroutes = app\core\Config::get("routes");
// Only keep the routes that use the requested HTTP method
$unsetkeys = preg_grep("/^" . strtoupper($_SERVER['REQUEST_METHOD']) . "/", array_keys($allroutes), PREG_GREP_INVERT);
foreach ($unsetkeys as $key) {
    unset($allroutes[$key]);
}
$routes = array();
// Drop the HTTP method from the route
foreach ($allroutes as $route => $controller) {
    $route = preg_replace('/^' . strtoupper($_SERVER['REQUEST_METHOD']) . '(\\s|\\t)*\\|(\\s|\\t)*/', "", trim($route));
    $routes[trim($route)] = trim($controller);
}
//$log->logInfo("The routes we are working with", $routes);
try {
    // This function will do the magic.
    Glue::stick($routes);
} catch (Exception $e) {
    // Instantiate a Logger
    $log = new Logger('router');
    $log->pushHandler(new StreamHandler(app\core\Config::get("general", "logging", "path") . "/log_" . date('Y-m-d') . ".txt", Logger::ERROR));
    // Generator to generate an error page
    $generator = new Generator();
    $generator->setTitle("The DataTank");
    if ($e instanceof tdt\exceptions\TDTException) {
        // DataTank error
        $log->addError($e->getMessage());
        set_error_header($e->getCode(), $e->getShort());
        if ($e->getCode() < 500) {
            $generator->error($e->getCode(), "Sorry, but there seems to be something wrong with the call you've made", $e->getMessage());
        } else {
            $generator->error($e->getCode(), "Sorry, there seems to be something wrong with our servers", "If you're the system administrator, please check the logs. Otherwise, check back in a short while.");