-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·38 lines (32 loc) · 1.14 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
<?php
include_once('lib/config.inc.php');
include_once('lib/db_connect.php');
$controller = 'main';
$function = 'home';
if (isset($_GET['controller']) && isset($_GET['function'])) {
$controller = $_GET['controller'];
$function = $_GET['function'];
} else if (isset($_GET['controller']) || isset($_GET['function'])) {
//$controller = 'error';
//$function = 'e404';
// redirect
loadView('error', ['msg' => 'Please check url']);
exit();
}
$controller_path = CONTROLLER_PATH.$controller.'.php';
if (file_exists($controller_path)) {
require_once($controller_path);
$controller_object = new $controller;
if (method_exists($controller_object, $function)) {
$controller_object->$function(array_merge(array_merge($_GET, $_POST), array_merge($_FILES, $_SERVER)));
} else {
// redirect
loadView('error', ['msg' => 'Controller Function does not exist']);
exit();
}
} else {
// redirect
loadView('error', ['msg' => 'Controller does not exist']);
exit();
}
?>