User:Fly-man-/Webbased Regions

How to create a region server that uses the Web to get his regions:

1: Create a database called regionxml

CREATE DATABASE regionxml

2: Create 2 tables that hold all the information for the regionserver and regions themselves

CREATE TABLE regionservers ( `IP` varchar(20) NOT NULL,  `ServerID` int(1) NOT NULL,  PRIMARY KEY  (`IP`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `xmlregions` ( `sim_UUID` varchar(50) NOT NULL,  `sim_name` varchar(255) NOT NULL,  `sim_location_x` int(6) NOT NULL,  `sim_location_y` int(6) NOT NULL,  `internal_ip_address` varchar(20) NOT NULL default '0.0.0.0',  `regionserver` int(1) NOT NULL,  `master_avatar_uuid` varchar(50) NOT NULL default '00000000-0000-0000-0000-000000000000',  `master_avatar_first` varchar(255) NOT NULL,  `master_avatar_last` varchar(255) NOT NULL,  `master_avatar_pass` varchar(255) NOT NULL,  `lastmap_uuid` varchar(50) NOT NULL,  `lastmap_refresh` int(11) NOT NULL,  PRIMARY KEY  (`sim_UUID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

3: Fill in your region server and give them a number

INSERT INTO `regionservers` VALUES ('', );

4: Fill the xmlregion table with the region info you need

INSERT INTO `xmlregions` VALUES ('', ' ', , , '0.0.0.0',, '00000000-0000-0000-0000-000000000000', '', '', '', '', 0);

5: Use these settings in your OpenSim.ini to get the region to poll the Grid server for regions:

region_info_source = "web"
 * Determine where OpenSimulator looks for the files which tell it which regions to server
 * Defaults to "filesystem" if this setting isn't present
 * region_info_source = "filesystem"


 * Determines where the region XML files are stored if you are loading these from the filesystem.
 * Defaults to bin/Regions in your OpenSimulator installation directory
 * regionload_regionsdir="C:\somewhere\xmlfiles\"

regionload_webserver_url = "http://grid/opensim/regions.php";
 * Determines the page from which regions xml is retrieved if you are loading these from the web
 * The XML here has the same format as it does on the filesystem (including the  tag),
 * except that everything is also enclosed in a  tag.

The region.php file looks like this:

<? include("database.inc.php");

// Setup the database connection mysql_connect($host,$username,$password); mysql_select_db($database);

// Getting the region server credits $external = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

$requestregion = "SELECT ServerID from regionservers where IP = '$external'";

$trapregion = mysql_query($requestregion);

while ($regions = mysql_fetch_row($trapregion)) { $region = $regions[0]; }

// Getting all region info for the calling server $sql = "SELECT sim_UUID,sim_name,sim_location_x,sim_location_y,master_avatar_uuid,       master_avatar_first,master_avatar_last,master_avatar_pass,        lastmap_uuid,lastmap_refresh FROM        $table WHERE regionserver = $region";

$result = mysql_query($sql);

// Set the Start for the XML echo "\r\n";

// Additional port info set here $port = 9000;

// Fill the XML with the region from the database while ($row = mysql_fetch_row($result)) {   echo "\r\n"; echo ''; echo "\r\n"; echo "\r\n"; $port = $port + 1; } echo ""; ?>