Add support files for search and mutelist module
This commit is contained in:
47
extra/OpenSimMutelist/mutelist.sql
Normal file
47
extra/OpenSimMutelist/mutelist.sql
Normal file
@@ -0,0 +1,47 @@
|
||||
/*M!999999\- enable the sandbox mode */
|
||||
-- MariaDB dump 10.19 Distrib 10.11.11-MariaDB, for debian-linux-gnu (aarch64)
|
||||
--
|
||||
-- Host: localhost Database: grid
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 10.11.11-MariaDB-0+deb12u1
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `mutelist`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `mutelist`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `mutelist` (
|
||||
`AgentID` char(36) NOT NULL,
|
||||
`MuteID` char(36) NOT NULL,
|
||||
`MuteName` varchar(255) NOT NULL,
|
||||
`type` int(11) unsigned NOT NULL,
|
||||
`flags` int(11) unsigned NOT NULL,
|
||||
`Stamp` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
UNIQUE KEY `AgentID_2` (`AgentID`,`MuteID`) USING BTREE,
|
||||
KEY `AgentID` (`AgentID`) USING BTREE
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2025-04-14 10:18:07
|
||||
10
extra/OpenSimMutelist/readme.txt
Normal file
10
extra/OpenSimMutelist/readme.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
OpenSimMutelist
|
||||
https://github.com/lickx/OpenSimMutelist
|
||||
|
||||
For having grid-stored mutelists on a grid
|
||||
|
||||
Only MySQL/MariaDB supported for now
|
||||
|
||||
To be sourced into your robust database
|
||||
|
||||
Needs the mute web helper to also be setup
|
||||
12
extra/OpenSimSearch/readme.txt
Normal file
12
extra/OpenSimSearch/readme.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
OpenSimSearch
|
||||
https://github.com/lickx/OpenSimSearch
|
||||
|
||||
For having search functionality on a grid
|
||||
|
||||
Only MySQL/MariaDB supported for now
|
||||
|
||||
To be sourced in your robust database
|
||||
|
||||
Note the classifieds table will already be made by robust itself
|
||||
|
||||
Needs the search web helper to also be setup
|
||||
198
extra/OpenSimSearch/search.sql
Normal file
198
extra/OpenSimSearch/search.sql
Normal file
@@ -0,0 +1,198 @@
|
||||
/*M!999999\- enable the sandbox mode */
|
||||
-- MariaDB dump 10.19 Distrib 10.11.11-MariaDB, for debian-linux-gnu (aarch64)
|
||||
--
|
||||
-- Host: localhost Database: grid
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 10.11.11-MariaDB-0+deb12u1
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_allparcels`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_allparcels`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_allparcels` (
|
||||
`regionUUID` char(36) NOT NULL,
|
||||
`parcelname` varchar(255) NOT NULL,
|
||||
`ownerUUID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
`groupUUID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
`landingpoint` varchar(255) NOT NULL,
|
||||
`parcelUUID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
`infoUUID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
`parcelarea` int(11) NOT NULL,
|
||||
PRIMARY KEY (`parcelUUID`),
|
||||
KEY `regionUUID` (`regionUUID`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_events`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_events`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_events` (
|
||||
`owneruuid` char(36) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`eventid` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`creatoruuid` char(36) NOT NULL,
|
||||
`category` int(2) NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`dateUTC` int(10) NOT NULL,
|
||||
`duration` int(10) NOT NULL,
|
||||
`covercharge` tinyint(1) NOT NULL,
|
||||
`coveramount` int(10) NOT NULL,
|
||||
`simname` varchar(255) NOT NULL,
|
||||
`parcelUUID` char(36) NOT NULL,
|
||||
`globalPos` varchar(255) NOT NULL,
|
||||
`eventflags` int(1) NOT NULL,
|
||||
PRIMARY KEY (`eventid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_hostsregister`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_hostsregister`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_hostsregister` (
|
||||
`host` varchar(255) NOT NULL,
|
||||
`port` int(5) NOT NULL,
|
||||
`register` int(10) NOT NULL,
|
||||
`nextcheck` int(10) NOT NULL,
|
||||
`checked` tinyint(1) NOT NULL,
|
||||
`failcounter` int(10) NOT NULL,
|
||||
PRIMARY KEY (`host`,`port`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_objects`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_objects`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_objects` (
|
||||
`objectuuid` char(36) NOT NULL,
|
||||
`parceluuid` char(36) NOT NULL,
|
||||
`location` varchar(255) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` varchar(255) NOT NULL,
|
||||
`regionuuid` char(36) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`objectuuid`,`parceluuid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_parcels`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_parcels`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_parcels` (
|
||||
`regionUUID` char(36) NOT NULL,
|
||||
`parcelname` varchar(255) NOT NULL,
|
||||
`parcelUUID` char(36) NOT NULL,
|
||||
`landingpoint` varchar(255) NOT NULL,
|
||||
`description` varchar(255) NOT NULL,
|
||||
`searchcategory` varchar(50) NOT NULL,
|
||||
`build` enum('true','false') NOT NULL,
|
||||
`script` enum('true','false') NOT NULL,
|
||||
`public` enum('true','false') NOT NULL,
|
||||
`dwell` float NOT NULL DEFAULT 0,
|
||||
`infouuid` varchar(36) NOT NULL DEFAULT '',
|
||||
`mature` varchar(10) NOT NULL DEFAULT 'PG',
|
||||
`pictureUUID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
PRIMARY KEY (`regionUUID`,`parcelUUID`),
|
||||
KEY `name` (`parcelname`),
|
||||
KEY `description` (`description`),
|
||||
KEY `searchcategory` (`searchcategory`),
|
||||
KEY `dwell` (`dwell`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_parcelsales`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_parcelsales`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_parcelsales` (
|
||||
`regionUUID` char(36) NOT NULL,
|
||||
`parcelname` varchar(255) NOT NULL,
|
||||
`parcelUUID` char(36) NOT NULL,
|
||||
`area` int(6) NOT NULL,
|
||||
`saleprice` int(11) NOT NULL,
|
||||
`landingpoint` varchar(255) NOT NULL,
|
||||
`infoUUID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
`dwell` int(11) NOT NULL,
|
||||
`parentestate` int(11) NOT NULL DEFAULT 1,
|
||||
`mature` varchar(10) NOT NULL DEFAULT 'PG',
|
||||
PRIMARY KEY (`regionUUID`,`parcelUUID`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_popularplaces`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_popularplaces`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_popularplaces` (
|
||||
`parcelUUID` char(36) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`dwell` float NOT NULL,
|
||||
`infoUUID` char(36) NOT NULL,
|
||||
`has_picture` tinyint(1) NOT NULL,
|
||||
`mature` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
PRIMARY KEY (`parcelUUID`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_regions`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_regions`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_regions` (
|
||||
`regionname` varchar(255) NOT NULL,
|
||||
`regionUUID` char(36) NOT NULL,
|
||||
`regionhandle` varchar(255) NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
`owner` varchar(255) NOT NULL,
|
||||
`owneruuid` char(36) NOT NULL,
|
||||
PRIMARY KEY (`regionUUID`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2025-04-14 10:16:19
|
||||
1
helper/index.html
Normal file
1
helper/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<p></p>
|
||||
6
helper/mute/databaseinfo.php
Normal file
6
helper/mute/databaseinfo.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$DB_HOST = "localhost";
|
||||
$DB_USER = "opensim";
|
||||
$DB_PASSWORD = "password";
|
||||
$DB_NAME = "grid";
|
||||
?>
|
||||
1
helper/mute/index.html
Normal file
1
helper/mute/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<p></p>
|
||||
144
helper/mute/mutelist.php
Normal file
144
helper/mute/mutelist.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
include("databaseinfo.php");
|
||||
|
||||
// Attempt to connect to the database with the mutelist table
|
||||
try {
|
||||
$db = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME", $DB_USER, $DB_PASSWORD);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
echo "Error connecting to the database with the mutelist table\n";
|
||||
file_put_contents('PDOErrors.txt', $e->getMessage() . "\n-----\n", FILE_APPEND);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
###################### No user serviceable parts below #####################
|
||||
|
||||
function get_error_message($result)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!$result)
|
||||
return "";
|
||||
|
||||
$errorInfo = $db->errorInfo();
|
||||
return $errorInfo[2];
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# The XMLRPC server object
|
||||
#
|
||||
|
||||
$xmlrpc_server = xmlrpc_server_create();
|
||||
|
||||
#
|
||||
# Return list of muted agents and objects
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "mutelist_request",
|
||||
"mutelist_request");
|
||||
|
||||
function mutelist_request($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$avatarUUID = $req['avataruuid'];
|
||||
|
||||
$query = $db->prepare("SELECT * FROM mutelist WHERE AgentID = ?");
|
||||
$result = $query->execute( array($avatarUUID) );
|
||||
|
||||
$mutelist = "";
|
||||
if ($query->rowCount() > 0)
|
||||
{
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$mutelist .= $row["type"] . " ";
|
||||
$mutelist .= $row["MuteID"] . " ";
|
||||
$mutelist .= $row["MuteName"] . "|";
|
||||
$mutelist .= $row["flags"] . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => $result,
|
||||
'errorMessage' => get_error_message($result),
|
||||
'mutelist' => $mutelist
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Remove an event notify reminder request
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "mutelist_update",
|
||||
"mutelist_update");
|
||||
|
||||
function mutelist_update($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$avatarUUID = $req['avataruuid'];
|
||||
$muteUUID = $req['muteuuid'];
|
||||
$name = $req['name'];
|
||||
$type = $req['type'];
|
||||
$flags = $req['flags'];
|
||||
|
||||
$query = $db->prepare("INSERT INTO mutelist VALUES (?, ?, ?, ?, ?, NOW())");
|
||||
$result = $query->execute(
|
||||
array($avatarUUID, $muteUUID, $name, $type, $flags) );
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => $result,
|
||||
'errorMessage' => get_error_message($result)
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Remove an event notify reminder request
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "mutelist_remove",
|
||||
"mutelist_remove");
|
||||
|
||||
function mutelist_remove($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$avatarUUID = $req['avataruuid'];
|
||||
$muteUUID = $req['muteuuid'];
|
||||
|
||||
$query = $db->prepare("DELETE FROM mutelist WHERE" .
|
||||
" AgentID = ? AND MuteID = ?");
|
||||
$result = $query->execute( array($avatarUUID, $muteUUID) );
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => $result,
|
||||
'errorMessage' => get_error_message($result)
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Process the request
|
||||
#
|
||||
|
||||
$request_xml = file_get_contents("php://input");
|
||||
|
||||
xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');
|
||||
xmlrpc_server_destroy($xmlrpc_server);
|
||||
?>
|
||||
2
helper/robots.txt
Normal file
2
helper/robots.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
6
helper/search/databaseinfo.php
Normal file
6
helper/search/databaseinfo.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$DB_HOST = "localhost";
|
||||
$DB_USER = "opensim";
|
||||
$DB_PASSWORD = "password";
|
||||
$DB_NAME = "grid";
|
||||
?>
|
||||
1
helper/search/index.html
Normal file
1
helper/search/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<p></p>
|
||||
354
helper/search/parser.php
Normal file
354
helper/search/parser.php
Normal file
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
include("databaseinfo.php");
|
||||
|
||||
//Supress all Warnings/Errors
|
||||
//error_reporting(0);
|
||||
|
||||
$now = time();
|
||||
|
||||
// Attempt to connect to the search database
|
||||
try {
|
||||
$db = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME", $DB_USER, $DB_PASSWORD);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
echo "Error connecting to the search database\n";
|
||||
file_put_contents('PDOErrors.txt', $e->getMessage() . "\n-----\n", FILE_APPEND);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function GetURL($host, $port, $url)
|
||||
{
|
||||
$url = "http://$host:$port/$url";
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
|
||||
$data = curl_exec($ch);
|
||||
if (curl_errno($ch) == 0)
|
||||
{
|
||||
curl_close($ch);
|
||||
return $data;
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
return "";
|
||||
}
|
||||
|
||||
function CheckHost($hostname, $port)
|
||||
{
|
||||
global $db, $now;
|
||||
|
||||
$xml = GetURL($hostname, $port, "?method=collector");
|
||||
if ($xml == "") //No data was retrieved? (CURL may have timed out)
|
||||
$failcounter = "failcounter + 1";
|
||||
else
|
||||
$failcounter = "0";
|
||||
|
||||
//Update nextcheck to be 10 minutes from now. The current OS instance
|
||||
//won't be checked again until at least this much time has gone by.
|
||||
$next = $now + 600;
|
||||
|
||||
$query = $db->prepare("UPDATE search_hostsregister SET nextcheck = ?," .
|
||||
" checked = 1, failcounter = $failcounter" .
|
||||
" WHERE host = ? AND port = ?");
|
||||
$query->execute( array($next, $hostname, $port) );
|
||||
|
||||
if ($xml != "")
|
||||
parse($hostname, $port, $xml);
|
||||
}
|
||||
|
||||
function parse($hostname, $port, $xml)
|
||||
{
|
||||
global $db, $now;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Search engine sim scanner
|
||||
//
|
||||
|
||||
//
|
||||
// Load XML doc from URL
|
||||
//
|
||||
$objDOM = new DOMDocument();
|
||||
$objDOM->resolveExternals = false;
|
||||
|
||||
//Don't try and parse if XML is invalid or we got an HTML 404 error.
|
||||
if ($objDOM->loadXML($xml) == False)
|
||||
return;
|
||||
|
||||
//
|
||||
// Get the region data to update
|
||||
//
|
||||
$regiondata = $objDOM->getElementsByTagName("regiondata");
|
||||
|
||||
//If returned length is 0, collector method may have returned an error
|
||||
if ($regiondata->length == 0)
|
||||
return;
|
||||
|
||||
$regiondata = $regiondata->item(0);
|
||||
|
||||
//
|
||||
// Update nextcheck so this host entry won't be checked again until after
|
||||
// the DataSnapshot module has generated a new set of data to be parsed.
|
||||
//
|
||||
$expire = $regiondata->getElementsByTagName("expire")->item(0)->nodeValue;
|
||||
$next = $now + $expire;
|
||||
|
||||
$query = $db->prepare("UPDATE search_hostsregister SET nextcheck = ?" .
|
||||
" WHERE host = ? AND port = ?");
|
||||
$query->execute( array($next, $hostname, $port) );
|
||||
|
||||
//
|
||||
// Get the region data to be saved in the database
|
||||
//
|
||||
$regionlist = $regiondata->getElementsByTagName("region");
|
||||
|
||||
foreach ($regionlist as $region)
|
||||
{
|
||||
$regioncategory = $region->getAttributeNode("category")->nodeValue;
|
||||
|
||||
//
|
||||
// Start reading the Region info
|
||||
//
|
||||
$info = $region->getElementsByTagName("info")->item(0);
|
||||
|
||||
$regionuuid = $info->getElementsByTagName("uuid")->item(0)->nodeValue;
|
||||
|
||||
$regionname = $info->getElementsByTagName("name")->item(0)->nodeValue;
|
||||
|
||||
$regionhandle = $info->getElementsByTagName("handle")->item(0)->nodeValue;
|
||||
|
||||
$url = $info->getElementsByTagName("url")->item(0)->nodeValue;
|
||||
|
||||
//
|
||||
// First, check if we already have a region that is the same
|
||||
//
|
||||
$check = $db->prepare("SELECT * FROM search_regions WHERE regionUUID = ?");
|
||||
$check->execute( array($regionuuid) );
|
||||
|
||||
if ($check->rowCount() > 0)
|
||||
{
|
||||
$query = $db->prepare("DELETE FROM search_regions WHERE regionUUID = ?");
|
||||
$query->execute( array($regionuuid) );
|
||||
$query = $db->prepare("DELETE FROM search_parcels WHERE regionUUID = ?");
|
||||
$query->execute( array($regionuuid) );
|
||||
$query = $db->prepare("DELETE FROM search_allparcels WHERE regionUUID = ?");
|
||||
$query->execute( array($regionuuid) );
|
||||
$query = $db->prepare("DELETE FROM search_parcelsales WHERE regionUUID = ?");
|
||||
$query->execute( array($regionuuid) );
|
||||
$query = $db->prepare("DELETE FROM search_objects WHERE regionuuid = ?");
|
||||
$query->execute( array($regionuuid) );
|
||||
}
|
||||
|
||||
$data = $region->getElementsByTagName("data")->item(0);
|
||||
$estate = $data->getElementsByTagName("estate")->item(0);
|
||||
|
||||
$username = $estate->getElementsByTagName("name")->item(0)->nodeValue;
|
||||
$useruuid = $estate->getElementsByTagName("uuid")->item(0)->nodeValue;
|
||||
|
||||
$estateid = $estate->getElementsByTagName("id")->item(0)->nodeValue;
|
||||
|
||||
//
|
||||
// Second, add the new info to the database
|
||||
//
|
||||
$query = $db->prepare("INSERT INTO search_regions VALUES(:r_name, :r_uuid, " .
|
||||
":r_handle, :url, :u_name, :u_uuid)");
|
||||
$query->execute( array("r_name" => $regionname, "r_uuid" => $regionuuid,
|
||||
"r_handle" => $regionhandle, "url" => $url,
|
||||
"u_name" => $username, "u_uuid" => $useruuid) );
|
||||
|
||||
//
|
||||
// Start reading the parcel info
|
||||
//
|
||||
$parcel = $data->getElementsByTagName("parcel");
|
||||
|
||||
foreach ($parcel as $value)
|
||||
{
|
||||
$parcelname = $value->getElementsByTagName("name")->item(0)->nodeValue;
|
||||
|
||||
$parceluuid = $value->getElementsByTagName("uuid")->item(0)->nodeValue;
|
||||
|
||||
$infouuid = $value->getElementsByTagName("infouuid")->item(0)->nodeValue;
|
||||
|
||||
$parcellanding = $value->getElementsByTagName("location")->item(0)->nodeValue;
|
||||
|
||||
$parceldescription = $value->getElementsByTagName("description")->item(0)->nodeValue;
|
||||
|
||||
$parcelarea = $value->getElementsByTagName("area")->item(0)->nodeValue;
|
||||
|
||||
$parcelcategory = $value->getAttributeNode("category")->nodeValue;
|
||||
|
||||
$parcelsaleprice = $value->getAttributeNode("salesprice")->nodeValue;
|
||||
|
||||
$dwell = $value->getElementsByTagName("dwell")->item(0)->nodeValue;
|
||||
|
||||
//The image tag will only exist if the parcel has a snapshot image
|
||||
$has_pic = 0;
|
||||
$image = "00000000-0000-0000-0000-000000000000";
|
||||
$image_node = $value->getElementsByTagName("image");
|
||||
|
||||
if ($image_node->length > 0)
|
||||
{
|
||||
$image = $image_node->item(0)->nodeValue;
|
||||
|
||||
if ($image != "00000000-0000-0000-0000-000000000000")
|
||||
$has_pic = 1;
|
||||
}
|
||||
|
||||
$owner = $value->getElementsByTagName("owner")->item(0);
|
||||
|
||||
$owneruuid = $owner->getElementsByTagName("uuid")->item(0)->nodeValue;
|
||||
|
||||
// Adding support for groups
|
||||
|
||||
$group = $value->getElementsByTagName("group")->item(0);
|
||||
|
||||
if ($group != "")
|
||||
{
|
||||
$groupuuid = $group->getElementsByTagName("groupuuid")->item(0)->nodeValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$groupuuid = "00000000-0000-0000-0000-000000000000";
|
||||
}
|
||||
|
||||
//
|
||||
// Check bits on Public, Build, Script
|
||||
//
|
||||
$parcelforsale = $value->getAttributeNode("forsale")->nodeValue;
|
||||
$parceldirectory = $value->getAttributeNode("showinsearch")->nodeValue;
|
||||
$parcelbuild = $value->getAttributeNode("build")->nodeValue;
|
||||
$parcelscript = $value->getAttributeNode("scripts")->nodeValue;
|
||||
$parcelpublic = $value->getAttributeNode("public")->nodeValue;
|
||||
|
||||
//Prepare for the insert of data in to the popularplaces table. This gets
|
||||
//rid of any obsolete data for parcels no longer set to show in search.
|
||||
$query = $db->prepare("DELETE FROM search_popularplaces WHERE parcelUUID = ?");
|
||||
$query->execute( array($parceluuid) );
|
||||
|
||||
//
|
||||
// Save
|
||||
//
|
||||
$query = $db->prepare("INSERT INTO search_allparcels VALUES(" .
|
||||
":r_uuid, :p_name, :o_uuid, :g_uuid, " .
|
||||
":landing, :p_uuid, :i_uuid, :area)");
|
||||
$query->execute( array("r_uuid" => $regionuuid,
|
||||
"p_name" => $parcelname,
|
||||
"o_uuid" => $owneruuid,
|
||||
"g_uuid" => $groupuuid,
|
||||
"landing" => $parcellanding,
|
||||
"p_uuid" => $parceluuid,
|
||||
"i_uuid" => $infouuid,
|
||||
"area" => $parcelarea) );
|
||||
|
||||
if ($parceldirectory == "true")
|
||||
{
|
||||
$query = $db->prepare("INSERT INTO search_parcels VALUES(" .
|
||||
":r_uuid, :p_name, :p_uuid, :landing, " .
|
||||
":desc, :cat, :build, :script, :public, ".
|
||||
":dwell, :i_uuid, :r_cat, :pic_uuid)");
|
||||
$query->execute( array("r_uuid" => $regionuuid,
|
||||
"p_name" => $parcelname,
|
||||
"p_uuid" => $parceluuid,
|
||||
"landing" => $parcellanding,
|
||||
"desc" => $parceldescription,
|
||||
"cat" => $parcelcategory,
|
||||
"build" => $parcelbuild,
|
||||
"script" => $parcelscript,
|
||||
"public" => $parcelpublic,
|
||||
"dwell" => $dwell,
|
||||
"i_uuid" => $infouuid,
|
||||
"r_cat" => $regioncategory,
|
||||
"pic_uuid" => $image) );
|
||||
|
||||
$query = $db->prepare("INSERT INTO search_popularplaces VALUES(" .
|
||||
":p_uuid, :p_name, :dwell, " .
|
||||
":i_uuid, :has_pic, :r_cat)");
|
||||
$query->execute( array("p_uuid" => $parceluuid,
|
||||
"p_name" => $parcelname,
|
||||
"dwell" => $dwell,
|
||||
"i_uuid" => $infouuid,
|
||||
"has_pic" => $has_pic,
|
||||
"r_cat" => $regioncategory) );
|
||||
}
|
||||
|
||||
if ($parcelforsale == "true")
|
||||
{
|
||||
$query = $db->prepare("INSERT INTO search_parcelsales VALUES(" .
|
||||
":r_uuid, :p_name, :p_uuid, :area, " .
|
||||
":price, :landing, :i_uuid, :dwell, " .
|
||||
":e_id, :r_cat)");
|
||||
$query->execute( array("r_uuid" => $regionuuid,
|
||||
"p_name" => $parcelname,
|
||||
"p_uuid" => $parceluuid,
|
||||
"area" => $parcelarea,
|
||||
"price" => $parcelsaleprice,
|
||||
"landing" => $parcellanding,
|
||||
"i_uuid" => $infouuid,
|
||||
"dwell" => $dwell,
|
||||
"e_id" => $estateid,
|
||||
"r_cat" => $regioncategory) );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Handle objects
|
||||
//
|
||||
$objects = $data->getElementsByTagName("object");
|
||||
|
||||
foreach ($objects as $value)
|
||||
{
|
||||
$uuid = $value->getElementsByTagName("uuid")->item(0)->nodeValue;
|
||||
|
||||
$regionuuid = $value->getElementsByTagName("regionuuid")->item(0)->nodeValue;
|
||||
|
||||
$parceluuid = $value->getElementsByTagName("parceluuid")->item(0)->nodeValue;
|
||||
|
||||
$location = $value->getElementsByTagName("location")->item(0)->nodeValue;
|
||||
|
||||
$title = $value->getElementsByTagName("title")->item(0)->nodeValue;
|
||||
|
||||
$description = $value->getElementsByTagName("description")->item(0)->nodeValue;
|
||||
|
||||
$flags = $value->getElementsByTagName("flags")->item(0)->nodeValue;
|
||||
|
||||
$query = $db->prepare("INSERT INTO search_objects VALUES(" .
|
||||
":uuid, :p_uuid, :location, " .
|
||||
":title, :desc, :r_uuid)");
|
||||
$query->execute( array("uuid" => $uuid,
|
||||
"p_uuid" => $parceluuid,
|
||||
"location" => $location,
|
||||
"title" => $title,
|
||||
"desc" => $description,
|
||||
"r_uuid" => $regionuuid) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT host, port FROM search_hostsregister " .
|
||||
"WHERE nextcheck<$now AND checked=0 AND failcounter<10 LIMIT 0,10";
|
||||
$jobsearch = $db->query($sql);
|
||||
|
||||
//
|
||||
// If the sql query returns no rows, all entries in the hostsregister
|
||||
// table have been checked. Reset the checked flag and re-run the
|
||||
// query to select the next set of hosts to be checked.
|
||||
//
|
||||
if ($jobsearch->rowCount() == 0)
|
||||
{
|
||||
$jobsearch = $db->query("UPDATE search_hostsregister SET checked = 0");
|
||||
|
||||
$jobsearch = $db->query($sql);
|
||||
}
|
||||
|
||||
while ($jobs = $jobsearch->fetch(PDO::FETCH_NUM))
|
||||
CheckHost($jobs[0], $jobs[1]);
|
||||
|
||||
$db = NULL;
|
||||
?>
|
||||
694
helper/search/query.php
Normal file
694
helper/search/query.php
Normal file
@@ -0,0 +1,694 @@
|
||||
<?php
|
||||
//The description of the flags used in this file are being based on the
|
||||
//DirFindFlags enum which is defined in OpenMetaverse/DirectoryManager.cs
|
||||
//of the libopenmetaverse library.
|
||||
|
||||
include("databaseinfo.php");
|
||||
|
||||
// Attempt to connect to the database
|
||||
try {
|
||||
$db = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME", $DB_USER, $DB_PASSWORD);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
echo "Error connecting to database\n";
|
||||
file_put_contents('PDOErrors.txt', $e->getMessage() . "\n-----\n", FILE_APPEND);
|
||||
exit;
|
||||
}
|
||||
|
||||
#
|
||||
# Copyright (c)Melanie Thielker (http://opensimulator.org/)
|
||||
#
|
||||
|
||||
###################### No user serviceable parts below #####################
|
||||
|
||||
//Join a series of terms together with optional parentheses around the result.
|
||||
//This function is used in place of the simpler join to handle the cases where
|
||||
//one or more of the supplied terms are an empty string. The parentheses can
|
||||
//be added when mixing AND and OR clauses in a SQL query.
|
||||
function join_terms($glue, $terms, $add_paren)
|
||||
{
|
||||
if (count($terms) > 1)
|
||||
{
|
||||
$type = join($glue, $terms);
|
||||
if ($add_paren == True)
|
||||
$type = "(" . $type . ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count($terms) == 1)
|
||||
$type = $terms[0];
|
||||
else
|
||||
$type = "";
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
|
||||
function process_region_type_flags($flags)
|
||||
{
|
||||
$terms = array();
|
||||
|
||||
if ($flags & 16777216) //IncludePG (1 << 24)
|
||||
$terms[] = "mature = 'PG'";
|
||||
if ($flags & 33554432) //IncludeMature (1 << 25)
|
||||
$terms[] = "mature = 'Mature'";
|
||||
if ($flags & 67108864) //IncludeAdult (1 << 26)
|
||||
$terms[] = "mature = 'Adult'";
|
||||
|
||||
return join_terms(" OR ", $terms, True);
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# The XMLRPC server object
|
||||
#
|
||||
|
||||
$xmlrpc_server = xmlrpc_server_create();
|
||||
|
||||
#
|
||||
# Places Query
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_places_query",
|
||||
"dir_places_query");
|
||||
|
||||
function dir_places_query($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$flags = $req['flags'];
|
||||
$text = $req['text'];
|
||||
$category = $req['category'];
|
||||
$query_start = $req['query_start'];
|
||||
|
||||
$pieces = explode(" ", $text);
|
||||
$text = join("%", $pieces);
|
||||
|
||||
if ($text != "%%%")
|
||||
$text = "%$text%";
|
||||
else
|
||||
{
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "Invalid search terms"
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$terms = array();
|
||||
$sqldata = array();
|
||||
|
||||
$type = process_region_type_flags($flags);
|
||||
if ($type != "")
|
||||
$type = " AND " . $type;
|
||||
|
||||
if ($flags & 1024)
|
||||
$order = "dwell DESC,";
|
||||
|
||||
if ($category <= 0)
|
||||
$cat_where = "";
|
||||
else
|
||||
{
|
||||
$cat_where = "searchcategory = :cat AND ";
|
||||
|
||||
$sqldata['cat'] = $category;
|
||||
}
|
||||
|
||||
$sqldata['text1'] = $text;
|
||||
$sqldata['text2'] = $text;
|
||||
|
||||
//Prevent SQL injection by checking that $query_start is a number
|
||||
$query_start = (int)$query_start;
|
||||
if ($query_start != 0 && ($query_start%100 != 0))
|
||||
$query_start = 0;
|
||||
|
||||
$query_end = 101;
|
||||
|
||||
$sql = "SELECT * FROM search_parcels WHERE $cat_where" .
|
||||
" (parcelname LIKE :text1" .
|
||||
" OR description LIKE :text2)" .
|
||||
$type . " ORDER BY $order parcelname" .
|
||||
" LIMIT ".$query_start.",".$query_end.";";
|
||||
$query = $db->prepare($sql);
|
||||
$result = $query->execute($sqldata);
|
||||
|
||||
$data = array();
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$data[] = array(
|
||||
"parcel_id" => $row["infouuid"],
|
||||
"name" => $row["parcelname"],
|
||||
"for_sale" => "False",
|
||||
"auction" => "False",
|
||||
"dwell" => $row["dwell"]);
|
||||
}
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Popular Places Query
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_popular_query",
|
||||
"dir_popular_query");
|
||||
|
||||
function dir_popular_query($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$text = $req['text'];
|
||||
$flags = $req['flags'];
|
||||
$query_start = $req['query_start'];
|
||||
|
||||
$terms = array();
|
||||
$sqldata = array();
|
||||
|
||||
if ($flags & 0x1000) //PicturesOnly (1 << 12)
|
||||
$terms[] = "has_picture = 1";
|
||||
|
||||
if ($flags & 0x0800) //PgSimsOnly (1 << 11)
|
||||
$terms[] = "mature = 0";
|
||||
|
||||
if ($text != "")
|
||||
{
|
||||
$terms[] = "(name LIKE :text)";
|
||||
|
||||
$text = "%text%";
|
||||
$sqldata['text'] = $text;
|
||||
}
|
||||
|
||||
if (count($terms) > 0)
|
||||
$where = " WHERE " . join_terms(" AND ", $terms, False);
|
||||
else
|
||||
$where = "";
|
||||
|
||||
//Prevent SQL injection by checking that $query_start is a number
|
||||
if (!is_int($query_start))
|
||||
$query_start = 0;
|
||||
|
||||
$query = $db->prepare("SELECT * FROM search_popularplaces" . $where .
|
||||
" LIMIT $query_start,101");
|
||||
$result = $query->execute($sqldata);
|
||||
|
||||
$data = array();
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$data[] = array(
|
||||
"parcel_id" => $row["infoUUID"],
|
||||
"name" => $row["name"],
|
||||
"dwell" => $row["dwell"]);
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Land Query
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_land_query",
|
||||
"dir_land_query");
|
||||
|
||||
function dir_land_query($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$flags = $req['flags'];
|
||||
$type = $req['type'];
|
||||
$price = $req['price'];
|
||||
$area = $req['area'];
|
||||
$query_start = $req['query_start'];
|
||||
|
||||
$terms = array();
|
||||
$sqldata = array();
|
||||
|
||||
if ($type != 4294967295) //Include all types of land?
|
||||
{
|
||||
//Do this check first so we can bail out quickly on Auction search
|
||||
if (($type & 26) == 2) // Auction (from SearchTypeFlags enum)
|
||||
{
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "No auctions listed"));
|
||||
|
||||
print $response_xml;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (($type & 24) == 8) //Mainland (24=0x18 [bits 3 & 4])
|
||||
$terms[] = "parentestate = 1";
|
||||
if (($type & 24) == 16) //Estate (24=0x18 [bits 3 & 4])
|
||||
$terms[] = "parentestate <> 1";
|
||||
}
|
||||
|
||||
$s = process_region_type_flags($flags);
|
||||
if ($s != "")
|
||||
$terms[] = $s;
|
||||
|
||||
if ($flags & 0x100000) //LimitByPrice (1 << 20)
|
||||
{
|
||||
$terms[] = "saleprice <= :price";
|
||||
|
||||
$sqldata['price'] = $price;
|
||||
}
|
||||
if ($flags & 0x200000) //LimitByArea (1 << 21)
|
||||
{
|
||||
$terms[] = "area >= :area";
|
||||
|
||||
$sqldata['area'] = $area;
|
||||
}
|
||||
|
||||
//The PerMeterSort flag is always passed from a map item query.
|
||||
//It doesn't hurt to have this as the default search order.
|
||||
$order = "lsq"; //PerMeterSort (1 << 17)
|
||||
|
||||
if ($flags & 0x80000) //NameSort (1 << 19)
|
||||
$order = "parcelname";
|
||||
if ($flags & 0x10000) //PriceSort (1 << 16)
|
||||
$order = "saleprice";
|
||||
if ($flags & 0x40000) //AreaSort (1 << 18)
|
||||
$order = "area";
|
||||
if (!($flags & 0x8000)) //SortAsc (1 << 15)
|
||||
$order .= " DESC";
|
||||
|
||||
if (count($terms) > 0)
|
||||
$where = " WHERE " . join_terms(" AND ", $terms, False);
|
||||
else
|
||||
$where = "";
|
||||
|
||||
//Prevent SQL injection by checking that $query_start is a number
|
||||
if (!is_int($query_start))
|
||||
$query_start = 0;
|
||||
|
||||
$sql = "SELECT *,saleprice/area AS lsq FROM search_parcelsales" . $where .
|
||||
" ORDER BY " . $order . " LIMIT $query_start,101";
|
||||
$query = $db->prepare($sql);
|
||||
$result = $query->execute($sqldata);
|
||||
|
||||
$data = array();
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$data[] = array(
|
||||
"parcel_id" => $row["infoUUID"],
|
||||
"name" => $row["parcelname"],
|
||||
"auction" => "false",
|
||||
"for_sale" => "true",
|
||||
"sale_price" => $row["saleprice"],
|
||||
"landing_point" => $row["landingpoint"],
|
||||
"region_UUID" => $row["regionUUID"],
|
||||
"area" => $row["area"]);
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Events Query
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_events_query",
|
||||
"dir_events_query");
|
||||
|
||||
function dir_events_query($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$text = $req['text'];
|
||||
$flags = $req['flags'];
|
||||
$query_start = $req['query_start'];
|
||||
|
||||
if ($text == "%%%")
|
||||
{
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "Invalid search terms"
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$pieces = explode("|", $text);
|
||||
|
||||
$day = $pieces[0];
|
||||
$category = $pieces[1];
|
||||
if (count($pieces) < 3)
|
||||
$search_text = "";
|
||||
else
|
||||
$search_text = $pieces[2];
|
||||
|
||||
$terms = array();
|
||||
$sqldata = array();
|
||||
|
||||
//Event times are in UTC so we need to get the current time in UTC.
|
||||
$now = time();
|
||||
|
||||
if ($day == "u") //Searching for current or ongoing events?
|
||||
{
|
||||
//This condition will include upcoming and in-progress events
|
||||
$terms[] = "dateUTC+duration*60 >= " . $now;
|
||||
}
|
||||
else
|
||||
{
|
||||
//For events in a given day we need to determine the days start time
|
||||
$now -= idate("Z"); //Adjust for timezone
|
||||
$now -= ($now % 86400); //Adjust to start of day
|
||||
|
||||
//Is $day a number of days before or after current date?
|
||||
if ($day != 0)
|
||||
$now += $day * 86400;
|
||||
|
||||
$then = $now + 86400; //Time for end of day
|
||||
|
||||
//This condition will include any in-progress events
|
||||
$terms[] = "(dateUTC+duration*60 >= $now AND dateUTC < $then)";
|
||||
}
|
||||
|
||||
if ($category > 0)
|
||||
{
|
||||
$terms[] = "category = :category";
|
||||
|
||||
$sqldata['category'] = $category;
|
||||
}
|
||||
|
||||
$type = array();
|
||||
if ($flags & 16777216) //IncludePG (1 << 24)
|
||||
$type[] = "eventflags = 0";
|
||||
if ($flags & 33554432) //IncludeMature (1 << 25)
|
||||
$type[] = "eventflags = 1";
|
||||
if ($flags & 67108864) //IncludeAdult (1 << 26)
|
||||
$type[] = "eventflags = 2";
|
||||
|
||||
//Was there at least one PG, Mature, or Adult flag?
|
||||
if (count($type) > 0)
|
||||
$terms[] = join_terms(" OR ", $type, True);
|
||||
|
||||
if ($search_text != "")
|
||||
{
|
||||
$terms[] = "(name LIKE :text1 OR " .
|
||||
"description LIKE :text2)";
|
||||
|
||||
$search_text = "%$search_text%";
|
||||
$sqldata['text1'] = $search_text;
|
||||
$sqldata['text2'] = $search_text;
|
||||
}
|
||||
|
||||
if (count($terms) > 0)
|
||||
$where = " WHERE " . join_terms(" AND ", $terms, False);
|
||||
else
|
||||
$where = "";
|
||||
|
||||
//Prevent SQL injection by checking that $query_start is a number
|
||||
if (!is_int($query_start))
|
||||
$query_start = 0;
|
||||
|
||||
$sql = "SELECT owneruuid,name,eventid,dateUTC,eventflags,globalPos" .
|
||||
" FROM search_events". $where. " LIMIT $query_start,101";
|
||||
$query = $db->prepare($sql);
|
||||
$result = $query->execute($sqldata);
|
||||
|
||||
$data = array();
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$date = strftime("%m/%d %I:%M %p", $row["dateUTC"]);
|
||||
|
||||
//The landing point is only needed when this event query is
|
||||
//called to allow placement of event markers on the world map.
|
||||
$data[] = array(
|
||||
"owner_id" => $row["owneruuid"],
|
||||
"name" => $row["name"],
|
||||
"event_id" => $row["eventid"],
|
||||
"date" => $date,
|
||||
"unix_time" => $row["dateUTC"],
|
||||
"event_flags" => $row["eventflags"],
|
||||
"landing_point" => $row["globalPos"]);
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Classifieds Query
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_classified_query",
|
||||
"dir_classified_query");
|
||||
|
||||
function dir_classified_query ($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$text = $req['text'];
|
||||
$flags = $req['flags'];
|
||||
$category = $req['category'];
|
||||
$query_start = $req['query_start'];
|
||||
|
||||
if ($text == "%%%")
|
||||
{
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "Invalid search terms"
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$terms = array();
|
||||
$sqldata = array();
|
||||
|
||||
//Renew Weekly flag is bit 5 (32) in $flags.
|
||||
//Bit 0 (PG) and bit 1 (Mature) are deprecated.
|
||||
//Bit 2 is PG, bit 3 is Mature, bit 5 is Adult.
|
||||
$maturity = 0;
|
||||
if ($flags & 5) //Legacy or current PG bit?
|
||||
$maturity |= 5;
|
||||
if ($flags & 10) //Legacy or current Mature bit?
|
||||
$maturity |= 8;
|
||||
if ($flags & 64) //Adult bit (1 << 6)
|
||||
$maturity |= 64;
|
||||
|
||||
if ($maturity)
|
||||
$terms[] = "classifiedflags & $maturity";
|
||||
|
||||
//Only restrict results based on category if it is not 0 (Any Category)
|
||||
if ($category > 0)
|
||||
{
|
||||
$terms[] = "category = :category";
|
||||
|
||||
$sqldata['category'] = $category;
|
||||
}
|
||||
|
||||
if ($text != "")
|
||||
{
|
||||
$terms[] = "(name LIKE :text1" .
|
||||
" OR description LIKE :text2)";
|
||||
|
||||
$text = "%$text%";
|
||||
$sqldata['text1'] = $text;
|
||||
$sqldata['text2'] = $text;
|
||||
}
|
||||
|
||||
//Was there at least condition for the search?
|
||||
if (count($terms) > 0)
|
||||
$where = " WHERE " . join_terms(" AND ", $terms, False);
|
||||
else
|
||||
$where = "";
|
||||
|
||||
//Prevent SQL injection by checking that $query_start is a number
|
||||
if (!is_int($query_start))
|
||||
$query_start = 0;
|
||||
|
||||
$sql = "SELECT * FROM classifieds" . $where .
|
||||
" ORDER BY priceforlisting DESC" .
|
||||
" LIMIT $query_start,101";
|
||||
$query = $db->prepare($sql);
|
||||
|
||||
$result = $query->execute($sqldata);
|
||||
|
||||
$data = array();
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
/* Test for legacy maturity bits and set current bits */
|
||||
$flags = $row["classifiedflags"];
|
||||
if ($flags & 1)
|
||||
$flags |= 4;
|
||||
if ($flags & 2)
|
||||
$flags |= 8;
|
||||
|
||||
$data[] = array(
|
||||
"classifiedid" => $row["classifieduuid"],
|
||||
"name" => $row["name"],
|
||||
"classifiedflags" => $flags,
|
||||
"creation_date" => $row["creationdate"],
|
||||
"expiration_date" => $row["expirationdate"],
|
||||
"priceforlisting" => $row["priceforlisting"]);
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Events Info Query
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "event_info_query",
|
||||
"event_info_query");
|
||||
|
||||
function event_info_query($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$eventID = $req['eventID'];
|
||||
|
||||
$query = $db->prepare("SELECT * FROM search_events WHERE eventID = ?");
|
||||
$result = $query->execute( array($eventID) );
|
||||
|
||||
$data = array();
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$date = strftime("%G-%m-%d %H:%M:%S", $row["dateUTC"]);
|
||||
|
||||
$category = "*Unspecified*";
|
||||
if ($row['category'] == 18) $category = "Discussion";
|
||||
if ($row['category'] == 19) $category = "Sports";
|
||||
if ($row['category'] == 20) $category = "Live Music";
|
||||
if ($row['category'] == 22) $category = "Commercial";
|
||||
if ($row['category'] == 23) $category = "Nightlife/Entertainment";
|
||||
if ($row['category'] == 24) $category = "Games/Contests";
|
||||
if ($row['category'] == 25) $category = "Pageants";
|
||||
if ($row['category'] == 26) $category = "Education";
|
||||
if ($row['category'] == 27) $category = "Arts and Culture";
|
||||
if ($row['category'] == 28) $category = "Charity/Support Groups";
|
||||
if ($row['category'] == 29) $category = "Miscellaneous";
|
||||
if ($row['category'] == 30) $category = "Live DJ";
|
||||
|
||||
$data[] = array(
|
||||
"event_id" => $row["eventid"],
|
||||
"creator" => $row["creatoruuid"],
|
||||
"name" => $row["name"],
|
||||
"category" => $category,
|
||||
"description" => $row["description"],
|
||||
"date" => $date,
|
||||
"dateUTC" => $row["dateUTC"],
|
||||
"duration" => $row["duration"],
|
||||
"covercharge" => $row["covercharge"],
|
||||
"coveramount" => $row["coveramount"],
|
||||
"simname" => $row["simname"],
|
||||
"globalposition" => $row["globalPos"],
|
||||
"eventflags" => $row["eventflags"]);
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Classifieds Info Query
|
||||
#
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "classifieds_info_query",
|
||||
"classifieds_info_query");
|
||||
|
||||
function classifieds_info_query($method_name, $params, $app_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$req = $params[0];
|
||||
|
||||
$classifiedID = $req['classifiedID'];
|
||||
|
||||
$query = $db->prepare("SELECT * FROM classifieds WHERE classifieduuid = ?");
|
||||
$result = $query->execute( array($classifiedID) );
|
||||
|
||||
$data = array();
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$data[] = array(
|
||||
"classifieduuid" => $row["classifieduuid"],
|
||||
"creatoruuid" => $row["creatoruuid"],
|
||||
"creationdate" => $row["creationdate"],
|
||||
"expirationdate" => $row["expirationdate"],
|
||||
"category" => $row["category"],
|
||||
"name" => $row["name"],
|
||||
"description" => $row["description"],
|
||||
"parceluuid" => $row["parceluuid"],
|
||||
"parentestate" => $row["parentestate"],
|
||||
"snapshotuuid" => $row["snapshotuuid"],
|
||||
"simname" => $row["simname"],
|
||||
"posglobal" => $row["posglobal"],
|
||||
"parcelname" => $row["parcelname"],
|
||||
"classifiedflags" => $row["classifiedflags"],
|
||||
"priceforlisting" => $row["priceforlisting"]);
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
#
|
||||
# Process the request
|
||||
#
|
||||
|
||||
$request_xml = file_get_contents("php://input");
|
||||
|
||||
xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');
|
||||
xmlrpc_server_destroy($xmlrpc_server);
|
||||
|
||||
$db = NULL;
|
||||
?>
|
||||
72
helper/search/register.php
Normal file
72
helper/search/register.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// register.php //
|
||||
// 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");
|
||||
|
||||
$hostname = "";
|
||||
$port = "";
|
||||
$service = "";
|
||||
|
||||
if (isset($_GET['host'])) $hostname = $_GET['host'];
|
||||
if (isset($_GET['port'])) $port = $_GET['port'];
|
||||
if (isset($_GET['service'])) $service = $_GET['service'];
|
||||
|
||||
if ($hostname == "" || $port == "")
|
||||
{
|
||||
echo "Missing host name and/or port address\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Attempt to connect to the database
|
||||
try {
|
||||
$db = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME", $DB_USER, $DB_PASSWORD);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
echo "Error connecting to database\n";
|
||||
file_put_contents('PDOErrors.txt', $e->getMessage() . "\n-----\n", FILE_APPEND);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($service == "online")
|
||||
{
|
||||
// Check if there is already a database row for this host
|
||||
$query = $db->prepare("SELECT register FROM search_hostsregister WHERE host = ? AND port = ?");
|
||||
$query->execute( array($hostname, $port) );
|
||||
|
||||
// Get the request time as a timestamp for later
|
||||
$timestamp = $_SERVER['REQUEST_TIME'];
|
||||
|
||||
// If a database row was returned check the nextcheck date
|
||||
if ($query->rowCount() > 0)
|
||||
{
|
||||
$query = $db->prepare("UPDATE search_hostsregister SET " .
|
||||
"register = ?, " .
|
||||
"nextcheck = 0, checked = 0, failcounter = 0 " .
|
||||
"WHERE host = ? AND port = ?");
|
||||
$query->execute( array($timestamp, $hostname, $port) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// The SELECT did not return a result. Insert a new record.
|
||||
$query = $db->prepare("INSERT INTO search_hostsregister VALUES (?, ?, ?, 0, 0, 0)");
|
||||
$query->execute( array($hostname, $port, $timestamp) );
|
||||
}
|
||||
}
|
||||
|
||||
if ($service == "offline")
|
||||
{
|
||||
$query = $db->prepare("DELETE FROM search_hostsregister WHERE host = ? AND port = ?");
|
||||
$query->execute( array($hostname, $port) );
|
||||
}
|
||||
|
||||
$db = NULL;
|
||||
?>
|
||||
@@ -19,13 +19,13 @@ rem if exist %VERSION_FILE% del %VERSION_FILE%
|
||||
SET TARGET_ZIP=opensim-%GIT_BRANCH%-%LAST_COMMIT_DATE%_%GIT_REV%.zip
|
||||
echo %TARGET_ZIP%
|
||||
set excludes=-x "*Tests*" "bin/Gloebit.*" "bin/OpenSimMutelist.Modules.*" "bin/MoneyServer.*" "OpenSim.Data.MySQL.MySQLMoneyDataWrapper.*" "OpenSim.Modules.Currency.dll.*" "OpenSim.ini.sample" "server_cert.p12" "SineWaveCert.pfx"
|
||||
zip -r -o "%TARGET_ZIP%" bin CONTRIBUTORS.txt LICENSE.txt README.md ThirdPartyLicenses %excludes%
|
||||
zip -r -o "%TARGET_ZIP%" bin CONTRIBUTORS.txt LICENSE.txt README.md ThirdPartyLicenses helper/index.html helper/robots.txt helper/search extra/OpenSimSearch %excludes%
|
||||
|
||||
if not exist bin\OpenSimMutelist.Modules.dll goto skipmutelist
|
||||
SET TARGET_ZIP=opensimmutelist-%GIT_BRANCH%-%LAST_COMMIT_DATE%_%GIT_REV%.zip
|
||||
set excludes=-x "*Tests*"
|
||||
echo %TARGET_ZIP%
|
||||
zip -r -o "%TARGET_ZIP%" bin/OpenSimMutelist.Modules.* %excludes%
|
||||
zip -r -o "%TARGET_ZIP%" bin/OpenSimMutelist.Modules.* helper/mute extra/OpenSimMutelist %excludes%
|
||||
:skipmutelist
|
||||
|
||||
if not exist bin\Gloebit.dll goto skipgloebit
|
||||
|
||||
@@ -12,14 +12,14 @@ echo "${GIT_BRANCH}@${GIT_REV} (${LAST_COMMIT_DATE})" > bin/.version
|
||||
EXCLUDES="*Tests* *Gloebit* *OpenSimMutelist* *MoneyServer* *OpenSim.Data.MySQL.MySQLMoneyDataWrapper* *OpenSim.Modules.Currency* *OpenSim.ini.sample* *server_cert.p12* *SineWaveCert.pfx*"
|
||||
TARGETZIP=opensim-${GIT_BRANCH}-${LAST_COMMIT_DATE}_${GIT_REV}.zip
|
||||
echo "${TARGETZIP}"
|
||||
zip -r -o ${TARGETZIP} bin CONTRIBUTORS.txt LICENSE.txt README.md ThirdPartyLicenses -x ${EXCLUDES}
|
||||
zip -r -o ${TARGETZIP} bin CONTRIBUTORS.txt LICENSE.txt README.md ThirdPartyLicenses helper/index.html helper/robots.txt helper/search extra/OpenSimSearch -x ${EXCLUDES}
|
||||
|
||||
#Make seperate zip for OpenSimMutelist addon:
|
||||
if [ -f bin/OpenSimMutelist.Modules.dll ]; then
|
||||
TARGETZIP=opensimmutelist-${GIT_BRANCH}-${LAST_COMMIT_DATE}_${GIT_REV}.zip
|
||||
EXCLUDES="*Tests*"
|
||||
echo "${TARGETZIP}"
|
||||
zip -r -o ${TARGETZIP} bin/OpenSimMutelist.Modules.* -x ${EXCLUDES}
|
||||
zip -r -o ${TARGETZIP} bin/OpenSimMutelist.Modules.* helper/mute extra/OpenSimMutelist -x ${EXCLUDES}
|
||||
fi
|
||||
|
||||
#Make seperate zip for Gloebit addon:
|
||||
|
||||
Reference in New Issue
Block a user