-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
74 lines (56 loc) · 1.57 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
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
error_reporting(-1);
// Loading Application Configurations
include("Configs/App.php");
include("Configs/Database.php");
// Loading Application Libraries
include("Libraries/DatabaseLib.php");
include("Libraries/Helper.php");
// Initiating Database
Init_Database();
// Loading Models
foreach (glob("Models/*.php") as $filename)
{
include_once $filename;
}
$page = (isset($_REQUEST['path'])) ? htmlspecialchars($_REQUEST['path']) : 'Home';
$action = (isset($_REQUEST['action'])) ? htmlspecialchars($_REQUEST['action']) : 'get';
$parameter = (isset($_REQUEST['parameter'])) ? htmlspecialchars($_REQUEST['parameter']) : '';
if($page == '')
{
header('Location:' . URL_PREFIX . "/Home");
die();
}
$routes = array(
'Home' => 'HomeController',
'Error' => 'ErrorController',
'Dashboard' => 'DashboardController',
'Users' => 'UsersController',
'Departments' => 'DepartController',
'Employes' => 'EmployeController',
'Customers' => 'CustomerController',
'Orders' => 'OrderController',
'Services' => 'ServiceController',
'Servicelog' => 'ServicelogController'
);
if(!isset($routes[$page])){
redirect_to(array("Error","NotFound"));
die();
}
include ('./Controllers/'.$routes[$page].'.php');
session_start();
$controller = new $routes[$page]();
if(method_exists($controller , $action))
{
if(isset($action) && $parameter != ''){
$controller->$action($parameter);
}
else if(isset($action)){
$controller->$action();
}
}
else {
redirect_to(array("Error","NotFound"));
die();
}
?>