Brought in other OGS server components and the all-important caffeine script

brokenplugins
gareth 2007-02-27 23:31:14 +00:00
parent 09dd4bd683
commit ed4dc30dc2
19 changed files with 1687 additions and 0 deletions

134
OGS.sql Normal file
View File

@ -0,0 +1,134 @@
-- phpMyAdmin SQL Dump
-- version 2.6.3-pl1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Feb 16, 2007 at 09:54 PM
-- Server version: 4.0.23
-- PHP Version: 4.4.0
--
-- Database: `OGS`
--
-- --------------------------------------------------------
--
-- Table structure for table `Grid_settings`
--
DROP TABLE IF EXISTS `Grid_settings`;
CREATE TABLE IF NOT EXISTS `Grid_settings` (
`Setting` text NOT NULL,
`value` text NOT NULL
) TYPE=MyISAM;
--
-- Dumping data for table `Grid_settings`
--
INSERT INTO `Grid_settings` (`Setting`, `value`) VALUES ('highest_LLUUID', '51AEFF430000000000000000000002fd');
-- --------------------------------------------------------
--
-- Table structure for table `foreign_profiles`
--
DROP TABLE IF EXISTS `foreign_profiles`;
CREATE TABLE IF NOT EXISTS `foreign_profiles` (
`userprofile_LLUUID` varchar(32) NOT NULL default '',
`foreigngrid` text NOT NULL,
`profile_firstname` text NOT NULL,
`profile_lastname` text NOT NULL,
`profile_passwdmd5` text NOT NULL,
`homesim_ip` text NOT NULL,
`homesim_port` int(11) NOT NULL default '0',
`homeasset_url` text NOT NULL,
`homeuser_url` text NOT NULL,
`look_at` text NOT NULL,
`region_handle` text NOT NULL,
`position` text NOT NULL,
PRIMARY KEY (`userprofile_LLUUID`)
) TYPE=MyISAM;
--
-- Dumping data for table `foreign_profiles`
--
-- --------------------------------------------------------
--
-- Table structure for table `local_user_profiles`
--
DROP TABLE IF EXISTS `local_user_profiles`;
CREATE TABLE IF NOT EXISTS `local_user_profiles` (
`userprofile_LLUUID` varchar(32) NOT NULL default '',
`profile_firstname` text NOT NULL,
`profile_lastname` text NOT NULL,
`profile_passwdmd5` text NOT NULL,
`homesim_ip` text NOT NULL,
`homesim_port` int(11) NOT NULL default '0',
`homeasset_url` text NOT NULL,
`look_at` text NOT NULL,
`region_handle` text NOT NULL,
`position` text NOT NULL,
PRIMARY KEY (`userprofile_LLUUID`)
) TYPE=MyISAM;
--
-- Dumping data for table `local_user_profiles`
--
INSERT INTO `local_user_profiles` (`userprofile_LLUUID`, `profile_firstname`, `profile_lastname`, `profile_passwdmd5`, `homesim_ip`, `homesim_port`, `homeasset_url`, `look_at`, `region_handle`, `position`) VALUES ('51AEFF43000000000000000000000100', 'Test', 'User', '$1$098f6bcd4621d373cade4e832627b4f6', '127.0.0.1', 1000, 'http://dummyassetserver.net/', 'r-0.57343, r-0.819255,r0', 'r255232,254976', 'r41.6589, r100.8374, r22.5072');
-- --------------------------------------------------------
--
-- Table structure for table `region_profiles`
--
DROP TABLE IF EXISTS `region_profiles`;
CREATE TABLE IF NOT EXISTS `region_profiles` (
`RegionID` varchar(32) NOT NULL default '',
`Name` text NOT NULL,
`GridLocX` bigint(20) NOT NULL default '0',
`GridLocY` bigint(20) NOT NULL default '0',
`region_handle` text NOT NULL,
`ip_addr` text NOT NULL,
`port` text NOT NULL,
PRIMARY KEY (`RegionID`)
) TYPE=MyISAM;
--
-- Dumping data for table `region_profiles`
--
INSERT INTO `region_profiles` (`RegionID`, `Name`, `GridLocX`, `GridLocY`, `region_handle`, `ip_addr`, `port`) VALUES ('51AEFF43000000000000000000000200', 'Test sandbox', 997, 996, 'r255232,254976', '127.0.0.1', '1000');
-- --------------------------------------------------------
--
-- Table structure for table `sessions`
--
DROP TABLE IF EXISTS `sessions`;
CREATE TABLE IF NOT EXISTS `sessions` (
`session_id` varchar(32) NOT NULL default '',
`secure_session_id` text NOT NULL,
`agent_id` text NOT NULL,
`session_start` datetime NOT NULL default '0000-00-00 00:00:00',
`session_end` datetime NOT NULL default '0000-00-00 00:00:00',
`session_active` tinyint(4) NOT NULL default '0',
`current_location` text NOT NULL,
`remote_ip` text NOT NULL,
`circuit_code` int(11) NOT NULL default '0',
PRIMARY KEY (`session_id`)
) TYPE=MyISAM;
--
-- Dumping data for table `sessions`
--
INSERT INTO `sessions` (`session_id`, `secure_session_id`, `agent_id`, `session_start`, `session_end`, `session_active`, `current_location`, `remote_ip`, `circuit_code`) VALUES ('51AEFF430000000000000000000002fc', '51AEFF430000000000000000000002fd', '51AEFF43000000000000000000000100', '2007-02-16 21:13:19', '0000-00-00 00:00:00', 1, 'r255232,254976', '81.174.255.70', 0);

