diff --git a/core/util.inc.php b/core/util.inc.php index 17895b26..7cb831dc 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -1725,7 +1725,26 @@ 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 d386aa44..7d66cb38 100644 --- a/index.php +++ b/index.php @@ -53,6 +53,7 @@ require_once "core/util.inc.php"; // set up and purify the environment _version_check(); _sanitise_environment(); +if(_router()) return false; try { // load base files