mirror of
https://github.com/kcozens/OpenSimSearch.git
synced 2026-08-14 08:52:28 +00:00
Added Event Search to query.php, experimental Events search
git-svn-id: http://forge.opensimulator.org/svn/ossearch/trunk@43 109abde3-1f22-4c10-b5d7-b6b0135cd00c
This commit is contained in:
+192
-136
@@ -9,9 +9,9 @@ $now = time();
|
||||
mysql_connect ($DB_HOST, $DB_USER, $DB_PASSWORD);
|
||||
mysql_select_db ($DB_NAME);
|
||||
|
||||
#
|
||||
#
|
||||
# Copyright (c)Melanie Thielker (http://opensimulator.org/)
|
||||
#
|
||||
#
|
||||
|
||||
###################### No user serviceable parts below #####################
|
||||
|
||||
@@ -22,7 +22,7 @@ mysql_select_db ($DB_NAME);
|
||||
$xmlrpc_server = xmlrpc_server_create();
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_places_query",
|
||||
"dir_places_query");
|
||||
"dir_places_query");
|
||||
|
||||
function dir_places_query($method_name, $params, $app_data)
|
||||
{
|
||||
@@ -32,60 +32,60 @@ function dir_places_query($method_name, $params, $app_data)
|
||||
$category = $req['category'];
|
||||
$query_start = $req['query_start'];
|
||||
|
||||
if ($text == "%%%")
|
||||
{
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "Invalid search terms"
|
||||
));
|
||||
if ($text == "%%%")
|
||||
{
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "Invalid search terms"
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
print $response_xml;
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($category != -1)
|
||||
{
|
||||
$result = mysql_query("select * from parcels where " .
|
||||
"(searchcategory = -1 or searchcategory = '" .
|
||||
mysql_escape_string($category) ."') and (parcelname like '%" .
|
||||
mysql_escape_string($text) . "%' or description like '" .
|
||||
mysql_escape_string($text) . "%') order by " .
|
||||
"dwell desc, parcelname" .
|
||||
" limit ".(0+$query_start).",100");
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = mysql_query("select * from parcels where " .
|
||||
"parcelname like '%" .
|
||||
mysql_escape_string($text) . "%' or description like '" .
|
||||
mysql_escape_string($text) . "%' order by " .
|
||||
"dwell desc, parcelname" .
|
||||
" limit ".(0+$query_start).",100");
|
||||
}
|
||||
if ($category != -1)
|
||||
{
|
||||
$result = mysql_query("select * from parcels where " .
|
||||
"(searchcategory = -1 or searchcategory = '" .
|
||||
mysql_escape_string($category) ."') and (parcelname like '%" .
|
||||
mysql_escape_string($text) . "%' or description like '" .
|
||||
mysql_escape_string($text) . "%') order by " .
|
||||
"dwell desc, parcelname" .
|
||||
" limit ".(0+$query_start).",100");
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = mysql_query("select * from parcels where " .
|
||||
"parcelname like '%" .
|
||||
mysql_escape_string($text) . "%' or description like '" .
|
||||
mysql_escape_string($text) . "%' order by " .
|
||||
"dwell desc, parcelname" .
|
||||
" limit ".(0+$query_start).",100");
|
||||
}
|
||||
|
||||
$data = array();
|
||||
while (($row = mysql_fetch_assoc($result)))
|
||||
{
|
||||
$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
|
||||
));
|
||||
$data = array();
|
||||
while (($row = mysql_fetch_assoc($result)))
|
||||
{
|
||||
$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;
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_popular_query",
|
||||
"dir_popular_query");
|
||||
"dir_popular_query");
|
||||
|
||||
function dir_popular_query($method_name, $params, $app_data)
|
||||
{
|
||||
@@ -93,41 +93,41 @@ function dir_popular_query($method_name, $params, $app_data)
|
||||
|
||||
$flags = $req['flags'];
|
||||
|
||||
$terms = array();
|
||||
$terms = array();
|
||||
|
||||
if ($flags & 0x1000)
|
||||
$terms[] = "has_picture = 1";
|
||||
|
||||
if ($flags & 0x0800)
|
||||
$terms[] = "mature = 0";
|
||||
|
||||
$where = "";
|
||||
if (count($terms) > 0)
|
||||
$where = " where " . join(" and ", $terms);
|
||||
if ($flags & 0x1000)
|
||||
$terms[] = "has_picture = 1";
|
||||
|
||||
$result = mysql_query("select * from popularplaces" . $where);
|
||||
if ($flags & 0x0800)
|
||||
$terms[] = "mature = 0";
|
||||
|
||||
$data = array();
|
||||
while (($row = mysql_fetch_assoc($result)))
|
||||
{
|
||||
$data[] = array(
|
||||
"parcel_id" => $row["infoUUID"],
|
||||
"name" => $row["name"],
|
||||
"dwell" => $row["dwell"]
|
||||
);
|
||||
}
|
||||
$where = "";
|
||||
if (count($terms) > 0)
|
||||
$where = " where " . join(" and ", $terms);
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data
|
||||
));
|
||||
$result = mysql_query("select * from popularplaces" . $where);
|
||||
|
||||
print $response_xml;
|
||||
$data = array();
|
||||
while (($row = mysql_fetch_assoc($result)))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_land_query",
|
||||
"dir_land_query");
|
||||
"dir_land_query");
|
||||
|
||||
function dir_land_query($method_name, $params, $app_data)
|
||||
{
|
||||
@@ -139,77 +139,133 @@ function dir_land_query($method_name, $params, $app_data)
|
||||
$area = $req['area'];
|
||||
$query_start = $req['query_start'];
|
||||
|
||||
$terms = array();
|
||||
$order = "lsq";
|
||||
if ($flags & 0x80000)
|
||||
$order = "parcelname";
|
||||
if ($flags & 0x10000)
|
||||
$order = "saleprice";
|
||||
if ($flags & 0x40000)
|
||||
$order = "area";
|
||||
if (!($flags & 0x8000))
|
||||
$order .= " desc";
|
||||
$terms = array();
|
||||
$order = "lsq";
|
||||
if ($flags & 0x80000)
|
||||
$order = "parcelname";
|
||||
if ($flags & 0x10000)
|
||||
$order = "saleprice";
|
||||
if ($flags & 0x40000)
|
||||
$order = "area";
|
||||
if (!($flags & 0x8000))
|
||||
$order .= " desc";
|
||||
|
||||
if ($flags & 0x100000)
|
||||
$terms[] = "saleprice <= '" . mysql_escape_string($price) . "'";
|
||||
if ($flags & 0x100000)
|
||||
$terms[] = "saleprice <= '" . mysql_escape_string($price) . "'";
|
||||
|
||||
if ($flags & 0x200000)
|
||||
$terms[] = "area >= '" . mysql_escape_string($area) . "'";
|
||||
if ($flags & 0x200000)
|
||||
$terms[] = "area >= '" . mysql_escape_string($area) . "'";
|
||||
|
||||
if (($type & 26) == 2) // Auction
|
||||
{
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "No auctions listed"
|
||||
));
|
||||
if (($type & 26) == 2) // Auction
|
||||
{
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "No auctions listed"
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
print $response_xml;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (($type & 24) == 8)
|
||||
$terms[] = "parentestate = 1";
|
||||
if (($type & 24) == 16)
|
||||
$terms[] = "parentestate <> 1";
|
||||
return;
|
||||
}
|
||||
|
||||
if ($flags & 0x800)
|
||||
$terms[] = "mature = 'false'";
|
||||
if ($flags & 0x4000)
|
||||
$terms[] = "mature = 'true'";
|
||||
|
||||
$where = "";
|
||||
if (count($terms) > 0)
|
||||
$where = " where " . join(" and ", $terms);
|
||||
if (($type & 24) == 8)
|
||||
$terms[] = "parentestate = 1";
|
||||
if (($type & 24) == 16)
|
||||
$terms[] = "parentestate <> 1";
|
||||
|
||||
$sql = "select *, saleprice/area as lsq from parcelsales" . $where .
|
||||
" order by " . $order . " limit " .
|
||||
mysql_escape_string($query_start) . ",101";
|
||||
|
||||
$result = mysql_query($sql);
|
||||
if ($flags & 0x800)
|
||||
$terms[] = "mature = 'false'";
|
||||
if ($flags & 0x4000)
|
||||
$terms[] = "mature = 'true'";
|
||||
|
||||
$data = array();
|
||||
while (($row = mysql_fetch_assoc($result)))
|
||||
{
|
||||
$data[] = array(
|
||||
"parcel_id" => $row["infoUUID"],
|
||||
"name" => $row["parcelname"],
|
||||
"auction" => "false",
|
||||
"for_sale" => "true",
|
||||
"sale_price" => $row["saleprice"],
|
||||
"area" => $row["area"]
|
||||
);
|
||||
}
|
||||
$where = "";
|
||||
if (count($terms) > 0)
|
||||
$where = " where " . join(" and ", $terms);
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data
|
||||
));
|
||||
$sql = "select *, saleprice/area as lsq from parcelsales" . $where .
|
||||
" order by " . $order . " limit " .
|
||||
mysql_escape_string($query_start) . ",101";
|
||||
|
||||
print $response_xml;
|
||||
$result = mysql_query($sql);
|
||||
|
||||
$data = array();
|
||||
while (($row = mysql_fetch_assoc($result)))
|
||||
{
|
||||
$data[] = array(
|
||||
"parcel_id" => $row["infoUUID"],
|
||||
"name" => $row["parcelname"],
|
||||
"auction" => "false",
|
||||
"for_sale" => "true",
|
||||
"sale_price" => $row["saleprice"],
|
||||
"area" => $row["area"]
|
||||
);
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
xmlrpc_server_register_method($xmlrpc_server, "dir_events_query",
|
||||
"dir_events_query");
|
||||
|
||||
function dir_events_query($method_name, $params, $app_data)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
if ($query_flags & 0x2000) $terms[] = "mature = 'false'";
|
||||
|
||||
$where = "";
|
||||
if (count($terms) > 0)
|
||||
$where = " where " . join(" and ", $terms);
|
||||
|
||||
$sql = "select * from events". $where.
|
||||
" limit " . mysql_escape_string($query_start) . ",101";
|
||||
|
||||
|
||||
$result = mysql_query($sql);
|
||||
|
||||
$data = array();
|
||||
while (($row = mysql_fetch_assoc($result)))
|
||||
{
|
||||
$data[] = array(
|
||||
"OwnerID" => $row["OwnerID"],
|
||||
"Name" => $row["Name"],
|
||||
"EventID" => $row["EventID"],
|
||||
"Date" => $row["Date"],
|
||||
"UnixTime" => $row["UnixTime"],
|
||||
"EventFlags" => $row["EventFlags"]
|
||||
);
|
||||
}
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'errorMessage' => "",
|
||||
'data' => $data
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
#
|
||||
# Process the request
|
||||
#
|
||||
@@ -217,4 +273,4 @@ function dir_land_query($method_name, $params, $app_data)
|
||||
$request_xml = $HTTP_RAW_POST_DATA;
|
||||
xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');
|
||||
xmlrpc_server_destroy($xmlrpc_server);
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user