blob: d50d1d71e3780dda7e98ab3334f001a2cc126122 (
plain) (
blame)
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
48
49
50
51
52
53
54
55
56
|
<?php
error_reporting(E_ALL);
// Autoload classes from ./inc which adhere to naming scheme <lowercasename>.inc.php
function slxAutoloader($class) {
$file = 'inc/' . preg_replace('/[^a-z0-9]/', '', mb_strtolower($class)) . '.inc.php';
if (!file_exists($file)) return;
require_once $file;
}
spl_autoload_register('slxAutoloader');
if (empty($_REQUEST['do'])) {
// No specific module - set default
$moduleName = 'main';
} else {
$moduleName = preg_replace('/[^a-z]/', '', $_REQUEST['do']);
}
$modulePath = 'modules/' . $moduleName . '.inc.php';
if (!file_exists($modulePath)) {
Util::traceError('Invalid module: ' . $moduleName);
}
// Deserialize any messages
if (isset($_REQUEST['message'])) {
Message::fromRequest();
}
// CSRF/XSS
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !Util::verifyToken()) {
Util::redirect('?do=' . $moduleName);
}
// Load module - it will execute pre-processing, or act upon request parameters
require_once($modulePath);
unset($modulePath);
// Main menu
$menu = new Menu;
Render::addTemplate('main-menu', $menu);
Message::renderList();
// Render module. If the module wants to output anything, it will be done here
render_module();
if (defined('CONFIG_DEBUG') && CONFIG_DEBUG) {
Message::addWarning('debug-mode');
}
// Send page to client.
Render::output();
|