comparison util/router.php @ 1022:f2b392ee89e8

Import utility directory.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Nov 2015 21:34:15 +0200
parents
children
comparison
equal deleted inserted replaced
1020:2a259e243350 1022:f2b392ee89e8
1 <?php
2 //
3 // The hack to get this working on PHP 5.4 built-in web server,
4 // simply run the following:
5 //
6 // $ php -S localhost:8888 router.php
7 //
8 // Then head your browser to http://localhost:8888/
9 //
10
11 if (!file_exists("index.php"))
12 return true;
13
14 $_SERVER["HTTPS"] = "on";
15
16 if (preg_match("/\/[a-z0-9_-]+\.(?:png|jpg|jpeg|gif|css|php|js|txt|ogg|mp3|ttf)/i", $_SERVER["REQUEST_URI"]))
17 return false; // Serve the requested resource as-is.
18 else
19 if (preg_match("/^\/([a-z]+)/", $_SERVER["REQUEST_URI"], $m))
20 {
21 $_GET["page"] = $m[1];
22 require_once "index.php";
23 return true;
24 }
25 else
26 return false;
27 ?>