示例#1
0
ini_set('display_errors', 1);
define("APPPATH", realpath(__DIR__ . "/../app") . DIRECTORY_SEPARATOR);
require_once APPPATH . "/ClassLoader.php";
system\core\ClassLoader::registerDir(APPPATH . "/models/lib");
system\core\ClassLoader::registerDir(APPPATH . "/models");
system\core\ClassLoader::registerDir(APPPATH . "/models/util");
system\core\ClassLoader::registerDir(APPPATH . "/controllers");
system\core\ClassLoader::registerDir(APPPATH . "/views");
system\core\ClassLoader::registerDir(APPPATH . "/views/helper");
system\core\ClassLoader::registerDir(APPPATH . "/views/util");
if (!empty($_SERVER["PATH_INFO"])) {
    $path = $_SERVER["PATH_INFO"];
} else {
    $controller = new ErrorController();
    $controller->render($_GET, 400, "PATH_INFO doesn't exist");
    exit;
}
if (preg_match("!/item/([0-9]+)/?!", $path, $match)) {
    $_GET["id"] = $match[1];
    $controller = new ItemController();
    $controller->detail($_GET);
} elseif (preg_match("!/items/?(.?+)!", $path, $match)) {
    $controller = new ItemController();
    $controller->search($_GET);
} elseif (preg_match("!/categories/?(.?+)!", $path, $match)) {
    $controller = new CategoryController();
    $controller->search($_GET);
} else {
    $controller = new ErrorController();
    $controller->render($_GET, 404, "Request URL is no longer available");
}