clockwerk-www – Blame information for rev 61

Subversion Repositories:
Rev:
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 );
61 vero 179  
180 function admin_update_user($firstname, $lastname, $password, $region_x, $region_y) {
181 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST);
182 $serializer = new XML_Serializer($this->options);
183 $xml = array(
184 "methodName" => htmlspecialchars('admin_update_user'),
185 "params" =>
186 array( "param" =>
187 array( "value" =>
188 array("struct" =>
189 array(
190 "member" =>
191 array(
192 "name" => 'password',
193 "value" => array(
194 "string" => htmlspecialchars($this->raPassword)
195 ),
196 ),
197 array(
198 "name" => 'user_firstname',
199 "value" => htmlspecialchars($firstname)
200 ),
201 array(
202 "name" => 'user_lastname',
203 "value" => htmlspecialchars($lastname)
204 ),
205 array(
206 "name" => 'user_password',
207 "value" => htmlspecialchars($password)
208 ),
209 array(
210 "name" => 'start_region_x',
211 "value" => htmlspecialchars($region_x)
212 ),
213 array(
214 "name" => 'start_region_y',
215 "value" => htmlspecialchars($region_y)
216 ),
217 ),
218 ),
219 ),
220 ),
221 );
1 eva 222  
223 $serializer->serialize($xml);
224 $xml_load = $serializer->getSerializedData();
225 $request->setBody($xml_load);
226 return $request->send()->getBody();
227 }
228  
229 function admin_get_agents($region_name, $include_children) {
230 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST);
231 $serializer = new XML_Serializer($this->options);
232 $xml = array(
233 "methodName" => htmlspecialchars('admin_get_agents'),
234 "params" =>
235 array( "param" =>
236 array( "value" =>
237 array("struct" =>
238 array(
239 "member" =>
240 array(
241 "name" => 'password',
242 "value" => array(
243 "string" => htmlspecialchars($this->raPassword)
244 ),
245 ),
246 array(
247 "name" => 'region_name',
248 "value" => htmlspecialchars($region_name)
249 ),
250 array(
251 "name" => 'include_children',
252 "value" => htmlspecialchars($include_children)
253 ),
254 ),
255 ),
256 ),
257 ),
258 );
259  
260 $serializer->serialize($xml);
261 $xml_load = $serializer->getSerializedData();
262 $request->setBody($xml_load);
263 return $request->send()->getBody();
264 }
265 }
266