13
caffeine.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# WILL NOT BUILD WITHOUT THIS FILE, VERY IMPORTANT!
kill -9 `/var/run/brain/pituaritygland/melatonin`
/usr/sbin/service norephrine start
rm -rf /brain/receptors/adenosine/*
# Caused a conflict with taste.buds, removed for now
# drink /var/drinks/coffee
# We use this instead, enables implementation of the WINGS (Will Interefere with Need for General Sleep) protocol
drink /var/drinks/redbull

View File

@ -0,0 +1,105 @@
LLWearable version 22
Female Shape and Outfit 3 Shape
Created by system from avatar's appearance.
permissions 0
{
base_mask 00082000
owner_mask 00082000
group_mask 00082000
everyone_mask 00082000
next_owner_mask 00082000
creator_id 3d924400-038e-6ad9-920b-cfbb9b40585c
owner_id 542ffb8e-8932-49b9-8664-58f53e442797
last_owner_id 3d924400-038e-6ad9-920b-cfbb9b40585c
group_id 00000000-0000-0000-0000-000000000000
}
sale_info 0
{
sale_type not
sale_price 0
}
type 0
parameters 82
1 .21
2 -.5
4 -.11
5 -.1
6 -.3
7 -.4
8 -.5
10 .7
11 .34
12 -.5
13 0
14 .04
15 .58
17 .56
18 -.26
19 -.73
20 -.34
21 -.01
22 1
23 -.5
24 -.63
25 .44
27 .05
33 -.24
34 -.7
35 -.16
36 -.2
37 -.98
38 -.5
80 0
105 .07
155 -.22
157 0
185 -1
193 .86
196 -.74
505 .65
506 .12
507 -1.5
515 0
517 .16
518 .8
629 0
637 0
646 .4
647 1
649 .36
650 .85
652 .49
653 -1
656 0
659 .65
662 .5
663 0
664 0
665 0
675 -.15
676 .26
678 .28
682 .27
683 -.19
684 -.09
685 0
690 .45
692 .4
693 -0
753 -.5
756 -.08
758 .24
759 .6
760 .11
764 -.38
765 -.3
769 .42
773 .51
795 .16
796 .11
799 .36
841 0
842 -.82
879 0
880 0
textures 0

View File

@ -0,0 +1,52 @@
LLWearable version 22
Sexy - Female Skin
permissions 0
{
base_mask 00086000
owner_mask 00086000
group_mask 00000000
everyone_mask 00000000
next_owner_mask 00086000
creator_id 3b659a92-dbf0-4301-8fdc-208d78f00d77
owner_id 3d924400-038e-6ad9-920b-cfbb9b40585c
last_owner_id 101358d5-469d-4b24-9b85-4dc3c05e635d
group_id 00000000-0000-0000-0000-000000000000
}
sale_info 0
{
sale_type not
sale_price 10
}
type 1
parameters 26
108 0
110 0
111 0
116 0
117 1
150 0
162 0
163 0
165 0
700 .01
701 .5
702 .26
703 0
704 0
705 .5
706 .6
707 0
708 0
709 0
710 0
711 .5
712 0
713 .7
714 0
715 0
775 0
textures 3
0 f9261672-5058-9ef8-c0c4-48f43a0b16d4
5 b6ba53be-b5bf-9a1f-2e19-21daf998429c
6 703f6e24-a1fb-1980-acaf-6ab8a99a5bd5

View File

@ -0,0 +1,16 @@
<?
// All the asset server specific stuff lives here
// The asset server's relative URL to the root of the webserver
// If you place this at http://servername/assets then this would be set to /assets/index.php
// 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)
$asset_home = "/ogs/assetserver/index.php/";
// The key we expect from sims
$sim_recvkey = "rtrgrgrgrgr894898f998re98rf989fds";
// The path where the asset repository is stored, this should be readable by the webserver but NOT in the document root
// The default below is BAD for production use and intended to be simply generic - change it or risk copyright theft
// greater than you could ever imagine, alternatively use .htaccess or other mechanisms.
$asset_repos = "/var/www/htdocs/ogs/assetserver/assets";
?>

24
ogs/assetserver/index.php Normal file
View File

@ -0,0 +1,24 @@
<?
error_reporting(0); // Remember kids, PHP errors kill XML-RPC responses and REST too! will the slaughter ever end?
include("assetserver_config.inc.php");
// Parse out the parameters from the URL
$params = str_replace($asset_home,'', $_SERVER['REQUEST_URI']);
$params = split('/',$params);
// Die if the key doesn't match
if($params[1]!=$sim_recvkey) {
die();
}
// Send requested data
switch($params[0]) {
case 'getasset':
if($params[3]=="data") {
Header("Content-Length: ". (string)filesize($asset_repos . "/" . $params[2] . "/data"));
readfile($asset_repos . "/" . $params[2] . "/data");
}
break;
}
?>

View File

@ -0,0 +1,9 @@
<?
// this file tells all the OGS services where to find the MySQL database
// if multiple OGS services are running on one machine, it is assumed that they all use the same MySQL server/database
$dbhost="YOURSERVERHERE";
$dbuser="opengridservice";
$dbname="OGS";
$dbpasswd="supersecret";
?>

View File

@ -0,0 +1,7 @@
<?
// this file is common across servers and must be kept in sync
$gridserver_url="http://www.garethnelson.com/ogs/gridserver/";
$grid_owner="Gareth Nelson";
?>

42
ogs/common/util.inc.php Normal file
View File

@ -0,0 +1,42 @@
<?
// Some generic utilities which may be used by any services
function inc_lluuid($lluuid)
{
$partB = substr($lluuid, 15);
$partB = (float)base_convert($partB,16,10)+1;
$partB = sprintf('%016x', $partB);
$partA = substr($lluuid, 0, 16);
if(substr($lluuid,15,16)=='FFFFFFFFFFFFFFFE') {
$partA = (float)base_convert($partA,16,10)+1;
$partA = sprintf('%016x', $partA);
}
$returnval = sprintf('%s%s',$partA, $partB);
return $returnval;
}
function format_lluuid($uuid)
{
return strtolower(substr($uuid,0,8)."-".substr($uuid,8,4)."-".substr($uuid,12,4)."-".substr($uuid,16,4)."-".substr($uuid,20));
}
function output_xml_block($blockname, $data) {
echo("<$blockname>\n");
foreach($data as $name => $value) {
echo(" <$name>$value</$name>\n");
}
echo("</$blockname>\n");
}
function rand_uuid()
{
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
mt_rand( 0, 0x0fff ) | 0x4000,
mt_rand( 0, 0x3fff ) | 0x8000,
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
}
?>

828
ogs/common/xmlrpc.inc.php Normal file
View File

@ -0,0 +1,828 @@
<?php
/*
IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002
Version 1.61 - Simon Willison, 11th July 2003 (htmlentities -> htmlspecialchars)
Site: http://scripts.incutio.com/xmlrpc/
Manual: http://scripts.incutio.com/xmlrpc/manual.php
Made available under the Artistic License: http://www.opensource.org/licenses/artistic-license.php
*/
class IXR_Value {
var $data;
var $type;
function IXR_Value ($data, $type = false) {
$this->data = $data;
if (!$type) {
$type = $this->calculateType();
}
$this->type = $type;
if ($type == 'struct') {
/* Turn all the values in the array in to new IXR_Value objects */
foreach ($this->data as $key => $value) {
$this->data[$key] = new IXR_Value($value);
}
}
if ($type == 'array') {
for ($i = 0, $j = count($this->data); $i < $j; $i++) {
$this->data[$i] = new IXR_Value($this->data[$i]);
}
}
}
function calculateType() {
if ($this->data === true || $this->data === false) {
return 'boolean';
}
if (is_integer($this->data)) {
return 'i4';
}
if (is_double($this->data)) {
return 'double';
}
// Deal with IXR object types base64 and date
if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
return 'date';
}
if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
return 'base64';
}
if (is_object($this->data)) {
return 'object';
}
if (!is_array($this->data)) {
return 'string';
}
/* We have an array - is it an array or a struct ? */
if ($this->isStruct($this->data)) {
return 'struct';
} else {
return 'array';
}
}
function getXml() {
/* Return XML for this value */
switch ($this->type) {
case 'boolean':
return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
break;
case 'i4':
return '<i4>'.$this->data.'</i4>';
break;
case 'double':
return '<double>'.$this->data.'</double>';
break;
case 'string':
return '<string>'.htmlspecialchars($this->data).'</string>';
break;
case 'array':
$return = '<array><data>'."";
foreach ($this->data as $item) {
$return .= ' <value>'.$item->getXml()."</value>";
}
$return .= '</data></array>';
return $return;
break;
case 'struct':
$return = '<struct>'."";
foreach ($this->data as $name => $value) {
$return .= "<member><name>$name</name><value>";
$return .= $value->getXml()."</value></member>";
}
$return .= '</struct>';
return $return;
break;
case 'date':
case 'base64':
return $this->data->getXml();
break;
case 'object':
return $this->data->getXml();
break;
}
return false;
}
function isStruct($array) {
/* Nasty function to check if an array is a struct or not */
$expected = 0;
foreach ($array as $key => $value) {
if ((string)$key != (string)$expected) {
return true;
}
$expected++;
}
return false;
}
}
class IXR_Message {
var $message;
var $messageType; // methodCall / methodResponse / fault
var $faultCode;
var $faultString;
var $methodName;
var $params;
// Current variable stacks
var $_arraystructs = array(); // The stack used to keep track of the current array/struct
var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
var $_currentStructName = array(); // A stack as well
var $_param;
var $_value;
var $_currentTag;
var $_currentTagContents;
// The XML parser
var $_parser;
function IXR_Message ($message) {
$this->message = $message;
}
function parse() {
// first remove the XML declaration
$this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
if (trim($this->message) == '') {
return false;
}
$this->_parser = xml_parser_create();
// Set XML parser to take the case of tags in to account
xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
// Set XML parser callback functions
xml_set_object($this->_parser, $this);
xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
xml_set_character_data_handler($this->_parser, 'cdata');
if (!xml_parse($this->_parser, $this->message)) {
/* die(sprintf('XML error: %s at line %d',
xml_error_string(xml_get_error_code($this->_parser)),
xml_get_current_line_number($this->_parser))); */
return false;
}
xml_parser_free($this->_parser);
// Grab the error messages, if any
if ($this->messageType == 'fault') {
$this->faultCode = $this->params[0]['faultCode'];
$this->faultString = $this->params[0]['faultString'];
}
return true;
}
function tag_open($parser, $tag, $attr) {
$this->currentTag = $tag;
switch($tag) {
case 'methodCall':
case 'methodResponse':
case 'fault':
$this->messageType = $tag;
break;
/* Deal with stacks of arrays and structs */
case 'data': // data is to all intents and puposes more interesting than array
$this->_arraystructstypes[] = 'array';
$this->_arraystructs[] = array();
break;
case 'struct':
$this->_arraystructstypes[] = 'struct';
$this->_arraystructs[] = array();
break;
}
}
function cdata($parser, $cdata) {
$this->_currentTagContents .= $cdata;
}
function tag_close($parser, $tag) {
$valueFlag = false;
switch($tag) {
case 'int':
case 'i4':
$value = (int)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'double':
$value = (double)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'string':
$value = (string)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'dateTime.iso8601':
$value = new IXR_Date(trim($this->_currentTagContents));
// $value = $iso->getTimestamp();
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'value':
// "If no type is indicated, the type is string."
if (trim($this->_currentTagContents) != '') {
$value = (string)$this->_currentTagContents;
$this->_currentTagContents = '';
$valueFlag = true;
}
break;
case 'boolean':
$value = (boolean)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'base64':
$value = base64_decode($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
/* Deal with stacks of arrays and structs */
case 'data':
case 'struct':
$value = array_pop($this->_arraystructs);
array_pop($this->_arraystructstypes);
$valueFlag = true;
break;
case 'member':
array_pop($this->_currentStructName);
break;
case 'name':
$this->_currentStructName[] = trim($this->_currentTagContents);
$this->_currentTagContents = '';
break;
case 'methodName':
$this->methodName = trim($this->_currentTagContents);
$this->_currentTagContents = '';
break;
}
if ($valueFlag) {
/*
if (!is_array($value) && !is_object($value)) {
$value = trim($value);
}
*/
if (count($this->_arraystructs) > 0) {
// Add value to struct or array
if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
// Add to struct
$this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
} else {
// Add to array
$this->_arraystructs[count($this->_arraystructs)-1][] = $value;
}
} else {
// Just add as a paramater
$this->params[] = $value;
}
}
}
}
class IXR_Server {
var $data;
var $callbacks = array();
var $message;
var $capabilities;
function IXR_Server($callbacks = false, $data = false) {
$this->setCapabilities();
if ($callbacks) {
$this->callbacks = $callbacks;
}
$this->setCallbacks();
$this->serve($data);
}
function serve($data = false) {
if (!$data) {
global $HTTP_RAW_POST_DATA;
if (!$HTTP_RAW_POST_DATA) {
die('XML-RPC server accepts POST requests only.');
}
$data = $HTTP_RAW_POST_DATA;
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
$this->error(-32700, 'parse error. not well formed');
}
if ($this->message->messageType != 'methodCall') {
$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
}
$result = $this->call($this->message->methodName, $this->message->params);
// Is the result an error?
if (is_a($result, 'IXR_Error')) {
$this->error($result);
}
// Encode the result
$r = new IXR_Value($result);
$resultxml = $r->getXml();
// Create the XML
$xml = <<<EOD
<methodResponse><params><param><value>$resultxml</value></param></params></methodResponse>
EOD;
// Send it
$this->output($xml);
}
function call($methodname, $args) {
if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
}
$method = $this->callbacks[$methodname];
// Perform the callback and send the response
if (count($args) == 1) {
// If only one paramater just send that instead of the whole array
$args = $args[0];
}
// Are we dealing with a function or a method?
if (substr($method, 0, 5) == 'this:') {
// It's a class method - check it exists
$method = substr($method, 5);
if (!method_exists($this, $method)) {
return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
}
// Call the method
$result = $this->$method($args);
} else {
// It's a function - does it exist?
if (!function_exists($method)) {
return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
}
// Call the function
$result = $method($args);
}
return $result;
}
function error($error, $message = false) {
// Accepts either an error object or an error code and message
if ($message && !is_object($error)) {
$error = new IXR_Error($error, $message);
}
$this->output($error->getXml());
}
function output($xml) {
$xml = '<?xml version="1.0" encoding="utf-8"?>'."".$xml;
$length = strlen($xml);
header('Connection: close');
header('Content-Length: '.$length);
header('Content-Type: text/xml');
header('Date: '.date('r'));
echo $xml;
exit;
}
function hasMethod($method) {
return in_array($method, array_keys($this->callbacks));
}
function setCapabilities() {
// Initialises capabilities array
$this->capabilities = array(
'xmlrpc' => array(
'specUrl' => 'http://www.xmlrpc.com/spec',
'specVersion' => 1
),
'faults_interop' => array(
'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
'specVersion' => 20010516
),
'system.multicall' => array(
'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
'specVersion' => 1
),
);
}
function getCapabilities($args) {
return $this->capabilities;
}
function setCallbacks() {
$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
$this->callbacks['system.listMethods'] = 'this:listMethods';
$this->callbacks['system.multicall'] = 'this:multiCall';
}
function listMethods($args) {
// Returns a list of methods - uses array_reverse to ensure user defined
// methods are listed before server defined methods
return array_reverse(array_keys($this->callbacks));
}
function multiCall($methodcalls) {
// See http://www.xmlrpc.com/discuss/msgReader$1208
$return = array();
foreach ($methodcalls as $call) {
$method = $call['methodName'];
$params = $call['params'];
if ($method == 'system.multicall') {
$result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
} else {
$result = $this->call($method, $params);
}
if (is_a($result, 'IXR_Error')) {
$return[] = array(
'faultCode' => $result->code,
'faultString' => $result->message
);
} else {
$return[] = array($result);
}
}
return $return;
}
}
class IXR_Request {
var $method;
var $args;
var $xml;
function IXR_Request($method, $args) {
$this->method = $method;
$this->args = $args;
$this->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$this->method}</methodName>
<params>
EOD;
foreach ($this->args as $arg) {
$this->xml .= '<param><value>';
$v = new IXR_Value($arg);
$this->xml .= $v->getXml();
$this->xml .= "</value></param>";
}
$this->xml .= '</params></methodCall>';
}
function getLength() {
return strlen($this->xml);
}
function getXml() {
return $this->xml;
}
}
class IXR_Client {
var $server;
var $port;
var $path;
var $useragent;
var $response;
var $message = false;
var $debug = false;
// Storage place for an error message
var $error = false;
function IXR_Client($server, $path = false, $port = 80) {
if (!$path) {
// Assume we have been given a URL instead
$bits = parse_url($server);
$this->server = $bits['host'];
$this->port = isset($bits['port']) ? $bits['port'] : 80;
$this->path = isset($bits['path']) ? $bits['path'] : '/';
// Make absolutely sure we have a path
if (!$this->path) {
$this->path = '/';
}
} else {
$this->server = $server;
$this->path = $path;
$this->port = $port;
}
$this->useragent = 'The Incutio XML-RPC PHP Library';
}
function query() {
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
$length = $request->getLength();
$xml = $request->getXml();
$r = "\r\n";
$request = "POST {$this->path} HTTP/1.0$r";
$request .= "Host: {$this->server}$r";
$request .= "Content-Type: text/xml$r";
$request .= "User-Agent: {$this->useragent}$r";
$request .= "Content-length: {$length}$r$r";
$request .= $xml;
// Now send the request
if ($this->debug) {
echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
}
$fp = @fsockopen($this->server, $this->port);
if (!$fp) {
$this->error = new IXR_Error(-32300, 'transport error - could not open socket');
return false;
}
fputs($fp, $request);
$contents = '';
$gotFirstLine = false;
$gettingHeaders = true;
while (!feof($fp)) {
$line = fgets($fp, 4096);
if (!$gotFirstLine) {
// Check line for '200'
if (strstr($line, '200') === false) {
$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
return false;
}
$gotFirstLine = true;
}
if (trim($line) == '') {
$gettingHeaders = false;
}
if (!$gettingHeaders) {
$contents .= trim($line)."\n";
}
}
if ($this->debug) {
echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
}
// Now parse what we've got back
$this->message = new IXR_Message($contents);
if (!$this->message->parse()) {
// XML error
$this->error = new IXR_Error(-32700, 'parse error. not well formed');
return false;
}
// Is the message a fault?
if ($this->message->messageType == 'fault') {
$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
return false;
}
// Message must be OK
return true;
}
function getResponse() {
// methodResponses can only have one param - return that
return $this->message->params[0];
}
function isError() {
return (is_object($this->error));
}
function getErrorCode() {
return $this->error->code;
}
function getErrorMessage() {
return $this->error->message;
}
}
class IXR_Error {
var $code;
var $message;
function IXR_Error($code, $message) {
$this->code = $code;
$this->message = $message;
}
function getXml() {
$xml = <<<EOD
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>{$this->code}</int></value>
</member>
<member>
<name>faultString</name>
<value><string>{$this->message}</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
EOD;
return $xml;
}
}
class IXR_Date {
var $year;
var $month;
var $day;
var $hour;
var $minute;
var $second;
function IXR_Date($time) {
// $time can be a PHP timestamp or an ISO one
if (is_numeric($time)) {
$this->parseTimestamp($time);
} else {
$this->parseIso($time);
}
}
function parseTimestamp($timestamp) {
$this->year = date('Y', $timestamp);
$this->month = date('Y', $timestamp);
$this->day = date('Y', $timestamp);
$this->hour = date('H', $timestamp);
$this->minute = date('i', $timestamp);
$this->second = date('s', $timestamp);
}
function parseIso($iso) {
$this->year = substr($iso, 0, 4);
$this->month = substr($iso, 4, 2);
$this->day = substr($iso, 6, 2);
$this->hour = substr($iso, 9, 2);
$this->minute = substr($iso, 12, 2);
$this->second = substr($iso, 15, 2);
}
function getIso() {
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
}
function getXml() {
return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
}
function getTimestamp() {
return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
}
}
class LLBlock {
var $data;
var $xml;
function LLBlock($data) {
$this->data = $data;
}
function getXml() {
if(count($this->data)>0) {
$this->xml="<array><data><value><struct>";
foreach($this->data as $name => $value) {
$this->xml=$this->xml."<member><name>".$name."</name><value><string>".$value."</string></value></member>";
}
$this->xml=$this->xml."</struct></value></data></array>";
return $this->xml;
}
}
}
class IXR_Base64 {
var $data;
function IXR_Base64($data) {
$this->data = $data;
}
function getXml() {
return '<base64>'.base64_encode($this->data).'</base64>';
}
}
class IXR_IntrospectionServer extends IXR_Server {
var $signatures;
var $help;
function IXR_IntrospectionServer() {
$this->setCallbacks();
$this->setCapabilities();
$this->capabilities['introspection'] = array(
'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
'specVersion' => 1
);
$this->addCallback(
'system.methodSignature',
'this:methodSignature',
array('array', 'string'),
'Returns an array describing the return type and required parameters of a method'
);
$this->addCallback(
'system.getCapabilities',
'this:getCapabilities',
array('struct'),
'Returns a struct describing the XML-RPC specifications supported by this server'
);
$this->addCallback(
'system.listMethods',
'this:listMethods',
array('array'),
'Returns an array of available methods on this server'
);
$this->addCallback(
'system.methodHelp',
'this:methodHelp',
array('string', 'string'),
'Returns a documentation string for the specified method'
);
}
function addCallback($method, $callback, $args, $help) {
$this->callbacks[$method] = $callback;
$this->signatures[$method] = $args;
$this->help[$method] = $help;
}
function call($methodname, $args) {
// Make sure it's in an array
if ($args && !is_array($args)) {
$args = array($args);
}
// Over-rides default call method, adds signature check
if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
}
$method = $this->callbacks[$methodname];
$signature = $this->signatures[$methodname];
$returnType = array_shift($signature);
// Check the number of arguments
if (count($args) != count($signature)) {
// print 'Num of args: '.count($args).' Num in signature: '.count($signature);
return new IXR_Error(-32602, 'server error. wrong number of method parameters');
}
// Check the argument types
$ok = true;
$argsbackup = $args;
for ($i = 0, $j = count($args); $i < $j; $i++) {
$arg = array_shift($args);
$type = array_shift($signature);
switch ($type) {
case 'int':
case 'i4':
if (is_array($arg) || !is_int($arg)) {
$ok = false;
}
break;
case 'base64':
case 'string':
if (!is_string($arg)) {
$ok = false;
}
break;
case 'boolean':
if ($arg !== false && $arg !== true) {
$ok = false;
}
break;
case 'float':
case 'double':
if (!is_float($arg)) {
$ok = false;
}
break;
case 'date':
case 'dateTime.iso8601':
if (!is_a($arg, 'IXR_Date')) {
$ok = false;
}
break;
}
if (!$ok) {
return new IXR_Error(-32602, 'server error. invalid method parameters');
}
}
// It passed the test - run the "real" method call
return parent::call($methodname, $argsbackup);
}
function methodSignature($method) {
if (!$this->hasMethod($method)) {
return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
}
// We should be returning an array of types
$types = $this->signatures[$method];
$return = array();
foreach ($types as $type) {
switch ($type) {
case 'string':
$return[] = 'string';
break;
case 'int':
case 'i4':
$return[] = 42;
break;
case 'double':
$return[] = 3.1415;
break;
case 'dateTime.iso8601':
$return[] = new IXR_Date(time());
break;
case 'boolean':
$return[] = true;
break;
case 'base64':
$return[] = new IXR_Base64('base64');
break;
case 'array':
$return[] = array('array');
break;
case 'struct':
$return[] = array('struct' => 'struct');
break;
}
}
return $return;
}
function methodHelp($method) {
return $this->help[$method];
}
}
class IXR_ClientMulticall extends IXR_Client {
var $calls = array();
function IXR_ClientMulticall($server, $path = false, $port = 80) {
parent::IXR_Client($server, $path, $port);
$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
}
function addCall() {
$args = func_get_args();
$methodName = array_shift($args);
$struct = array(
'methodName' => $methodName,
'params' => $args
);
$this->calls[] = $struct;
}
function query() {
// Prepare multicall, then call the parent::query() method
return parent::query('system.multicall', $this->calls);
}
}
?>

