f0ca57dffc47ae77875070c3681ae57b09d24f26
3 //Function to get resources (using $nlevels below)
7 for ($i=0; $i<$nlevels; $i++
)
13 //////////////////////////////////////////////////
15 //Start buffering output
19 error_reporting(E_ALL
);
21 //Sub-path path to the currently running script. If we're directly on top of a
22 //domain, this will probably be empty, else for instance: /john/mysite
23 $subpath = str_replace('/index.php', '', $_SERVER['PHP_SELF']);
25 //Turn a request like /john/mysite/get/page.php?a=32 into /get/page.php?a=32
26 $request = str_replace($subpath, '', $_SERVER['REQUEST_URI']);
28 //Turn a request like /get/page.php?a=32 into get/page?a=32
29 $request = str_replace('.php', '', $request);
31 //Keep only what stands before '?' : get/page
32 $location = trim(explode('?', $request)[0], '/');
33 //[HACK] The following works better on my university server
34 //~ $interrmark = strrpos($request, '?');
35 //~ $location = trim(($interrmark!==FALSE ? substr($request,0,$interrmark) : $request), '/');
37 //If the user asked for main index.php, consider he wanted home page
38 if ($location == 'index') $location = '';
40 //[HACK] Count the number of sub-levels to go up to meet assets folder
41 $nlevels = substr_count($location, '/');
43 //Turn get/page into site/get/page.php
44 $phpfile = 'site/'.(strlen($location)>0?$location:'home').'.php';
46 //Include default values for title, headers, javascripts...
47 include 'defaults.php';
49 //Include common PHP code (functions and constants)
52 //Finally, include the PHP file
53 include (file_exists($phpfile) ? $phpfile : 'site/404.php');
55 //regular template: flush output into $content variable
56 $content = ob_get_contents();