forked from whamchris/libstats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller.php
44 lines (35 loc) · 1.25 KB
/
Controller.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
<?php
// Handle some very basic initalization functions... make sure everything
// is in place, do requires, and such. Also set up global constants
// such as DSN.
require_once "Init.php";
require_once "ControllerFunctions.php";
// We do includes based on rInfo; ensure that the only way to set it
// is internally.
$rInfo['renderer'] = '';
$rInfo['content'] = '';
// This will be used to find out our intended action
$opMap = buildOpMap();
$operation = getOperation($_SERVER['REQUEST_URI']);
// Get the Action for this operation, or a PageNotFoundAction if there's
// no match.
$action = new PageErrorAction();
if (isset($opMap[$operation])) { $action = $opMap[$operation]; }
// Defined in Init.php
if (SITE_MAINTANENCE && getRemoteIp() != DEBUG_IP) {
$action = new SiteMaintanenceAction();
}
// There's one special case to worry about: the action requires
// authentication, and we're not logged in. Handle that and perform the
// Action.
if ($action->isAuthenticationRequired() && !isLoggedIn()) {
$action = new LoginFormAction();
}
if ($action->isAdminRequired() && !isAdmin()) {
$action = new PageErrorAction();
}
$rInfo = $action->perform();
$rInfo = fixRenderDefaults($rInfo);
// And dispatch the request to the view...
include $rInfo['renderer'];
?>