From 21a1b176c66e74942808d76c13b4c055dad4f5eb Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 1 Aug 2015 16:27:07 +0100 Subject: [PATCH] separate router from index.php --- core/util.inc.php | 20 -------------------- index.php | 1 - tests/router.php | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 tests/router.php diff --git a/core/util.inc.php b/core/util.inc.php index 7cb831dc..b00b96e2 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -1725,26 +1725,6 @@ function _get_query() { return @$_POST["q"]?:@$_GET["q"]; } -function _router() { - // custom routing for stand-alone mode - if(php_sapi_name() == 'cli-server') { - // warehouse files - $matches = array(); - if(preg_match('/\/_(images|thumbs)\/([0-9a-f]{32}).*$/', $_SERVER["REQUEST_URI"], $matches)) { - header('Content-Type: image/jpeg'); - print(file_get_contents(warehouse_path($matches[1], $matches[2]))); - exit; - } - - // static files - if(preg_match('/\.(?:png|jpg|jpeg|gif|css|js)$/', $_SERVER["REQUEST_URI"])) { - return true; - } - - $_SERVER["PHP_SELF"] = '/'; - $_GET['q'] = $_SERVER["REQUEST_URI"]; - } -} /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Code coverage * diff --git a/index.php b/index.php index 7d66cb38..d386aa44 100644 --- a/index.php +++ b/index.php @@ -53,7 +53,6 @@ require_once "core/util.inc.php"; // set up and purify the environment _version_check(); _sanitise_environment(); -if(_router()) return false; try { // load base files diff --git a/tests/router.php b/tests/router.php new file mode 100644 index 00000000..99edbcc5 --- /dev/null +++ b/tests/router.php @@ -0,0 +1,24 @@ +