From b10d45175be46f5ce014c650738af8a1cf110b83 Mon Sep 17 00:00:00 2001 From: fly-man- Date: Sun, 26 Oct 2008 21:18:27 +0000 Subject: [PATCH] Updated svn git-svn-id: http://forge.opensimulator.org/svn/ossearch/trunk@92 109abde3-1f22-4c10-b5d7-b6b0135cd00c --- .../Modules/SearchModule/OpenSearch.cs | 44 +++-- patches/OpenSearch.patch | 71 -------- patches/Query.patch | 164 ------------------ webroot/query.php | 117 ++++++++----- 4 files changed, 107 insertions(+), 289 deletions(-) delete mode 100644 patches/OpenSearch.patch delete mode 100644 patches/Query.patch diff --git a/OpenSimSearch/Modules/SearchModule/OpenSearch.cs b/OpenSimSearch/Modules/SearchModule/OpenSearch.cs index 9ec4f9c..4ca16b4 100644 --- a/OpenSimSearch/Modules/SearchModule/OpenSearch.cs +++ b/OpenSimSearch/Modules/SearchModule/OpenSearch.cs @@ -102,6 +102,7 @@ namespace OpenSimSearch.Modules.OpenSearch client.OnDirClassifiedQuery += DirClassifiedQuery; // Response after Directory Queries client.OnEventInfoRequest += EventInfoRequest; + //client.OnEventLocationRequest += EventLocationRequest; } @@ -444,8 +445,8 @@ namespace OpenSimSearch.Modules.OpenSearch // data[i].classifiedID = new UUID(d["classifiedid"].ToString()); // data[i].name = d["name"].ToString(); // data[i].classifiedFlags = (byte)d["classifiedflags"]; -// data[i].creationDate = Convert.ToUInt32(d["creationdate"]); -// data[i].expirationDate = Convert.ToUInt32(d["expirationdate"]); +// data[i].creationDate = Convert.ToUInt32(d["creation_date"]); +// data[i].expirationDate = Convert.ToUInt32(d["expiration_date"]); // data[i].price = Convert.ToInt32(d["priceforlisting"]); // i++; // if (i >= count) @@ -485,20 +486,35 @@ namespace OpenSimSearch.Modules.OpenSearch Hashtable d = (Hashtable)dataArray[0]; EventData data = new EventData(); data.eventID = Convert.ToUInt32(d["event_id"]); - data.creator = d["Creator"].ToString(); - data.name = d["Name"].ToString(); - data.category = d["Category"].ToString(); - data.description = d["Description"].ToString(); - data.date = d["Date"].ToString(); - data.dateUTC = Convert.ToUInt32(d["DateUTC"]); - data.duration = Convert.ToUInt32(d["Duration"]); - data.cover = Convert.ToUInt32(d["Cover"]); - data.amount = Convert.ToUInt32(d["Amount"]); - data.simName = d["SimName"].ToString(); - Vector3.TryParse(d["GlobalPos"].ToString(), out data.globalPos); - data.eventFlags = Convert.ToUInt32(d["EventFlags"]); + data.creator = d["creator"].ToString(); + data.name = d["name"].ToString(); + data.category = d["category"].ToString(); + data.description = d["description"].ToString(); + data.date = d["date"].ToString(); + data.dateUTC = Convert.ToUInt32(d["dateUTC"]); + data.duration = Convert.ToUInt32(d["duration"]); + data.cover = Convert.ToUInt32(d["covercharge"]); + data.amount = Convert.ToUInt32(d["coveramount"]); + data.simName = d["simname"].ToString(); + Vector3.TryParse(d["globalposition"].ToString(), out data.globalPos); + data.eventFlags = Convert.ToUInt32(d["eventflags"]); remoteClient.SendEventInfoReply(data); } + + public void EventLocationRequest(IClientAPI remoteClient, UUID queryID, uint queryEventID) + { + Hashtable ReqHash = new Hashtable(); + ReqHash["eventID"] = queryEventID.ToString(); + + Hashtable result = GenericXMLRPCRequest(ReqHash, + "event_location_query"); + if (!Convert.ToBoolean(result["success"])) + { + remoteClient.SendAgentAlertMessage( + result["errorMessage"].ToString(), false); + return; + } + } } } diff --git a/patches/OpenSearch.patch b/patches/OpenSearch.patch deleted file mode 100644 index 8289586..0000000 --- a/patches/OpenSearch.patch +++ /dev/null @@ -1,71 +0,0 @@ -Index: OpenSimSearch/Modules/SearchModule/OpenSearch.cs -=================================================================== ---- OpenSimSearch/Modules/SearchModule/OpenSearch.cs (revision 89) -+++ OpenSimSearch/Modules/SearchModule/OpenSearch.cs (working copy) -@@ -102,6 +102,7 @@ - client.OnDirClassifiedQuery += DirClassifiedQuery; - // Response after Directory Queries - client.OnEventInfoRequest += EventInfoRequest; -+ //client.OnEventLocationRequest += EventLocationRequest; - - } - -@@ -444,8 +445,8 @@ - // data[i].classifiedID = new UUID(d["classifiedid"].ToString()); - // data[i].name = d["name"].ToString(); - // data[i].classifiedFlags = (byte)d["classifiedflags"]; --// data[i].creationDate = Convert.ToUInt32(d["creationdate"]); --// data[i].expirationDate = Convert.ToUInt32(d["expirationdate"]); -+// data[i].creationDate = Convert.ToUInt32(d["creation_date"]); -+// data[i].expirationDate = Convert.ToUInt32(d["expiration_date"]); - // data[i].price = Convert.ToInt32(d["priceforlisting"]); - // i++; - // if (i >= count) -@@ -485,20 +486,35 @@ - Hashtable d = (Hashtable)dataArray[0]; - EventData data = new EventData(); - data.eventID = Convert.ToUInt32(d["event_id"]); -- data.creator = d["Creator"].ToString(); -- data.name = d["Name"].ToString(); -- data.category = d["Category"].ToString(); -- data.description = d["Description"].ToString(); -- data.date = d["Date"].ToString(); -- data.dateUTC = Convert.ToUInt32(d["DateUTC"]); -- data.duration = Convert.ToUInt32(d["Duration"]); -- data.cover = Convert.ToUInt32(d["Cover"]); -- data.amount = Convert.ToUInt32(d["Amount"]); -- data.simName = d["SimName"].ToString(); -- Vector3.TryParse(d["GlobalPos"].ToString(), out data.globalPos); -- data.eventFlags = Convert.ToUInt32(d["EventFlags"]); -+ data.creator = d["creator"].ToString(); -+ data.name = d["name"].ToString(); -+ data.category = d["category"].ToString(); -+ data.description = d["description"].ToString(); -+ data.date = d["date"].ToString(); -+ data.dateUTC = Convert.ToUInt32(d["dateUTC"]); -+ data.duration = Convert.ToUInt32(d["duration"]); -+ data.cover = Convert.ToUInt32(d["covercharge"]); -+ data.amount = Convert.ToUInt32(d["coveramount"]); -+ data.simName = d["simname"].ToString(); -+ Vector3.TryParse(d["globalposition"].ToString(), out data.globalPos); -+ data.eventFlags = Convert.ToUInt32(d["eventflags"]); - - remoteClient.SendEventInfoReply(data); - } -+ -+ public void EventLocationRequest(IClientAPI remoteClient, UUID queryID, uint queryEventID) -+ { -+ Hashtable ReqHash = new Hashtable(); -+ ReqHash["eventID"] = queryEventID.ToString(); -+ -+ Hashtable result = GenericXMLRPCRequest(ReqHash, -+ "event_location_query"); -+ if (!Convert.ToBoolean(result["success"])) -+ { -+ remoteClient.SendAgentAlertMessage( -+ result["errorMessage"].ToString(), false); -+ return; -+ } -+ } - } - } diff --git a/patches/Query.patch b/patches/Query.patch deleted file mode 100644 index e569e7b..0000000 --- a/patches/Query.patch +++ /dev/null @@ -1,164 +0,0 @@ -Index: webroot/query.php -=================================================================== ---- webroot/query.php (revision 88) -+++ webroot/query.php (working copy) -@@ -215,42 +215,57 @@ - $flags = $req['flags']; - $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; -+ } - -- $terms = array(); -+ $pieces = explode("|", $text); -+ -+ $day = $pieces[0]; -+ $category = $pieces[1]; - -+ //Setting a variable for NOW -+ $now = time(); -+ -+ $terms = array(); -+ -+ if ($day == "u") $terms[] = "dateUTC > ".$now.""; -+ -+ if ($category <> 0) $terms[] = "category = ".$category.""; -+ - if ($flags & 0x2000) $terms[] = "mature = 'false'"; - -- $where = ""; -- if (count($terms) > 0) -- $where = " where " . join(" and ", $terms); -+ $where = ""; - -- $sql = "select * from events". $where. -- " limit " . mysql_escape_string($query_start) . ",101"; -+ 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))) - { -+ $date = strftime("%m/%d %I:%M %p",$row["dateUTC"]); -+ - $data[] = array( -- "owner_id" => $row["OwnerID"], -- "name" => $row["Name"], -- "event_id" => $row["EventID"], -- "date" => $row["Date"], -- "unix_time" => $row["UnixTime"], -- "event_flags" => $row["EventFlags"]); -+ "owner_id" => $row["owneruuid"], -+ "name" => $row["name"], -+ "event_id" => $row["eventid"], -+ "date" => $date, -+ "unix_time" => $row["dateUTC"], -+ "event_flags" => $row["eventflags"]); - } - - $response_xml = xmlrpc_encode(array( -@@ -268,18 +283,38 @@ - { - $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; -+ } -+ -+ $sql = "select * from classifieds". $where. -+ " limit " . mysql_escape_string($query_start) . ",101"; -+ - $result = mysql_query($sql); - - $data = array(); - while (($row = mysql_fetch_assoc($result))) - { - $data[] = array( -- "ClassifiedID" => $row["ClassifiedID"], -- "Name" => $row["Name"], -- "ClassifiedFlags" => $row["ClassifiedFlags"], -- "CreationDate" => $row["CreationDate"], -- "ExpirationDate" => $row["ExpirationDate"], -- "PriceForListing" => $row["PriceForListing"]); -+ "classifiedid" => $row["classifieduuid"], -+ "name" => $row["name"], -+ "classifiedflags" => $row["classifiedflags"], -+ "creation_date" => $row["creationdate"], -+ "expiration_date" => $row["expirationdate"], -+ "priceforlisting" => $row["priceforlisting"]); - } - - $response_xml = xmlrpc_encode(array( -@@ -309,20 +344,22 @@ - $data = array(); - while (($row = mysql_fetch_assoc($result))) - { -+ $date = strftime("%G-%m-%d %H:%M:%S",$row["dateUTC"]); -+ - $data[] = array( -- "event_id" => $row["eventID"], -- "creator" => $row["Creator"], -- "name" => $row["Name"], -- "category" => $row["Category"], -- "description" => $row["Desc"], -- "date" => $row["Date"], -- "dateUTC" => $row["DateUTC"], -- "duration" => $row["Duration"], -- "covercharge" => $row["Cover"], -- "coveramount" => $row["Amount"], -- "simName" => $row["SimName"], -- "globalposition" => $row["GlobalPos"], -- "eventflags" => $row["EventFlags"]); -+ "event_id" => $row["eventid"], -+ "creator" => $row["creatoruuid"], -+ "name" => $row["name"], -+ "category" => $row["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( diff --git a/webroot/query.php b/webroot/query.php index d7fa8ce..8dbc3a4 100644 --- a/webroot/query.php +++ b/webroot/query.php @@ -215,42 +215,57 @@ function dir_events_query($method_name, $params, $app_data) $flags = $req['flags']; $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; + } - $terms = array(); + $pieces = explode("|", $text); + + $day = $pieces[0]; + $category = $pieces[1]; + //Setting a variable for NOW + $now = time(); + + $terms = array(); + + if ($day == "u") $terms[] = "dateUTC > ".$now.""; + + if ($category <> 0) $terms[] = "category = ".$category.""; + if ($flags & 0x2000) $terms[] = "mature = 'false'"; - $where = ""; - if (count($terms) > 0) - $where = " where " . join(" and ", $terms); + $where = ""; - $sql = "select * from events". $where. - " limit " . mysql_escape_string($query_start) . ",101"; + 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))) { + $date = strftime("%m/%d %I:%M %p",$row["dateUTC"]); + $data[] = array( - "owner_id" => $row["OwnerID"], - "name" => $row["Name"], - "event_id" => $row["EventID"], - "date" => $row["Date"], - "unix_time" => $row["UnixTime"], - "event_flags" => $row["EventFlags"]); + "owner_id" => $row["owneruuid"], + "name" => $row["name"], + "event_id" => $row["eventid"], + "date" => $date, + "unix_time" => $row["dateUTC"], + "event_flags" => $row["eventflags"]); } $response_xml = xmlrpc_encode(array( @@ -268,18 +283,38 @@ function dir_classified_query ($method_name, $params, $app_data) { $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; + } + + $sql = "select * from classifieds". $where. + " limit " . mysql_escape_string($query_start) . ",101"; + $result = mysql_query($sql); $data = array(); while (($row = mysql_fetch_assoc($result))) { $data[] = array( - "ClassifiedID" => $row["ClassifiedID"], - "Name" => $row["Name"], - "ClassifiedFlags" => $row["ClassifiedFlags"], - "CreationDate" => $row["CreationDate"], - "ExpirationDate" => $row["ExpirationDate"], - "PriceForListing" => $row["PriceForListing"]); + "classifiedid" => $row["classifieduuid"], + "name" => $row["name"], + "classifiedflags" => $row["classifiedflags"], + "creation_date" => $row["creationdate"], + "expiration_date" => $row["expirationdate"], + "priceforlisting" => $row["priceforlisting"]); } $response_xml = xmlrpc_encode(array( @@ -309,20 +344,22 @@ function event_info_query($method_name, $params, $app_data) $data = array(); while (($row = mysql_fetch_assoc($result))) { + $date = strftime("%G-%m-%d %H:%M:%S",$row["dateUTC"]); + $data[] = array( - "event_id" => $row["eventID"], - "creator" => $row["Creator"], - "name" => $row["Name"], - "category" => $row["Category"], - "description" => $row["Desc"], - "date" => $row["Date"], - "dateUTC" => $row["DateUTC"], - "duration" => $row["Duration"], - "covercharge" => $row["Cover"], - "coveramount" => $row["Amount"], - "simName" => $row["SimName"], - "globalposition" => $row["GlobalPos"], - "eventflags" => $row["EventFlags"]); + "event_id" => $row["eventid"], + "creator" => $row["creatoruuid"], + "name" => $row["name"], + "category" => $row["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(