forked from phoxy/phoxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphoxy.php
63 lines (51 loc) · 1.57 KB
/
phoxy.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
54
55
56
57
58
59
60
61
62
63
<?php
class phoxy extends api
{
// Calling api/phoxy returning server configuration for current session
protected function Reserve()
{
return self::Config();
}
// For user phoxy configuration overload we using phoxy_conf method redefine
public static function Config()
{
return phoxy_conf();
}
// Calling phoxy::modulename immideatelly loading or using preloaded module object
public static function __callStatic($name, $arguments)
{
$dir = phoxy::Config()['api_dir'];
$names = explode('/', $name);
$module = array_pop($names);
$directory = $dir.'/'.implode('/', $names);
return LoadModule($directory, $module);
}
// Begin default phoxy behaviour
public static function Start()
{
global $_SERVER;
if (phoxy_conf()["api_xss_prevent"] && $_SERVER['HTTP_X_LAIN'] !== 'Wake up')
die("Request aborted due API direct XSS warning");
global $_GET;
$get_param = phoxy::Config()["get_api_param"];
$file = $_GET[$get_param];
unset($_GET[$get_param]);
if ($file === 'htaccess')
exit('Rewrite engine work SUCCESS');
try
{
include_once('rpc_string_parser.php');
$parser = new \phoxy\rpc_string_parser();
global $_phoxy_process_obj;
$_phoxy_process_obj = $obj = $parser->GetRpcObject($file, $_GET);
$a = $obj['obj'];
$method = $obj['method'];
if (is_string($method))
$method = [$method, []];
echo $a->APICall($method[0], $method[1]);
} catch (phoxy_protected_call_error $e)
{
echo new phoxy_return_worker($e->result);
}
}
}