forked from stuporglue/TreeTrumpet
/
index.php
32 lines (26 loc) · 1.22 KB
/
index.php
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
<?php
// This is the router for TreeTrumpet.
// Since TreeTrumpet is supposed to be 0-config we need to work where .htaccess doesn't
// PHP files such as tree.php or individual.php should require index.php which will take over
require_once('lib/treetrumpet.php');
// Some pretty simple processing to handle getting here either via
// tree.php or tree
$endpoint = basename($_SERVER['SCRIPT_FILENAME']); // index.php if htaccess is working, or tree.php
// If htaccess is working and the page was tree then ruri (REQUEST_URI) should be filled in.
if(array_key_exists('ruri',$_GET)){
$path_info = str_replace(dirname($_SERVER['SCRIPT_NAME']),'',$_GET['ruri']);
$path_info = trim($path_info,"/'");
$path_info = explode('/',$path_info);
$endpoint = array_shift($path_info);
$endpoint = preg_replace('/(.*)\..*/',"$1",$endpoint);
$_SERVER['PATH_INFO'] = implode('/',$path_info);
}
// At this point PATH_INFO should be present, either organically or with the the ruri fix above
$args = Array();
if(array_key_exists('PATH_INFO',$_SERVER)){
$args = explode('/',trim($_SERVER['PATH_INFO'],'/'));
}
// Call the requested controller
controller('setup');
controller('cache',Array($endpoint,$args));
controller($endpoint,$args);