-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
61 lines (56 loc) · 1.47 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
define('__ROOT__', dirname(__FILE__));
require_once __ROOT__ . '/controller/Controller.php';
require_once __ROOT__ . '/controller/BasePageController.php';
session_start();
/** Enable error reporting **/
/** Enable debug mode **/
define('DBGMODE', true);
/** Comment the followign lines to disable error reporting **/
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
/**/
/**
* Require once from the root dir.
*
* @param string $path
*/
function relRequire($path)
{
require_once __ROOT__ . "/" . $path;
}
/**
* Handles the pages.
*/
class FrontController extends Controller
{
/**
* Select the correct controller function according to the page.
*
* As a security feature the functions have their name starting with
* "loadPagePAGENAME" to avoid the user exploiting them to call potentially
* dangerous functions.
*/
public static function page(&$request)
{
$controller = new BasePageController($request);
if (isset($controller->page))
{
$page = "loadPage" . ucfirst($controller->page); //Camel Case
if(is_callable(array($controller,$page)))
{
$controller->$page();
}
else
{
$controller->loadPageErr404();
}
}
else //home
{
$controller->loadPageHome();
}
}
}
FrontController::page($_REQUEST);