View File

@ -0,0 +1,14 @@
<?
// All the grid server specific stuff lives here
// What we send to authenticate to the user/login server
$userserver_sendkey="1234";
// What we expect to get back from the user/login server
$userserver_recvkey="1234";
$sim_recvkey = "1234";
$sim_sendkey = "1234";
$grid_home = "/ogs/gridserver/";
?>

176
ogs/gridserver/index.php Normal file
View File

@ -0,0 +1,176 @@
<?
error_reporting(E_ALL); // yes, we remember this from the login server, don't we boys and girls? don't kill innocent XML-RPC!
// these files are soooo common..... (to the grid)
include("../common/xmlrpc.inc.php");
include("../common/database.inc.php");
include("../common/grid_config.inc.php");
include("../common/util.inc.php");
include("gridserver_config.inc.php"); // grid server specific config stuff
function get_sim_info($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $userserver_sendkey, $userserver_recvkey;
// First see who's talking to us, if key is invalid then send an invalid one back and nothing more
if($args['authkey']!=$userserver_recvkey) {
return Array(
'authkey' => 'I can play the bad key trick too you know',
'login' => 'false'
);
}
// if we get to here, the key is valid, give that login server what it wants!
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$region_handle = $args['region_handle'];
$query = "SELECT * FROM region_profiles WHERE region_handle='$region_handle'";
$result = mysql_query($query);
return mysql_fetch_assoc($result);
}
function get_session_info($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $sim_sendkey, $sim_recvkey;
// authkey, session-id, agent-id
// First see who's talking to us, if key is invalid then send an invalid one back and nothing more
if($args[0]!=$sim_recvkey) {
return Array(
'authkey' => "I can play the bad key trick too you know"
);
}
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$session_id = $args[1];
$agent_id = $args[2];
$query = "SELECT * FROM sessions WHERE session_id = '$session_id' AND agent_id='$agent_id' AND session_active=1";
$result = mysql_query($query);
if(mysql_num_rows($result)>0) {
$info=mysql_fetch_assoc($result);
$circuit_code = $info['circuit_code'];
$secure_session_id=$info['secure_session_id'];
$query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
$result=mysql_query($query);
$userinfo=mysql_fetch_assoc($result);
$firstname=$userinfo['profile_firstname'];
$lastname=$userinfo['profile_lastname'];
$agent_id=$userinfo['userprofile_LLUUID'];
return Array(
'authkey' => $sim_sendkey,
'circuit_code' => $circuit_code,
'agent_id' => $agent_id,
'session_id' => $session_id,
'secure_session_id' => $secure_session_id,
'firstname' => $firstname,
'lastname' => $lastname
);
}
}
function check_loggedin($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $userserver_sendkey, $userserver_recvkey;
// First see who's talking to us, if key is invalid then send an invalid one back and nothing more
if($args['authkey']!=$userserver_recvkey) {
return Array(
'authkey' => "I can play the bad key trick too you know"
);
}
// if we get to here, the key is valid, give that login server what it wants!
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$userprofile_LLUUID = $args['userprofile_LLUUID'];
$query = "SELECT * FROM sessions WHERE agent_id='$userprofile_LLUUID' AND session_active=1";
$result = mysql_query($query);
if(mysql_num_rows($result)>1) {
return Array(
'authkey' => $userserver_sendkey,
'logged_in' => 1
);
} else {
return Array(
'authkey' => $userserver_sendkey,
'logged_in' => 0
);
}
}
function create_session($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $userserver_sendkey, $userserver_recvkey;
// First see who's talking to us, if key is invalid then send an invalid one back and nothing more
if($args['authkey']!=$userserver_recvkey) {
return Array(
'authkey' => "I can play the bad key trick too you know"
);
}
// if we get to here, the key is valid, give that login server what it wants!
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
// yes, secure_sessionid should be different, i know...
$query = "SELECT value FROM Grid_settings WHERE setting='highest_LLUUID'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$highest_LLUUID = $row['value'];
$newsession_id=inc_lluuid($highest_LLUUID);
$secure_session_id=inc_lluuid($newsession_id);
$query="UPDATE Grid_settings SET value='$secure_session_id' WHERE setting='highest_LLUUID' LIMIT 1";
$result=mysql_query($query);
$userprofile_LLUUID=$args['userprofile_LLUUID'];
$current_location=$args['current_location'];
$remote_ip=$args['remote_ip'];
$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')";
$result=mysql_query($query);
if(!isset($result)) {
die();
}
return Array(
'authkey' => $userserver_sendkey,
'session_id' => $newsession_id,
'secure_session_id' => $secure_session_id
);
}
$server=new IXR_Server(
Array(
'check_session_loggedin' => 'check_loggedin',
'create_session' => 'create_session',
'get_sim_info' => 'get_sim_info',
'get_session_info' => 'get_session_info'
)
);
?>

