From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- web/parser.php | 317 --------------------------------------------------------- 1 file changed, 317 deletions(-) delete mode 100644 web/parser.php (limited to 'web/parser.php') diff --git a/web/parser.php b/web/parser.php deleted file mode 100644 index 4783148..0000000 --- a/web/parser.php +++ /dev/null @@ -1,317 +0,0 @@ -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; - - $updater = mysql_query("UPDATE hostsregister SET nextcheck = $next " . - "WHERE host = '" . mysql_real_escape_string($hostname) . "' AND " . - "port = '" . mysql_real_escape_string($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 = mysql_query("SELECT * FROM osregions WHERE regionuuid = '" . - mysql_real_escape_string($regionuuid) . "'"); - - if (mysql_num_rows($check) > 0) - { - mysql_query("DELETE FROM osregions WHERE regionuuid = '" . - mysql_real_escape_string($regionuuid) . "'"); - mysql_query("DELETE FROM parcels WHERE regionuuid = '" . - mysql_real_escape_string($regionuuid) . "'"); - mysql_query("DELETE FROM allparcels WHERE regionUUID = '" . - mysql_real_escape_string($regionuuid) . "'"); - mysql_query("DELETE FROM parcelsales WHERE regionUUID = '" . - mysql_real_escape_string($regionuuid) . "'"); - mysql_query("DELETE FROM objects WHERE regionuuid = '" . - mysql_real_escape_string($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 - // - $sql = "INSERT INTO osregions VALUES('" . - mysql_real_escape_string($regionname) . "','" . - mysql_real_escape_string($regionuuid) . "','" . - mysql_real_escape_string($regionhandle) . "','" . - mysql_real_escape_string($url) . "','" . - mysql_real_escape_string($username) ."','" . - mysql_real_escape_string($useruuid) ."')"; - - mysql_query($sql); - - // - // 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; - - $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; - - // - // Save - // - $sql = "INSERT INTO allparcels VALUES('" . - mysql_real_escape_string($regionuuid) . "','" . - mysql_real_escape_string($parcelname) . "','" . - mysql_real_escape_string($owneruuid) . "','" . - mysql_real_escape_string($groupuuid) . "','" . - mysql_real_escape_string($parcellanding) . "','" . - mysql_real_escape_string($parceluuid) . "','" . - mysql_real_escape_string($infouuid) . "','" . - mysql_real_escape_string($parcelarea) . "' )"; - - mysql_query($sql); - - if ($parceldirectory == "true") - { - $sql = "INSERT INTO parcels VALUES('" . - mysql_real_escape_string($regionuuid) . "','" . - mysql_real_escape_string($parcelname) . "','" . - mysql_real_escape_string($parceluuid) . "','" . - mysql_real_escape_string($parcellanding) . "','" . - mysql_real_escape_string($parceldescription) . "','" . - mysql_real_escape_string($parcelcategory) . "','" . - mysql_real_escape_string($parcelbuild) . "','" . - mysql_real_escape_string($parcelscript) . "','" . - mysql_real_escape_string($parcelpublic) . "','". - mysql_real_escape_string($dwell) . "','" . - mysql_real_escape_string($infouuid) . "','" . - mysql_real_escape_string($regioncategory) . "')"; - - mysql_query($sql); - } - - if ($parcelforsale == "true") - { - $sql = "INSERT INTO parcelsales VALUES('" . - mysql_real_escape_string($regionuuid) . "','" . - mysql_real_escape_string($parcelname) . "','" . - mysql_real_escape_string($parceluuid) . "','" . - mysql_real_escape_string($parcelarea) . "','" . - mysql_real_escape_string($parcelsaleprice) . "','" . - mysql_real_escape_string($parcellanding) . "','" . - mysql_real_escape_string($infouuid) . "', '" . - mysql_real_escape_string($dwell) . "', '" . - mysql_real_escape_string($estateid) . "', '" . - mysql_real_escape_string($regioncategory) . "')"; - - mysql_query($sql); - } - } - - // - // 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; - - mysql_query("INSERT INTO objects VALUES('" . - mysql_real_escape_string($uuid) . "','" . - mysql_real_escape_string($parceluuid) . "','" . - mysql_real_escape_string($location) . "','" . - mysql_real_escape_string($title) . "','" . - mysql_real_escape_string($description) . "','" . - mysql_real_escape_string($regionuuid) . "')"); - } - } -} - -$sql = "SELECT host, port FROM hostsregister " . - "WHERE nextcheck < $now AND checked = 0 LIMIT 0,10"; - -$jobsearch = mysql_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 (mysql_num_rows($jobsearch) == 0) -{ - mysql_query("UPDATE hostsregister SET checked = 0"); - $jobsearch = mysql_query($sql); -} - -while ($jobs = mysql_fetch_row($jobsearch)) - CheckHost($jobs[0], $jobs[1]); -?> -- cgit v1.1