-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
44 lines (36 loc) · 770 Bytes
/
api.php
File metadata and controls
44 lines (36 loc) · 770 Bytes
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
<?php
require_once 'session_init.php';
require_once 'classes/controller/API.php';
require_once 'classes/utils/Exceptions.php';
if(isset($_GET['method']))
{
$data = $_GET;
}
if(isset($_POST['method']))
{
$data = $_POST;
}
if(!isset($data)) die();
$method = $data['method'];
if(isset($data['params']))
$params = $data['params'];
try{
$p = array();
if(isset($params))
{
$p = json_decode(stripslashes($params));
if(json_last_error()!=JSON_ERROR_NONE)
throw new JSONDecodeException(json_last_error());
}
$api = new API();
$res = call_user_func_array(array($api,$method), $p);
echo $res;
}
catch(Exception $e)
{
echo $e->getMessage()."<br/>";
echo htmlentities($_SERVER['REQUEST_URI'])."<br/>";
echo $method."<br/>";
print_r($p);
die();
}