View File

@ -0,0 +1,5 @@
Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteRule .* index.php [L]

View File

@ -0,0 +1,81 @@
<?
// DIRTY HACK ALERT!!!!!!!!!!!!!
// The following code shows the vital importance of the r69 revision of the original gareth/ branch
// This file parses URLs of the format:
// usersessions/key/userid/data
// 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
// if the data requested is left out, an XML response will be sent
error_reporting(E_ALL); // Remember kids, PHP errors kill XML-RPC responses and REST too! will the slaughter ever end?
include("../gridserver_config.inc.php");
include("../../common/database.inc.php");
include("../../common/util.inc.php");
// Parse out the parameters from the URL
$params = str_replace($grid_home,'', $_SERVER['REQUEST_URI']);
$params = str_replace("index.php/","",$params);
$params = split('/',$params);
// Die if the key doesn't match
if($params[1]!=$sim_recvkey) {
die();
}
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$agent_id = strtolower($params[2]);
$query = "SELECT * FROM sessions WHERE agent_id='$agent_id' AND session_active=1";
// if we have 4 params, then param 4 is the command
if(count($params)==4) {
$cmd=$params['3'];
} else if(count($params)==5) {
$circuit_code=$params[3];
$cmd=$params[4]; // otherwise, 5 is the command and 4 is the circuit code
}
$result = mysql_query($query);
if(mysql_num_rows($result)>0) {
$info=mysql_fetch_assoc($result);
$circuit_code = $info['circuit_code'];
if($circuit_code == 0) $circuit_code=$params['4'];
$secure_session_id=$info['secure_session_id'];
$session_id=$info['session_id'];
$query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
$result=mysql_query($query);
$userinfo=mysql_fetch_assoc($result);
$firstname=$userinfo['profile_firstname'];
$lastname=$userinfo['profile_lastname'];
$agent_id=$userinfo['userprofile_LLUUID'];
$exists=1;
} else {
$exists=0;
}
// if only 3 params, assume we are sending an XML response
if(count($params)==3) {
output_xml_block("usersession",Array(
'authkey' => $sim_sendkey,
'circuit_code' => $circuit_code,
'agent_id' => $agent_id,
'session_id' => $session_id,
'secure_session_id' => $secure_session_id,
'firstname' => $firstname,
'lastname' => $lastname
));
}
switch($cmd) {
case 'exists':
echo $exists;
break;
}
?>

