-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.php
executable file
·47 lines (37 loc) · 1.76 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* dxprog.com PHP library
*/
// Load the client specific configs, then boot over to where the core lives
require_once('app-config.php');
chdir(CORE_LOCATION);
require_once('config.php');
// Used to keep track of page generation time
$_begin = microtime (true);
// Include base libraries
require_once('./lib/aal.php');
// Set the time zone
date_default_timezone_set('America/Chicago');
Lib\Session::start();
// Check for the controller and either throw a 404 or let the controller do its thing
$route = Lib\Url::getRoute();
if (class_exists('Controller\\' . $route->controller, true)) {
call_user_func([ 'Controller\\' . $route->controller, 'render' ], $route->route);
// Catch the route being passed as the second part of the path to catch `bracket-perma/route` style URLs
// Eventually, this will be the default, but is a hack for now.
} else if (count($route->route) && class_exists('Controller\\' . $route->route[0], true)) {
$controller = array_shift($route->route);
array_unshift($route->route, $route->controller);
call_user_func([ 'Controller\\' . $controller, 'render' ], $route->route);
// For any unrecognized URL with a "controller" in the route, pass over to the
// Bracket view in the hopes that it's a bracket slud. If that bracket can't
// be found, that controller will 404 the whole request
} else {
Controller\Bracket::render(array_merge([ $route->controller ], $route->route));
}
// Render the page to output
Lib\Display::render($route);
// Calculate the amount of time it took to generate the page
$genTime = microtime (true) - $GLOBALS['_begin'];
echo "<!--\n\tGenerated in ", $genTime, " seconds.\n\tAPI hits - ", $_apiHits, ".\n\tMax memory used - ", memory_get_peak_usage(), "\n-->";
Api\DxApi::clean();