stand-alone router mode
This commit is contained in:
parent
e3cb33efb9
commit
3d5172e235
2 changed files with 20 additions and 0 deletions
|
@ -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 *
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue