-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
49 lines (47 loc) · 1.99 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
<?php
require "./inc/bootstrap.php";
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri = explode( '/', $uri );
$json = file_get_contents('php://input');
$array=json_decode($json,true);
$requestMethod = $_SERVER["REQUEST_METHOD"];
if (strtoupper($requestMethod) == 'OPTIONS'){
header('Access-control-allow-origin: http://localhost:3000');
}
else {
if ((isset($uri[3]) && $uri[3] == 'user') && isset($uri[4])) { //user gateway
require PROJECT_ROOT_PATH."/Controller/Api/UserController.php";
$objFeedController = new UserController();
$strMethodName = $uri[4].'Action';
$objFeedController->{$strMethodName}($array);
}
elseif ((isset($uri[3]) && $uri[3] == 'dm') && isset($uri[4])){ //dm gateway
require PROJECT_ROOT_PATH."/Controller/Api/Dmcontroller.php";
$objFeedController = new DmController();
$strMethodName = $uri[4].'Action';
$objFeedController->{$strMethodName}($array);
}
elseif ((isset($uri[3]) && $uri[3] == 'session') && isset($uri[4])) { // session gateway
require PROJECT_ROOT_PATH."/Controller/Api/Sessioncontroller.php";
$objFeedController = new SessionController();
$strMethodName = $uri[4].'Session';
$objFeedController->{$strMethodName}($array);
}
elseif ((isset($uri[3]) && $uri[3] == 'characters') && isset($uri[4])) { // characters gateway
require PROJECT_ROOT_PATH."/Controller/Api/Charactercontroller.php";
$objFeedController = new CharacterController();
$strMethodName = $uri[4].'Action';
$objFeedController->{$strMethodName}($array);
}
elseif ((isset($uri[3]) && $uri[3] == 'files') && isset($uri[4])) { // files gateway
require PROJECT_ROOT_PATH."/Controller/Api/Filecontroller.php";
$objFeedController = new FileController();
$strMethodName = $uri[4].'Action';
$objFeedController->{$strMethodName}($array);
}
else {
header("HTTP/1.1 404 Not Found");
exit();
}
}
?>