示例#1
0
文件: bootstrap.php 项目: GVSO/stupid
<?php

// Load the configuration data
require __DIR__ . '/config.php';
// Load the active modules
$modules = (require __DIR__ . '/modules.php');
// Load the autoloader
require __DIR__ . '/vendor/autoload.php';
use Stupid\Core\Route\RouteManager;
$routeManager = new RouteManager();
$routeManager->setBasePath('/stupid');
foreach ($modules as $module) {
    if (isset($module['routes'])) {
        addRoutes($module['routes'], $routeManager);
    }
}
function addRoutes($routes, &$routeManager)
{
    /** E.g 'get' => array()
     *
     * $method = 'get'
     *
     * $route = the array array()
     */
    foreach ($routes as $method => $route) {
        foreach ($route as $path => $class) {
            $routeManager->map($method, $path, $class);
        }
    }
}
// match current request url
示例#2
0
    if ($_SERVER['SERVER_PORT'] != $default_port) {
        // Если нет, то добавим порт в URL
        $result .= ':' . $_SERVER['SERVER_PORT'];
    }
    // Последняя часть запроса (путь и GET-параметры).
    $result .= $_SERVER['REQUEST_URI'];
    // Уфф, вроде получилось!
    return $result;
}
function addRoutes()
{
    $urlKey = $_SERVER[REQUEST_URI];
    add_rewrite_rule('(kupit_bilet)?$', 'kupit_bilet/' . $urlKey . 'zopa', 'top');
}
//index.php?pagename=$matches[1]
addRoutes();
function to_short_mth($date_str)
{
    $space_idx = strpos($date_str, ' ');
    $date_part = mb_substr($date_str, 0, $space_idx, 'utf-8');
    $mth_part = mb_substr($date_str, $space_idx + 1, 3, 'utf-8');
    return $date_part . ' ' . $mth_part;
}
function to_afisha_date($str, $format, $lang)
{
    $dd = substr($str, 0, 2);
    $mm = substr($str, 3, 2);
    $yy = substr($str, 6, 4);
    $hh = substr($str, 11, 2);
    $mi = substr($str, 14, 2);
    $si = substr($str, 17, 2);