diff --git a/webroot/parser.php b/webroot/parser.php index 7da9a12..f35e9b9 100644 --- a/webroot/parser.php +++ b/webroot/parser.php @@ -188,6 +188,18 @@ function parse($hostname, $port, $xml) $dwell = $value->getElementsByTagName("dwell")->item(0)->nodeValue; + //The image tag will only exist if the parcel has a snapshot image + $has_pic = 0; + $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; @@ -214,6 +226,11 @@ function parse($hostname, $port, $xml) $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 popularplaces WHERE parcelUUID = ?"); + $query->execute( array($parceluuid) ); + // // Save // @@ -247,6 +264,16 @@ function parse($hostname, $port, $xml) "dwell" => $dwell, "i_uuid" => $infouuid, "r_cat" => $regioncategory) ); + + $query = $db->prepare("INSERT INTO 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")