diff options
Diffstat (limited to 'web/offline.php')
-rw-r--r-- | web/offline.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/web/offline.php b/web/offline.php new file mode 100644 index 0000000..f4b26c6 --- /dev/null +++ b/web/offline.php | |||
@@ -0,0 +1,51 @@ | |||
1 | <?php | ||
2 | include("../config/os_modules_mysql.php"); | ||
3 | |||
4 | define("C_DB_TYPE","mysql"); | ||
5 | define("C_DB_HOST",$DB_HOST); | ||
6 | define("C_DB_NAME",$DB_NAME); | ||
7 | define("C_DB_USER",$DB_USER); | ||
8 | define("C_DB_PASS",$DB_PASSWORD); | ||
9 | define("C_OFFLINE_IM_TBL", "Offline_IM"); | ||
10 | include("offline_mysql.php"); | ||
11 | $DbLink = new DB; | ||
12 | $method = $_SERVER["PATH_INFO"]; | ||
13 | if ($method == "/SaveMessage/") | ||
14 | { | ||
15 | $msg = $HTTP_RAW_POST_DATA; | ||
16 | $start = strpos($msg, "?>"); | ||
17 | if ($start != -1) | ||
18 | { | ||
19 | $start+=2; | ||
20 | $msg = substr($msg, $start); | ||
21 | $parts = split("[<>]", $msg); | ||
22 | $to_agent = $parts[12]; | ||
23 | $DbLink->query("insert into ".C_OFFLINE_IM_TBL." (uuid, message) values ('" . | ||
24 | mysql_escape_string($to_agent) . "', '" . | ||
25 | mysql_escape_string($msg) . "')"); | ||
26 | echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><boolean>true</boolean>"; | ||
27 | } | ||
28 | else | ||
29 | { | ||
30 | echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><boolean>false</boolean>"; | ||
31 | } | ||
32 | exit; | ||
33 | } | ||
34 | if ($method == "/RetrieveMessages/") | ||
35 | { | ||
36 | $parms = $HTTP_RAW_POST_DATA; | ||
37 | $parts = split("[<>]", $parms); | ||
38 | $agent_id = $parts[6]; | ||
39 | $DbLink->query("select message from ".C_OFFLINE_IM_TBL." where uuid='" . | ||
40 | mysql_escape_string($agent_id) . "'"); | ||
41 | echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><ArrayOfGridInstantMessage xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"; | ||
42 | while(list($message) = $DbLink->next_record()) | ||
43 | { | ||
44 | echo $message; | ||
45 | } | ||
46 | echo "</ArrayOfGridInstantMessage>"; | ||
47 | $DbLink->query("delete from ".C_OFFLINE_IM_TBL." where uuid='" . | ||
48 | mysql_escape_string($agent_id) . "'"); | ||
49 | exit; | ||
50 | } | ||
51 | ?> | ||