Вход Регистрация
Файл: wenr.online/public/index.php
Строк: 10
<?php



require '../system/bootstrap.php';


$routes = require '../routes.php';
$uri = htmlspecialchars($_SERVER['REQUEST_URI']);
$file = false;
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);


foreach (
$routes as $pattern => $route) {
    if (
preg_match(sprintf('#^%s$#', $pattern), $uri, $matches)) {
        
array_shift($matches);
        if (!empty(
$matches)) {
            foreach (
$matches as $key => $value) {
                if (!
is_int($key)) {
                    
$symbol[$key] = $value;
                }
            }
            foreach (
$symbol as $key => $value) {
                
$key = sprintf('<%s>', $key);
                if (
strpos($route, $key) !== false) {
                    
$route = str_replace($key, $value, $route);
                }
            }
            
$_GET = array_merge($_GET, $symbol);
        }
        unset(
$value);
        
$file = __ROOT__ . '/app/' . $route . '.php';
    }
}

unset(
$routes, $uri, $route, $pattern, $matches);

if (
is_file($file)) {
    require 
$file;
} else {
    
header('Location: /?404');
    exit;
}
Онлайн: 0
Реклама