clockwerk-www – Diff between revs 61 and 63
?pathlinks?
Rev 61 | Rev 63 | |||
---|---|---|---|---|
1 | <?php |
1 | <?php |
|
2 | |
2 | |
|
3 | ///////////////////////////////////////////////////////////// |
3 | ///////////////////////////////////////////////////////////// |
|
4 | // Wizardry and Steamworks (c) was.fm - 2013, License: MIT // |
4 | // Wizardry and Steamworks (c) was.fm - 2013, License: MIT // |
|
5 | // // |
5 | // // |
|
6 | // Permission is hereby granted, free of charge, to any // |
6 | // Permission is hereby granted, free of charge, to any // |
|
7 | // person obtaining a copy of this software and associated // |
7 | // person obtaining a copy of this software and associated // |
|
8 | // documentation files (the "Software"), to deal in the // |
8 | // documentation files (the "Software"), to deal in the // |
|
9 | // Software without restriction, //including without // |
9 | // Software without restriction, //including without // |
|
10 | // limitation the rights to use, copy, modify, merge, // |
10 | // limitation the rights to use, copy, modify, merge, // |
|
11 | // publish, distribute, sublicense, and/or sell copies of // |
11 | // publish, distribute, sublicense, and/or sell copies of // |
|
12 | // the Software, and to permit persons to whom the // |
12 | // the Software, and to permit persons to whom the // |
|
13 | // Software is furnished to do so, subject to the // |
13 | // Software is furnished to do so, subject to the // |
|
14 | // following conditions: // |
14 | // following conditions: // |
|
15 | // // |
15 | // // |
|
16 | // The above copyright notice and this permission notice // |
16 | // The above copyright notice and this permission notice // |
|
17 | // shall be included in all copies or substantial portions // |
17 | // shall be included in all copies or substantial portions // |
|
18 | // of the Software. // |
18 | // of the Software. // |
|
19 | // // |
19 | // // |
|
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF // |
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF // |
|
21 | // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // |
21 | // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // |
|
22 | // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // |
22 | // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // |
|
23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO // |
23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO // |
|
24 | // EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE // |
24 | // EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE // |
|
25 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // |
25 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // |
|
26 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // |
26 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // |
|
27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR // |
27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR // |
|
28 | // THE USE OR OTHER DEALINGS IN THE SOFTWARE. // |
28 | // THE USE OR OTHER DEALINGS IN THE SOFTWARE. // |
|
29 | ///////////////////////////////////////////////////////////// |
29 | ///////////////////////////////////////////////////////////// |
|
30 | |
30 | |
|
31 | /* Requires pear module HTTP Request2 and XML Serializer. */ |
31 | /* Requires pear module HTTP Request2 and XML Serializer. */ |
|
32 | require_once 'HTTP/Request2.php'; |
32 | require_once 'HTTP/Request2.php'; |
|
33 | require_once 'XML/Serializer.php'; |
33 | require_once 'XML/Serializer.php'; |
|
34 | |
34 | |
|
35 | class wasRemoteAdmin { |
35 | class wasRemoteAdmin { |
|
36 | |
36 | |
|
37 | var $url; |
37 | var $url; |
|
38 | var $raPassword; |
38 | var $raPassword; |
|
39 | var $options; |
39 | var $options; |
|
40 | |
40 | |
|
41 | function wasRemoteAdmin($url,$raPassword) { |
41 | function wasRemoteAdmin($url,$raPassword) { |
|
42 | $this->url = $url; |
42 | $this->url = $url; |
|
43 | $this->raPassword = $raPassword; |
43 | $this->raPassword = $raPassword; |
|
44 | $this->options = |
44 | $this->options = |
|
45 | array ( |
45 | array ( |
|
46 | "indent" => " ", |
46 | "indent" => " ", |
|
47 | "linebreak" => "\n", |
47 | "linebreak" => "\n", |
|
48 | "typeHints" => false, |
48 | "typeHints" => false, |
|
49 | "addDecl" => true, |
49 | "addDecl" => true, |
|
50 | "encoding" => "UTF-8", |
50 | "encoding" => "UTF-8", |
|
51 | "rootName" => "methodCall", |
51 | "rootName" => "methodCall", |
|
52 | "defaultTagName" => "member", |
52 | "defaultTagName" => "member", |
|
53 | "mode" => "simplexml" |
53 | "mode" => "simplexml" |
|
54 | ); |
54 | ); |
|
55 | } |
55 | } |
|
56 | |
56 | |
|
57 | function admin_console_command($console_command) { |
57 | function admin_console_command($console_command) { |
|
58 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
58 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
|
59 | $serializer = new XML_Serializer($this->options); |
59 | $serializer = new XML_Serializer($this->options); |
|
60 | $xml = array( |
60 | $xml = array( |
|
61 | "methodName" => htmlspecialchars('admin_console_command'), |
61 | "methodName" => htmlspecialchars('admin_console_command'), |
|
62 | "params" => |
62 | "params" => |
|
63 | array( "param" => |
63 | array( "param" => |
|
64 | array( "value" => |
64 | array( "value" => |
|
65 | array("struct" => |
65 | array("struct" => |
|
66 | array( |
66 | array( |
|
67 | "member" => |
67 | "member" => |
|
68 | array( |
68 | array( |
|
69 | "name" => 'password', |
69 | "name" => 'password', |
|
70 | "value" => array( |
70 | "value" => array( |
|
71 | "string" => htmlspecialchars($this->raPassword) |
71 | "string" => htmlspecialchars($this->raPassword) |
|
72 | ), |
72 | ), |
|
73 | ), |
73 | ), |
|
74 | array( |
74 | array( |
|
75 | "name" => 'command', |
75 | "name" => 'command', |
|
76 | "value" => array( |
76 | "value" => array( |
|
77 | "string" => htmlspecialchars($console_command) |
77 | "string" => htmlspecialchars($console_command) |
|
78 | ) |
78 | ) |
|
79 | ) |
79 | ) |
|
80 | ), |
80 | ), |
|
81 | ), |
81 | ), |
|
82 | ), |
82 | ), |
|
83 | ), |
83 | ), |
|
84 | ); |
84 | ); |
|
85 | |
85 | |
|
86 | $serializer->serialize($xml); |
86 | $serializer->serialize($xml); |
|
87 | $xml_load = $serializer->getSerializedData(); |
87 | $xml_load = $serializer->getSerializedData(); |
|
88 | $request->setBody($xml_load); |
88 | $request->setBody($xml_load); |
|
89 | return $request->send()->getBody(); |
89 | return $request->send()->getBody(); |
|
90 | } |
90 | } |
|
91 | |
91 | |
|
92 | function admin_authenticate_user($firstname, $lastname, $password, $tokentime) { |
92 | function admin_authenticate_user($firstname, $lastname, $password, $tokentime) { |
|
93 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
93 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
|
94 | $serializer = new XML_Serializer($this->options); |
94 | $serializer = new XML_Serializer($this->options); |
|
95 | $xml = array( |
95 | $xml = array( |
|
96 | "methodName" => htmlspecialchars('admin_authenticate_user'), |
96 | "methodName" => htmlspecialchars('admin_authenticate_user'), |
|
97 | "params" => |
97 | "params" => |
|
98 | array( "param" => |
98 | array( "param" => |
|
99 | array( "value" => |
99 | array( "value" => |
|
100 | array("struct" => |
100 | array("struct" => |
|
101 | array( |
101 | array( |
|
102 | "member" => |
102 | "member" => |
|
103 | array( |
103 | array( |
|
104 | "name" => 'password', |
104 | "name" => 'password', |
|
105 | "value" => array( |
105 | "value" => array( |
|
106 | "string" => htmlspecialchars($this->raPassword) |
106 | "string" => htmlspecialchars($this->raPassword) |
|
107 | ), |
107 | ), |
|
108 | ), |
108 | ), |
|
109 | array( |
109 | array( |
|
110 | "name" => 'user_firstname', |
110 | "name" => 'user_firstname', |
|
111 | "value" => htmlspecialchars($firstname) |
111 | "value" => htmlspecialchars($firstname) |
|
112 | ), |
112 | ), |
|
113 | array( |
113 | array( |
|
114 | "name" => 'user_lastname', |
114 | "name" => 'user_lastname', |
|
115 | "value" => htmlspecialchars($lastname) |
115 | "value" => htmlspecialchars($lastname) |
|
116 | ), |
116 | ), |
|
117 | array( |
117 | array( |
|
118 | "name" => 'user_password', |
118 | "name" => 'user_password', |
|
119 | "value" => htmlspecialchars($password) |
119 | "value" => htmlspecialchars($password) |
|
120 | ), |
120 | ), |
|
121 | array( |
121 | array( |
|
122 | "name" => 'token_lifetime', |
122 | "name" => 'token_lifetime', |
|
123 | "value" => htmlspecialchars($tokentime) |
123 | "value" => htmlspecialchars($tokentime) |
|
124 | ), |
124 | ), |
|
125 | ), |
125 | ), |
|
126 | ), |
126 | ), |
|
127 | ), |
127 | ), |
|
128 | ), |
128 | ), |
|
129 | ); |
129 | ); |
|
130 | |
130 | |
|
131 | $serializer->serialize($xml); |
131 | $serializer->serialize($xml); |
|
132 | $xml_load = $serializer->getSerializedData(); |
132 | $xml_load = $serializer->getSerializedData(); |
|
133 | $request->setBody($xml_load); |
133 | $request->setBody($xml_load); |
|
134 | return $request->send()->getBody(); |
134 | return $request->send()->getBody(); |
|
135 | } |
135 | } |
|
136 | |
136 | |
|
137 | function admin_create_user($firstname, $lastname, $password, $region_x, $region_y) { |
137 | function admin_create_user($firstname, $lastname, $password, $region_x, $region_y) { |
|
138 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
138 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
|
139 | $serializer = new XML_Serializer($this->options); |
139 | $serializer = new XML_Serializer($this->options); |
|
140 | $xml = array( |
140 | $xml = array( |
|
141 | "methodName" => htmlspecialchars('admin_create_user'), |
141 | "methodName" => htmlspecialchars('admin_create_user'), |
|
142 | "params" => |
142 | "params" => |
|
143 | array( "param" => |
143 | array( "param" => |
|
144 | array( "value" => |
144 | array( "value" => |
|
145 | array("struct" => |
145 | array("struct" => |
|
146 | array( |
146 | array( |
|
147 | "member" => |
147 | "member" => |
|
148 | array( |
148 | array( |
|
149 | "name" => 'password', |
149 | "name" => 'password', |
|
150 | "value" => array( |
150 | "value" => array( |
|
151 | "string" => htmlspecialchars($this->raPassword) |
151 | "string" => htmlspecialchars($this->raPassword) |
|
152 | ), |
152 | ), |
|
153 | ), |
153 | ), |
|
154 | array( |
154 | array( |
|
155 | "name" => 'user_firstname', |
155 | "name" => 'user_firstname', |
|
156 | "value" => htmlspecialchars($firstname) |
156 | "value" => htmlspecialchars($firstname) |
|
157 | ), |
157 | ), |
|
158 | array( |
158 | array( |
|
159 | "name" => 'user_lastname', |
159 | "name" => 'user_lastname', |
|
160 | "value" => htmlspecialchars($lastname) |
160 | "value" => htmlspecialchars($lastname) |
|
161 | ), |
161 | ), |
|
162 | array( |
162 | array( |
|
163 | "name" => 'user_password', |
163 | "name" => 'user_password', |
|
164 | "value" => htmlspecialchars($password) |
164 | "value" => htmlspecialchars($password) |
|
165 | ), |
165 | ), |
|
166 | array( |
166 | array( |
|
167 | "name" => 'start_region_x', |
167 | "name" => 'start_region_x', |
|
168 | "value" => htmlspecialchars($region_x) |
168 | "value" => htmlspecialchars($region_x) |
|
169 | ), |
169 | ), |
|
170 | array( |
170 | array( |
|
171 | "name" => 'start_region_y', |
171 | "name" => 'start_region_y', |
|
172 | "value" => htmlspecialchars($region_y) |
172 | "value" => htmlspecialchars($region_y) |
|
173 | ), |
173 | ), |
|
174 | ), |
174 | ), |
|
175 | ), |
175 | ), |
|
176 | ), |
176 | ), |
|
177 | ), |
177 | ), |
|
178 | ); |
178 | ); |
|
179 | |
179 | |
|
- | 180 | $serializer->serialize($xml); |
||
- | 181 | $xml_load = $serializer->getSerializedData(); |
||
- | 182 | $request->setBody($xml_load); |
||
- | 183 | return $request->send()->getBody(); |
||
- | 184 | } |
||
- | 185 | |
||
180 | function admin_update_user($firstname, $lastname, $password, $region_x, $region_y) { |
186 | function admin_update_user($firstname, $lastname, $password, $region_x, $region_y) { |
|
181 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
187 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
|
182 | $serializer = new XML_Serializer($this->options); |
188 | $serializer = new XML_Serializer($this->options); |
|
183 | $xml = array( |
189 | $xml = array( |
|
184 | "methodName" => htmlspecialchars('admin_update_user'), |
190 | "methodName" => htmlspecialchars('admin_update_user'), |
|
185 | "params" => |
191 | "params" => |
|
186 | array( "param" => |
192 | array( "param" => |
|
187 | array( "value" => |
193 | array( "value" => |
|
188 | array("struct" => |
194 | array("struct" => |
|
189 | array( |
195 | array( |
|
190 | "member" => |
196 | "member" => |
|
191 | array( |
197 | array( |
|
192 | "name" => 'password', |
198 | "name" => 'password', |
|
193 | "value" => array( |
199 | "value" => array( |
|
194 | "string" => htmlspecialchars($this->raPassword) |
200 | "string" => htmlspecialchars($this->raPassword) |
|
195 | ), |
201 | ), |
|
196 | ), |
202 | ), |
|
197 | array( |
203 | array( |
|
198 | "name" => 'user_firstname', |
204 | "name" => 'user_firstname', |
|
199 | "value" => htmlspecialchars($firstname) |
205 | "value" => htmlspecialchars($firstname) |
|
200 | ), |
206 | ), |
|
201 | array( |
207 | array( |
|
202 | "name" => 'user_lastname', |
208 | "name" => 'user_lastname', |
|
203 | "value" => htmlspecialchars($lastname) |
209 | "value" => htmlspecialchars($lastname) |
|
204 | ), |
210 | ), |
|
205 | array( |
211 | array( |
|
206 | "name" => 'user_password', |
212 | "name" => 'user_password', |
|
207 | "value" => htmlspecialchars($password) |
213 | "value" => htmlspecialchars($password) |
|
208 | ), |
214 | ), |
|
209 | array( |
215 | array( |
|
210 | "name" => 'start_region_x', |
216 | "name" => 'start_region_x', |
|
211 | "value" => htmlspecialchars($region_x) |
217 | "value" => htmlspecialchars($region_x) |
|
212 | ), |
218 | ), |
|
213 | array( |
219 | array( |
|
214 | "name" => 'start_region_y', |
220 | "name" => 'start_region_y', |
|
215 | "value" => htmlspecialchars($region_y) |
221 | "value" => htmlspecialchars($region_y) |
|
216 | ), |
222 | ), |
|
217 | ), |
223 | ), |
|
218 | ), |
224 | ), |
|
219 | ), |
225 | ), |
|
220 | ), |
226 | ), |
|
221 | ); |
227 | ); |
|
222 | |
228 | |
|
223 | $serializer->serialize($xml); |
229 | $serializer->serialize($xml); |
|
224 | $xml_load = $serializer->getSerializedData(); |
230 | $xml_load = $serializer->getSerializedData(); |
|
225 | $request->setBody($xml_load); |
231 | $request->setBody($xml_load); |
|
226 | return $request->send()->getBody(); |
232 | return $request->send()->getBody(); |
|
227 | } |
233 | } |
|
228 | |
234 | |
|
229 | function admin_get_agents($region_name, $include_children) { |
235 | function admin_get_agents($region_name, $include_children) { |
|
230 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
236 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
|
231 | $serializer = new XML_Serializer($this->options); |
237 | $serializer = new XML_Serializer($this->options); |
|
232 | $xml = array( |
238 | $xml = array( |
|
233 | "methodName" => htmlspecialchars('admin_get_agents'), |
239 | "methodName" => htmlspecialchars('admin_get_agents'), |
|
234 | "params" => |
240 | "params" => |
|
235 | array( "param" => |
241 | array( "param" => |
|
236 | array( "value" => |
242 | array( "value" => |
|
237 | array("struct" => |
243 | array("struct" => |
|
238 | array( |
244 | array( |
|
239 | "member" => |
245 | "member" => |
|
240 | array( |
246 | array( |
|
241 | "name" => 'password', |
247 | "name" => 'password', |
|
242 | "value" => array( |
248 | "value" => array( |
|
243 | "string" => htmlspecialchars($this->raPassword) |
249 | "string" => htmlspecialchars($this->raPassword) |
|
244 | ), |
250 | ), |
|
245 | ), |
251 | ), |
|
246 | array( |
252 | array( |
|
247 | "name" => 'region_name', |
253 | "name" => 'region_name', |
|
248 | "value" => htmlspecialchars($region_name) |
254 | "value" => htmlspecialchars($region_name) |
|
249 | ), |
255 | ), |
|
250 | array( |
256 | array( |
|
251 | "name" => 'include_children', |
257 | "name" => 'include_children', |
|
252 | "value" => htmlspecialchars($include_children) |
258 | "value" => htmlspecialchars($include_children) |
|
253 | ), |
259 | ), |
|
254 | ), |
260 | ), |
|
255 | ), |
261 | ), |
|
256 | ), |
262 | ), |
|
257 | ), |
263 | ), |
|
258 | ); |
264 | ); |
|
259 | |
265 | |
|
260 | $serializer->serialize($xml); |
266 | $serializer->serialize($xml); |
|
261 | $xml_load = $serializer->getSerializedData(); |
267 | $xml_load = $serializer->getSerializedData(); |
|
262 | $request->setBody($xml_load); |
268 | $request->setBody($xml_load); |
|
263 | return $request->send()->getBody(); |
269 | return $request->send()->getBody(); |
|
264 | } |
270 | } |
|
265 | } |
271 | } |
|
266 | |
272 | |
|
267 | |
273 | |