-
Notifications
You must be signed in to change notification settings - Fork 7
/
rest_presence.php
executable file
·72 lines (66 loc) · 1.56 KB
/
rest_presence.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
<?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>Success</result></ServerResponse>";
}
else
{
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><ServerResponse><result>Failure</result></ServerResponse>";
}
}
try
{
$_RPC_REQUEST=RESTRPCHandler::parseREST($_POST);
}
catch(Exception $e)
{
http_response_code("400");
header("Content-Type: text/plain");
echo "Parsing error: ".$e->getMessage();
exit;
}
if(isset($debugoutput) && $debugoutput)
{
trigger_error("/presence Method=".$_RPC_REQUEST->Method);
}
if(!preg_match("/^[A-Za-z_]*$/", $_RPC_REQUEST->Method))
{
http_response_code("400");
header("Content-Type: text/plain");
echo "Misformatted method";
exit;
}
else if(!file_exists("presence/rpc_".$_RPC_REQUEST->Method.".php"))
{
http_response_code("400");
header("Content-Type: text/plain");
echo "Unsupported method";
exit;
}
else
{
require_once("presence/rpc_".$_RPC_REQUEST->Method.".php");
}