clockwerk-www – Blame information for rev 63
?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 wasRemoteAdmin { |
||
36 | |||
37 | var $url; |
||
38 | var $raPassword; |
||
39 | var $options; |
||
40 | |||
41 | function wasRemoteAdmin($url,$raPassword) { |
||
42 | $this->url = $url; |
||
43 | $this->raPassword = $raPassword; |
||
44 | $this->options = |
||
45 | array ( |
||
46 | "indent" => " ", |
||
47 | "linebreak" => "\n", |
||
48 | "typeHints" => false, |
||
49 | "addDecl" => true, |
||
50 | "encoding" => "UTF-8", |
||
51 | "rootName" => "methodCall", |
||
52 | "defaultTagName" => "member", |
||
53 | "mode" => "simplexml" |
||
54 | ); |
||
55 | } |
||
56 | |||
57 | function admin_console_command($console_command) { |
||
58 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
||
59 | $serializer = new XML_Serializer($this->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->raPassword) |
||
72 | ), |
||
73 | ), |
||
74 | array( |
||
75 | "name" => 'command', |
||
76 | "value" => array( |
||
77 | "string" => htmlspecialchars($console_command) |
||
78 | ) |
||
79 | ) |
||
80 | ), |
||
81 | ), |
||
82 | ), |
||
83 | ), |
||
84 | ); |
||
85 | |||
86 | $serializer->serialize($xml); |
||
87 | $xml_load = $serializer->getSerializedData(); |
||
88 | $request->setBody($xml_load); |
||
89 | return $request->send()->getBody(); |
||
90 | } |
||
91 | |||
92 | function admin_authenticate_user($firstname, $lastname, $password, $tokentime) { |
||
93 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
||
94 | $serializer = new XML_Serializer($this->options); |
||
95 | $xml = array( |
||
96 | "methodName" => htmlspecialchars('admin_authenticate_user'), |
||
97 | "params" => |
||
98 | array( "param" => |
||
99 | array( "value" => |
||
100 | array("struct" => |
||
101 | array( |
||
102 | "member" => |
||
103 | array( |
||
104 | "name" => 'password', |
||
105 | "value" => array( |
||
106 | "string" => htmlspecialchars($this->raPassword) |
||
107 | ), |
||
108 | ), |
||
109 | array( |
||
110 | "name" => 'user_firstname', |
||
111 | "value" => htmlspecialchars($firstname) |
||
112 | ), |
||
113 | array( |
||
114 | "name" => 'user_lastname', |
||
115 | "value" => htmlspecialchars($lastname) |
||
116 | ), |
||
117 | array( |
||
118 | "name" => 'user_password', |
||
119 | "value" => htmlspecialchars($password) |
||
120 | ), |
||
121 | array( |
||
122 | "name" => 'token_lifetime', |
||
123 | "value" => htmlspecialchars($tokentime) |
||
124 | ), |
||
125 | ), |
||
126 | ), |
||
127 | ), |
||
128 | ), |
||
129 | ); |
||
130 | |||
131 | $serializer->serialize($xml); |
||
132 | $xml_load = $serializer->getSerializedData(); |
||
133 | $request->setBody($xml_load); |
||
134 | return $request->send()->getBody(); |
||
135 | } |
||
136 | |||
137 | function admin_create_user($firstname, $lastname, $password, $region_x, $region_y) { |
||
138 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
||
139 | $serializer = new XML_Serializer($this->options); |
||
140 | $xml = array( |
||
141 | "methodName" => htmlspecialchars('admin_create_user'), |
||
142 | "params" => |
||
143 | array( "param" => |
||
144 | array( "value" => |
||
145 | array("struct" => |
||
146 | array( |
||
147 | "member" => |
||
148 | array( |
||
149 | "name" => 'password', |
||
150 | "value" => array( |
||
151 | "string" => htmlspecialchars($this->raPassword) |
||
152 | ), |
||
153 | ), |
||
154 | array( |
||
155 | "name" => 'user_firstname', |
||
156 | "value" => htmlspecialchars($firstname) |
||
157 | ), |
||
158 | array( |
||
159 | "name" => 'user_lastname', |
||
160 | "value" => htmlspecialchars($lastname) |
||
161 | ), |
||
162 | array( |
||
163 | "name" => 'user_password', |
||
164 | "value" => htmlspecialchars($password) |
||
165 | ), |
||
166 | array( |
||
167 | "name" => 'start_region_x', |
||
168 | "value" => htmlspecialchars($region_x) |
||
169 | ), |
||
170 | array( |
||
171 | "name" => 'start_region_y', |
||
172 | "value" => htmlspecialchars($region_y) |
||
173 | ), |
||
174 | ), |
||
175 | ), |
||
176 | ), |
||
177 | ), |
||
178 | ); |
||
63 | vero | 179 | |
180 | $serializer->serialize($xml); |
||
181 | $xml_load = $serializer->getSerializedData(); |
||
182 | $request->setBody($xml_load); |
||
183 | return $request->send()->getBody(); |
||
184 | } |
||
185 | |||
61 | vero | 186 | function admin_update_user($firstname, $lastname, $password, $region_x, $region_y) { |
187 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
||
188 | $serializer = new XML_Serializer($this->options); |
||
189 | $xml = array( |
||
190 | "methodName" => htmlspecialchars('admin_update_user'), |
||
191 | "params" => |
||
192 | array( "param" => |
||
193 | array( "value" => |
||
194 | array("struct" => |
||
195 | array( |
||
196 | "member" => |
||
197 | array( |
||
198 | "name" => 'password', |
||
199 | "value" => array( |
||
200 | "string" => htmlspecialchars($this->raPassword) |
||
201 | ), |
||
202 | ), |
||
203 | array( |
||
204 | "name" => 'user_firstname', |
||
205 | "value" => htmlspecialchars($firstname) |
||
206 | ), |
||
207 | array( |
||
208 | "name" => 'user_lastname', |
||
209 | "value" => htmlspecialchars($lastname) |
||
210 | ), |
||
211 | array( |
||
212 | "name" => 'user_password', |
||
213 | "value" => htmlspecialchars($password) |
||
214 | ), |
||
215 | array( |
||
216 | "name" => 'start_region_x', |
||
217 | "value" => htmlspecialchars($region_x) |
||
218 | ), |
||
219 | array( |
||
220 | "name" => 'start_region_y', |
||
221 | "value" => htmlspecialchars($region_y) |
||
222 | ), |
||
223 | ), |
||
224 | ), |
||
225 | ), |
||
226 | ), |
||
227 | ); |
||
63 | vero | 228 | |
1 | eva | 229 | $serializer->serialize($xml); |
230 | $xml_load = $serializer->getSerializedData(); |
||
231 | $request->setBody($xml_load); |
||
232 | return $request->send()->getBody(); |
||
233 | } |
||
234 | |||
235 | function admin_get_agents($region_name, $include_children) { |
||
236 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
||
237 | $serializer = new XML_Serializer($this->options); |
||
238 | $xml = array( |
||
239 | "methodName" => htmlspecialchars('admin_get_agents'), |
||
240 | "params" => |
||
241 | array( "param" => |
||
242 | array( "value" => |
||
243 | array("struct" => |
||
244 | array( |
||
245 | "member" => |
||
246 | array( |
||
247 | "name" => 'password', |
||
248 | "value" => array( |
||
249 | "string" => htmlspecialchars($this->raPassword) |
||
250 | ), |
||
251 | ), |
||
252 | array( |
||
253 | "name" => 'region_name', |
||
254 | "value" => htmlspecialchars($region_name) |
||
255 | ), |
||
256 | array( |
||
257 | "name" => 'include_children', |
||
258 | "value" => htmlspecialchars($include_children) |
||
259 | ), |
||
260 | ), |
||
261 | ), |
||
262 | ), |
||
263 | ), |
||
264 | ); |
||
265 | |||
266 | $serializer->serialize($xml); |
||
267 | $xml_load = $serializer->getSerializedData(); |
||
268 | $request->setBody($xml_load); |
||
269 | return $request->send()->getBody(); |
||
270 | } |
||
271 | } |
||
272 |