[Opensim-dev] Introduction of a sitemap style system for users and land

Michel Beauregard gimisa at yahoo.fr
Wed Jul 4 20:21:10 UTC 2018


The following   email present was  is already existing via Diva and other contibutors. 

 search php  source code for access registered datasnapshot information:
<?php
$dbug=false;
$sval=mysql_real_escape_string($_GET["sname"]);
echo "searching for ", $sval," \n";
if ( strlen($sval) <3){
  echo  "need more then two letters to make search please \n"; 
  return;
}

if ( strlen($sval) >63){
  echo  "not more then 63  letters to make search please \n"; 
  return;
}
    
if (!preg_match("/^[a-zA-Z ]*$/",$sval)) {
  echo  "Only letters and white space allowed \n"; 
  return;
}

$sval="%".mysql_real_escape_string($_GET["sname"])."%";

$DB_HOST = "localhost";
$DB_USER = "opensim";
$DB_PASSWORD = "xxxxx";
$DB_NAME = "ossearch";

if ($dbug){
    echo $sval;
    echo "<br/>";
    echo $DB_HOST ;
    echo "<br/>";
    echo $DB_USER;
    echo "<br/>";
    echo $DB_PASSWORD;
    echo "<br/>";
    }

$conn = mysqli_connect ($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_NAME);

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

//$sql = "SELECT * FROM `objects` WHERE `name` LIKE \'%Tulip%\' LIMIT 0, 30 ";
//$sql = "SELECT * FROM `objects` WHERE `name` LIKE '%Tulip%'  LIMIT 0, 30 ";
//$sql = "SELECT * FROM `objects` INNER JOIN `regions` ON `objects.regionuuid` = `regions.regionuuid` LIMIT 0, 30 ";
//$sql = "SELECT `regionuuid` FROM `objects`";
//$sql = "SELECT `regionname`, `regionuuid`, `regionhandle`, `url`, `owner`, `owneruuid` FROM `regions` WHERE 1 LIMIT 0, 30 ";
$sql = "SELECT `location`, `name`, `description` , `regionname` FROM `objects` INNER JOIN `regions` ON objects.`regionuuid`=regions.`regionuuid` WHERE `name`  LIKE  '".  $sval . "' LIMIT 0, 300 ";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
   echo "found ".$result->num_rows." item(s)  clic on the link below TWO times to teleport to object  \n";
    // output data of each row
    while($row = $result->fetch_assoc()) {
//        echo "Name: " . $row["name"]. " - Description: " . $row["description"]. " RegionName" . $row["regionname"]." Location" . $row["location"]. "<br>";
        echo "NAME: " . $row["name"]. " - DESC: " . $row["description"]. "  - LOC  https://gimisa/region/" . $row["regionname"]."/" . $row["location"];
    }
} else {
    echo "0 results";
}
$conn->close();
?>

As explain here http://metaverseink.com/docs/listing.html  To create your owne address search location using the above is as  simple as populating the opensim.ini file with  your site data. For exemple for my location  (3d.gimisa.ca:9000 ) the opensim.ini dataSnapshot  configuration is changed as follow with data_services pointing to metaverse search location in addition to my own internal location search facility :

[DataSnapshot]
    index_sims = true
    data_exposure = minimum

    gridname = "GiMiSa"
    ; 1 hour
    default_snapshot_period = 13600
    snapshot_cache_directory = "DataSnapshot"
    data_services="http://192.168.2.105/register.php;http://metaverseink.com/cgi-bin/register.py"

The data_service register.php code is as follows:
<?php
//////////////////////////////////////////////////////////////////////////////
// register.php                                                             //
// (C) 2008, Fly-man-                                                       //
// This file contains the registration of a simulator to the database       //
// and checks if the simulator is new in the database or a reconnected one  //
//                                                                          //
// If the simulator is old, check if the nextcheck date > registration      //
// When the date is older, make a request to the Parser to grab new data    //
//////////////////////////////////////////////////////////////////////////////

include("databaseinfo.php");
//establish connection to master db server
mysql_connect ($DB_HOST, $DB_USER, $DB_PASSWORD);
mysql_select_db ($DB_NAME);

$hostname = $_GET['host'];
$port = $_GET['port'];
$service = $_GET['service'];

if ($hostname != "" && $port != "" && $service == "online")
{
    // Check if there is already a database row for this host
    $checkhost = mysql_query("SELECT register FROM hostsregister WHERE " .
            "host = '" . mysql_real_escape_string($hostname) . "' AND " .
            "port = '" . mysql_real_escape_string($port) . "'");

    // Get the request time as a timestamp for later
    $timestamp = $_SERVER['REQUEST_TIME'];

    // if greater than 1, check the nextcheck date
    if (mysql_num_rows($checkhost) > 0)
    {
        $update = "UPDATE hostsregister SET " .
                "register = '" . mysql_real_escape_string($timestamp) . "', " . 
                "nextcheck = '0', checked = '0', " .
                "failcounter = '0' " .  
                "WHERE host = '" . mysql_real_escape_string($hostname) . "' AND " .
                "port = '" . mysql_real_escape_string($port) . "'";

        $runupdate = mysql_query($update);
    }
    else
    {
        $register = "INSERT INTO hostsregister VALUES ".
                    "('" . mysql_real_escape_string($hostname) . "', " .
                    "'" . mysql_real_escape_string($port) . "', " .
                    "'" . mysql_real_escape_string($timestamp) . "', 0, 0, 0)";

        $runupdate = mysql_query($register);
    }
}
elseif ($hostname != "" && $port != "" && $service = "offline")
{
        $delete = "DELETE FROM hostsregister " .
                "WHERE host = '" . mysql_real_escape_string($hostname) . "' AND " .
                "port = '" . mysql_real_escape_string($port) . "'";

        $rundelete = mysql_query($delete);
}
?>

More detail about diva search can be found here: http://www.metaverseink.com/blog/news/metaverse-ink-search-for-opensims/ . Please note Metaverse search facility is broken since about begining of the year as it was before and  as it was never intended for full fledge support as opensim searching tool. 

This article in hypergrid business give Maria's reflection on the subject in 2014  https://www.hypergridbusiness.com/2014/07/two-ideas-for-better-search-for-opensim/

(Happy 4th of July to our Americain friends .)

hope the above is  helpfull. GiMiSa 


More information about the Opensim-dev mailing list