170
ogs/login/index.php Normal file
View File

@ -0,0 +1,170 @@
<?
error_reporting(0); // Remember kids, PHP errors kill XML-RPC responses!
// include all the common stuff
include("../common/xmlrpc.inc.php");
include("../common/database.inc.php");
include("../common/grid_config.inc.php");
include("../common/util.inc.php");
include("login_config.inc.php"); // include login/user specific config stuff (authentication keys etc)
function login($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $grid_owner, $gridserver_sendkey, $gridserver_recvkey, $gridserver_url;
if(get_magic_quotes_gpc()) {
$firstname=addslashes($args['first']);
$lastname=addslashes($args['last']);
$passwd=addslashes($args['passwd']);
} else {
$firstname=$args['first'];
$lastname=$args['last'];
$passwd=$args['passwd'];
}
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$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."'";
$profile_lookup_result=mysql_query($query);
if(mysql_num_rows($profile_lookup_result) >0) {
$profiledata = mysql_fetch_assoc($profile_lookup_result);
// if we get here, the username/password is valid, but still need to check there's not an already existing session
$client = new IXR_Client($gridserver_url);
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
return Array (
'reason' => 'key',
'message' => "Could not connect to grid server. Please try again later or contact the grid owner ". $grid_owner,
'login' => "false"
);
}
$response=$client->getResponse();
if($response['authkey'] != $gridserver_recvkey) { // if this doesn't match up, it's a fake grid server
return Array (
'reason' => 'key',
'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",
'login' => "false"
);
}
if($response['logged_in'] == 1) { // if the user is already logged in, tell them
return Array (
'reason' => 'presence',
'message' => "You appear to already be logged into this grid, if your client has recently crashed then please try again later",
'login' => "false"
);
}
// now we start a new session on the grid
$remote_ip=$_SERVER['REMOTE_ADDR'];
$region_handle=$profiledata['region_handle'];
$client->query('create_session',Array('userprofile_LLUUID' => $profiledata['userprofile_LLUUID'], 'authkey' => $gridserver_sendkey, 'remote_ip' => $remote_ip, 'current_location' => $region_handle));
$response = $client->getResponse();
$session_id = $response['session_id'];
$secure_session_id = $response['secure_session_id'];
// ask the grid server what the IP address and port of the sim we want to connect to is
$client->query('get_sim_info', Array('region_handle' => $region_handle, 'authkey' => $gridserver_sendkey) );
$siminfo = $client->getResponse();
// send the final response!
$position=$profiledata['position'];
$look_at=$profiledata['look_at'];
$LocX=intval($siminfo['GridLocX'])*256;
$LocY=intval($siminfo['GridLocY'])*256;
$home="{'region_handle':'$region_handle', 'position':'$position', 'look_at':'$look_at'}";
$globaltextures = new LLBlock(
Array(
'sun_texture_id' => "cce0f112-878f-4586-a2e2-a8f104bba271",
'cloud_texture_id' => "fc4b9f0b-d008-45c6-96a4-01dd947ac621",
'moon_texture_id' => "d07f6eed-b96a-47cd-b51d-400ad4a1c428"
));
$login_flags = new LLBlock(
Array(
'stipend_since_login' => "N",
'ever_logged_in' => "Y",
'gendered' => "Y",
'daylight_savings' => "N"
));
$ui_config = new LLBlock(
Array(
'allow_first_life' => "Y"
));
$inventory_skeleton = new LLBlock(Array(
Array(
'name' => 'My inventory',
'parent_id' => '00000000-0000-0000-0000-000000000000',
'version' => 4,
'type_default' => 8,
'folder_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8'
),
Array(
'name' => 'Textures',
'parent_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8',
'version' => 1,
'type_default' => 0,
'folder_id' => 'fc8b4059-30bb-43a8-a042-46f5b431ad82'
)));
$inventory_root = new LLBlock(
Array(
'folder_id' => "f798e114-c10f-409b-a90d-a11577ff1de8"
));
$initial_outfit = new LLBlock(
Array(
'folder_name' => "Nightclub Female",
'gender' => "female"
));
return Array (
'message' => "Welcome to OGS!",
'session_id' => format_lluuid($session_id),
'sim_port' => intval($siminfo['port']),
'agent_access' => "M",
'start_location' => "last",
'global-textures' => $globaltextures,
'seconds_since_epoch' => time(),
'first_name' => $profiledata['profile_firstname'],
'circuit_code' => 50633318,
'login_flags' => $login_flags,
'seed_capability' => '',
'home' => $home,
'secure_session_id' => format_lluuid($secure_session_id),
'last_name' => $profiledata['profile_lastname'],
'ui-config' => $ui_config,
'region_x' => $LocX,
'inventory_skeleton' => $inventory_skeleton,
'sim_ip' => $siminfo['ip_addr'],
'region_y' => $LocY,
'inventory-root' => $inventory_root,
'login' => "true",
'look_at' => $look_at,
'agent_id' => format_lluuid($profiledata['userprofile_LLUUID']),
'initial-outfit' => $initial_outfit
);
} else {
// this is the default invalid username/password error
return Array (
'reason' => 'key',
'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.",
'login' => "false",
);
}
}
$server=new IXR_Server(array('login_to_simulator' => 'login'));
?>

View File

@ -0,0 +1,11 @@
<?
// All the user/login server specific stuff lives here
// What we send to authenticate to the grid server
$gridserver_sendkey="1234";
// What we expect to get back from the grid server
$gridserver_recvkey="1234";
$gridserver_url="http://www.osgrid.org/ogs/gridserver/index.php";
?>