|
From: <ma...@sc...> - 2006-04-14 13:08:28
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20671 Modified Files: google.php Log Message: got rid of the last few bugs, expiry now works properly Index: google.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/google.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- google.php 13 Apr 2006 18:02:40 -0000 1.3 +++ google.php 14 Apr 2006 13:08:20 -0000 1.4 @@ -13,7 +13,7 @@ echo " <Folder><name>error: $error</name></Folder>\n"; echo " </Document>\n"; echo "</kml>\n"; - return; + exit(0); } /* restrict to one node */ @@ -27,9 +27,12 @@ $links = $HTTP_GET_VARS['links']; } - /* used to mark an error */ - $rows = 0; - + /* show links to peers */ + $maxdays = 365 * 2; + if (isset($HTTP_GET_VARS['maxdays'])) { + $maxdays = $HTTP_GET_VARS['maxdays']; + } + /* Connect */ $db = mysql_connect($MYSQLHOST, $MYSQLUSER, $MYSQLPASS); mysql_select_db($MYSQLDB, $db) @@ -42,13 +45,13 @@ $updated = intval($row[0]); /* comment this out if testing */ - //header("Last-Modified: ".gmdate("D, d M Y H:i:s", $updated)." GMT"); + header("Last-Modified: ".gmdate("D, d M Y H:i:s", $updated)." GMT"); /* give back memory */ mysql_free_result($result); - /* single or multiple query */ - $query = "SELECT a.nodeid,a.nodename,a.status,a.updated,p.e,p.n,p.h,c.contactname FROM admin a, physloc p, contact c where a.nodeid = p.nodeid and a.nodeid=c.nodeid and p.e is not NULL and p.n is not null"; + /* single or multiple query (limits results to $maxdays, *unless* the node is "nan" or either end of an established link) */ + $query = "SELECT a.nodeid,a.nodename,a.status,a.updated,p.e,p.n,p.h,c.contactname FROM admin a, physloc p, contact c where (a.nodeid = p.nodeid and a.nodeid=c.nodeid and p.e is not NULL and p.n is not null) and ((DATE_SUB(CURDATE(),INTERVAL ".$maxdays." DAY) <= a.updated) or a.status = 'nan' or EXISTS (select * from netloc where peerid = a.nodeid) or EXISTS (select * from netloc where nodeid = a.nodeid))"; if (isset($nodeid)) { $query = $query . " and a.nodeid=$nodeid"; } else { @@ -64,8 +67,10 @@ echo "<kml xmlns=\"http://earth.google.com/kml/2.0\">\n"; echo "<Document>\n"; - /* predefine styles to save space */ - /* start icon styles */ + /* 0 used to mark "not found" later */ + $rows = 0; + + /* predefine styles to save space later, these are referred to when the nodes and links are written out */ $validStyles = array ("nan","interest","build","gather","waiting","test","full","default"); for ($i=0; $i<8; $i++) { @@ -120,10 +125,14 @@ echo " <h>$sizey</h>\n"; echo " </Icon>\n"; echo " </IconStyle>\n"; + + /* default label seems to be fine, so no change for now */ //echo " <LabelStyle id=\"labelStyle_$validStyles[$i]\">\n"; //echo " <color>7fffaaff</color>\n"; //echo " <scale>1.5</scale>\n"; //echo " </LabelStyle>\n"; + + /* style for line extrused from ground to $alt */ echo " <LineStyle id=\"lineStyle_$validStyles[$i]\">\n"; echo " <color>ff0000ff</color>\n"; echo " <width>3</width>\n"; @@ -138,7 +147,7 @@ echo " <color>7fff0000</color>\n"; echo " <width>3</width>\n"; echo " </LineStyle>\n"; - echo " <IconStyle id=\"iconStyle_$validStyles[$i]\">\n"; + echo " <IconStyle id=\"iconStyle_linkStyle\">\n"; echo " <Icon>\n"; echo " <href>root://icons/palette-5.png</href>\n"; echo " <x>96</x>\n"; @@ -171,7 +180,7 @@ $lat = $lat_lon[0]; $lon = $lat_lon[1]; - /* skip invalid values */ + /* skip invalid values (out of zone coords) */ if ($lat == 0 || $lon == 0) { echo "<!-- zero lat=$lat OR lon=$lon, skipping -->/n"; continue; @@ -187,7 +196,7 @@ /* display the row */ echo " <Placemark>\n"; echo " <description><![CDATA[Contact's Name: " . htmlspecialchars($row['contactname']) . "<br>View <a href=\"http://www.itee.uq.edu.au/~mesh/db-srtm/view.php?nodeid=".$row['nodeid']."\">Node Details</a> on BrisMESH<br>Last Updated: ".$updated."]]></description>\n"; - echo " <name><![CDATA[" . htmlspecialchars($row['nodename']) . "]]></name>\n"; + echo " <name><![CDATA[" . $row['nodename'] . "]]></name>\n"; echo " <styleUrl>$style</styleUrl>\n"; echo " <LookAt>\n"; echo " <longitude>$lon</longitude>\n"; @@ -209,16 +218,17 @@ /* add links as placemarks */ if ($links == 1) { - - /* find this node's links, if none or error, do nothing */ + + /* find current node's peers, and thier locations (in eastings / northings) */ $query2 = "SELECT n.nodeid, n.peerid, p1.e as e1, p1.n as n1, p1.h as h1, p2.e as e2, p2.n as n2, p2.h as h2 from netloc n, physloc p1, physloc p2 where n.nodeid is not null and n.peerid is not null and n.nodeid=p1.nodeid and n.peerid=p2.nodeid and n.nodeid=" . $row['nodeid']; + /* find this node's links, if none or error, do nothing */ if ($result2 = mysql_query($query2, $db)) { /* now do "placemarks" for node links */ while (($row2 = mysql_fetch_assoc($result2))) { - /* convert to lat / lon for p1 */ + /* convert eastings / northings to lat / lon for nodeid */ $lat_lon1 = cvtlatlon($row2['e1'], $row2['n1']); $lat1 = $lat_lon1[0]; $lon1 = $lat_lon1[1]; @@ -227,7 +237,7 @@ $alt1 = $row2['h1']; } - /* convert to lat / lon for p2 */ + /* convert eastings / northings to lat / lon for peerid */ $lat_lon2 = cvtlatlon($row2['e2'], $row2['n2']); $lat2 = $lat_lon2[0]; $lon2 = $lat_lon2[1]; @@ -267,9 +277,9 @@ /* if we got no rows, display an error */ if ($rows == 0) { if (isset($nodeid)) { - echo "<Folder><name>no results available</name></Folder>"; + echo "<Folder><name>Node ".$nodeid." not valid.</name></Folder>"; } else { - echo "<Folder><name>Node ".$nodeid." is not valid.</name></Folder>"; + echo "<Folder><name>no results available</name></Folder>"; } } |