opensim-www – Blame information for rev 19

Subversion Repositories:
Rev:
Rev Author Line No. Line
8 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;
13 eva 38 var $raPassword;
12 eva 39 var $options;
8 eva 40  
13 eva 41 function wasRemoteAdmin($url,$raPassword) {
8 eva 42 $this->url = $url;
13 eva 43 $this->raPassword = $raPassword;
8 eva 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  
12 eva 57 function admin_console_command($console_command) {
8 eva 58 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST);
12 eva 59 $serializer = new XML_Serializer($this->options);
8 eva 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(
13 eva 71 "string" => htmlspecialchars($this->raPassword)
8 eva 72 ),
73 ),
74 array(
75 "name" => 'command',
76 "value" => array(
12 eva 77 "string" => htmlspecialchars($console_command)
8 eva 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  
12 eva 95 $serializer = new XML_Serializer($this->options);
8 eva 96 $xml = array(
97 "methodName" => htmlspecialchars('admin_authenticate_user'),
98 "params" =>
99 array( "param" =>
100 array( "value" =>
101 array("struct" =>
102 array(
103 "member" =>
104 array(
105 "name" => 'password',
106 "value" => array(
13 eva 107 "string" => htmlspecialchars($this->raPassword)
8 eva 108 ),
109 ),
110 array(
111 "name" => 'user_firstname',
112 "value" => htmlspecialchars($firstname)
113 ),
114 array(
115 "name" => 'user_lastname',
116 "value" => htmlspecialchars($lastname)
117 ),
118 array(
119 "name" => 'user_password',
120 "value" => htmlspecialchars($password)
121 ),
122 array(
123 "name" => 'token_lifetime',
124 "value" => htmlspecialchars($tokentime)
125 ),
126 ),
127 ),
128 ),
129 ),
130 );
131  
132 $serializer->serialize($xml);
133 $xml_load = $serializer->getSerializedData();
134 $request->setBody($xml_load);
135 return $request->send()->getBody();
136 }
13 eva 137  
138 function admin_create_user($firstname, $lastname, $password, $region_x, $region_y) {
139 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST);
140  
141 $serializer = new XML_Serializer($this->options);
142 $xml = array(
143 "methodName" => htmlspecialchars('admin_create_user'),
144 "params" =>
145 array( "param" =>
146 array( "value" =>
147 array("struct" =>
148 array(
149 "member" =>
150 array(
151 "name" => 'password',
152 "value" => array(
153 "string" => htmlspecialchars($this->raPassword)
154 ),
155 ),
156 array(
157 "name" => 'user_firstname',
158 "value" => htmlspecialchars($firstname)
159 ),
160 array(
161 "name" => 'user_lastname',
162 "value" => htmlspecialchars($lastname)
163 ),
164 array(
165 "name" => 'user_password',
166 "value" => htmlspecialchars($password)
167 ),
168 array(
169 "name" => 'start_region_x',
170 "value" => htmlspecialchars($region_x)
171 ),
172 array(
173 "name" => 'start_region_y',
174 "value" => htmlspecialchars($region_y)
175 ),
176 ),
177 ),
178 ),
179 ),
180 );
181  
182 $serializer->serialize($xml);
183 $xml_load = $serializer->getSerializedData();
184 $request->setBody($xml_load);
185 return $request->send()->getBody();
186 }
19 vero 187  
188 function admin_get_agents($region_name, $include_children) {
189 $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST);
190  
191 $serializer = new XML_Serializer($this->options);
192 $xml = array(
193 "methodName" => htmlspecialchars('admin_get_agents'),
194 "params" =>
195 array( "param" =>
196 array( "value" =>
197 array("struct" =>
198 array(
199 "member" =>
200 array(
201 "name" => 'password',
202 "value" => array(
203 "string" => htmlspecialchars($this->raPassword)
204 ),
205 ),
206 array(
207 "name" => 'region_name',
208 "value" => htmlspecialchars($region_name)
209 ),
210 array(
211 "name" => 'include_children',
212 "value" => htmlspecialchars($include_children)
213 ),
214 ),
215 ),
216 ),
217 ),
218 );
219  
220 $serializer->serialize($xml);
221 $xml_load = $serializer->getSerializedData();
222 $request->setBody($xml_load);
223 return $request->send()->getBody();
224 }
8 eva 225 }
226