opensim-www – Blame information for rev 12

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;
38 var $pwd;
12 eva 39 var $options;
8 eva 40  
41 function wasRemoteAdmin($url,$pwd) {
42 $this->url = $url;
43 $this->pwd = $pwd;
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(
71 "string" => htmlspecialchars($this->pwd)
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(
107 "string" => htmlspecialchars($this->pwd)
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 }
137 }
138