clockwerk-www – Diff between revs 1 and 61

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 1 Rev 61
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 -  
95 $serializer = new XML_Serializer($this->options); 94 $serializer = new XML_Serializer($this->options);
96 $xml = array( 95 $xml = array(
97 "methodName" => htmlspecialchars('admin_authenticate_user'), 96 "methodName" => htmlspecialchars('admin_authenticate_user'),
98 "params" => 97 "params" =>
99 array( "param" => 98 array( "param" =>
100 array( "value" => 99 array( "value" =>
101 array("struct" => 100 array("struct" =>
102 array( 101 array(
103 "member" => 102 "member" =>
104 array( 103 array(
105 "name" => 'password', 104 "name" => 'password',
106 "value" => array( 105 "value" => array(
107 "string" => htmlspecialchars($this->raPassword) 106 "string" => htmlspecialchars($this->raPassword)
108 ), 107 ),
109 ), 108 ),
110 array( 109 array(
111 "name" => 'user_firstname', 110 "name" => 'user_firstname',
112 "value" => htmlspecialchars($firstname) 111 "value" => htmlspecialchars($firstname)
113 ), 112 ),
114 array( 113 array(
115 "name" => 'user_lastname', 114 "name" => 'user_lastname',
116 "value" => htmlspecialchars($lastname) 115 "value" => htmlspecialchars($lastname)
117 ), 116 ),
118 array( 117 array(
119 "name" => 'user_password', 118 "name" => 'user_password',
120 "value" => htmlspecialchars($password) 119 "value" => htmlspecialchars($password)
121 ), 120 ),
122 array( 121 array(
123 "name" => 'token_lifetime', 122 "name" => 'token_lifetime',
124 "value" => htmlspecialchars($tokentime) 123 "value" => htmlspecialchars($tokentime)
125 ), 124 ),
126 ), 125 ),
127 ), 126 ),
128 ), 127 ),
129 ), 128 ),
130 ); 129 );
131 130
132 $serializer->serialize($xml); 131 $serializer->serialize($xml);
133 $xml_load = $serializer->getSerializedData(); 132 $xml_load = $serializer->getSerializedData();
134 $request->setBody($xml_load); 133 $request->setBody($xml_load);
135 return $request->send()->getBody(); 134 return $request->send()->getBody();
136 } 135 }
137   136  
138 function admin_create_user($firstname, $lastname, $password, $region_x, $region_y) { 137 function admin_create_user($firstname, $lastname, $password, $region_x, $region_y) {
139 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); 138 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST);
140 -  
141 $serializer = new XML_Serializer($this->options); 139 $serializer = new XML_Serializer($this->options);
142 $xml = array( 140 $xml = array(
143 "methodName" => htmlspecialchars('admin_create_user'), 141 "methodName" => htmlspecialchars('admin_create_user'),
144 "params" => 142 "params" =>
145 array( "param" => 143 array( "param" =>
146 array( "value" => 144 array( "value" =>
147 array("struct" => 145 array("struct" =>
148 array( 146 array(
149 "member" => 147 "member" =>
150 array( 148 array(
151 "name" => 'password', 149 "name" => 'password',
152 "value" => array( 150 "value" => array(
153 "string" => htmlspecialchars($this->raPassword) 151 "string" => htmlspecialchars($this->raPassword)
154 ), 152 ),
155 ), 153 ),
156 array( 154 array(
157 "name" => 'user_firstname', 155 "name" => 'user_firstname',
158 "value" => htmlspecialchars($firstname) 156 "value" => htmlspecialchars($firstname)
159 ), 157 ),
160 array( 158 array(
161 "name" => 'user_lastname', 159 "name" => 'user_lastname',
162 "value" => htmlspecialchars($lastname) 160 "value" => htmlspecialchars($lastname)
163 ), 161 ),
164 array( 162 array(
165 "name" => 'user_password', 163 "name" => 'user_password',
166 "value" => htmlspecialchars($password) 164 "value" => htmlspecialchars($password)
167 ), 165 ),
168 array( 166 array(
169 "name" => 'start_region_x', 167 "name" => 'start_region_x',
170 "value" => htmlspecialchars($region_x) 168 "value" => htmlspecialchars($region_x)
171 ), 169 ),
172 array( 170 array(
173 "name" => 'start_region_y', 171 "name" => 'start_region_y',
174 "value" => htmlspecialchars($region_y) 172 "value" => htmlspecialchars($region_y)
175 ), 173 ),
176 ), 174 ),
177 ), 175 ),
178 ), 176 ),
179 ), 177 ),
180 ); 178 );
-   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 );
181 222
182 $serializer->serialize($xml); 223 $serializer->serialize($xml);
183 $xml_load = $serializer->getSerializedData(); 224 $xml_load = $serializer->getSerializedData();
184 $request->setBody($xml_load); 225 $request->setBody($xml_load);
185 return $request->send()->getBody(); 226 return $request->send()->getBody();
186 } 227 }
187 228
188 function admin_get_agents($region_name, $include_children) { 229 function admin_get_agents($region_name, $include_children) {
189 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); 230 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST);
190 -  
191 $serializer = new XML_Serializer($this->options); 231 $serializer = new XML_Serializer($this->options);
192 $xml = array( 232 $xml = array(
193 "methodName" => htmlspecialchars('admin_get_agents'), 233 "methodName" => htmlspecialchars('admin_get_agents'),
194 "params" => 234 "params" =>
195 array( "param" => 235 array( "param" =>
196 array( "value" => 236 array( "value" =>
197 array("struct" => 237 array("struct" =>
198 array( 238 array(
199 "member" => 239 "member" =>
200 array( 240 array(
201 "name" => 'password', 241 "name" => 'password',
202 "value" => array( 242 "value" => array(
203 "string" => htmlspecialchars($this->raPassword) 243 "string" => htmlspecialchars($this->raPassword)
204 ), 244 ),
205 ), 245 ),
206 array( 246 array(
207 "name" => 'region_name', 247 "name" => 'region_name',
208 "value" => htmlspecialchars($region_name) 248 "value" => htmlspecialchars($region_name)
209 ), 249 ),
210 array( 250 array(
211 "name" => 'include_children', 251 "name" => 'include_children',
212 "value" => htmlspecialchars($include_children) 252 "value" => htmlspecialchars($include_children)
213 ), 253 ),
214 ), 254 ),
215 ), 255 ),
216 ), 256 ),
217 ), 257 ),
218 ); 258 );
219 259
220 $serializer->serialize($xml); 260 $serializer->serialize($xml);
221 $xml_load = $serializer->getSerializedData(); 261 $xml_load = $serializer->getSerializedData();
222 $request->setBody($xml_load); 262 $request->setBody($xml_load);
223 return $request->send()->getBody(); 263 return $request->send()->getBody();
224 } 264 }
225 } 265 }
226   266  
227   267