public
Description: Command-line blog engine
Homepage: http://rcrowley.org/2008/09/03/bashpress
Clone URL: git://github.com/rcrowley/bashpress.git
bashpress / public / __banzai__.php
100644 41 lines (36 sloc) 1.161 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
 
require_once dirname(__FILE__) . '/../include/init.php';
 
# Find the proper route to use
require_once dirname(__FILE__) . '/../include/routes.php';
if ('' == $_GET['__url__']) { $_GET['__url__'] = '/'; }
foreach ($routes as $pattern => $FILE) {
if (preg_match(
"!^$pattern(?:/|\.(html|xml|json|rss|rdf|atom|php))?(?:\?.*)?$!",
$_GET['__url__'], $URL_PARTS)) {
$URL = array_shift($URL_PARTS);
if (false === strpos($URL, '.')) { $FORMAT = 'html'; }
else { $FORMAT = array_pop($URL_PARTS); }
break;
}
}
if (!isset($URL)) {
$FILE = '404.php';
$URL = $_GET['__url__'];
$URL_PARTS = array();
$FORMAT = 'html';
}
unset($routes);
unset($pattern);
unset($_GET['__url__']);
 
assign('FILE', $FILE);
assign('URL', $URL);
assign('URL_PARTS', $URL_PARTS);
assign('FORMAT', $FORMAT);
 
# Dispatch
# Beyond the superglobals, these are passed to the called file:
# FILE: the name of the file included to handle the request
# URL: the complete request URL, minus the query string
# URL_PARTS: array of matched sub-patterns in the URL
# FORMAT: one (html|xml|json|rss|rdf|php) for determining output format
require_once $FILE;
display();