aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ogs
diff options
context:
space:
mode:
Diffstat (limited to 'ogs')
-rw-r--r--ogs/assetserver/assets/00000000000000005005000000000005/databin0 -> 291 bytes
-rw-r--r--ogs/assetserver/assets/00000000000000007007000000000006/databin0 -> 153 bytes
-rw-r--r--ogs/assetserver/assets/00000000000000007009000000000008/databin0 -> 570 bytes
-rw-r--r--ogs/assetserver/assets/66c41e3938f9f75a024e585989bfab73/data105
-rw-r--r--ogs/assetserver/assets/e0ee49b5a4184df8d3c9a65361fe7f49/data52
-rw-r--r--ogs/assetserver/assetserver_config.inc.php16
-rw-r--r--ogs/assetserver/index.php24
-rw-r--r--ogs/common/database.inc.php.tmpl9
-rw-r--r--ogs/common/grid_config.inc.php7
-rw-r--r--ogs/common/util.inc.php42
-rw-r--r--ogs/common/xmlrpc.inc.php828
-rw-r--r--ogs/gridserver/gridserver_config.inc.php14
-rw-r--r--ogs/gridserver/index.php176
-rw-r--r--ogs/gridserver/usersessions/.htaccess5
-rw-r--r--ogs/gridserver/usersessions/index.php81
-rw-r--r--ogs/login/index.php170
-rw-r--r--ogs/login/login_config.inc.php11
17 files changed, 1540 insertions, 0 deletions
diff --git a/ogs/assetserver/assets/00000000000000005005000000000005/data b/ogs/assetserver/assets/00000000000000005005000000000005/data
new file mode 100644
index 0000000..e6840e2
--- /dev/null
+++ b/ogs/assetserver/assets/00000000000000005005000000000005/data
Binary files differ
diff --git a/ogs/assetserver/assets/00000000000000007007000000000006/data b/ogs/assetserver/assets/00000000000000007007000000000006/data
new file mode 100644
index 0000000..5ad1fd0
--- /dev/null
+++ b/ogs/assetserver/assets/00000000000000007007000000000006/data
Binary files differ
diff --git a/ogs/assetserver/assets/00000000000000007009000000000008/data b/ogs/assetserver/assets/00000000000000007009000000000008/data
new file mode 100644
index 0000000..cd2fd94
--- /dev/null
+++ b/ogs/assetserver/assets/00000000000000007009000000000008/data
Binary files differ
diff --git a/ogs/assetserver/assets/66c41e3938f9f75a024e585989bfab73/data b/ogs/assetserver/assets/66c41e3938f9f75a024e585989bfab73/data
new file mode 100644
index 0000000..920c775
--- /dev/null
+++ b/ogs/assetserver/assets/66c41e3938f9f75a024e585989bfab73/data
@@ -0,0 +1,105 @@
1LLWearable version 22
2Female Shape and Outfit 3 Shape
3Created by system from avatar's appearance.
4 permissions 0
5 {
6 base_mask 00082000
7 owner_mask 00082000
8 group_mask 00082000
9 everyone_mask 00082000
10 next_owner_mask 00082000
11 creator_id 3d924400-038e-6ad9-920b-cfbb9b40585c
12 owner_id 542ffb8e-8932-49b9-8664-58f53e442797
13 last_owner_id 3d924400-038e-6ad9-920b-cfbb9b40585c
14 group_id 00000000-0000-0000-0000-000000000000
15 }
16 sale_info 0
17 {
18 sale_type not
19 sale_price 0
20 }
21type 0
22parameters 82
231 .21
242 -.5
254 -.11
265 -.1
276 -.3
287 -.4
298 -.5
3010 .7
3111 .34
3212 -.5
3313 0
3414 .04
3515 .58
3617 .56
3718 -.26
3819 -.73
3920 -.34
4021 -.01
4122 1
4223 -.5
4324 -.63
4425 .44
4527 .05
4633 -.24
4734 -.7
4835 -.16
4936 -.2
5037 -.98
5138 -.5
5280 0
53105 .07
54155 -.22
55157 0
56185 -1
57193 .86
58196 -.74
59505 .65
60506 .12
61507 -1.5
62515 0
63517 .16
64518 .8
65629 0
66637 0
67646 .4
68647 1
69649 .36
70650 .85
71652 .49
72653 -1
73656 0
74659 .65
75662 .5
76663 0
77664 0
78665 0
79675 -.15
80676 .26
81678 .28
82682 .27
83683 -.19
84684 -.09
85685 0
86690 .45
87692 .4
88693 -0
89753 -.5
90756 -.08
91758 .24
92759 .6
93760 .11
94764 -.38
95765 -.3
96769 .42
97773 .51
98795 .16
99796 .11
100799 .36
101841 0
102842 -.82
103879 0
104880 0
105textures 0
diff --git a/ogs/assetserver/assets/e0ee49b5a4184df8d3c9a65361fe7f49/data b/ogs/assetserver/assets/e0ee49b5a4184df8d3c9a65361fe7f49/data
new file mode 100644
index 0000000..95cc683
--- /dev/null
+++ b/ogs/assetserver/assets/e0ee49b5a4184df8d3c9a65361fe7f49/data
@@ -0,0 +1,52 @@
1LLWearable version 22
2Sexy - Female Skin
3
4 permissions 0
5 {
6 base_mask 00086000
7 owner_mask 00086000
8 group_mask 00000000
9 everyone_mask 00000000
10 next_owner_mask 00086000
11 creator_id 3b659a92-dbf0-4301-8fdc-208d78f00d77
12 owner_id 3d924400-038e-6ad9-920b-cfbb9b40585c
13 last_owner_id 101358d5-469d-4b24-9b85-4dc3c05e635d
14 group_id 00000000-0000-0000-0000-000000000000
15 }
16 sale_info 0
17 {
18 sale_type not
19 sale_price 10
20 }
21type 1
22parameters 26
23108 0
24110 0
25111 0
26116 0
27117 1
28150 0
29162 0
30163 0
31165 0
32700 .01
33701 .5
34702 .26
35703 0
36704 0
37705 .5
38706 .6
39707 0
40708 0
41709 0
42710 0
43711 .5
44712 0
45713 .7
46714 0
47715 0
48775 0
49textures 3
500 f9261672-5058-9ef8-c0c4-48f43a0b16d4
515 b6ba53be-b5bf-9a1f-2e19-21daf998429c
526 703f6e24-a1fb-1980-acaf-6ab8a99a5bd5
diff --git a/ogs/assetserver/assetserver_config.inc.php b/ogs/assetserver/assetserver_config.inc.php
new file mode 100644
index 0000000..529a4f7
--- /dev/null
+++ b/ogs/assetserver/assetserver_config.inc.php
@@ -0,0 +1,16 @@
1<?
2// All the asset server specific stuff lives here
3
4// The asset server's relative URL to the root of the webserver
5// If you place this at http://servername/assets then this would be set to /assets/index.php
6// wikipedia style URLs need to be implemented - and will be (en.wikipedia.org/wiki/blabla rather than en.wikipedia.org/wiki/index.php?something=bla or en.wikipedia.org/wiki.php/bla)
7$asset_home = "/ogs/assetserver/index.php/";
8
9// The key we expect from sims
10$sim_recvkey = "rtrgrgrgrgr894898f998re98rf989fds";
11
12// The path where the asset repository is stored, this should be readable by the webserver but NOT in the document root
13// The default below is BAD for production use and intended to be simply generic - change it or risk copyright theft
14// greater than you could ever imagine, alternatively use .htaccess or other mechanisms.
15$asset_repos = "/var/www/htdocs/ogs/assetserver/assets";
16?> \ No newline at end of file
diff --git a/ogs/assetserver/index.php b/ogs/assetserver/index.php
new file mode 100644
index 0000000..82cf9d4
--- /dev/null
+++ b/ogs/assetserver/index.php
@@ -0,0 +1,24 @@
1<?
2error_reporting(0); // Remember kids, PHP errors kill XML-RPC responses and REST too! will the slaughter ever end?
3
4include("assetserver_config.inc.php");
5
6// Parse out the parameters from the URL
7$params = str_replace($asset_home,'', $_SERVER['REQUEST_URI']);
8$params = split('/',$params);
9
10// Die if the key doesn't match
11if($params[1]!=$sim_recvkey) {
12 die();
13}
14
15// Send requested data
16switch($params[0]) {
17 case 'getasset':
18 if($params[3]=="data") {
19 Header("Content-Length: ". (string)filesize($asset_repos . "/" . $params[2] . "/data"));
20 readfile($asset_repos . "/" . $params[2] . "/data");
21 }
22 break;
23}
24?> \ No newline at end of file
diff --git a/ogs/common/database.inc.php.tmpl b/ogs/common/database.inc.php.tmpl
new file mode 100644
index 0000000..42ac5ca
--- /dev/null
+++ b/ogs/common/database.inc.php.tmpl
@@ -0,0 +1,9 @@
1<?
2// this file tells all the OGS services where to find the MySQL database
3// if multiple OGS services are running on one machine, it is assumed that they all use the same MySQL server/database
4
5$dbhost="YOURSERVERHERE";
6$dbuser="opengridservice";
7$dbname="OGS";
8$dbpasswd="supersecret";
9?>
diff --git a/ogs/common/grid_config.inc.php b/ogs/common/grid_config.inc.php
new file mode 100644
index 0000000..0bc6a5e
--- /dev/null
+++ b/ogs/common/grid_config.inc.php
@@ -0,0 +1,7 @@
1<?
2// this file is common across servers and must be kept in sync
3
4$gridserver_url="http://www.garethnelson.com/ogs/gridserver/";
5
6$grid_owner="Gareth Nelson";
7?> \ No newline at end of file
diff --git a/ogs/common/util.inc.php b/ogs/common/util.inc.php
new file mode 100644
index 0000000..b931205
--- /dev/null
+++ b/ogs/common/util.inc.php
@@ -0,0 +1,42 @@
1<?
2// Some generic utilities which may be used by any services
3
4function inc_lluuid($lluuid)
5{
6 $partB = substr($lluuid, 15);
7 $partB = (float)base_convert($partB,16,10)+1;
8 $partB = sprintf('%016x', $partB);
9 $partA = substr($lluuid, 0, 16);
10
11 if(substr($lluuid,15,16)=='FFFFFFFFFFFFFFFE') {
12 $partA = (float)base_convert($partA,16,10)+1;
13 $partA = sprintf('%016x', $partA);
14 }
15
16 $returnval = sprintf('%s%s',$partA, $partB);
17
18 return $returnval;
19}
20
21function format_lluuid($uuid)
22{
23 return strtolower(substr($uuid,0,8)."-".substr($uuid,8,4)."-".substr($uuid,12,4)."-".substr($uuid,16,4)."-".substr($uuid,20));
24}
25
26function output_xml_block($blockname, $data) {
27 echo("<$blockname>\n");
28 foreach($data as $name => $value) {
29 echo(" <$name>$value</$name>\n");
30 }
31 echo("</$blockname>\n");
32}
33
34function rand_uuid()
35{
36 return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
37 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
38 mt_rand( 0, 0x0fff ) | 0x4000,
39 mt_rand( 0, 0x3fff ) | 0x8000,
40 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
41}
42?>
diff --git a/ogs/common/xmlrpc.inc.php b/ogs/common/xmlrpc.inc.php
new file mode 100644
index 0000000..03c1ee7
--- /dev/null
+++ b/ogs/common/xmlrpc.inc.php
@@ -0,0 +1,828 @@
1<?php
2
3/*
4 IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002
5 Version 1.61 - Simon Willison, 11th July 2003 (htmlentities -> htmlspecialchars)
6 Site: http://scripts.incutio.com/xmlrpc/
7 Manual: http://scripts.incutio.com/xmlrpc/manual.php
8 Made available under the Artistic License: http://www.opensource.org/licenses/artistic-license.php
9*/
10
11
12class IXR_Value {
13 var $data;
14 var $type;
15 function IXR_Value ($data, $type = false) {
16 $this->data = $data;
17 if (!$type) {
18 $type = $this->calculateType();
19 }
20 $this->type = $type;
21 if ($type == 'struct') {
22 /* Turn all the values in the array in to new IXR_Value objects */
23 foreach ($this->data as $key => $value) {
24 $this->data[$key] = new IXR_Value($value);
25 }
26 }
27 if ($type == 'array') {
28 for ($i = 0, $j = count($this->data); $i < $j; $i++) {
29 $this->data[$i] = new IXR_Value($this->data[$i]);
30 }
31 }
32 }
33 function calculateType() {
34 if ($this->data === true || $this->data === false) {
35 return 'boolean';
36 }
37 if (is_integer($this->data)) {
38 return 'i4';
39 }
40 if (is_double($this->data)) {
41 return 'double';
42 }
43 // Deal with IXR object types base64 and date
44 if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
45 return 'date';
46 }
47 if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
48 return 'base64';
49 }
50 if (is_object($this->data)) {
51 return 'object';
52 }
53 if (!is_array($this->data)) {
54 return 'string';
55 }
56 /* We have an array - is it an array or a struct ? */
57 if ($this->isStruct($this->data)) {
58 return 'struct';
59 } else {
60 return 'array';
61 }
62 }
63 function getXml() {
64 /* Return XML for this value */
65 switch ($this->type) {
66 case 'boolean':
67 return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
68 break;
69 case 'i4':
70 return '<i4>'.$this->data.'</i4>';
71 break;
72 case 'double':
73 return '<double>'.$this->data.'</double>';
74 break;
75 case 'string':
76 return '<string>'.htmlspecialchars($this->data).'</string>';
77 break;
78 case 'array':
79 $return = '<array><data>'."";
80 foreach ($this->data as $item) {
81 $return .= ' <value>'.$item->getXml()."</value>";
82 }
83 $return .= '</data></array>';
84 return $return;
85 break;
86 case 'struct':
87 $return = '<struct>'."";
88 foreach ($this->data as $name => $value) {
89 $return .= "<member><name>$name</name><value>";
90 $return .= $value->getXml()."</value></member>";
91 }
92 $return .= '</struct>';
93 return $return;
94 break;
95 case 'date':
96 case 'base64':
97 return $this->data->getXml();
98 break;
99 case 'object':
100 return $this->data->getXml();
101 break;
102 }
103 return false;
104 }
105 function isStruct($array) {
106 /* Nasty function to check if an array is a struct or not */
107 $expected = 0;
108 foreach ($array as $key => $value) {
109 if ((string)$key != (string)$expected) {
110 return true;
111 }
112 $expected++;
113 }
114 return false;
115 }
116}
117
118
119class IXR_Message {
120 var $message;
121 var $messageType; // methodCall / methodResponse / fault
122 var $faultCode;
123 var $faultString;
124 var $methodName;
125 var $params;
126 // Current variable stacks
127 var $_arraystructs = array(); // The stack used to keep track of the current array/struct
128 var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
129 var $_currentStructName = array(); // A stack as well
130 var $_param;
131 var $_value;
132 var $_currentTag;
133 var $_currentTagContents;
134 // The XML parser
135 var $_parser;
136 function IXR_Message ($message) {
137 $this->message = $message;
138 }
139 function parse() {
140 // first remove the XML declaration
141 $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
142 if (trim($this->message) == '') {
143 return false;
144 }
145 $this->_parser = xml_parser_create();
146 // Set XML parser to take the case of tags in to account
147 xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
148 // Set XML parser callback functions
149 xml_set_object($this->_parser, $this);
150 xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
151 xml_set_character_data_handler($this->_parser, 'cdata');
152 if (!xml_parse($this->_parser, $this->message)) {
153 /* die(sprintf('XML error: %s at line %d',
154 xml_error_string(xml_get_error_code($this->_parser)),
155 xml_get_current_line_number($this->_parser))); */
156 return false;
157 }
158 xml_parser_free($this->_parser);
159 // Grab the error messages, if any
160 if ($this->messageType == 'fault') {
161 $this->faultCode = $this->params[0]['faultCode'];
162 $this->faultString = $this->params[0]['faultString'];
163 }
164 return true;
165 }
166 function tag_open($parser, $tag, $attr) {
167 $this->currentTag = $tag;
168 switch($tag) {
169 case 'methodCall':
170 case 'methodResponse':
171 case 'fault':
172 $this->messageType = $tag;
173 break;
174 /* Deal with stacks of arrays and structs */
175 case 'data': // data is to all intents and puposes more interesting than array
176 $this->_arraystructstypes[] = 'array';
177 $this->_arraystructs[] = array();
178 break;
179 case 'struct':
180 $this->_arraystructstypes[] = 'struct';
181 $this->_arraystructs[] = array();
182 break;
183 }
184 }
185 function cdata($parser, $cdata) {
186 $this->_currentTagContents .= $cdata;
187 }
188 function tag_close($parser, $tag) {
189 $valueFlag = false;
190 switch($tag) {
191 case 'int':
192 case 'i4':
193 $value = (int)trim($this->_currentTagContents);
194 $this->_currentTagContents = '';
195 $valueFlag = true;
196 break;
197 case 'double':
198 $value = (double)trim($this->_currentTagContents);
199 $this->_currentTagContents = '';
200 $valueFlag = true;
201 break;
202 case 'string':
203 $value = (string)trim($this->_currentTagContents);
204 $this->_currentTagContents = '';
205 $valueFlag = true;
206 break;
207 case 'dateTime.iso8601':
208 $value = new IXR_Date(trim($this->_currentTagContents));
209 // $value = $iso->getTimestamp();
210 $this->_currentTagContents = '';
211 $valueFlag = true;
212 break;
213 case 'value':
214 // "If no type is indicated, the type is string."
215 if (trim($this->_currentTagContents) != '') {
216 $value = (string)$this->_currentTagContents;
217 $this->_currentTagContents = '';
218 $valueFlag = true;
219 }
220 break;
221 case 'boolean':
222 $value = (boolean)trim($this->_currentTagContents);
223 $this->_currentTagContents = '';
224 $valueFlag = true;
225 break;
226 case 'base64':
227 $value = base64_decode($this->_currentTagContents);
228 $this->_currentTagContents = '';
229 $valueFlag = true;
230 break;
231 /* Deal with stacks of arrays and structs */
232 case 'data':
233 case 'struct':
234 $value = array_pop($this->_arraystructs);
235 array_pop($this->_arraystructstypes);
236 $valueFlag = true;
237 break;
238 case 'member':
239 array_pop($this->_currentStructName);
240 break;
241 case 'name':
242 $this->_currentStructName[] = trim($this->_currentTagContents);
243 $this->_currentTagContents = '';
244 break;
245 case 'methodName':
246 $this->methodName = trim($this->_currentTagContents);
247 $this->_currentTagContents = '';
248 break;
249 }
250 if ($valueFlag) {
251 /*
252 if (!is_array($value) && !is_object($value)) {
253 $value = trim($value);
254 }
255 */
256 if (count($this->_arraystructs) > 0) {
257 // Add value to struct or array
258 if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
259 // Add to struct
260 $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
261 } else {
262 // Add to array
263 $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
264 }
265 } else {
266 // Just add as a paramater
267 $this->params[] = $value;
268 }
269 }
270 }
271}
272
273
274class IXR_Server {
275 var $data;
276 var $callbacks = array();
277 var $message;
278 var $capabilities;
279 function IXR_Server($callbacks = false, $data = false) {
280 $this->setCapabilities();
281 if ($callbacks) {
282 $this->callbacks = $callbacks;
283 }
284 $this->setCallbacks();
285 $this->serve($data);
286 }
287 function serve($data = false) {
288 if (!$data) {
289 global $HTTP_RAW_POST_DATA;
290 if (!$HTTP_RAW_POST_DATA) {
291 die('XML-RPC server accepts POST requests only.');
292 }
293 $data = $HTTP_RAW_POST_DATA;
294 }
295 $this->message = new IXR_Message($data);
296 if (!$this->message->parse()) {
297 $this->error(-32700, 'parse error. not well formed');
298 }
299 if ($this->message->messageType != 'methodCall') {
300 $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
301 }
302 $result = $this->call($this->message->methodName, $this->message->params);
303 // Is the result an error?
304 if (is_a($result, 'IXR_Error')) {
305 $this->error($result);
306 }
307 // Encode the result
308 $r = new IXR_Value($result);
309 $resultxml = $r->getXml();
310 // Create the XML
311 $xml = <<<EOD
312<methodResponse><params><param><value>$resultxml</value></param></params></methodResponse>
313EOD;
314 // Send it
315 $this->output($xml);
316 }
317 function call($methodname, $args) {
318 if (!$this->hasMethod($methodname)) {
319 return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
320 }
321 $method = $this->callbacks[$methodname];
322 // Perform the callback and send the response
323 if (count($args) == 1) {
324 // If only one paramater just send that instead of the whole array
325 $args = $args[0];
326 }
327 // Are we dealing with a function or a method?
328 if (substr($method, 0, 5) == 'this:') {
329 // It's a class method - check it exists
330 $method = substr($method, 5);
331 if (!method_exists($this, $method)) {
332 return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
333 }
334 // Call the method
335 $result = $this->$method($args);
336 } else {
337 // It's a function - does it exist?
338 if (!function_exists($method)) {
339 return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
340 }
341 // Call the function
342 $result = $method($args);
343 }
344 return $result;
345 }
346
347 function error($error, $message = false) {
348 // Accepts either an error object or an error code and message
349 if ($message && !is_object($error)) {
350 $error = new IXR_Error($error, $message);
351 }
352 $this->output($error->getXml());
353 }
354 function output($xml) {
355 $xml = '<?xml version="1.0" encoding="utf-8"?>'."".$xml;
356 $length = strlen($xml);
357 header('Connection: close');
358 header('Content-Length: '.$length);
359 header('Content-Type: text/xml');
360 header('Date: '.date('r'));
361 echo $xml;
362 exit;
363 }
364 function hasMethod($method) {
365 return in_array($method, array_keys($this->callbacks));
366 }
367 function setCapabilities() {
368 // Initialises capabilities array
369 $this->capabilities = array(
370 'xmlrpc' => array(
371 'specUrl' => 'http://www.xmlrpc.com/spec',
372 'specVersion' => 1
373 ),
374 'faults_interop' => array(
375 'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
376 'specVersion' => 20010516
377 ),
378 'system.multicall' => array(
379 'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
380 'specVersion' => 1
381 ),
382 );
383 }
384 function getCapabilities($args) {
385 return $this->capabilities;
386 }
387 function setCallbacks() {
388 $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
389 $this->callbacks['system.listMethods'] = 'this:listMethods';
390 $this->callbacks['system.multicall'] = 'this:multiCall';
391 }
392 function listMethods($args) {
393 // Returns a list of methods - uses array_reverse to ensure user defined
394 // methods are listed before server defined methods
395 return array_reverse(array_keys($this->callbacks));
396 }
397 function multiCall($methodcalls) {
398 // See http://www.xmlrpc.com/discuss/msgReader$1208
399 $return = array();
400 foreach ($methodcalls as $call) {
401 $method = $call['methodName'];
402 $params = $call['params'];
403 if ($method == 'system.multicall') {
404 $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
405 } else {
406 $result = $this->call($method, $params);
407 }
408 if (is_a($result, 'IXR_Error')) {
409 $return[] = array(
410 'faultCode' => $result->code,
411 'faultString' => $result->message
412 );
413 } else {
414 $return[] = array($result);
415 }
416 }
417 return $return;
418 }
419}
420
421class IXR_Request {
422 var $method;
423 var $args;
424 var $xml;
425 function IXR_Request($method, $args) {
426 $this->method = $method;
427 $this->args = $args;
428 $this->xml = <<<EOD
429<?xml version="1.0"?>
430<methodCall>
431<methodName>{$this->method}</methodName>
432<params>
433
434EOD;
435 foreach ($this->args as $arg) {
436 $this->xml .= '<param><value>';
437 $v = new IXR_Value($arg);
438 $this->xml .= $v->getXml();
439 $this->xml .= "</value></param>";
440 }
441 $this->xml .= '</params></methodCall>';
442 }
443 function getLength() {
444 return strlen($this->xml);
445 }
446 function getXml() {
447 return $this->xml;
448 }
449}
450
451
452class IXR_Client {
453 var $server;
454 var $port;
455 var $path;
456 var $useragent;
457 var $response;
458 var $message = false;
459 var $debug = false;
460 // Storage place for an error message
461 var $error = false;
462 function IXR_Client($server, $path = false, $port = 80) {
463 if (!$path) {
464 // Assume we have been given a URL instead
465 $bits = parse_url($server);
466 $this->server = $bits['host'];
467 $this->port = isset($bits['port']) ? $bits['port'] : 80;
468 $this->path = isset($bits['path']) ? $bits['path'] : '/';
469 // Make absolutely sure we have a path
470 if (!$this->path) {
471 $this->path = '/';
472 }
473 } else {
474 $this->server = $server;
475 $this->path = $path;
476 $this->port = $port;
477 }
478 $this->useragent = 'The Incutio XML-RPC PHP Library';
479 }
480 function query() {
481 $args = func_get_args();
482 $method = array_shift($args);
483 $request = new IXR_Request($method, $args);
484 $length = $request->getLength();
485 $xml = $request->getXml();
486 $r = "\r\n";
487 $request = "POST {$this->path} HTTP/1.0$r";
488 $request .= "Host: {$this->server}$r";
489 $request .= "Content-Type: text/xml$r";
490 $request .= "User-Agent: {$this->useragent}$r";
491 $request .= "Content-length: {$length}$r$r";
492 $request .= $xml;
493 // Now send the request
494 if ($this->debug) {
495 echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
496 }
497 $fp = @fsockopen($this->server, $this->port);
498 if (!$fp) {
499 $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
500 return false;
501 }
502 fputs($fp, $request);
503 $contents = '';
504 $gotFirstLine = false;
505 $gettingHeaders = true;
506 while (!feof($fp)) {
507 $line = fgets($fp, 4096);
508 if (!$gotFirstLine) {
509 // Check line for '200'
510 if (strstr($line, '200') === false) {
511 $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
512 return false;
513 }
514 $gotFirstLine = true;
515 }
516 if (trim($line) == '') {
517 $gettingHeaders = false;
518 }
519 if (!$gettingHeaders) {
520 $contents .= trim($line)."\n";
521 }
522 }
523 if ($this->debug) {
524 echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
525 }
526 // Now parse what we've got back
527 $this->message = new IXR_Message($contents);
528 if (!$this->message->parse()) {
529 // XML error
530 $this->error = new IXR_Error(-32700, 'parse error. not well formed');
531 return false;
532 }
533 // Is the message a fault?
534 if ($this->message->messageType == 'fault') {
535 $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
536 return false;
537 }
538 // Message must be OK
539 return true;
540 }
541 function getResponse() {
542 // methodResponses can only have one param - return that
543 return $this->message->params[0];
544 }
545 function isError() {
546 return (is_object($this->error));
547 }
548 function getErrorCode() {
549 return $this->error->code;
550 }
551 function getErrorMessage() {
552 return $this->error->message;
553 }
554}
555
556
557class IXR_Error {
558 var $code;
559 var $message;
560 function IXR_Error($code, $message) {
561 $this->code = $code;
562 $this->message = $message;
563 }
564 function getXml() {
565 $xml = <<<EOD
566<methodResponse>
567 <fault>
568 <value>
569 <struct>
570 <member>
571 <name>faultCode</name>
572 <value><int>{$this->code}</int></value>
573 </member>
574 <member>
575 <name>faultString</name>
576 <value><string>{$this->message}</string></value>
577 </member>
578 </struct>
579 </value>
580 </fault>
581</methodResponse>
582
583EOD;
584 return $xml;
585 }
586}
587
588
589class IXR_Date {
590 var $year;
591 var $month;
592 var $day;
593 var $hour;
594 var $minute;
595 var $second;
596 function IXR_Date($time) {
597 // $time can be a PHP timestamp or an ISO one
598 if (is_numeric($time)) {
599 $this->parseTimestamp($time);
600 } else {
601 $this->parseIso($time);
602 }
603 }
604 function parseTimestamp($timestamp) {
605 $this->year = date('Y', $timestamp);
606 $this->month = date('Y', $timestamp);
607 $this->day = date('Y', $timestamp);
608 $this->hour = date('H', $timestamp);
609 $this->minute = date('i', $timestamp);
610 $this->second = date('s', $timestamp);
611 }
612 function parseIso($iso) {
613 $this->year = substr($iso, 0, 4);
614 $this->month = substr($iso, 4, 2);
615 $this->day = substr($iso, 6, 2);
616 $this->hour = substr($iso, 9, 2);
617 $this->minute = substr($iso, 12, 2);
618 $this->second = substr($iso, 15, 2);
619 }
620 function getIso() {
621 return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
622 }
623 function getXml() {
624 return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
625 }
626 function getTimestamp() {
627 return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
628 }
629}
630
631class LLBlock {
632 var $data;
633 var $xml;
634
635 function LLBlock($data) {
636 $this->data = $data;
637 }
638
639 function getXml() {
640 if(count($this->data)>0) {
641 $this->xml="<array><data><value><struct>";
642 foreach($this->data as $name => $value) {
643 $this->xml=$this->xml."<member><name>".$name."</name><value><string>".$value."</string></value></member>";
644 }
645 $this->xml=$this->xml."</struct></value></data></array>";
646 return $this->xml;
647 }
648 }
649}
650
651class IXR_Base64 {
652 var $data;
653 function IXR_Base64($data) {
654 $this->data = $data;
655 }
656 function getXml() {
657 return '<base64>'.base64_encode($this->data).'</base64>';
658 }
659}
660
661
662class IXR_IntrospectionServer extends IXR_Server {
663 var $signatures;
664 var $help;
665 function IXR_IntrospectionServer() {
666 $this->setCallbacks();
667 $this->setCapabilities();
668 $this->capabilities['introspection'] = array(
669 'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
670 'specVersion' => 1
671 );
672 $this->addCallback(
673 'system.methodSignature',
674 'this:methodSignature',
675 array('array', 'string'),
676 'Returns an array describing the return type and required parameters of a method'
677 );
678 $this->addCallback(
679 'system.getCapabilities',
680 'this:getCapabilities',
681 array('struct'),
682 'Returns a struct describing the XML-RPC specifications supported by this server'
683 );
684 $this->addCallback(
685 'system.listMethods',
686 'this:listMethods',
687 array('array'),
688 'Returns an array of available methods on this server'
689 );
690 $this->addCallback(
691 'system.methodHelp',
692 'this:methodHelp',
693 array('string', 'string'),
694 'Returns a documentation string for the specified method'
695 );
696 }
697 function addCallback($method, $callback, $args, $help) {
698 $this->callbacks[$method] = $callback;
699 $this->signatures[$method] = $args;
700 $this->help[$method] = $help;
701 }
702 function call($methodname, $args) {
703 // Make sure it's in an array
704 if ($args && !is_array($args)) {
705 $args = array($args);
706 }
707 // Over-rides default call method, adds signature check
708 if (!$this->hasMethod($methodname)) {
709 return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
710 }
711 $method = $this->callbacks[$methodname];
712 $signature = $this->signatures[$methodname];
713 $returnType = array_shift($signature);
714 // Check the number of arguments
715 if (count($args) != count($signature)) {
716 // print 'Num of args: '.count($args).' Num in signature: '.count($signature);
717 return new IXR_Error(-32602, 'server error. wrong number of method parameters');
718 }
719 // Check the argument types
720 $ok = true;
721 $argsbackup = $args;
722 for ($i = 0, $j = count($args); $i < $j; $i++) {
723 $arg = array_shift($args);
724 $type = array_shift($signature);
725 switch ($type) {
726 case 'int':
727 case 'i4':
728 if (is_array($arg) || !is_int($arg)) {
729 $ok = false;
730 }
731 break;
732 case 'base64':
733 case 'string':
734 if (!is_string($arg)) {
735 $ok = false;
736 }
737 break;
738 case 'boolean':
739 if ($arg !== false && $arg !== true) {
740 $ok = false;
741 }
742 break;
743 case 'float':
744 case 'double':
745 if (!is_float($arg)) {
746 $ok = false;
747 }
748 break;
749 case 'date':
750 case 'dateTime.iso8601':
751 if (!is_a($arg, 'IXR_Date')) {
752 $ok = false;
753 }
754 break;
755 }
756 if (!$ok) {
757 return new IXR_Error(-32602, 'server error. invalid method parameters');
758 }
759 }
760 // It passed the test - run the "real" method call
761 return parent::call($methodname, $argsbackup);
762 }
763 function methodSignature($method) {
764 if (!$this->hasMethod($method)) {
765 return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
766 }
767 // We should be returning an array of types
768 $types = $this->signatures[$method];
769 $return = array();
770 foreach ($types as $type) {
771 switch ($type) {
772 case 'string':
773 $return[] = 'string';
774 break;
775 case 'int':
776 case 'i4':
777 $return[] = 42;
778 break;
779 case 'double':
780 $return[] = 3.1415;
781 break;
782 case 'dateTime.iso8601':
783 $return[] = new IXR_Date(time());
784 break;
785 case 'boolean':
786 $return[] = true;
787 break;
788 case 'base64':
789 $return[] = new IXR_Base64('base64');
790 break;
791 case 'array':
792 $return[] = array('array');
793 break;
794 case 'struct':
795 $return[] = array('struct' => 'struct');
796 break;
797 }
798 }
799 return $return;
800 }
801 function methodHelp($method) {
802 return $this->help[$method];
803 }
804}
805
806
807class IXR_ClientMulticall extends IXR_Client {
808 var $calls = array();
809 function IXR_ClientMulticall($server, $path = false, $port = 80) {
810 parent::IXR_Client($server, $path, $port);
811 $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
812 }
813 function addCall() {
814 $args = func_get_args();
815 $methodName = array_shift($args);
816 $struct = array(
817 'methodName' => $methodName,
818 'params' => $args
819 );
820 $this->calls[] = $struct;
821 }
822 function query() {
823 // Prepare multicall, then call the parent::query() method
824 return parent::query('system.multicall', $this->calls);
825 }
826}
827
828?>
diff --git a/ogs/gridserver/gridserver_config.inc.php b/ogs/gridserver/gridserver_config.inc.php
new file mode 100644
index 0000000..98ebed3
--- /dev/null
+++ b/ogs/gridserver/gridserver_config.inc.php
@@ -0,0 +1,14 @@
1<?
2// All the grid server specific stuff lives here
3
4// What we send to authenticate to the user/login server
5$userserver_sendkey="1234";
6
7// What we expect to get back from the user/login server
8$userserver_recvkey="1234";
9
10$sim_recvkey = "1234";
11$sim_sendkey = "1234";
12
13$grid_home = "/ogs/gridserver/";
14?>
diff --git a/ogs/gridserver/index.php b/ogs/gridserver/index.php
new file mode 100644
index 0000000..f7754c6
--- /dev/null
+++ b/ogs/gridserver/index.php
@@ -0,0 +1,176 @@
1<?
2error_reporting(E_ALL); // yes, we remember this from the login server, don't we boys and girls? don't kill innocent XML-RPC!
3
4// these files are soooo common..... (to the grid)
5include("../common/xmlrpc.inc.php");
6include("../common/database.inc.php");
7include("../common/grid_config.inc.php");
8include("../common/util.inc.php");
9
10include("gridserver_config.inc.php"); // grid server specific config stuff
11
12function get_sim_info($args) {
13 global $dbhost,$dbuser,$dbpasswd,$dbname;
14 global $userserver_sendkey, $userserver_recvkey;
15
16 // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
17 if($args['authkey']!=$userserver_recvkey) {
18 return Array(
19 'authkey' => 'I can play the bad key trick too you know',
20 'login' => 'false'
21 );
22 }
23
24 // if we get to here, the key is valid, give that login server what it wants!
25
26 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
27 OR die("Unable to connect to database");
28
29 mysql_select_db($dbname)
30 or die("Unable to select database");
31
32 $region_handle = $args['region_handle'];
33 $query = "SELECT * FROM region_profiles WHERE region_handle='$region_handle'";
34 $result = mysql_query($query);
35
36 return mysql_fetch_assoc($result);
37}
38
39function get_session_info($args) {
40 global $dbhost,$dbuser,$dbpasswd,$dbname;
41 global $sim_sendkey, $sim_recvkey;
42
43 // authkey, session-id, agent-id
44
45 // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
46 if($args[0]!=$sim_recvkey) {
47 return Array(
48 'authkey' => "I can play the bad key trick too you know"
49 );
50 }
51
52 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
53 OR die("Unable to connect to database");
54
55 mysql_select_db($dbname)
56 or die("Unable to select database");
57
58 $session_id = $args[1];
59 $agent_id = $args[2];
60
61 $query = "SELECT * FROM sessions WHERE session_id = '$session_id' AND agent_id='$agent_id' AND session_active=1";
62 $result = mysql_query($query);
63 if(mysql_num_rows($result)>0) {
64 $info=mysql_fetch_assoc($result);
65 $circuit_code = $info['circuit_code'];
66 $secure_session_id=$info['secure_session_id'];
67
68 $query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
69 $result=mysql_query($query);
70 $userinfo=mysql_fetch_assoc($result);
71 $firstname=$userinfo['profile_firstname'];
72 $lastname=$userinfo['profile_lastname'];
73 $agent_id=$userinfo['userprofile_LLUUID'];
74 return Array(
75 'authkey' => $sim_sendkey,
76 'circuit_code' => $circuit_code,
77 'agent_id' => $agent_id,
78 'session_id' => $session_id,
79 'secure_session_id' => $secure_session_id,
80 'firstname' => $firstname,
81 'lastname' => $lastname
82 );
83 }
84}
85
86function check_loggedin($args) {
87 global $dbhost,$dbuser,$dbpasswd,$dbname;
88 global $userserver_sendkey, $userserver_recvkey;
89
90 // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
91 if($args['authkey']!=$userserver_recvkey) {
92 return Array(
93 'authkey' => "I can play the bad key trick too you know"
94 );
95 }
96
97 // if we get to here, the key is valid, give that login server what it wants!
98
99 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
100 OR die("Unable to connect to database");
101
102 mysql_select_db($dbname)
103 or die("Unable to select database");
104
105 $userprofile_LLUUID = $args['userprofile_LLUUID'];
106 $query = "SELECT * FROM sessions WHERE agent_id='$userprofile_LLUUID' AND session_active=1";
107 $result = mysql_query($query);
108
109 if(mysql_num_rows($result)>1) {
110 return Array(
111 'authkey' => $userserver_sendkey,
112 'logged_in' => 1
113 );
114 } else {
115 return Array(
116 'authkey' => $userserver_sendkey,
117 'logged_in' => 0
118 );
119 }
120}
121
122function create_session($args) {
123 global $dbhost,$dbuser,$dbpasswd,$dbname;
124 global $userserver_sendkey, $userserver_recvkey;
125
126 // First see who's talking to us, if key is invalid then send an invalid one back and nothing more
127 if($args['authkey']!=$userserver_recvkey) {
128 return Array(
129 'authkey' => "I can play the bad key trick too you know"
130 );
131 }
132
133 // if we get to here, the key is valid, give that login server what it wants!
134
135 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
136 OR die("Unable to connect to database");
137
138 mysql_select_db($dbname)
139 or die("Unable to select database");
140
141 // yes, secure_sessionid should be different, i know...
142 $query = "SELECT value FROM Grid_settings WHERE setting='highest_LLUUID'";
143 $result = mysql_query($query);
144 $row = mysql_fetch_array($result);
145 $highest_LLUUID = $row['value'];
146 $newsession_id=inc_lluuid($highest_LLUUID);
147 $secure_session_id=inc_lluuid($newsession_id);
148
149 $query="UPDATE Grid_settings SET value='$secure_session_id' WHERE setting='highest_LLUUID' LIMIT 1";
150 $result=mysql_query($query);
151
152 $userprofile_LLUUID=$args['userprofile_LLUUID'];
153 $current_location=$args['current_location'];
154 $remote_ip=$args['remote_ip'];
155 $query="INSERT INTO sessions(session_id,secure_session_id,agent_id,session_start,session_active,current_location,remote_ip) VALUES('$newsession_id','$secure_session_id','$userprofile_LLUUID',NOW(),1,'$current_location','$remote_ip')";
156 $result=mysql_query($query);
157 if(!isset($result)) {
158 die();
159 }
160 return Array(
161 'authkey' => $userserver_sendkey,
162 'session_id' => $newsession_id,
163 'secure_session_id' => $secure_session_id
164 );
165}
166
167$server=new IXR_Server(
168 Array(
169 'check_session_loggedin' => 'check_loggedin',
170 'create_session' => 'create_session',
171 'get_sim_info' => 'get_sim_info',
172 'get_session_info' => 'get_session_info'
173 )
174);
175
176?> \ No newline at end of file
diff --git a/ogs/gridserver/usersessions/.htaccess b/ogs/gridserver/usersessions/.htaccess
new file mode 100644
index 0000000..3b76a74
--- /dev/null
+++ b/ogs/gridserver/usersessions/.htaccess
@@ -0,0 +1,5 @@
1Options +FollowSymlinks
2
3RewriteEngine on
4RewriteOptions MaxRedirects=1
5RewriteRule .* index.php [L]
diff --git a/ogs/gridserver/usersessions/index.php b/ogs/gridserver/usersessions/index.php
new file mode 100644
index 0000000..3c18932
--- /dev/null
+++ b/ogs/gridserver/usersessions/index.php
@@ -0,0 +1,81 @@
1<?
2// DIRTY HACK ALERT!!!!!!!!!!!!!
3// The following code shows the vital importance of the r69 revision of the original gareth/ branch
4
5
6// This file parses URLs of the format:
7// usersessions/key/userid/data
8// where key is the key to authenticate with the grid, userid is the user's LLUUID and data is the data about the user's session being requested
9// if the data requested is left out, an XML response will be sent
10
11error_reporting(E_ALL); // Remember kids, PHP errors kill XML-RPC responses and REST too! will the slaughter ever end?
12
13include("../gridserver_config.inc.php");
14include("../../common/database.inc.php");
15include("../../common/util.inc.php");
16
17// Parse out the parameters from the URL
18$params = str_replace($grid_home,'', $_SERVER['REQUEST_URI']);
19$params = str_replace("index.php/","",$params);
20$params = split('/',$params);
21
22// Die if the key doesn't match
23if($params[1]!=$sim_recvkey) {
24 die();
25}
26
27$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
28 OR die("Unable to connect to database");
29
30mysql_select_db($dbname)
31 or die("Unable to select database");
32
33$agent_id = strtolower($params[2]);
34$query = "SELECT * FROM sessions WHERE agent_id='$agent_id' AND session_active=1";
35
36// if we have 4 params, then param 4 is the command
37if(count($params)==4) {
38 $cmd=$params['3'];
39} else if(count($params)==5) {
40 $circuit_code=$params[3];
41 $cmd=$params[4]; // otherwise, 5 is the command and 4 is the circuit code
42}
43
44$result = mysql_query($query);
45if(mysql_num_rows($result)>0) {
46 $info=mysql_fetch_assoc($result);
47 $circuit_code = $info['circuit_code'];
48 if($circuit_code == 0) $circuit_code=$params['4'];
49 $secure_session_id=$info['secure_session_id'];
50 $session_id=$info['session_id'];
51
52 $query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
53 $result=mysql_query($query);
54 $userinfo=mysql_fetch_assoc($result);
55 $firstname=$userinfo['profile_firstname'];
56 $lastname=$userinfo['profile_lastname'];
57 $agent_id=$userinfo['userprofile_LLUUID'];
58 $exists=1;
59} else {
60 $exists=0;
61}
62
63// if only 3 params, assume we are sending an XML response
64if(count($params)==3) {
65 output_xml_block("usersession",Array(
66 'authkey' => $sim_sendkey,
67 'circuit_code' => $circuit_code,
68 'agent_id' => $agent_id,
69 'session_id' => $session_id,
70 'secure_session_id' => $secure_session_id,
71 'firstname' => $firstname,
72 'lastname' => $lastname
73 ));
74}
75
76switch($cmd) {
77 case 'exists':
78 echo $exists;
79 break;
80}
81?>
diff --git a/ogs/login/index.php b/ogs/login/index.php
new file mode 100644
index 0000000..4f53c11
--- /dev/null
+++ b/ogs/login/index.php
@@ -0,0 +1,170 @@
1<?
2error_reporting(0); // Remember kids, PHP errors kill XML-RPC responses!
3
4// include all the common stuff
5include("../common/xmlrpc.inc.php");
6include("../common/database.inc.php");
7include("../common/grid_config.inc.php");
8include("../common/util.inc.php");
9
10include("login_config.inc.php"); // include login/user specific config stuff (authentication keys etc)
11
12function login($args) {
13 global $dbhost,$dbuser,$dbpasswd,$dbname;
14 global $grid_owner, $gridserver_sendkey, $gridserver_recvkey, $gridserver_url;
15
16
17 if(get_magic_quotes_gpc()) {
18 $firstname=addslashes($args['first']);
19 $lastname=addslashes($args['last']);
20 $passwd=addslashes($args['passwd']);
21 } else {
22 $firstname=$args['first'];
23 $lastname=$args['last'];
24 $passwd=$args['passwd'];
25 }
26
27 $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
28 OR die("Unable to connect to database");
29
30 mysql_select_db($dbname)
31 or die("Unable to select database");
32
33 $query = "SELECT userprofile_LLUUID, profile_firstname, profile_lastname, profile_passwdmd5, homesim_ip, homesim_port, homeasset_url, look_at, region_handle, position FROM local_user_profiles WHERE profile_firstname='".$firstname."' AND profile_lastname='".$lastname."' AND profile_passwdmd5='" .$passwd."'";
34
35 $profile_lookup_result=mysql_query($query);
36
37 if(mysql_num_rows($profile_lookup_result) >0) {
38 $profiledata = mysql_fetch_assoc($profile_lookup_result);
39
40 // if we get here, the username/password is valid, but still need to check there's not an already existing session
41 $client = new IXR_Client($gridserver_url);
42 if (!$client->query('check_session_loggedin', Array('userprofile_LLUUID' => $profiledata['userprofile_LLUUID'], 'authkey' => $gridserver_sendkey, 'server_type' => 'login'))) { // if this doesn't work, grid server is down - that's bad
43 return Array (
44 'reason' => 'key',
45 'message' => "Could not connect to grid server. Please try again later or contact the grid owner ". $grid_owner,
46 'login' => "false"
47 );
48 }
49
50 $response=$client->getResponse();
51 if($response['authkey'] != $gridserver_recvkey) { // if this doesn't match up, it's a fake grid server
52 return Array (
53 'reason' => 'key',
54 'message' => "Could not connect to grid server due to possible security issues. It is possible that the grid has been compromised. Please contact the grid owner " . $grid_owner . " and report this issue",
55 'login' => "false"
56 );
57 }
58
59
60 if($response['logged_in'] == 1) { // if the user is already logged in, tell them
61 return Array (
62 'reason' => 'presence',
63 'message' => "You appear to already be logged into this grid, if your client has recently crashed then please try again later",
64 'login' => "false"
65 );
66 }
67
68 // now we start a new session on the grid
69 $remote_ip=$_SERVER['REMOTE_ADDR'];
70 $region_handle=$profiledata['region_handle'];
71 $client->query('create_session',Array('userprofile_LLUUID' => $profiledata['userprofile_LLUUID'], 'authkey' => $gridserver_sendkey, 'remote_ip' => $remote_ip, 'current_location' => $region_handle));
72 $response = $client->getResponse();
73 $session_id = $response['session_id'];
74 $secure_session_id = $response['secure_session_id'];
75
76 // ask the grid server what the IP address and port of the sim we want to connect to is
77 $client->query('get_sim_info', Array('region_handle' => $region_handle, 'authkey' => $gridserver_sendkey) );
78 $siminfo = $client->getResponse();
79
80 // send the final response!
81 $position=$profiledata['position'];
82 $look_at=$profiledata['look_at'];
83
84 $LocX=intval($siminfo['GridLocX'])*256;
85 $LocY=intval($siminfo['GridLocY'])*256;
86 $home="{'region_handle':'$region_handle', 'position':'$position', 'look_at':'$look_at'}";
87
88 $globaltextures = new LLBlock(
89 Array(
90 'sun_texture_id' => "cce0f112-878f-4586-a2e2-a8f104bba271",
91 'cloud_texture_id' => "fc4b9f0b-d008-45c6-96a4-01dd947ac621",
92 'moon_texture_id' => "d07f6eed-b96a-47cd-b51d-400ad4a1c428"
93 ));
94
95 $login_flags = new LLBlock(
96 Array(
97 'stipend_since_login' => "N",
98 'ever_logged_in' => "Y",
99 'gendered' => "Y",
100 'daylight_savings' => "N"
101 ));
102 $ui_config = new LLBlock(
103 Array(
104 'allow_first_life' => "Y"
105 ));
106 $inventory_skeleton = new LLBlock(Array(
107 Array(
108 'name' => 'My inventory',
109 'parent_id' => '00000000-0000-0000-0000-000000000000',
110 'version' => 4,
111 'type_default' => 8,
112 'folder_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8'
113 ),
114 Array(
115 'name' => 'Textures',
116 'parent_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8',
117 'version' => 1,
118 'type_default' => 0,
119 'folder_id' => 'fc8b4059-30bb-43a8-a042-46f5b431ad82'
120 )));
121 $inventory_root = new LLBlock(
122 Array(
123 'folder_id' => "f798e114-c10f-409b-a90d-a11577ff1de8"
124 ));
125 $initial_outfit = new LLBlock(
126 Array(
127 'folder_name' => "Nightclub Female",
128 'gender' => "female"
129 ));
130 return Array (
131 'message' => "Welcome to OGS!",
132 'session_id' => format_lluuid($session_id),
133 'sim_port' => intval($siminfo['port']),
134 'agent_access' => "M",
135 'start_location' => "last",
136 'global-textures' => $globaltextures,
137 'seconds_since_epoch' => time(),
138 'first_name' => $profiledata['profile_firstname'],
139 'circuit_code' => 50633318,
140 'login_flags' => $login_flags,
141 'seed_capability' => '',
142 'home' => $home,
143 'secure_session_id' => format_lluuid($secure_session_id),
144 'last_name' => $profiledata['profile_lastname'],
145 'ui-config' => $ui_config,
146 'region_x' => $LocX,
147 'inventory_skeleton' => $inventory_skeleton,
148 'sim_ip' => $siminfo['ip_addr'],
149 'region_y' => $LocY,
150 'inventory-root' => $inventory_root,
151 'login' => "true",
152 'look_at' => $look_at,
153 'agent_id' => format_lluuid($profiledata['userprofile_LLUUID']),
154 'initial-outfit' => $initial_outfit
155 );
156
157
158 } else {
159 // this is the default invalid username/password error
160 return Array (
161 'reason' => 'key',
162 'message' => "You have entered an invalid name/password combination or are using an incompatible client. Please check with the grid owner " .$grid_owner . " if you are sure your login details are accurate.",
163 'login' => "false",
164 );
165 }
166
167}
168
169$server=new IXR_Server(array('login_to_simulator' => 'login'));
170?>
diff --git a/ogs/login/login_config.inc.php b/ogs/login/login_config.inc.php
new file mode 100644
index 0000000..4cce696
--- /dev/null
+++ b/ogs/login/login_config.inc.php
@@ -0,0 +1,11 @@
1<?
2// All the user/login server specific stuff lives here
3
4// What we send to authenticate to the grid server
5$gridserver_sendkey="1234";
6
7// What we expect to get back from the grid server
8$gridserver_recvkey="1234";
9
10$gridserver_url="http://www.osgrid.org/ogs/gridserver/index.php";
11?>