forked from alixaxel/ArrestDB
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.php
53 lines (39 loc) · 1.53 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
<?php
//Path for oauth lib
set_include_path(__DIR__."/library/");
if(!file_exists(__DIR__."/config.php"))
die("No config file found!");
require_once(__DIR__.'/config.php');
require_once(__DIR__.'/include/DBController.php');
require_once(__DIR__.'/include/ApiResponse.php');
require_once(__DIR__.'/include/SwaggerHelper.php');
require_once(__DIR__.'/include/ResterController.php');
require_once(__DIR__.'/include/ApiCacheManager.php');
require_once(__DIR__.'/include/model/RouteCommand.php');
//TODO; Make this smarter
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, X-StackMob-Proxy-Plain');
header('X-XRDS-Location: http://' . $_SERVER['SERVER_NAME'] .'/services.xrds.php');
$resterController = new ResterController();
if(isset($_GET["cacheClear"])) {
ApiCacheManager::clear();
//exit();
}
if (array_key_exists('_method', $_GET) === true)
{
$_SERVER['REQUEST_METHOD'] = strtoupper(trim($_GET['_method']));
}
else if (array_key_exists('HTTP_X_HTTP_METHOD_OVERRIDE', $_SERVER) === true)
{
$_SERVER['REQUEST_METHOD'] = strtoupper(trim($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']));
}
//Include API Versions
if(defined('API_VERSION') && file_exists(__DIR__."/versions/".API_VERSION.".php")) {
include(__DIR__."/versions/".API_VERSION.".php");
}
//Do the work
$resterController->processRequest($_SERVER['REQUEST_METHOD']);
//We never have to be here
$resterController->showError(405);
?>