view 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
line wrap: on
line source

<?php
//
// The hack to get this working on PHP 5.4 built-in web server,
// simply run the following:
//
// $ php -S localhost:8888 router.php
//
// Then head your browser to http://localhost:8888/
//

if (!file_exists("index.php"))
  return true;

$_SERVER["HTTPS"] = "on";

if (preg_match("/\/[a-z0-9_-]+\.(?:png|jpg|jpeg|gif|css|php|js|txt|ogg|mp3|ttf)/i", $_SERVER["REQUEST_URI"]))
  return false; // Serve the requested resource as-is.
else
if (preg_match("/^\/([a-z]+)/", $_SERVER["REQUEST_URI"], $m))
{
  $_GET["page"] = $m[1];
  require_once "index.php";
  return true;
}
else
  return false;
?>