/
rest_hggroups.php
executable file
·85 lines (76 loc) · 1.92 KB
/
rest_hggroups.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/******************************************************************************
* phpGridServer
*
* GNU LESSER GENERAL PUBLIC LICENSE
* Version 2.1, February 1999
*
*/
set_include_path(dirname($_SERVER["SCRIPT_FILENAME"]).PATH_SEPARATOR.get_include_path());
require_once("lib/services.php");
require_once("lib/rpc/restrpc.php");
if(function_exists("apache_request_headers"))
{
$headers = apache_request_headers();
if(isset($headers["X-SecondLife-Shard"]))
{
http_response_code("400");
exit;
}
}
function sendBooleanResponse($result, $msg="")
{
if($result)
{
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><ServerResponse><RESULT>true</RESULT></ServerResponse>";
}
else if($msg != "")
{
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><ServerResponse><RESULT>false</RESULT><REASON>".htmlentities($msg)."</REASON></ServerResponse>";
}
else
{
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><ServerResponse><RESULT>false</RESULT></ServerResponse>";
}
}
function sendNullResult($msg)
{
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo "<ServerResponse><RESULT>NULL</RESULT><REASON>".htmlentities($msg)."</REASON></ServerResponse>";
exit;
}
try
{
$_RPC_REQUEST=RESTRPCHandler::parseREST($_POST);
}
catch(Exception $e)
{
http_response_code("400");
header("Content-Type: text/plain");
echo $e->getMessage();
exit;
}
if(isset($debugoutput) && $debugoutput)
{
trigger_error("/hg-groups Method=".$_RPC_REQUEST->Method);
}
require_once("lib/services.php");
$groupsService = getService("RPC_HGGroups");
if(!preg_match("/^[A-Za-z_]*$/", $_RPC_REQUEST->Method))
{
http_response_code("400");
exit;
}
else if(!file_exists("hggroups/rpc_".$_RPC_REQUEST->Method.".php"))
{
http_response_code("400");
exit;
}
else
{
require_once("hggroups/rpc_".$_RPC_REQUEST->Method.".php");
}