Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 43 lines (32 sloc) 1.017 kB
f828656 @pkrumins imported the code
authored
1 <?php
2 /*
3 ** Peteris Krumins
4 ** peteris.krumins@gmail.com
5 **
cf9c194 @pkrumins explained it a bit more. renamed framework to 'piece of code'
authored
6 ** A simple URL routing code, written in 2000.
f828656 @pkrumins imported the code
authored
7 */
8
9 error_reporting(E_ALL);
10
11 # check and parse the site configuration
12 #
13 if (!file_exists('website.conf')) {
14 die('site configuration file was not found');
15 }
16
17 $SiteConfig = parse_ini_file('website.conf', true);
18
19 $parts = parse_url($_SERVER['REQUEST_URI']);
20 $path = preg_replace('#^/+#', '', $parts['path']); // drop slashes from the beginning of the request path
cf9c194 @pkrumins explained it a bit more. renamed framework to 'piece of code'
authored
21 $path = preg_replace('#(//)+#', '', $path); // drop duplicate slashes
f828656 @pkrumins imported the code
authored
22 $path = preg_replace('#/+$#', '', $path); // drop trailing slashes
23 $path = split('/', $path);
24
25 $VConfig['request_path'] = $path;
26
27 $request_page = $VConfig['request_path'][0];
28
29 if (isset($SiteConfig['pages'][$request_page])) {
30 $page = $request_page;
31 }
32 else if ($request_page == '') {
33 $page = 'default';
34 }
35 else {
36 $page = 'error';
37 }
38
39 require_once $SiteConfig['pages'][$page];
40
41 ?>
42
Something went wrong with that request. Please try again.