-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
40 lines (34 loc) · 1.07 KB
/
index.php
File metadata and controls
40 lines (34 loc) · 1.07 KB
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
<?php
require_once'bootstrap.php';
session_start();
$params = explode('/', $_GET['p']);
if (isset($params[0]) & !empty($params[0])) {
$controller = ucfirst($params[0]) . "Controller";
if (file_exists("Controller/" . $controller . ".php")) {
require_once "Controller/" . $controller . ".php";
$obj = new $controller();
if (isset($params[1]) & !empty($params[1])) {
if (method_exists($obj, $params[1])){
$action = $params[1];
if (isset($params[2]) & !empty($params[2])) {
$obj->$action($params[2]);
}else {
$obj->$action();
}
}else {
http_response_code(404);
echo "this method doesn't exist";
}
}else {
$action = "index";
$obj->$action();
}
}else {
http_response_code(404);
echo "this method doesn't exist";
}
}else {
require_once"controller/home.php";
$obj=new index();
$obj->index();
}