opensim-tools – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 1 | <?php |
2 | |||
3 | ///////////////////////////////////////////////////////////// |
||
4 | // Wizardry and Steamworks (c) was.fm - 2013, License: MIT // |
||
5 | // // |
||
6 | // Permission is hereby granted, free of charge, to any // |
||
7 | // person obtaining a copy of this software and associated // |
||
8 | // documentation files (the "Software"), to deal in the // |
||
9 | // Software without restriction, //including without // |
||
10 | // limitation the rights to use, copy, modify, merge, // |
||
11 | // publish, distribute, sublicense, and/or sell copies of // |
||
12 | // the Software, and to permit persons to whom the // |
||
13 | // Software is furnished to do so, subject to the // |
||
14 | // following conditions: // |
||
15 | // // |
||
16 | // The above copyright notice and this permission notice // |
||
17 | // shall be included in all copies or substantial portions // |
||
18 | // of the Software. // |
||
19 | // // |
||
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF // |
||
21 | // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // |
||
22 | // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // |
||
23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO // |
||
24 | // EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE // |
||
25 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // |
||
26 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // |
||
27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR // |
||
28 | // THE USE OR OTHER DEALINGS IN THE SOFTWARE. // |
||
29 | ///////////////////////////////////////////////////////////// |
||
30 | |||
31 | /* Requires pear module HTTP Request2 and XML Serializer. */ |
||
32 | require_once 'HTTP/Request2.php'; |
||
33 | require_once 'XML/Serializer.php'; |
||
34 | |||
35 | class KOS { |
||
36 | |||
37 | var $url; |
||
38 | var $pwd; |
||
39 | |||
40 | function KOS($url,$pwd) { |
||
41 | $this->url = $url; |
||
42 | $this->pwd = $pwd; |
||
43 | } |
||
44 | |||
45 | function send($cmd) { |
||
46 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
||
47 | $options = |
||
48 | array ( |
||
49 | "indent" => " ", |
||
50 | "linebreak" => "\n", |
||
51 | "typeHints" => false, |
||
52 | "addDecl" => true, |
||
53 | "encoding" => "UTF-8", |
||
54 | "rootName" => "methodCall", |
||
55 | "defaultTagName" => "member", |
||
56 | "mode" => "simplexml" |
||
57 | ); |
||
58 | |||
59 | $serializer = new XML_Serializer($options); |
||
60 | $xml = array( |
||
61 | "methodName" => htmlspecialchars('admin_console_command'), |
||
62 | "params" => |
||
63 | array( "param" => |
||
64 | array( "value" => |
||
65 | array("struct" => |
||
66 | array( |
||
67 | "member" => |
||
68 | array( |
||
69 | "name" => 'password', |
||
70 | "value" => array( |
||
71 | "string" => htmlspecialchars($this->pwd) |
||
72 | ), |
||
73 | ), |
||
74 | array( |
||
75 | "name" => 'command', |
||
76 | "value" => array( |
||
77 | "string" => htmlspecialchars($cmd) |
||
78 | ) |
||
79 | ) |
||
80 | ), |
||
81 | ), |
||
82 | ), |
||
83 | ), |
||
84 | ); |
||
85 | |||
86 | $serializer->serialize($xml); |
||
87 | $xml_load = $serializer->getSerializedData(); |
||
88 | $request->setBody($xml_load); |
||
89 | try { |
||
90 | return $request->send()->getBody(); |
||
91 | } catch (Exception $e) { |
||
92 | return $e->getMessage(); |
||
93 | } |
||
94 | } |
||
95 | } |
||
96 |