-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
36 lines (30 loc) · 826 Bytes
/
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
<?php
require_once('config.php');
$requestURI = explode('/', $_SERVER['REQUEST_URI']);
$scriptName = explode('/', $_SERVER['SCRIPT_NAME']);
for($i= 0;$i < sizeof($scriptName);$i++){
if ($requestURI[$i] == $scriptName[$i])
{
unset($requestURI[$i]);
}
}
$command = array_values($requestURI);
$action = $command[1];
//TODO remove following 2 lines
//print_r($command);
//exit;
if(file_exists('controllers/'.$command[0].'.php')){
new $command[0]();
}
function __autoload($controller) {
global $action;
if(file_exists('controllers/'.$controller.'.php')){
require_once 'controllers/'.$controller.'.php';
$ctrlObj = new $controller();
if(method_exists($ctrlObj, $action)){
$ctrlObj::$action();
}else{
echo "Invalid Function";
}
}
}