opensim-www – Diff between revs 13 and 19
?pathlinks?
Rev 13 | Rev 19 | |||
---|---|---|---|---|
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 | |
94 | |
|
95 | $serializer = new XML_Serializer($this->options); |
95 | $serializer = new XML_Serializer($this->options); |
|
96 | $xml = array( |
96 | $xml = array( |
|
97 | "methodName" => htmlspecialchars('admin_authenticate_user'), |
97 | "methodName" => htmlspecialchars('admin_authenticate_user'), |
|
98 | "params" => |
98 | "params" => |
|
99 | array( "param" => |
99 | array( "param" => |
|
100 | array( "value" => |
100 | array( "value" => |
|
101 | array("struct" => |
101 | array("struct" => |
|
102 | array( |
102 | array( |
|
103 | "member" => |
103 | "member" => |
|
104 | array( |
104 | array( |
|
105 | "name" => 'password', |
105 | "name" => 'password', |
|
106 | "value" => array( |
106 | "value" => array( |
|
107 | "string" => htmlspecialchars($this->raPassword) |
107 | "string" => htmlspecialchars($this->raPassword) |
|
108 | ), |
108 | ), |
|
109 | ), |
109 | ), |
|
110 | array( |
110 | array( |
|
111 | "name" => 'user_firstname', |
111 | "name" => 'user_firstname', |
|
112 | "value" => htmlspecialchars($firstname) |
112 | "value" => htmlspecialchars($firstname) |
|
113 | ), |
113 | ), |
|
114 | array( |
114 | array( |
|
115 | "name" => 'user_lastname', |
115 | "name" => 'user_lastname', |
|
116 | "value" => htmlspecialchars($lastname) |
116 | "value" => htmlspecialchars($lastname) |
|
117 | ), |
117 | ), |
|
118 | array( |
118 | array( |
|
119 | "name" => 'user_password', |
119 | "name" => 'user_password', |
|
120 | "value" => htmlspecialchars($password) |
120 | "value" => htmlspecialchars($password) |
|
121 | ), |
121 | ), |
|
122 | array( |
122 | array( |
|
123 | "name" => 'token_lifetime', |
123 | "name" => 'token_lifetime', |
|
124 | "value" => htmlspecialchars($tokentime) |
124 | "value" => htmlspecialchars($tokentime) |
|
125 | ), |
125 | ), |
|
126 | ), |
126 | ), |
|
127 | ), |
127 | ), |
|
128 | ), |
128 | ), |
|
129 | ), |
129 | ), |
|
130 | ); |
130 | ); |
|
131 | |
131 | |
|
132 | $serializer->serialize($xml); |
132 | $serializer->serialize($xml); |
|
133 | $xml_load = $serializer->getSerializedData(); |
133 | $xml_load = $serializer->getSerializedData(); |
|
134 | $request->setBody($xml_load); |
134 | $request->setBody($xml_load); |
|
135 | return $request->send()->getBody(); |
135 | return $request->send()->getBody(); |
|
136 | } |
136 | } |
|
137 | |
137 | |
|
138 | function admin_create_user($firstname, $lastname, $password, $region_x, $region_y) { |
138 | function admin_create_user($firstname, $lastname, $password, $region_x, $region_y) { |
|
139 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
139 | $request = new HTTP_Request2($this->url, HTTP_Request2::METHOD_POST); |
|
140 | |
140 | |
|
141 | $serializer = new XML_Serializer($this->options); |
141 | $serializer = new XML_Serializer($this->options); |
|
142 | $xml = array( |
142 | $xml = array( |
|
143 | "methodName" => htmlspecialchars('admin_create_user'), |
143 | "methodName" => htmlspecialchars('admin_create_user'), |
|
144 | "params" => |
144 | "params" => |
|
145 | array( "param" => |
145 | array( "param" => |
|
146 | array( "value" => |
146 | array( "value" => |
|
147 | array("struct" => |
147 | array("struct" => |
|
148 | array( |
148 | array( |
|
149 | "member" => |
149 | "member" => |
|
150 | array( |
150 | array( |
|
151 | "name" => 'password', |
151 | "name" => 'password', |
|
152 | "value" => array( |
152 | "value" => array( |
|
153 | "string" => htmlspecialchars($this->raPassword) |
153 | "string" => htmlspecialchars($this->raPassword) |
|
154 | ), |
154 | ), |
|
155 | ), |
155 | ), |
|
156 | array( |
156 | array( |
|
157 | "name" => 'user_firstname', |
157 | "name" => 'user_firstname', |
|
158 | "value" => htmlspecialchars($firstname) |
158 | "value" => htmlspecialchars($firstname) |
|
159 | ), |
159 | ), |
|
160 | array( |
160 | array( |
|
161 | "name" => 'user_lastname', |
161 | "name" => 'user_lastname', |
|
162 | "value" => htmlspecialchars($lastname) |
162 | "value" => htmlspecialchars($lastname) |
|
163 | ), |
163 | ), |
|
164 | array( |
164 | array( |
|
165 | "name" => 'user_password', |
165 | "name" => 'user_password', |
|
166 | "value" => htmlspecialchars($password) |
166 | "value" => htmlspecialchars($password) |
|
167 | ), |
167 | ), |
|
168 | array( |
168 | array( |
|
169 | "name" => 'start_region_x', |
169 | "name" => 'start_region_x', |
|
170 | "value" => htmlspecialchars($region_x) |
170 | "value" => htmlspecialchars($region_x) |
|
171 | ), |
171 | ), |
|
172 | array( |
172 | array( |
|
173 | "name" => 'start_region_y', |
173 | "name" => 'start_region_y', |
|
174 | "value" => htmlspecialchars($region_y) |
174 | "value" => htmlspecialchars($region_y) |
|
175 | ), |
175 | ), |
|
176 | ), |
176 | ), |
|
177 | ), |
177 | ), |
|
178 | ), |
178 | ), |
|
179 | ), |
179 | ), |
|
180 | ); |
180 | ); |
|
181 | |
181 | |
|
182 | $serializer->serialize($xml); |
182 | $serializer->serialize($xml); |
|
183 | $xml_load = $serializer->getSerializedData(); |
183 | $xml_load = $serializer->getSerializedData(); |
|
184 | $request->setBody($xml_load); |
184 | $request->setBody($xml_load); |
|
185 | return $request->send()->getBody(); |
185 | return $request->send()->getBody(); |
|
186 | } |
186 | } |
|
- | 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 | } |
||
187 | } |
225 | } |
|
188 | |
226 | |
|
189 | |
227 | |