/
rest_offlineim.php
executable file
·58 lines (53 loc) · 1.2 KB
/
rest_offlineim.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
<?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;
}
}
try
{
$_RPC_REQUEST=RESTRPCHandler::parseREST($_POST);
}
catch(Exception $e)
{
http_response_code("400");
header("Content-Type: text/plain");
echo "Parse Error: ".$e->getMessage();
exit;
}
if(isset($debugoutput) && $debugoutput)
{
trigger_error("/offlineim Method=".$_RPC_REQUEST->Method);
}
if(!preg_match("/^[A-Za-z_]*$/", $_RPC_REQUEST->Method))
{
http_response_code("400");
header("Content-Type: text/plain");
echo "Invalid method name";
exit;
}
else if(!file_exists("offlineim/rpc_".$_RPC_REQUEST->Method.".php"))
{
http_response_code("400");
header("Content-Type: text/plain");
echo "Unsupported method";
exit;
}
else
{
require_once("offlineim/rpc_".$_RPC_REQUEST->Method.".php");
}