This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/tests/router.php

26 lines
759 B
PHP
Raw Normal View History

2015-08-01 15:27:07 +00:00
<?php
// custom routing for stand-alone mode
if (PHP_SAPI !== 'cli-server') {
die('cli only');
}
2015-08-01 15:27:07 +00:00
// warehouse files
$matches = [];
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])));
return true;
2015-08-01 15:27:07 +00:00
}
2015-08-02 18:29:25 +00:00
unset($matches);
2015-08-01 15:27:07 +00:00
// use the default handler (serve static files, interpret php files)
if (preg_match('/\.(?:png|jpg|jpeg|gif|css|js|php)(\?.*)?$/', $_SERVER["REQUEST_URI"])) {
return false;
2015-08-01 15:27:07 +00:00
}
// all other requests (use shimmie routing based on URL)
2017-09-22 18:09:07 +00:00
$_SERVER["PHP_SELF"] = '/index.php';
2016-06-17 23:45:58 +00:00
$_GET['q'] = explode("?", $_SERVER["REQUEST_URI"])[0];
error_log($_GET['q']);
2015-08-01 15:27:07 +00:00
require_once "index.php";