-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.php
47 lines (38 loc) · 980 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
37
38
39
40
41
42
43
44
45
46
47
<?php
require_once 'functions.php';
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE');
header('Content-Type: application/json');
try {
if (empty($_GET['page'])) {
http_response_code(404);
exit('Not found');
}
$route = $_GET['page'];
$data;
switch($_GET['method']) {
case 'GET': {
$data = getData($route, $_GET);
break;
}
case 'POST': {
$data = postData($route, $_GET);
break;
}
case 'DELETE': {
$data = deleteData($route, $_GET);
break;
}
case 'OPTIONS': {
$data = ['auth' => true];
}
}
if (empty($data)) {
http_response_code(404);
exit('Not found');
}
echo json_encode($data, JSON_UNESCAPED_UNICODE);
} catch (Exception $error) {
http_response_code(500);
exit('Internal server error');
}