You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(49) |
Sep
(25) |
Oct
(2) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(24) |
Nov
(50) |
Dec
(4) |
2004 |
Jan
(2) |
Feb
(2) |
Mar
(5) |
Apr
|
May
(10) |
Jun
|
Jul
(10) |
Aug
(22) |
Sep
(10) |
Oct
|
Nov
(57) |
Dec
(5) |
2005 |
Jan
(24) |
Feb
(12) |
Mar
|
Apr
|
May
(3) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
(5) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
From: <il...@pr...> - 2005-02-16 11:18:00
|
Update of /cvsroot/meshdb/src/geo/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25181/src/geo/dist Modified Files: create.sql Log Message: Added a status column to netloc, to allow people that have a pressing desire to record interfaces that aren't yet working to do so without them appearing on the network maps. Index: create.sql =================================================================== RCS file: /cvsroot/meshdb/src/geo/dist/create.sql,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- create.sql 27 Jul 2004 08:09:33 -0000 1.2 +++ create.sql 16 Feb 2005 11:17:34 -0000 1.3 @@ -70,6 +70,7 @@ peerid int(11) default NULL, mac mediumtext, ifname varchar(16) NOT NULL default '', + status tinytext, active tinyint(4) NOT NULL default '0', comment mediumtext, channel tinyint(4) default NULL, |
From: <il...@pr...> - 2005-02-16 10:52:56
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20274 Modified Files: map4b.php Log Message: For interfaces running as access points (i.e. those without peers entered), show only the portion of the circle that represents the direction in which radiation is being emitted (based on the recorded direction and spread). Partial ImageArc was buggy in old versions of GD/PHP but appears to be reliable now. Index: map4b.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/map4b.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- map4b.php 9 May 2004 03:32:30 -0000 1.4 +++ map4b.php 16 Feb 2005 10:52:46 -0000 1.5 @@ -91,12 +91,17 @@ .",e" .",n" .",active" + .",antspread" + .",direction" ." FROM" ." netloc" + .",config" .",admin" .",physloc" ." WHERE" - ." physloc.nodeid = netloc.nodeid AND admin.nodeid = netloc.nodeid" + ." physloc.nodeid = netloc.nodeid" + ." AND admin.nodeid = netloc.nodeid" + ." AND config.nodeid = netloc.nodeid" ." AND" ." peerid is null" ." AND" @@ -109,8 +114,20 @@ $result = mysql_query($q, $db) or die(mysql_error($db)); while ($row = mysql_fetch_assoc($result)) { + if (isset($row["antspread"]) + && (isset($row["direction"]) || intval($row["antspread"] == 360))) { + $start = intval($row["direction"]) - 90 - intval($row["antspread"]) / 2; + $end = intval($row["direction"]) - 90 + intval($row["antspread"]) / 2; + if ($start < 0) { + $start += 360; + $end += 360; + } + } else { + $start = 0; + $end = 360; + } list($x,$y) = coord(doubleval($row["e"]), doubleval($row["n"])); - ImageArc($im, $x,$y, 10, 10, 0, 360, + ImageArc($im, $x,$y, 10, 10, $start, $end, intval($row["active"]) ? $LIGHTBLUE : $LIGHTGREY); plotx($im, $x, $y, $RED, $row["nodename"], $BLACK); } |
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12631 Modified Files: Tag: leonard-dev address.html cookies.inc cookies.php create.php edit.php elev.php footer.inc gps.php index.php map2d.inc map3b.php map4b.php search.php select.php submit.php touch.php touchgraph.php util.php view.php Added Files: Tag: leonard-dev official-style.css view-maps.inc.php view-util.inc Log Message: * Add an extra preference variable "mode", which is either "official", "public" or "all" (defaults "official".. for now). * Add a new 'official' stylesheet which has a purple theme. This is is to visually distinguish between the different modes. It is only in effect in 'official' mode (and can't be usurped by stylesheet pref). * Correct the cookies.php script so it returns you to the calling page when you 'save changes'. It also adds an extra bit to the URL that should cause a cache miss, but is otherwise harmless. * Add a 'readonly' check inside edit.php * Split the overlay map code out into a separate file (still work in progress) * Correct index.php's broken overlay map code. * Add a debug() function which allows scripts to send messages to Apache's error_log. * Use the $BINDIR var (from the config file) when finding some programs. * Correct bug in overlay map where checkboxes weren't de-checking. --- NEW FILE: official-style.css --- /* Overrides for 'official' mode. Mostly a purplish color scheme. */ @import url("style.css"); body { background-color: rgb(90%,90%,95%); font-family: "Arial" } th.major { background-color: purple; color: white; } th.minor { background-color: rgb(70%,70%,85%); color: purple;} --- NEW FILE: view-maps.inc.php --- <!-- begin view-maps.inc --> <script lang="javascript"> <!-- /** * Converts a boolean into a visibility style string * @param b boolean visibility * @return the string "visible" or "hidden" */ function getVisString(b) { return b ? "visible" : "hidden"; } /** * Changes a layer's visibility. * @param n The layer's name (ID) * @param b A boolean indicating the desired visibility */ var setMapLayerVisibility; if (document.getElementById) setMapLayerVisibility = function(n,b) { document.getElementById(n).style.visibility = getVisString(b); }; else if (document.all) setMapLayerVisibility = function(n,b) { document.all[n].style.visibility = getVisString(b); }; else if (document.layers) setMapLayerVisibility = function(n,b) { document[n].visibility = getVisString(b); }; else setMapLayerVisibility = function(n,b) { alert("Can't figure out how to change visibility; report this error!"); }; /** * Called when a checkbox changes (or is clicked). * @param chk the checkbox that changed * @return false, indicating that other handlers should be called */ function layerBoxChanged(chk) { var name = chk.name.substring(3); setMapLayerVisibility("MAP"+name, chk.checked); return true; } // --> </script> <? global $IMGWIDTH, $IMGHEIGHT; global $zoom; global $nodeid,$e,$n,$s; global $peerid,$e2,$n2,$h2; global $hasloc, $PREF; include("view-util.inc"); $maps = explode(" ", trim($PREF["viewmaplist"])); if ($hasloc && count($maps)) { $w = $IMGWIDTH; $h = $IMGHEIGHT; $mdist = $peerid ? sqrt(($e-$e2)*($e-$e2) + ($n-$n2)*($n-$n2)) : 0; if (isset($_GET["zoom"])) { $zoom = doubleval($_GET["zoom"]); $mdist = 0; } else if ($mdist > 0) $zoom = 1; else $zoom = $PREF["viewzoom"]; echo "<!-- mdist=$mdist e=$e e2=$e2 n=$n n2=$n2 -->\n"; if ($mdist < 1 || $peerid == "") $mdist = 20000; /* use a base distance of 20km */ if ($s == 0) $s = $zoom * sqrt($w*$h) / $mdist / 4; echo "<!-- peerid=$peerid mdist=$mdist s=$s -->\n"; $param = "s=${s}&w=${w}&h=${h}&n=${n}&e=${e}"; $paramb = $param; /* paranoia */ $e=doubleval($e); $n=doubleval($n); $w=doubleval($w); $h=doubleval($h); $s=doubleval($s); $altinfo = split(" ", mybacktick("$BINDIR/alt -t" ." -S ${SHIFTFILE} -A ${ALTFILE}" ." $e $n $w $h $s")); if (isnan($altinfo[0])) $localt = "unknown"; else $localt = sprintf("%.2fm", $altinfo[0]); $minalt = sprintf("%.2f", $altinfo[1]); $maxalt = sprintf("%.2f", $altinfo[2]); $De = $w / $s / 2; $Dn = $h / $s / 2; $q = "SELECT" ." admin.nodeid AS nodeid," ." e," ." n," ." nodename," ." ((e-$e)*(e-$e) + (n-$n)*(n-$n)) AS distance" ." FROM admin, physloc" ." WHERE admin.nodeid = physloc.nodeid" ." AND n>".($n-$Dn) ." AND n<".($n+$Dn) ." AND e>".($e-$De) ." AND e<".($e+$De) ." AND admin.nodeid != $nodeid" ." AND to_days(now()) - to_days(admin.updated) <= ".$PREF["maxnodeage"] ." ORDER BY distance DESC"; $result = mysql_query($q, $db); $i = 0; $mapdef = ""; while ($row = mysql_fetch_assoc($result)) { $param .= "&pe[$i]=$row[e]"; $param .= "&pn[$i]=$row[n]"; $param .= "&pl[$i]=".urlencode($row["nodename"]); if ($peerid && $peerid == $row["nodeid"]) { $param .= "&pt[$i]=o"; $param .= "&pi[$i]=5"; } else $param .= "&pt[$i]=x"; $x = intval($w/2 + ($row["e"]-$e)*$s); $y = intval($h/2 - ($row["n"]-$n)*$s); $mapdef .= "<area href=\"view.php?nodeid=$row[nodeid]\""; $mapdef .= " alt=\"".htmlspecialchars($row["nodename"])."\""; $mapdef .= " shape=circle coords=\"$x,$y,8\">\n"; $i++; /* if internet explorer, we should cull far nodes? */ } $param .= "&pe[$i]=$e&pn[$i]=$n"; $param .= "&pi[$i]=5"; $param .= "&pl[$i]=".urlencode(val("admin[nodename]")); $paramb .= "&t[$nodeid]=X"; if ($peerid) $paramb .= "&t[$peerid]=o"; $paramb .= "&maxage=".$PREF["maxnodeage"]; $param = htmlspecialchars($param); $paramb = htmlspecialchars($paramb); ?> <map name="nodes"><?=$mapdef?></map> <table class="maps"> <tr><th class="major">Maps</th></tr> <? /* Returns an URL that zooms in/out */ function zoomlink($desired, $current) { if ($desired < 1) $desiredtext = round(1 / -$desired); else $desiredtext = $desired; if ($desired != $current) print "<a href=".selfurl(array("zoom"=>$desired)).">".$desiredtext."x</a>"; else print $desiredtext . "x"; } /* Prints HTML that provides zoom in/out choices */ function zoomlinks($current) { ?> zoom: <a href="<?=selfurl(array("zoom"=>$current*2))?>">in</a> | <?=zoomlink(16, $current)?> | <?=zoomlink(8, $current)?> | <?=zoomlink(4, $current)?> | <?=zoomlink(2, $current)?> | <?=zoomlink(1, $current)?> | <?=zoomlink(0.5, $current)?> | <?=zoomlink(0.25, $current)?> | <a href="<?=selfurl(array("zoom"=>$current/2))?>">out</a> <? } $layers = array(); function printlayeredmaps($layers,$w,$h,$zoom) { if (count($layers)) { ?> <tr><th class="minor">Integrated maps</th></tr> <tr><th class="figure"><table><tr><td><div id=integrated style="position: relative"><? foreach ($layers as $l) { print "<div id=\"MAP". $l["name"] ."\" style=\"position: absolute\">" ."<img style=\"border:none\" usemap=\"#nodes\" src=\"".$l["url"]."\" width=$w height=$h></div>\n"; } print "</div><img style=\"border:none\" src=\"white.gif\" width=$w height=$h></td><td>"; print "<form name=\"FORM1\">"; foreach ($layers as $l) { print "<nobr>" ."<input type=checkbox name=\"BOX".$l["name"]."\" checked" ." onClick=\"return layerBoxChanged(this)\"" .">" . $l["name"] . "</nobr><br>"; } print "</form></td></tr></table></td></tr>"; ?> <tr><td class="caption"><? zoomlinks($zoom); foreach ($layers as $l) { if ($l["info"]) { print "<br><i>".$l["name"]." info:</i> ".$l["info"]; } } ?> </td></tr> <? } } foreach ($maps as $maptype) { $mapname = ""; $mapdesc = ""; $mapurl = ""; $mapinfo = ""; if ($maptype == "net") { $mapname = "Network"; $mapdesc = "Active node-to-node links"; $mapurl = "map4b.php?$paramb"; $mapinfo = "Key: <font color=blue>-</font> active," ." <font color=gray>-</font> inactive," ."<font color=gray>O</font> multipeer"; } else if ($maptype == "loc") { $mapname = "Location"; $mapdesc = "Street directory features"; $mapurl = "map2b.php?$paramb"; } else if ($maptype == "ter") { $mapname = "Terrain"; $mapdesc = "Surface altitude and visibility"; $mapurl = "map3b.php?$paramb&nodeid=$nodeid"; $mapinfo = "Ground height at site: " . "<strong>$localt</strong> AHD est.<br>" . "Range: low <font color=blue>$minalt</font>m" . " high <font color=green>$maxalt</font>m<br>" . " Blue shows predicted visible area"; } if ($mapname) { if ($nolayers) { ?> <tr><th class="minor"><?=$mapname?></th></tr> <tr><td class="figure"><img width=<?=$w?> height=<?=$h?> usemap="#nodes" src="<?=$mapurl?>" title="<?=$mapdesc?>"</td></tr> <tr><td class="caption"><?=zoomlinks($zoom)?> <? if ($mapinfo) { print "<br>".$mapinfo; } ?> </td></tr> <? } else { array_push($layers, array( "name" => $mapname, "desc" => $mapdesc, "url" => $mapurl, "info" => $mapinfo)); } } else { printlayeredmaps($layers,$w,$h,$zoom); $layers = array(); } if ($maptype == "elev") { ?> <tr><th class="minor">Elevation diagram</th></tr> <tr><td><form action="view.php"> Peer node: <select name="peerid"> <? $peername = "#$peerid"; $limit = ""; /* $limit = "LIMIT 255"; */ $nodename = htmlspecialchars($admin["nodename"]); if (!$peerid) echo "<option value=\"\" selected>(none)</option>\n"; if ($PREF["viewpeersortdist"]) { $sort = "dist"; if (intval($PREF["viewpeermenulimit"]) > 0) $limit = "LIMIT ".intval($PREF["viewpeermenulimit"]); } else $sort = "admin.nodeid"; $result = mysql_query("SELECT" ." admin.nodeid," ." nodename," ." sqrt(pow($n - n, 2) + pow($e - e, 2)) AS dist" ." FROM admin,physloc" ." WHERE admin.nodeid = physloc.nodeid" ." AND n IS NOT NULL" ." AND e IS NOT NULL" ." AND to_days(now()) - to_days(admin.updated) <= ".$PREF["maxnodeage"] ." ORDER BY $sort" ." $limit", $db) or die(mysql_error($db)); while ($row = mysql_fetch_assoc($result)) { if (intval($row["nodeid"]) == $nodeid) continue; echo "<option value=\"".$row["nodeid"]."\""; if ($peerid && $row["nodeid"] == $peerid) { echo " selected"; $peername = htmlspecialchars($row["nodename"]); } echo ">". htmlspecialchars($row["nodeid"]." ".$row["nodename"]); printf(", %.1fkm", $row["dist"] / 1000); echo "</option>\n"; } if ($limit != "") echo "<option value=\"-\">... (truncated)</option>\n"; ?> </select> <!-- input name="peerid" value="<?=$peerid?>" size=6 --> <input type=submit value="plot"> <input type=hidden name="nodeid" value="<?=$nodeid?>"> </form> <?=$peermsg?> </td></tr> <? if ($peerid) { $w = $IMGWIDTH; $hh = $IMGHEIGHT / 2; $info = elev($physloc, $peerloc); if (isnan($info["distance"])) { $distance = "unknown"; $pathloss24 = 0; $pathloss58 = 0; } else { /* * Lp = 20*log10(4*pi*R/lambda) dB * = 20*log10(4*pi*R*f/c) dB where c=299792458 m/s * = 20*log10(R) + 40.17 @ f=2.431e9 * = 20*log10(R) + 47.72 @ f=5.8e9 */ $distance = doubleval($info["distance"]); $pathloss24 = 20*log10($distance) + 40.1652687; $pathloss58 = 20*log10($distance) + 47.7163430931; $distance = sprintf("%.2fm", $distance); } if (isnan($info["incl1"]) || isnan($info["incl2"])) { $incl1 = $incl2 = "?"; } else { $incl1 = sprintf("%.2f", doubleval($info["incl1"]) * 180 / M_PI); $incl2 = sprintf("%.2f", doubleval($info["incl2"]) * 180 / M_PI); } ?> <tr><td><table> <tr><td valign=top><?printf("%.0f", $info["altmax"])?>m</td> <td class="figure" colspan=2 rowspan=2><img width="<?=$w?>" height="<?=$hh?>" src="<?=elevurl($physloc, $peerloc, $w, $hh)?>"></td></tr> <tr><td valign=bottom> <?printf("%.0f", $info["altmin"])?>m</td></tr> <tr><td></td> <td colspan=2 class="caption" align=center><?=$distance?></td></tr> <tr><td></td> <td class="caption"> <strong><?=$nodename?></strong> <br> Altitude: <? printf("%.2f", $info["alt1"] + $h1); ?>m <br> Azimuth: <? printf("%.2f", $info["bearing1"]); ?>° <br> Inclination: <?=$incl1?>° </td> <td class="caption"> <strong><a href="view.php?nodeid=<?=$peerid?>&peerid=<?=$nodeid?>"><?=$peername?></a></strong> <br> Altitude: <? printf("%.2f", $info["alt2"] + $h2); ?>m <br> Azimuth: <? printf("%.2f", $info["bearing2"]); ?>° <br> Inclination: <?=$incl2?>° </td> </tr> </table> <? if ($distance > 0) { ?> <p> Clear path loss: <ul> <li> <?printf("%.2f", $pathloss24);?>dB <small>@ 2.4GHz</small> <li> <?printf("%.2f", $pathloss58);?>dB <small>@ 5.8GHz</small> </ul> </p> <? } ?> </td></tr> <? } /* elevation diagram */ } else if ($maptype == "elev") { ?> <tr><th class="minor">Unknown: <?=htmlspecialchars($maptype)?></th></tr> <? } } /* foreach maptype */ printlayeredmaps($layers,$w,$h,$zoom); ?> </table> <? } /* hasloc (maps) */ else { ?> <i>Can't plot maps without location!</i> <? } /* !hasloc (maps) */ ?> <!-- end view-maps.inc --> --- NEW FILE: view-util.inc --- <? /* * Returns an URL to this page, merging the array $a * into the current _GET array */ function selfurl($a) { $oa = array(); $defvars = array("nodeid", "peerid", "zoom"); foreach ($defvars as $k) { if (isset($_GET[$k])) $oa[$k] = $_GET[$k]; } $oa = array_merge($oa, $a); $url = ""; foreach ($oa as $k => $v) { if ($url != "") $url .= "&"; $url .= urlencode($k) ."=". urlencode($v); } return "view.php?" . $url; } /* Returns a global value, named as "<name>[<key>]" or "name". * This is called by every val* function below. */ function valof($name) { if (substr($name, strlen($name) - 1, 1) == "]") { $zz = split('\[', substr($name, 0, strlen($name) - 1)); $an = $zz[0]; $kn = $zz[1]; return $GLOBALS[$an][$kn]; } else return $$name; /* XXX $GLOBALS[$name] ? */ } /* Protects and returns a normal variable in HTML */ function val($name, $attr = "") { /* convert @ to @ as spam bots mightn't see them */ return str_replace("@", "@", htmlspecialchars(valof($name))); } /* Returns a plain URL variable as HTML */ function valurl($name, $attr = "") { $v = valof($name); if ($v == "") return ""; return "<a href=\"$v\">". htmlspecialchars($v) . "</a>"; } /* Returns an image URL variable as HTML */ function valimgurl($name, $attr = "", $alt="Site image") { $v = valof($name); if ($v == "") return ""; return "<a href=\"$v\"><img src=\"$v\" alt=\"" .htmlspecialchars($alt)."\"" ." style=\"max-width: 20em\"" ."></a>"; } /* Return a multiline text variable in HTML */ function valtext($name, $attr = "") { /* Replace 'node #nn' with a hyperlink */ $markeduptext = eregi_replace("(node #?([0-9]+))", "<a href=\"view.php?nodeid=\\2\">\\1</a>", htmlspecialchars(valof($name))); return "<span class=\"text\">$markeduptext</span>"; } /* Return a code-like variable in HTML */ function valcode($name, $attr = "") { return "<code>".htmlspecialchars(valof($name))."</code>"; } /* Return a nodeid variable as a pull-down HTML */ function valnodeid($name, $attr = "") { global $db; global $PREF; $v = valof($name); if ($v == "") return "<i>none</i>"; $v = intval($v); $result = mysql_query("SELECT" ." nodename," ." to_days(now()) - to_days(admin.updated) AS age" ." FROM admin" ." WHERE nodeid=$v", $db) or die(mysql_error($db)); $row = mysql_fetch_row($result); if ($row) { $v .= " <i>(<a href=\"view.php?nodeid=$v\">".htmlspecialchars($row[0])."</a>)</i>"; if ($row[1] > $PREF["maxnodeage"]) $v .= " <strong>(old)</strong>"; } else $v .= " <strong>(invalid)</strong>"; return $v; } /* Return a boolean variable as Yes or No */ function valyesno($name, $attr = "") { if (valof($name)) return "Yes"; else return "No"; } function selectval($name, $options, $attr = "") { return htmlspecialchars($options[valof($name)]); } function edithelp($text) { } /* Computes a map of useful calculations about two physloc records */ function elev($loc1, $loc2) { global $ZONE, $SHIFTFILE, $ALTFILE, $BINDIR; $e1 = doubleval($loc1["e"]); $n1 = doubleval($loc1["n"]); $h1 = doubleval($loc1["h"]); $e2 = doubleval($loc2["e"]); $n2 = doubleval($loc2["n"]); $h2 = doubleval($loc2["h"]); $info = split(" ", mybacktick("$BINDIR/elev" ." -z ${ZONE}" ." -S ${SHIFTFILE}" ." -A ${ALTFILE}" ." -a $e1 $n1 $h1" ." -b $e2 $n2 $h2")); $distance = $info[0]; $bearing1 = doubleval($info[1]) * 180 / M_PI; if ($bearing1 < 0) $bearing1 += 360; $bearing2 = doubleval($info[2]) * 180 / M_PI; if ($bearing2 < 0) $bearing2 += 360; $alt1 = doubleval($info[3]); $alt2 = doubleval($info[4]); $altmin = doubleval($info[5]); $altmax = doubleval($info[6]); $incl1 = $info[7]; $incl2 = $info[8]; $isclear = intval($info[9]); return array("distance" => $distance, "bearing1" => $bearing1, "bearing2" => $bearing2, "alt1" => $alt1, "alt2" => $alt2, "altmin" => $altmin, "altmax" => $altmax, "incl1" => $incl1, "incl2" => $incl2, "isclear" => $isclear); } /* Returns an URL to an elevation diagram for two locs */ function elevurl($loc1, $loc2, $w, $h) { $e1 = doubleval($loc1["e"]); $n1 = doubleval($loc1["n"]); $h1 = doubleval($loc1["h"]); $e2 = doubleval($loc2["e"]); $n2 = doubleval($loc2["n"]); $h2 = doubleval($loc2["h"]); $elevarg = "e1=$e1&n1=$n1&h1=$h1&e2=$e2&n2=$n2&h2=$h2&w=$w&h=$h"; return "elev.php?" . htmlspecialchars($elevarg); } ?> Index: address.html =================================================================== RCS file: /cvsroot/meshdb/www/db2/address.html,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- address.html 2 Nov 2003 02:07:00 -0000 1.2 +++ address.html 12 Feb 2005 06:05:41 -0000 1.2.2.1 @@ -1,8 +1,8 @@ <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> -<link rel="start" href="index.php"> <link rel="icon" href="favicon.ico"> +<link rel="start" href="index.php"> <title>How to obtain and allocate IPv6 addresses</title> <style type="text/css"> blockquote { font-style: italic; } Index: cookies.inc =================================================================== RCS file: /cvsroot/meshdb/www/db2/cookies.inc,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -d -r1.5 -r1.5.2.1 --- cookies.inc 9 May 2004 03:32:30 -0000 1.5 +++ cookies.inc 12 Feb 2005 06:05:41 -0000 1.5.2.1 @@ -1,7 +1,7 @@ <? /* Load default or cookie preferences */ - global $PREF; + global $PREF, $STYLESHEET; $PREF = array( "stylesheet" => "style.css", "imgsz" => "350", @@ -16,8 +16,8 @@ "viewlosonly" => "0", "maxnodeage" => "1000", "_moddate" => "0", - "viewmaplist" => "net loc ter elev", - + "viewmaplist" => "loc ter net elev", + "mode" => "official", ); $PREF_integers = array("imgsz", "myid", "indexlimit", @@ -41,4 +41,8 @@ } } + + $STYLESHEET = $PREF["mode"] == "official" + ? "official-style.css" + : $PREF["stylesheet"]; ?> Index: cookies.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/cookies.php,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -d -r1.10 -r1.10.2.1 --- cookies.php 9 May 2004 03:45:24 -0000 1.10 +++ cookies.php 12 Feb 2005 06:05:41 -0000 1.10.2.1 @@ -1,6 +1,16 @@ <? include("config.php"); + function referer() { + global $_SERVER; + if ($_SERVER["HTTP_REFERER"] == "") + return "http://" . $_SERVER["HTTP_HOST"] + . dirname($_SERVER["PHP_SELF"]) + . "/"; + else + return $_SERVER["HTTP_REFERER"]; + } + if (isset($_POST["submit"])) { global $PREF; $x = "_moddate=".strval(time()); @@ -20,6 +30,9 @@ $dbloc = substr($pageloc, 0, strrpos($pageloc, "/")); setcookie("preferences", $x, time()+365*24*60*60, $dbloc, $_SERVER["HTTP_HOST"], 0); + $location = $_POST["referer"] . ";nocache=" . time(); + header("Location: " . $location); + exit ("redirecting to $location"); } $yesno = array("0" => "no", "1" => "yes"); @@ -49,6 +62,13 @@ "Age:desc" => "by age descending", "Distance:asc" => "by distance to your node, asc", "Distance:desc" => "by distance to your node, desc")), + "mode" => array("Database view mode", + "select", "Changes the node view filter", + array( + "official" => "official (Brismesh Inc.)", + "public" => "public (non-member)", + "all" => "all nodes", + )), "wantgps" => array("GPS coords", "select", "Use GPS lat/long instead of UTM eastings/northings", $yesno), @@ -125,6 +145,12 @@ </tr> </table> + +<? $referer = referer(); ?> +<p>After saving, you will be returned to +<a href="<?=htmlspecialchars($referer)?>">where you were before</a>. +<input type=hidden name="referer" value="<?=htmlspecialchars($referer)?>"> + </form> <!-- Index: create.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/create.php,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- create.php 12 Jan 2004 09:15:22 -0000 1.4 +++ create.php 12 Feb 2005 06:05:41 -0000 1.4.2.1 @@ -2,7 +2,7 @@ <html> <head> -<link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> +<link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="icon" href="favicon.ico"> <title>Create new node</title> </head> Index: edit.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/edit.php,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- edit.php 11 Jul 2004 09:23:58 -0000 1.3 +++ edit.php 12 Feb 2005 06:05:41 -0000 1.3.2.1 @@ -3,6 +3,9 @@ include("config.php"); $EDITONLY = 1; + if ($READONLY) + die("database has been marked read only"); + if (isset($_GET["nodeid"])) $nodeid = $_GET["nodeid"]; if ($nodeid == "") @@ -14,7 +17,7 @@ ?> <head> -<link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> +<link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="icon" href="favicon.ico"> <title>Edit node #<?=$nodeid?>: <?=htmlspecialchars(valof("admin[nodename]"))?></title> </head> Index: elev.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/elev.php,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -u -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 --- elev.php 7 Nov 2004 05:50:06 -0000 1.1.1.1.2.1 +++ elev.php 12 Feb 2005 06:05:41 -0000 1.1.1.1.2.2 @@ -21,7 +21,7 @@ header("Content-type: image/png"); /* if ($REQUEST_METHOD == "GET") */ - mypassthru("$BINDIR/elev" + mypassthru("${BINDIR}/elev" ." -i -g ${w}x${h}" ." -z ${ZONE}" ." -S ${SHIFTFILE} -A ${ALTFILE}" Index: footer.inc =================================================================== RCS file: /cvsroot/meshdb/www/db2/footer.inc,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- footer.inc 18 Sep 2004 01:31:45 -0000 1.3 +++ footer.inc 12 Feb 2005 06:05:41 -0000 1.3.2.1 @@ -10,7 +10,7 @@ echo "<a href=\"edit.php?nodeid=$n\">Edit #$n</a> | "; } if ($this != "cookies.php") - echo "<a href=\"cookies.php\">Preferences</a> | "; + echo "<a href=\"cookies.php?\">Preferences</a> | "; if ($this != "index.php") echo "<a href=\".\">Database index</a> | "; ?> Index: gps.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/gps.php,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.3 diff -u -d -r1.3.2.2 -r1.3.2.3 --- gps.php 7 Nov 2004 05:50:06 -0000 1.3.2.2 +++ gps.php 12 Feb 2005 06:05:41 -0000 1.3.2.3 @@ -1,7 +1,7 @@ <? include("config.php"); ?> <html> <head> -<link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> +<link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="icon" href="favicon.ico"> <title>Convert between GPS/curvilinear and UTM/grid</title> <body> Index: index.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/index.php,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -d -r1.11 -r1.11.2.1 --- index.php 28 Jul 2004 07:43:01 -0000 1.11 +++ index.php 12 Feb 2005 06:05:41 -0000 1.11.2.1 @@ -1,5 +1,6 @@ <? include("config.php"); + include("util.php"); /* Use the imgsz query arg if it is there */ $len = 0; @@ -21,7 +22,7 @@ <html> <head> -<link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> +<link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="icon" href="favicon.ico"> <title>Brisbane Mesh node database</title> <style type="text/css"> @@ -59,14 +60,14 @@ else printf("are $nentries nodes"); ?> and <? - $result = mysql_query("SELECT count(*) from netloc where active", $db) + $result = mysql_query("SELECT count(*) from netloc where active and blessed", $db) or die(mysql_error($db)); $row = mysql_fetch_row($result); $nentries = intval($row[0]); if ($nentries == 1) printf("1 active interface"); else - printf("$nentries active interfaces"); + printf("$nentries active, blessed interfaces"); ?> (<? $result = mysql_query("SELECT count(*) from netloc", $db) or die(mysql_error($db)); @@ -296,6 +297,18 @@ if (count($maps)) { ?> <td> + +<? if (1) { + global $w,$h,$s,$n,$e,$hasloc; + $hasloc=1; + $IMGWIDTH=$len; + $IMGHEIGHT=$len; + $s=$mapscale; + $n=$mapn; + $e=$mape; + include("view-maps.inc.php"); + } else { ?> + <table> <? foreach ($maps as $maptype) { @@ -338,6 +351,7 @@ </table> </td> <? } /* if maps */ ?> +<? } ?> </tr> </table> Index: map2d.inc =================================================================== RCS file: /cvsroot/meshdb/www/db2/map2d.inc,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -d -r1.4.2.2 -r1.4.2.3 --- map2d.inc 7 Nov 2004 05:50:06 -0000 1.4.2.2 +++ map2d.inc 12 Feb 2005 06:05:41 -0000 1.4.2.3 @@ -5,8 +5,11 @@ /* Return a string containing the PNG data of a map */ function getmappng($n,$e,$w,$h,$s, $src="local", $nocache=0) { global $MYSQLHOST, $MYSQLUSER, $MYSQLPASS, $MYSQLDB, $OURPROXY; + global $BINDIR; global $PREFS; + $nocache = 1; + if ($s < 0.00001) die("Scale too small: $s m/pixel"); Index: map3b.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/map3b.php,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -d -r1.4.2.2 -r1.4.2.3 --- map3b.php 21 Jan 2005 16:07:26 -0000 1.4.2.2 +++ map3b.php 12 Feb 2005 06:05:41 -0000 1.4.2.3 @@ -6,7 +6,7 @@ * * David Leonard, 2001. Public domain. * - * Usage: map3b.php?e=#&n=#&s=#&w=#&h=#&t[#]=# + * Usage: map3b.php?e=#&n=#&s=#&w=#&h=#&t[#]=#&nodeid=# */ include("config.php"); @@ -17,8 +17,14 @@ $w = intval($_GET["w"]); $h = intval($_GET["h"]); $s = doubleval($_GET["s"]); +$t = $_GET["t"]; $vrml = intval($_GET["vrml"]); $maxage = intval($_GET["maxage"]); +if (isset($_GET["nodeid"])) + $nodeid = intval($_GET["nodeid"]); +else + $nodeid = -1; + if (!$maxage) $maxage = $PREF["maxnodeage"]; @@ -38,7 +44,7 @@ if ($vrml) header("Content-type: model/vrml"); else - header("Content-type: image/jpeg"); + header("Content-type: image/png"); if ($REQUEST_METHOD == "HEAD") exit; debug("w=$w h=$h s=$s"); @@ -60,13 +66,15 @@ $c = ""; $result = mysql_query($q, $db); while ($row = mysql_fetch_assoc($result)) { - if (isset($t[$row["nodeid"]])) { + $rownodeid = $row["nodeid"]; + if (isset($t[$rownodeid])) { $x = $t[$row["nodeid"]]; - if ($x == "X" && $row["h"]) { - $los = " -l ".$row["h"]; + if ($x == "X" || $row["nodeid"] == $nodeid){ + $los = " -l ".doubleval($row["h"]); } } else $x = "x"; + debug("nodeid=".$rownodeid.", t[nodeid]=".$t[$rownodeid]." x=$x"); if ($x == 'o' || $x == 'X' || $x == 'x') $c .= " -$x ".doubleval($row["e"])." ".doubleval($row["n"]); } Index: map4b.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/map4b.php,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -d -r1.4.2.1 -r1.4.2.2 --- map4b.php 23 Jan 2005 11:38:55 -0000 1.4.2.1 +++ map4b.php 12 Feb 2005 06:05:41 -0000 1.4.2.2 @@ -93,6 +93,7 @@ .",e" .",n" .",active" + .",blessed" ." FROM" ." netloc" .",admin" @@ -102,6 +103,8 @@ ." AND" ." peerid is null" ." AND" + ." blessed" + ." AND" ." n>".($n-$Dn)." AND n<".($n+$Dn) ." AND" ." e>".($e-$De)." AND e<".($e+$De) @@ -130,6 +133,7 @@ .",a2.nodename as name2" .",p2.n as n2" .",active" + .",blessed" ." FROM" ." netloc" .",physloc AS p1" @@ -138,6 +142,7 @@ .",admin AS a2" ." WHERE p1.nodeid = netloc.nodeid AND p2.nodeid = netloc.peerid" ." AND p1.nodeid = a1.nodeid AND p2.nodeid = a2.nodeid" + ." AND blessed" ." AND " ."(" ."(p1.n>".($n-$Dn)." AND p1.n<".($n+$Dn) Index: search.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/search.php,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- search.php 9 May 2004 03:32:30 -0000 1.4 +++ search.php 12 Feb 2005 06:05:41 -0000 1.4.2.1 @@ -96,7 +96,7 @@ ?> <html><head> -<link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> +<link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="icon" href="favicon.ico"> <title>Mesh search: <?=htmlspecialchars($q)?></title> </head> Index: select.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/select.php,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -d -r1.6 -r1.6.2.1 --- select.php 10 Dec 2003 05:43:02 -0000 1.6 +++ select.php 12 Feb 2005 06:05:41 -0000 1.6.2.1 @@ -1,4 +1,8 @@ <? + $q = $_GET["q"]; + $format = $_GET["format"]; + $top = $_GET["top"]; + if (strtolower(substr($q, 0, 7)) != "select " && strtolower($q) != "show tables" && strtolower(substr($q, 0, 9)) != "describe ") @@ -98,7 +102,7 @@ if ($format == "html") { ?> <html> <head> - <link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> + <link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="icon" href="favicon.ico"> </head> <body><table border=1> Index: submit.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/submit.php,v retrieving revision 1.14.2.1 retrieving revision 1.14.2.2 diff -u -d -r1.14.2.1 -r1.14.2.2 --- submit.php 7 Nov 2004 05:39:03 -0000 1.14.2.1 +++ submit.php 12 Feb 2005 06:05:41 -0000 1.14.2.2 @@ -65,6 +65,7 @@ $ipchangedstring. "\n". ($changes ? "Changes:\n".$changes : "No changes.\n"), + /* XXX These should be defined in the config file */ "From: Brisbane Mesh Database <own...@it...>\n". "Return-Path: own...@it...\n" ); @@ -130,7 +131,7 @@ ?> <html> <head> - <link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> + <link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="icon" href="favicon.ico"> <title>Confirm delete</title> </head> Index: touch.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/touch.php,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- touch.php 2 Nov 2003 02:07:00 -0000 1.4 +++ touch.php 12 Feb 2005 06:05:41 -0000 1.4.2.1 @@ -25,7 +25,7 @@ <html> <head> <title>Node <?=$nodeid?> touched!</title> - <link rel=stylesheet type="text/css" href="<?=$PREF["stylesheet"]?>"> + <link rel=stylesheet type="text/css" href="<?=$STYLESHEET?>"> <link rel="icon" href="favicon.ico"> </head> <body> Index: touchgraph.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/touchgraph.php,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- touchgraph.php 9 May 2004 03:32:30 -0000 1.4 +++ touchgraph.php 12 Feb 2005 06:05:41 -0000 1.4.2.1 @@ -25,7 +25,7 @@ ?> <html> <head> -<link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> +<link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="icon" href="favicon.ico"> <title>Brisbane Mesh TouchGraph view</title> </head> Index: util.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/util.php,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -d -r1.2.2.1 -r1.2.2.2 --- util.php 7 Nov 2004 05:50:06 -0000 1.2.2.1 +++ util.php 12 Feb 2005 06:05:41 -0000 1.2.2.2 @@ -1,4 +1,13 @@ <? + +function debug($msg) { + global $STDERR; + if (!isset($STDERR)) + $STDERR = fopen("php://stderr", "w"); + if ($STDERR) + fwrite($STDERR, $msg . "\n"); +} + function mybacktick($cmd) { /* Only give processes 2 minutes of CPU to do their thing */ $fp = popen("ulimit -c 0; ulimit -t 120; ".$cmd, "r"); @@ -11,7 +20,7 @@ } function cvtlatlon($E,$N,$noshift=0) { - global $SHIFTFILE, $ZONE; + global $SHIFTFILE, $ZONE, $BINDIR; if ($E == "" && $N == "") return array("",""); $E1 = doubleval($E); @@ -26,7 +35,7 @@ } function cvteastnorth($Lat, $Lon) { - global $SHIFTFILE, $ZONE; + global $SHIFTFILE, $ZONE, $BINDIR; if ($Lat == "" && $Lon == "") return array("",""); $Lat = doubleval($Lat); @@ -41,4 +50,10 @@ return array($E,$N); } + +function isnan($s) { + return ("x".strtolower($s) == "xnan"); +} + + ?> Index: view.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/view.php,v retrieving revision 1.16.2.6 retrieving revision 1.16.2.7 diff -u -d -r1.16.2.6 -r1.16.2.7 --- view.php 28 Jan 2005 07:16:27 -0000 1.16.2.6 +++ view.php 12 Feb 2005 06:05:41 -0000 1.16.2.7 @@ -15,166 +15,9 @@ if ($nodeid == "") die("no nodeid"); - /* - * Returns an URL to this page, merging the array $a - * into the current _GET array - */ - function selfurl($a) { - $oa = array(); - $defvars = array("nodeid", "peerid", "zoom"); - foreach ($defvars as $k) { - if (isset($_GET[$k])) - $oa[$k] = $_GET[$k]; - } - $oa = array_merge($oa, $a); - $url = ""; - foreach ($oa as $k => $v) { - if ($url != "") $url .= "&"; - $url .= urlencode($k) ."=". urlencode($v); - } - return "view.php?" . $url; - } - - /* Returns a global value, named as "<name>[<key>]" or "name". - * This is called by every val* function below. */ - function valof($name) { - if (substr($name, strlen($name) - 1, 1) == "]") { - $zz = split('\[', substr($name, 0, strlen($name) - 1)); - $an = $zz[0]; - $kn = $zz[1]; - return $GLOBALS[$an][$kn]; - } else - return $$name; /* XXX $GLOBALS[$name] ? */ - } - - /* Protects and returns a normal variable in HTML */ - function val($name, $attr = "") { - /* convert @ to @ as spam bots mightn't see them */ - return str_replace("@", "@", htmlspecialchars(valof($name))); - } - /* Returns a plain URL variable as HTML */ - function valurl($name, $attr = "") { - $v = valof($name); - if ($v == "") return ""; - return "<a href=\"$v\">". htmlspecialchars($v) . "</a>"; - } - /* Returns an image URL variable as HTML */ - function valimgurl($name, $attr = "", $alt="Site image") { - $v = valof($name); - if ($v == "") return ""; - return "<a href=\"$v\"><img src=\"$v\" alt=\"" - .htmlspecialchars($alt)."\"></a>"; - } - /* Return a multiline text variable in HTML */ - function valtext($name, $attr = "") { - /* Replace 'node #nn' with a hyperlink */ - $markeduptext = - eregi_replace("(node #?([0-9]+))", - "<a href=\"view.php?nodeid=\\2\">\\1</a>", - htmlspecialchars(valof($name))); - return "<span class=\"text\">$markeduptext</span>"; - } - /* Return a code-like variable in HTML */ - function valcode($name, $attr = "") { - return "<code>".htmlspecialchars(valof($name))."</code>"; - } - /* Return a nodeid variable as a pull-down HTML */ - function valnodeid($name, $attr = "") { - global $db; - global $PREF; - $v = valof($name); - if ($v == "") - return "<i>none</i>"; - $v = intval($v); - $result = mysql_query("SELECT" - ." nodename," - ." to_days(now()) - to_days(admin.updated) AS age" - ." FROM admin" - ." WHERE nodeid=$v", - $db) or die(mysql_error($db)); - $row = mysql_fetch_row($result); - if ($row) { - $v .= " <i>(<a href=\"view.php?nodeid=$v\">".htmlspecialchars($row[0])."</a>)</i>"; - if ($row[1] > $PREF["maxnodeage"]) - $v .= " <strong>(old)</strong>"; - } else - $v .= " <strong>(invalid)</strong>"; - return $v; - } - /* Return a boolean variable as Yes or No */ - function valyesno($name, $attr = "") { - if (valof($name)) - return "Yes"; - else - return "No"; - } - function selectval($name, $options, $attr = "") { - return htmlspecialchars($options[valof($name)]); - } - function edithelp($text) { - } - - - /* Computes a map of useful calculations about two physloc records */ - function elev($loc1, $loc2) { - global $ZONE, $SHIFTFILE, $ALTFILE, $BINDIR; - - $e1 = doubleval($loc1["e"]); - $n1 = doubleval($loc1["n"]); - $h1 = doubleval($loc1["h"]); - - $e2 = doubleval($loc2["e"]); - $n2 = doubleval($loc2["n"]); - $h2 = doubleval($loc2["h"]); - - $info = split(" ", - mybacktick("$BINDIR/elev" - ." -z ${ZONE}" - ." -S ${SHIFTFILE}" - ." -A ${ALTFILE}" - ." -a $e1 $n1 $h1" - ." -b $e2 $n2 $h2")); - - $distance = $info[0]; - $bearing1 = doubleval($info[1]) * 180 / M_PI; - if ($bearing1 < 0) $bearing1 += 360; - $bearing2 = doubleval($info[2]) * 180 / M_PI; - if ($bearing2 < 0) $bearing2 += 360; - $alt1 = doubleval($info[3]); - $alt2 = doubleval($info[4]); - $altmin = doubleval($info[5]); - $altmax = doubleval($info[6]); - $incl1 = $info[7]; - $incl2 = $info[8]; - $isclear = intval($info[9]); - - return array("distance" => $distance, - "bearing1" => $bearing1, - "bearing2" => $bearing2, - "alt1" => $alt1, - "alt2" => $alt2, - "altmin" => $altmin, - "altmax" => $altmax, - "incl1" => $incl1, - "incl2" => $incl2, - "isclear" => $isclear); - } - - /* Returns an URL to an elevation diagram for two locs */ - function elevurl($loc1, $loc2, $w, $h) { - $e1 = doubleval($loc1["e"]); - $n1 = doubleval($loc1["n"]); - $h1 = doubleval($loc1["h"]); - - $e2 = doubleval($loc2["e"]); - $n2 = doubleval($loc2["n"]); - $h2 = doubleval($loc2["h"]); - - $elevarg = "e1=$e1&n1=$n1&h1=$h1&e2=$e2&n2=$n2&h2=$h2&w=$w&h=$h"; - return "elev.php?" . htmlspecialchars($elevarg); - } - + include("view-util.inc"); include("lookup.inc.php"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s", $maxupdated) . " GMT"); if ($physloc["e"] == "" || $physloc["n"] == "") { @@ -218,7 +61,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> -<link rel="stylesheet" href="<?=$PREF["stylesheet"]?>" type="text/css"> +<link rel="stylesheet" href="<?=$STYLESHEET?>" type="text/css"> <link rel="start" href="index.php"> <link rel="icon" href="favicon.ico"> <title>View node #<?=$nodeid?>: <?=val("admin[nodename]")?></title> @@ -244,7 +87,7 @@ function blah(chk) { var name = chk.name.substring(3); setMapLayerVisibility("MAP"+name, chk.checked); - return false; + return true; } </script> |
From: <il...@pr...> - 2005-02-09 11:31:19
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21272 Modified Files: create.php Log Message: Default the node status to "Possibly interested", which is a lot safer and more likely than the previous "Fully operational". Index: create.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/create.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- create.php 12 Jan 2004 09:15:22 -0000 1.4 +++ create.php 9 Feb 2005 11:31:10 -0000 1.5 @@ -42,6 +42,7 @@ $EDITONLY = 1; include("edit.inc"); + $admin = array("status" => "interest"); $config = array("protocol" => "802.11b"); $physloc = array( "error" => "50", |
From: <il...@pr...> - 2005-02-03 14:43:17
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11232 Modified Files: index.h mkill.c msgid.c t.c update.c util.c view.c Log Message: More endianness fixes. Index: index.h =================================================================== RCS file: /cvsroot/meshdb/src/mailt/index.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- index.h 29 Jan 2005 04:37:45 -0000 1.2 +++ index.h 3 Feb 2005 14:43:06 -0000 1.3 @@ -53,6 +53,6 @@ #define READONLY 1 #define READWRITE 0 -#define CHILD(o,i) ((o)->m[(i)].child) -#define SIBLING(o,i) ((o)->m[(i)].sibling) -#define PARENT(o,i) ((o)->m[(i)].parent) +#define CHILD(o,i) (betoh32((o)->m[(i)].child)) +#define SIBLING(o,i) (betoh32((o)->m[(i)].sibling)) +#define PARENT(o,i) (betoh32((o)->m[(i)].parent)) Index: mkill.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/mkill.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mkill.c 29 Jan 2005 13:08:41 -0000 1.4 +++ mkill.c 3 Feb 2005 14:43:07 -0000 1.5 @@ -66,12 +66,12 @@ m = o.m; m0 = o.m0; mbox = o.mbox; + msgs = betoh32(m0->msgs); if (mid == NULL) { /* List killed messages */ - msgs = betoh32(m0->msgs); - for (i = 1; i < m0->msgs; i++) - if (m[i].flags & FLAGS_KILLED) { + for (i = 1; i < msgs; i++) + if (betoh32(m[i].flags) & FLAGS_KILLED) { if (nflag) /* Only show numbers if -n given */ printf("%lu\n", (unsigned long)i); @@ -86,16 +86,16 @@ /* Search for the first message with that ID */ if (nflag) { i = atoi(mid); - if (i < 1 || i >= m0->msgs) { + if (i < 1 || i >= msgs) { fprintf(stderr, "index '%s' out of range\n", mid); exit(1); } kid = i; } else { midend = mid + strlen(mid); - for (i = 1; i < m0->msgs; i++) { + for (i = 1; i < msgs; i++) { cstring_t s, e; - if ((m[i].flags & FLAGS_KILLED) == FLAGS_KILLED) + if ((betoh32(m[i].flags) & FLAGS_KILLED) == FLAGS_KILLED) continue; if (find1hdr(m+i, mbox, "message-id", &s, &e) && msgid(s, e, &s, &e) && @@ -104,24 +104,24 @@ break; } } - if (i >= m0->msgs) { + if (i >= msgs) { fprintf(stderr, "couldn't find message-id <%s>\n", mid); exit(1); } } if (uflag) { - if ((m[kid].flags & FLAGS_KILLED) == 0) { + if ((betoh32(m[kid].flags) & FLAGS_KILLED) == 0) { fprintf(stderr, "message already killed\n"); exit(1); } /* Modify kill flag */ - m[kid].flags &= ~FLAGS_KILLED; + m[kid].flags &= betoh32(~FLAGS_KILLED); /* Insert into beginning of tree */ - m[kid].parent = 0; - m[kid].child = 0; - m[kid].sibling = m[0].child; + m[kid].parent = betoh32(0); + m[kid].child = betoh32(0); + m[kid].sibling = betoh32(m[0].child); m[0].child = kid; printf("unkilled message #%lu\n", (unsigned long)kid); @@ -129,18 +129,18 @@ "to rebuild the index.\n"); } else { /* Find the link in the reply-tree to the doomed node */ - for (sp = &m[m[kid].parent].child; *sp; sp = &m[*sp].sibling) - if (*sp == kid) + for (sp = &m[betoh32(m[kid].parent)].child; *sp; sp = &m[betoh32(*sp)].sibling) + if (betoh32(*sp) == kid) break; - if (*sp != kid) { + if (betoh32(*sp) != kid) { fprintf(stderr, "reply-tree corrupt\n"); exit(1); } /* Reparent all of its children. */ - for (lasti = 0, i = m[kid].child; i; - lasti = i, i = m[i].sibling) + for (lasti = 0, i = betoh32(m[kid].child); i; + lasti = i, i = betoh32(m[i].sibling)) m[i].parent = m[kid].parent; - if (m[kid].child) { + if (betoh32(m[kid].child)) { /* * insert the child list into where the doomed * node was. XXX - DATES WILL NOT BE CONSISTENT!! @@ -155,12 +155,12 @@ *sp = m[kid].sibling; /* Unlink the doomed node from the tree */ - m[kid].parent = 0; - m[kid].sibling = 0; - m[kid].child = 0; + m[kid].parent = betoh32(0); + m[kid].sibling = betoh32(0); + m[kid].child = betoh32(0); /* Modify the kill flag */ - m[kid].flags |= FLAGS_KILLED; + m[kid].flags |= betoh32(FLAGS_KILLED); printf("killed message #%lu\n", (unsigned long)kid); } Index: msgid.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/msgid.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- msgid.c 29 Jan 2005 13:08:41 -0000 1.3 +++ msgid.c 3 Feb 2005 14:43:07 -0000 1.4 @@ -21,6 +21,7 @@ struct open o; struct mail0 *m0; struct mail *m; + uint32_t msgs; msgid_t i, kid; cstring_t mbox, mid, midend; int error = 0; @@ -55,13 +56,14 @@ m = o.m; m0 = o.m0; mbox = o.mbox; + msgs = betoh32(m0->msgs); /* Search for the first message with that ID */ if (mid) midend = mid + strlen(mid); - for (i = 1; i < m0->msgs; i++) { + for (i = 1; i < msgs; i++) { cstring_t s, e; - if ((m[i].flags & FLAGS_KILLED) == FLAGS_KILLED) + if ((betoh32(m[i].flags) & FLAGS_KILLED) == FLAGS_KILLED) continue; if (find1hdr(m+i, mbox, "message-id", &s, &e) && msgid(s, e, &s, &e)) @@ -77,7 +79,7 @@ if (mid) { - if (i >= m0->msgs) { + if (i >= msgs) { fprintf(stderr, "couldn't find message-id <%s>\n", mid); exit(1); } Index: t.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/t.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- t.c 29 Jan 2005 13:08:41 -0000 1.3 +++ t.c 3 Feb 2005 14:43:07 -0000 1.4 @@ -13,10 +13,12 @@ int level; { static char when[80]; + time_t date; do { if (i) { + date = o->m[i].date; strftime(when, sizeof when, "%e-%b-%y", - localtime(&o->m[i].date)); + localtime(&date)); printf("%*s* %lu %.20s, %.50s %s\n", level * 3, "", (unsigned long)i, o->m[i].from, @@ -26,12 +28,12 @@ printf("%*s* %lu <root>\n", level * 3, "", (unsigned long)i); - if (o->m[i].child) { - printit(o, o->m[i].child, level + 1); - if (o->m[o->m[i].child].parent != i) + if (betoh32(o->m[i].child)) { + printit(o, betoh32(o->m[i].child), level + 1); + if (betoh32(o->m[betoh32(o->m[i].child)].parent) != i) printf("@@### WRONG PARENT\n"); } - i = o->m[i].sibling; + i = betoh32(o->m[i].sibling); } while (i); } Index: update.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/update.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- update.c 29 Jan 2005 13:08:42 -0000 1.4 +++ update.c 3 Feb 2005 14:43:07 -0000 1.5 @@ -90,6 +90,7 @@ struct mail *m = o->m; cstring_t mbox = o->mbox; struct mail0 *m0 = o->m0; + uint32_t msgs; struct hashent *h; hash_t tab; int i, j, hashval; @@ -100,7 +101,8 @@ fprintf(stderr, "malloc failed\n"); return NULL; } - tab->ents = (struct hashent *)malloc(m0->msgs * sizeof (struct hashent)); + msgs = betoh32(m0->msgs); + tab->ents = (struct hashent *)malloc(msgs * sizeof (struct hashent)); if (tab->ents == NULL) { fprintf(stderr, "malloc failed\n"); return NULL; @@ -108,8 +110,8 @@ for (i = 0; i < HASHLEN; i++) tab->entry[i] = NULL; - for (i = 1; i < m0->msgs; i++) { - if (m[i].flags & FLAGS_KILLED) + for (i = 1; i < msgs; i++) { + if (betoh32(m[i].flags) & FLAGS_KILLED) continue; h = &(tab->ents[i]); h->next = NULL; @@ -117,7 +119,7 @@ if (!msgid(hstart, hend, &h->start, &h->end)) { fprintf(stderr, "message %d: bad message-id\n", i); - m[i].flags |= FLAGS_KILLED; + m[i].flags |= betoh32(FLAGS_KILLED); continue; } j = find_msgbyid(tab, h->start, h->end); @@ -125,7 +127,7 @@ fflush(stdout); fprintf(stderr, "Message %d has same Message-ID" " as message %d: killing.\n", i, j); - m[i].flags |= FLAGS_KILLED; + m[i].flags |= betoh32(FLAGS_KILLED); h->start = h->end = NULL; hashval = -1; } else { @@ -167,12 +169,12 @@ break; } - m->pos = start-mbox; - m->hdrlen = p - start; - m->bodylen = end - p; - m->child = 0; - m->sibling = 0; - m->parent = 0; + m->pos = betoh64(start-mbox); + m->hdrlen = betoh32(p - start); + m->bodylen = betoh32(end - p); + m->child = betoh32(0); + m->sibling = betoh32(0); + m->parent = betoh32(0); if (find1hdr(m, mbox, "subject", &hstart, &hend)) { cstring_t t; @@ -242,12 +244,12 @@ tm.tm_isdst = -1; m->date = mktime(&tm); - if (index > 1 && m->date < (m-1)->date) { + if (index > 1 && betoh32(m->date) < betoh32((m-1)->date)) { fprintf(stderr, "msg %lu: warning: date bad, fixing\n" "\t('%.*s' earlier than '%.24s')\n", (unsigned long)index, start-p - 1, p, ctime(&(m-1)->date)); - m->date = (m-1)->date + 1; + m->date = betoh32(betoh32((m-1)->date) + 1); } #else /* Parse the Date header */ @@ -259,24 +261,25 @@ tm.tm_gmtoff = 0; tm.tm_zone = NULL; tm.tm_isdst = -1; - m->date = mktime(&tm); - if (m->date > 0) - m->date -= gmtoff; + m->date = betoh32(mktime(&tm)); + if (betoh32(m->date) > 0) + m->date = betoh32(betoh32(m->date) - gmtoff); else - m->date = -1; + m->date = betoh32(-1); } else - m->date = -1; + m->date = betoh32(-1); #endif if (vflag) { char buf[80] = "INVALID"; - if (m->date != -1) + if (betoh32(m->date) != -1) strftime(buf, sizeof buf, "%a, %e %b %Y %H:%M:%S GMT", &tm); printf("Message %lu '%.10s' from '%.10s' date '%s'\n" "\tpos %llu hdrlen %d bodylen %d\n", (unsigned long)index, m->subject, m->from, buf, - (unsigned long long)m->pos, (int)m->hdrlen, - (int)m->bodylen); + (unsigned long long)betoh64(m->pos), + (int)betoh32(m->hdrlen), + (int)betoh32(m->bodylen)); } } @@ -300,16 +303,16 @@ /* Just load the zero entry to find the old mailbox size */ if ((m0 = (struct mail0 *)index_loadn(idxfd, 1, READWRITE)) == NULL) exit(1); - oldend = m0->end; + oldend = betoh64(m0->end); if (oldend == sb.st_size) { /* No change detected */ index_unloadn((struct mail *)m0, 1); return 0; } - m0->end = sb.st_size; + m0->end = betoh64(sb.st_size); if ((mbox = mbox_map(m0, mboxfd)) == NULL) { - m0->end = oldend; + m0->end = betoh64(oldend); exit(1); } @@ -317,7 +320,7 @@ if (memcmp(p, From, sizeof From) != 0) { fprintf(stderr, "Changes to mbox do not start with '%.*s'\n", (int)sizeof From, From); - m0->end = oldend; + m0->end = betoh64(oldend); exit(1); } newmsgs = 1; @@ -328,12 +331,12 @@ /* Expand the index file to cpe with the new messages */ mbox_unmap(m0, mbox); - m0->msgs += newmsgs; + m0->msgs = betoh32(betoh32(m0->msgs) + newmsgs); #if 0 #define st_mtime st_mtimespec.tv_sec #endif - m0->date = sb.st_mtime; - msgs = m0->msgs; + m0->date = betoh32(sb.st_mtime); + msgs = betoh32(m0->msgs); index_unloadn((struct mail *)m0, 1); m0 = NULL; if (index_resize(idxfd, msgs) == -1) @@ -381,11 +384,11 @@ m0 = o->m0; m = o->m; mbox = o->mbox; - end = mbox + m0->end; + end = mbox + betoh64(m0->end); /* if not -r, check the consistency of the existing reply tree */ if (!rflag) { - if (!check_reply_tree(m, m0->msgs - newmsgs, oldend)) { + if (!check_reply_tree(m, betoh32(m0->msgs) - newmsgs, oldend)) { fprintf(stderr, "Re-run with -r flag!\n"); exit(1); } @@ -396,7 +399,7 @@ /* Find each 'From '-commenced message */ start = p = mbox + oldend; - index = m0->msgs - newmsgs; + index = betoh32(m0->msgs) - newmsgs; for (p += sizeof From; p < end - sizeof From - 1; p++) /* Look for the beginning of the next message */ if (*p == '\n' && memcmp(p + 1, From, sizeof From) @@ -428,22 +431,22 @@ if (rflag) { if (vflag) printf("re-building reply-tree from scratch\n"); - m[0].child = 0; - for (i = 1; i < m0->msgs; i++) - m[i].child = m[i].parent = m[i].sibling = 0; + m[0].child = betoh32(0); + for (i = 1; i < betoh32(m0->msgs); i++) + m[i].child = m[i].parent = m[i].sibling = betoh32(0); } /* * Look at the new messages's In-reply-to and References headers * and insert them into the reply-tree accordingly. */ - for (i = rflag ? 1 : m0->msgs - newmsgs; i < m0->msgs; i++) { + for (i = rflag ? 1 : betoh32(m0->msgs) - newmsgs; i < betoh32(m0->msgs); i++) { cstring_t istart, iend; msgid_t parent = 0; msgid_t *jp; /* Ignore killed messages */ - if (m[i].flags & FLAGS_KILLED) + if (betoh32(m[i].flags) & FLAGS_KILLED) continue; if (find1hdr(&m[i], mbox, "in-reply-to", &istart, &iend) @@ -486,7 +489,7 @@ } if (subj != m[i].subject && subj[0] != '\0') - for (j = m[0].child; j; j = m[j].sibling) { + for (j = betoh32(m[0].child); j; j = betoh32(m[j].sibling)) { /* Skip the Re */ const char *subj2 = m[j].subject; while (tolower(subj2[0]) == 'r' && @@ -509,18 +512,18 @@ } if (parent == 0 && last0 && last0 < i - && m[last0].sibling == 0) + && betoh32(m[last0].sibling) == 0) /* Common case is that 0 holds all the messages */ jp = &m[last0].sibling; else /* Walk existing siblings till we find a later one or the end */ - for (jp = &m[parent].child; *jp; jp = &m[*jp].sibling) - if (*jp > i) + for (jp = &m[parent].child; betoh32(*jp); jp = &m[betoh32(*jp)].sibling) + if (betoh32(*jp) > i) break; - m[i].parent = parent; - m[i].child = 0; - m[i].sibling = *jp; - *jp = i; + m[i].parent = betoh32(parent); + m[i].child = betoh32(0); + m[i].sibling = betoh32(*jp); + *jp = betoh32(i); if (parent == 0) last0 = i; } Index: util.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/util.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- util.c 3 Feb 2005 14:05:49 -0000 1.4 +++ util.c 3 Feb 2005 14:43:07 -0000 1.5 @@ -186,7 +186,9 @@ cstring_t mbox; cstring_t name, *startp, *endp; { - findhdr(mbox + m->pos, mbox + m->pos + m->hdrlen, name, startp, endp); + findhdr(mbox + betoh64(m->pos), + mbox + betoh64(m->pos) + betoh32(m->hdrlen), + name, startp, endp); return (*startp != NULL); } @@ -222,11 +224,11 @@ /* initialise the 'seen' array */ for (i = 0; i < msgs; i++) - seen[i] = (m[i].flags & FLAGS_KILLED) ? -1 : 0; + seen[i] = (betoh32(m[i].flags) & FLAGS_KILLED) ? -1 : 0; /* Recursively check children */ - if (m[0].child) - if (!check_reply_sub(m, m[0].child, seen, msgs, end)) + if (betoh32(m[0].child)) + if (!check_reply_sub(m, betoh32(m[0].child), seen, msgs, end)) return 0; /* look at the contents of the 'seen' list */ @@ -284,30 +286,30 @@ seen[i] = 1; /* Check message body and header extents against file size */ - if (m[i].pos + m[i].bodylen + m[i].hdrlen > end) + if (betoh64(m[i].pos) + betoh32(m[i].bodylen) + betoh32(m[i].hdrlen) > end) fprintf(stderr, "msg %lu: exceeds bounds\n", (unsigned long)i); - if (m[i].child) { + if (betoh32(m[i].child)) { /* Check parental back-link */ - if (m[m[i].child].parent != i) { + if (betoh32(m[betoh32(m[i].child)].parent) != i) { fprintf(stderr, "msg %lu: bad parent", - (unsigned long)m[i].child); + (unsigned long)betoh32(m[i].child)); return 0; } /* Recurse */ - if (!check_reply_sub(m, m[i].child, seen, max, end)) + if (!check_reply_sub(m, betoh32(m[i].child), seen, max, end)) return 0; } - if (m[i].sibling) { + if (betoh32(m[i].sibling)) { /* Check parental back-link */ - if (m[m[i].sibling].parent != m[i].parent) { + if (betoh32(m[betoh32(m[i].sibling)].parent) != betoh32(m[i].parent)) { fprintf(stderr, "msg %lu: bad parent", - (unsigned long)m[i].child); + (unsigned long)betoh32(m[i].child)); return 0; } /* Recurse */ - if (!check_reply_sub(m, m[i].sibling, seen, max, end)) + if (!check_reply_sub(m, betoh32(m[i].sibling), seen, max, end)) return 0; } Index: view.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/view.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- view.c 29 Jan 2005 13:08:42 -0000 1.5 +++ view.c 3 Feb 2005 14:43:07 -0000 1.6 @@ -236,14 +236,14 @@ { if (id == 0) return 0; - if (o->m[id].child) - return o->m[id].child; - while (!o->m[id].sibling) { - id = o->m[id].parent; + if (betoh32(o->m[id].child)) + return betoh32(o->m[id].child); + while (!betoh32(o->m[id].sibling)) { + id = betoh32(o->m[id].parent); if (!id) return 0; } - return o->m[id].sibling; + return betoh32(o->m[id].sibling); } /* Return previous sibling or parent if none */ @@ -256,15 +256,15 @@ if (id == 0) return 0; - parent = o->m[id].parent; - i = o->m[parent].child; + parent = betoh32(o->m[id].parent); + i = betoh32(o->m[parent].child); if (i == id) return parent; - while (o->m[i].sibling) - if (o->m[i].sibling == id) + while (betoh32(o->m[i].sibling)) + if (betoh32(o->m[i].sibling) == id) return i; else - i = o->m[i].sibling; + i = betoh32(o->m[i].sibling); /* XXX should not be reached */ fprintf(stderr, "corrupt index tree\n"); exit(1); @@ -302,7 +302,9 @@ struct mail *m = &o->m[id]; printf("Content-type: text/plain\n\n"); - fwrite(o->mbox + m->pos, m->bodylen + m->hdrlen, 1, stdout); + fwrite(o->mbox + betoh64(m->pos), + betoh32(m->bodylen) + betoh32(m->hdrlen), + 1, stdout); } /* Print related article subjects in a tree. */ @@ -313,6 +315,7 @@ int nosib, nochld; { char when[256]; + time_t date; if (id == 0) return; @@ -333,12 +336,13 @@ printesc(o->m[id].from, o->m[id].from + strlen(o->m[id].from)); printf("</SPAN>"); - strftime(when, sizeof when, "%e%b%y", localtime(&o->m[id].date)); + date = betoh32(o->m[id].date); + strftime(when, sizeof when, "%e%b%y", localtime(&date)); printf(", <SPAN CLASS=shortdate>%s</SPAN> ", when); - if (o->m[id].child) { + if (betoh32(o->m[id].child)) { if (nochld) { - int replies = counttree(o, o->m[id].child); + int replies = counttree(o, betoh32(o->m[id].child)); printf("<SPAN CLASS=replies>["); if (replies == 1) @@ -348,15 +352,15 @@ printf("]</SPAN>"); } else { printf("<UL>\n"); - print_threadlist(o, o->m[id].child, displayed, 0, 0); + print_threadlist(o, betoh32(o->m[id].child), displayed, 0, 0); printf("</UL>\n"); } } printf("</LI>\n"); - if (!nosib && o->m[id].sibling) - print_threadlist(o, o->m[id].sibling, displayed, 0, 0); + if (!nosib && betoh32(o->m[id].sibling)) + print_threadlist(o, betoh32(o->m[id].sibling), displayed, 0, 0); } struct idchain { @@ -506,8 +510,8 @@ if (!killed) { /* Start is the most distant ancestor */ start = id; - while (o->m[start].parent) - start = o->m[start].parent; + while (betoh32(o->m[start].parent)) + start = betoh32(o->m[start].parent); /* Find the previous sibling */ next = findnext(o, id); @@ -549,8 +553,8 @@ } printf("<TABLE CLASS=header>"); - ha = o->mbox + m->pos; - hb = o->mbox + m->pos + m->hdrlen; + ha = o->mbox + betoh64(m->pos); + hb = o->mbox + betoh64(m->pos) + betoh32(m->hdrlen); if (findhdr(ha, hb, "from", &s, &e)) { printf("<TR><TH>From:</TH><TD><SPAN CLASS=email>"); printesc(s, e); @@ -588,8 +592,8 @@ if (findhdr(ha, hb, "content-type", &hs, &he)) { cstring_t *v; v = hdr_split(hs, he); - s = o->mbox + m->pos; - e = s + m->hdrlen + m->bodylen; + s = o->mbox + betoh64(m->pos); + e = s + betoh32(m->hdrlen) + betoh32(m->bodylen); if (!v[0] || !*v[0] || strcasecmp(v[0], "text/plain") == 0) goto textplain; else if (strcasecmp(v[0], "multipart/mixed") == 0) @@ -606,8 +610,8 @@ textplain: qp = isqp(ha, hb); - bodystart = o->mbox + m->pos + m->hdrlen; - bodyend = bodystart + m->bodylen; + bodystart = o->mbox + betoh64(m->pos) + betoh32(m->hdrlen); + bodyend = bodystart + betoh32(m->bodylen); printf("<PRE WRAP=AUTO>"); #if 1 @@ -667,7 +671,7 @@ printf("<UL CLASS=thread>"); print_threadlist(o, findprevsib(o, start), id, 1, 1); print_threadlist(o, start, id, 1, 0); - print_threadlist(o, o->m[start].sibling, id, 1, 1); + print_threadlist(o, betoh32(o->m[start].sibling), id, 1, 1); printf("</UL>\n"); } @@ -809,7 +813,7 @@ raw = (strcmp(p, ";raw") == 0); /* Check first part of path component is valid message ID */ - if (path[0] < 1 || path[0] >= o.m0->msgs) { + if (path[0] < 1 || path[0] >= betoh32(o.m0->msgs)) { printf("Content-type: text/plain\n\n"); printf("error: invalid message ID\n"); exit(0); @@ -829,8 +833,8 @@ else { struct mail *m = &o.m[path[0]]; - show_mime_part(&o, o.mbox + m->pos, - o.mbox + m->pos + m->hdrlen + m->bodylen, + show_mime_part(&o, o.mbox + betoh64(m->pos), + o.mbox + betoh64(m->pos) + betoh32(m->hdrlen) + betoh32(m->bodylen), path + 1, pathlen - 1); } |
From: <il...@pr...> - 2005-02-03 14:05:57
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2271 Modified Files: util.c Log Message: Include string.h for memcmp(). Index: util.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/util.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- util.c 29 Jan 2005 13:35:19 -0000 1.3 +++ util.c 3 Feb 2005 14:05:49 -0000 1.4 @@ -1,6 +1,7 @@ /* $Id$ */ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <ctype.h> #include <sys/types.h> |
From: <il...@pr...> - 2005-02-03 10:38:07
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29912/www/db2 Modified Files: cookies.inc Log Message: Reduce the default maximum node age to 18 months to reduce whinging. Index: cookies.inc =================================================================== RCS file: /cvsroot/meshdb/www/db2/cookies.inc,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- cookies.inc 9 May 2004 03:32:30 -0000 1.5 +++ cookies.inc 3 Feb 2005 10:37:58 -0000 1.6 @@ -14,7 +14,7 @@ "viewpeermenulimit" => "200", "viewpeertablelimit" => "10", "viewlosonly" => "0", - "maxnodeage" => "1000", + "maxnodeage" => "548", "_moddate" => "0", "viewmaplist" => "net loc ter elev", |
From: <il...@pr...> - 2005-02-03 10:31:06
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28957/www/db2 Modified Files: submit.php view.inc.php Log Message: Require a node name (before creating the node), contact name, contact phone or email and a suburb for each new node. Index: submit.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/submit.php,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- submit.php 18 Sep 2004 06:08:11 -0000 1.14 +++ submit.php 3 Feb 2005 10:30:57 -0000 1.15 @@ -170,6 +170,19 @@ $result = mysql_query("BEGIN"); if ($operation == "insert") { + if (empty($VAR["admin"]["nodename"])) + die("node name cannot be empty"); + elseif (empty($VAR["contact"]["contactname"])) + die("contact name cannot be empty"); + elseif (empty($VAR["contact"]["contactemail"]) + && empty($VAR["contact"]["contactphone"])) + die("contact email and phone cannot both be empty"); + elseif (!empty($VAR["contact"]["contactemail"]) + && !ereg("^[^@]+@([^.]+\.)+[^.]*$", $VAR["contact"]["contactemail"])) + die("contact email does not look valid"); + elseif (empty($VAR["physaddr"]["suburb"])) + die("suburb cannot be empty"); + $result = mysql_query("INSERT INTO admin SET " . " created = NOW()" . ",updated = NOW()" Index: view.inc.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/view.inc.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- view.inc.php 25 Feb 2004 07:11:13 -0000 1.3 +++ view.inc.php 3 Feb 2005 10:30:57 -0000 1.4 @@ -112,7 +112,7 @@ <tr> <th>Suburb:</th> <td><?=val("physaddr[suburb]")?></td> - <?=edithelp("e.g. Coopers Plains")?> + <?=edithelp("e.g. Coopers Plains (<strong>required</strong>)")?> </tr> <tr> |
From: <le...@pr...> - 2005-01-29 13:35:27
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7763 Modified Files: util.c Log Message: merge Yahoo! fix from r1.1.1.1.2.2 into HEAD Index: util.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/util.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- util.c 29 Jan 2005 13:08:42 -0000 1.2 +++ util.c 29 Jan 2005 13:35:19 -0000 1.3 @@ -20,6 +20,7 @@ int spaces = 0; /* + * =?iso-8859-1?q?F S?= -> F S * u@h -> u@h * F S <u@h> -> F S * "F S" <u@h> -> F S @@ -36,6 +37,17 @@ *sp = s; *ep = e; + /* Hooray! for! Yahoo! */ + if (s + 15 < e && memcmp(s, "=?iso-8859-1?q?", 15) == 0) { + cstring_t f; + for (f = s + 15; f + 1 < e; f++) + if (f[0] == '?' && f[1] == '=') { + *sp = s + 15; + *ep = f; + return; + } + } + /* Skip, and record text in angled brackets */ if (s < e && *s == '<') { s++; |
From: <le...@pr...> - 2005-01-29 13:20:45
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5011 Removed Files: NOTES Log Message: remove out-of-date notes --- NOTES DELETED --- |
From: <le...@pr...> - 2005-01-29 13:08:53
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2316 Modified Files: mkill.c msgid.c size.c t.c update.c util.c view.c Log Message: get rid of compiler warnings; cast msgid_t variables when printing. Index: mkill.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/mkill.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mkill.c 29 Jan 2005 04:37:45 -0000 1.3 +++ mkill.c 29 Jan 2005 13:08:41 -0000 1.4 @@ -74,10 +74,11 @@ if (m[i].flags & FLAGS_KILLED) { if (nflag) /* Only show numbers if -n given */ - printf("%lu\n", i); + printf("%lu\n", (unsigned long)i); else printf("%3lu %-10s %-50s\n", - i, m[i].from, m[i].subject); + (unsigned long)i, + m[i].from, m[i].subject); } exit(0); } @@ -123,7 +124,7 @@ m[kid].sibling = m[0].child; m[0].child = kid; - printf("unkilled message #%ld\n", kid); + printf("unkilled message #%lu\n", (unsigned long)kid); fprintf(stderr, "NOTE: you should run update with the -r flag " "to rebuild the index.\n"); } else { @@ -161,7 +162,7 @@ /* Modify the kill flag */ m[kid].flags |= FLAGS_KILLED; - printf("killed message #%ld\n", kid); + printf("killed message #%lu\n", (unsigned long)kid); } exit(0); Index: msgid.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/msgid.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- msgid.c 24 Nov 2003 06:27:28 -0000 1.2 +++ msgid.c 29 Jan 2005 13:08:41 -0000 1.3 @@ -71,7 +71,7 @@ break; } if (!mid) - printf("%ld %.*s\n", i, e-s, s); + printf("%lu %.*s\n", (unsigned long)i, e-s, s); } } @@ -81,7 +81,7 @@ fprintf(stderr, "couldn't find message-id <%s>\n", mid); exit(1); } - printf("%ld\n", kid); + printf("%lu\n", (unsigned long)kid); } exit(0); Index: size.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/size.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- size.c 29 Jan 2005 04:33:40 -0000 1.3 +++ size.c 29 Jan 2005 13:08:41 -0000 1.4 @@ -8,7 +8,7 @@ case 2: printf("n%s", #n); break; \ case 4: printf("L%s", #n); break; \ case 8: printf("L%shi/L%slo", #n, #n); break; \ - default: printf("a%zu%s", sizeof ((struct t *)0)->n, #n); \ + default: printf("a%d%s", (int)sizeof ((struct t *)0)->n, #n); \ } int main() @@ -37,7 +37,7 @@ P(mail0, ign8); putchar('/'); P(mail0, flags); printf("\";\n"); - printf("\t$FMTSZ = %zu;\n", sizeof (struct mail)); + printf("\t$FMTSZ = %d;\n", (int)sizeof (struct mail)); printf("\t$KILLED = %d;\n", FLAGS_KILLED); exit(0); } Index: t.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/t.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- t.c 24 Nov 2003 06:23:53 -0000 1.2 +++ t.c 29 Jan 2005 13:08:41 -0000 1.3 @@ -18,12 +18,13 @@ strftime(when, sizeof when, "%e-%b-%y", localtime(&o->m[i].date)); printf("%*s* %lu %.20s, %.50s %s\n", - level * 3, "", i, + level * 3, "", (unsigned long)i, o->m[i].from, *o->m[i].subject ? o->m[i].subject : "(no subject)", when); } else - printf("%*s* %lu <root>\n", level * 3, "", i); + printf("%*s* %lu <root>\n", level * 3, "", + (unsigned long)i); if (o->m[i].child) { printit(o, o->m[i].child, level + 1); Index: update.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/update.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- update.c 24 Nov 2003 06:26:01 -0000 1.3 +++ update.c 29 Jan 2005 13:08:42 -0000 1.4 @@ -156,7 +156,8 @@ struct tm tm; if (vflag) - printf("message %lu at offset %d length %d (end %d)\n", index, + printf("message %lu at offset %d length %d (end %d)\n", + (unsigned long)index, start-mbox, end-start, end-mbox); /* Look for headers */ @@ -235,7 +236,7 @@ memset(&tm, 0, sizeof tm); if (strptime(p, "%a %b %e %T %Y", &tm) == NULL) { fprintf(stderr, "msg %lu: invalid date in From header: %.*s\n", - index, start - p - 1, p); + (unsigned long)index, start - p - 1, p); exit(1); } tm.tm_isdst = -1; @@ -244,7 +245,8 @@ if (index > 1 && m->date < (m-1)->date) { fprintf(stderr, "msg %lu: warning: date bad, fixing\n" "\t('%.*s' earlier than '%.24s')\n", - index, start-p - 1, p, ctime(&(m-1)->date)); + (unsigned long)index, start-p - 1, p, + ctime(&(m-1)->date)); m->date = (m-1)->date + 1; } #else @@ -272,8 +274,9 @@ strftime(buf, sizeof buf, "%a, %e %b %Y %H:%M:%S GMT", &tm); printf("Message %lu '%.10s' from '%.10s' date '%s'\n" "\tpos %llu hdrlen %d bodylen %d\n", - index, m->subject, m->from, buf, - m->pos, (int)m->hdrlen, (int)m->bodylen); + (unsigned long)index, m->subject, m->from, buf, + (unsigned long long)m->pos, (int)m->hdrlen, + (int)m->bodylen); } } @@ -500,7 +503,8 @@ parent = best; if (vflag) printf("%lu: Guessing best parent is %lu" - " (%s)\n", i, best, subj); + " (%s)\n", (unsigned long)i, + (unsigned long)best, subj); } } Index: util.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/util.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- util.c 10 Aug 2002 03:45:14 -0000 1.1.1.1 +++ util.c 29 Jan 2005 13:08:42 -0000 1.2 @@ -220,7 +220,8 @@ for (i = 1; i < msgs; i++) switch (seen[i]) { case 0: - fprintf(stderr, "msg %lu: not reachable\n", i); + fprintf(stderr, "msg %lu: not reachable\n", + (unsigned long)i); return 0; case 2: /* message was checked ok */ @@ -247,7 +248,8 @@ { /* Check index is within bounds */ if (i < 1 || i >= max) { - fprintf(stderr, "msg %lu: no such message\n", i); + fprintf(stderr, "msg %lu: no such message\n", + (unsigned long)i); return 0; } @@ -256,25 +258,27 @@ case 0: break; /* we expect this case */ case -1: - fprintf(stderr, "msg %lu: deleted but reachable\n", i); + fprintf(stderr, "msg %lu: deleted but reachable\n", + (unsigned long)i); return 0; case 1: - fprintf(stderr, "msg %lu: reached twice\n", i); + fprintf(stderr, "msg %lu: reached twice\n", (unsigned long)i); return 0; default: - fprintf(stderr, "msg %lu: corrupt index\n", i); + fprintf(stderr, "msg %lu: corrupt index\n", (unsigned long)i); return 0; } seen[i] = 1; /* Check message body and header extents against file size */ if (m[i].pos + m[i].bodylen + m[i].hdrlen > end) - fprintf(stderr, "msg %lu: exceeds bounds\n", i); + fprintf(stderr, "msg %lu: exceeds bounds\n", (unsigned long)i); if (m[i].child) { /* Check parental back-link */ if (m[m[i].child].parent != i) { - fprintf(stderr, "msg %lu: bad parent", m[i].child); + fprintf(stderr, "msg %lu: bad parent", + (unsigned long)m[i].child); return 0; } /* Recurse */ @@ -285,7 +289,8 @@ if (m[i].sibling) { /* Check parental back-link */ if (m[m[i].sibling].parent != m[i].parent) { - fprintf(stderr, "msg %lu: bad parent", m[i].child); + fprintf(stderr, "msg %lu: bad parent", + (unsigned long)m[i].child); return 0; } /* Recurse */ @@ -295,7 +300,8 @@ /* Ensure that nothing strange has happened (XXX unnecessary?) */ if (seen[i] != 1) { - fprintf(stderr, "msg %lu: reached twice\n", i); + fprintf(stderr, "msg %lu: reached twice\n", + (unsigned long)i); return 0; } /* Mark as successful */ Index: view.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/view.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- view.c 22 Oct 2003 06:24:34 -0000 1.4 +++ view.c 29 Jan 2005 13:08:42 -0000 1.5 @@ -318,10 +318,10 @@ return; printf("<LI>"); - /* printf("<SPAN CLASS=seqno>[%lu]</SPAN> ", id); */ + /* printf("<SPAN CLASS=seqno>[%lu]</SPAN> ", (unsigned long)id); */ if (id != displayed) - printf("<A HREF=\"%lu\">", id); + printf("<A HREF=\"%lu\">", (unsigned long)id); else printf("<SPAN CLASS=current>"); printesc(o->m[id].subject, o->m[id].subject + strlen(o->m[id].subject)); @@ -371,7 +371,7 @@ { if (path) { printidchain(path->prev, ch); - printf("%c%lu", ch, path->id); + printf("%c%lu", ch, (unsigned long)path->id); } } @@ -417,10 +417,10 @@ } else { printf("<p>Attachment:"); /* - printf("%lu", id); + printf("%lu", (unsigned long)id); printidchain(&c, '.'); */ - printf(" <a href=\"%lu", id); + printf(" <a href=\"%lu", (unsigned long)id); printidchain(&c, '/'); printf("\">"); printesc(hstart, hend); @@ -473,7 +473,8 @@ cstring_t hstart, hend; if (index == shown) continue; - printf("<LI>%u. <A HREF=\"%lu/%u\">", index, id, index); + printf("<LI>%u. <A HREF=\"%lu/%u\">", index, + (unsigned long)id, index); if (findhdr(ps, bs, "content-type", &hstart, &hend)) printesc(hstart, hend); else @@ -513,14 +514,17 @@ prev = findprev(o, id); if (prev) - printf("<REL LINK=PREV HREF=\"%lu\">", prev); + printf("<REL LINK=PREV HREF=\"%lu\">", + (unsigned long)prev); if (next) - printf("<REL LINK=NEXT HREF=\"%lu\">", next); + printf("<REL LINK=NEXT HREF=\"%lu\">", + (unsigned long)next); if (start) - printf("<REL LINK=START HREF=\"%lu\">", start); + printf("<REL LINK=START HREF=\"%lu\">", + (unsigned long)start); } printf("<TITLE>"); - /* printf("[%lu] ", id); */ + /* printf("[%lu] ", (unsigned long)id); */ printesc(m->subject, m->subject + strlen(m->subject)); printf("</TITLE></HEAD>\n"); @@ -530,13 +534,16 @@ printf("<P><STRONG>Message killed</STRONG></P>\n"); else { printf("<P>["); - if (prev) printf("<A HREF=\"%lu\">prev</A>", prev); + if (prev) printf("<A HREF=\"%lu\">prev</A>", + (unsigned long)prev); else printf("prev"); printf(" | "); printf("<A HREF=\"../%s/%s?.%lu#m%lu\">index</A>", - relpath, indexfile, id, id); + relpath, indexfile, (unsigned long)id, + (unsigned long)id); printf(" | "); - if (next) printf("<A HREF=\"%lu\">next</A>", next); + if (next) printf("<A HREF=\"%lu\">next</A>", + (unsigned long)next); else printf("next"); printf("]</P>\n"); } @@ -593,7 +600,8 @@ choosemixed(v, s, e, id); else printf("<a href=\"%lu/0\" type=\"%s\">" - "Attachment of type %s</a>", id, v[0], v[0]); + "Attachment of type %s</a>", + (unsigned long)id, v[0], v[0]); } else { textplain: qp = isqp(ha, hb); @@ -634,22 +642,24 @@ if (!killed) { printf("<P>["); - if (prev) printf("<A HREF=\"%lu\">prev</A>", prev); + if (prev) printf("<A HREF=\"%lu\">prev</A>", + (unsigned long)prev); else printf("prev"); printf(" | "); printf("<A HREF=\"../%s/%s#m%lu\">index</A>", relpath, - indexfile, start); + indexfile, (unsigned long)start); printf(" | "); - if (next) printf("<A HREF=\"%lu\">next</A>", next); + if (next) printf("<A HREF=\"%lu\">next</A>", + (unsigned long)next); else printf("next"); printf("]</P>\n"); } /* printf("<P>["); - printf("<a href=\"%lu;mbox\">view raw</a>", id); + printf("<a href=\"%lu;mbox\">view raw</a>", (unsigned long)id); printf(" | "); - printf("<a href=\"%lu;raw\">download raw</a>", id); + printf("<a href=\"%lu;raw\">download raw</a>", (unsigned long)id); printf("]</P>\n"); */ @@ -662,7 +672,7 @@ } if (findhdr(ha, hb, "message-id", &s, &e)) { - printf("<P>[%ld] <SPAN CLASS=messageid>", id); + printf("<P>[%lu] <SPAN CLASS=messageid>", (unsigned long)id); printesc(s, e); printf("</SPAN></P\n"); } |
From: <le...@pr...> - 2005-01-29 13:06:55
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1879 Modified Files: index.c Log Message: correct benign endian conversion direction; add explicit casts to mmap/munmap arguments Index: index.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/index.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- index.c 29 Jan 2005 04:37:45 -0000 1.4 +++ index.c 29 Jan 2005 13:06:46 -0000 1.5 @@ -126,13 +126,13 @@ return -1; /* Initialise the mail0 record */ m0 = (struct mail0 *)m; - m0->version = betoh32(MAIL0_VERSION); - m0->size = betoh32(sizeof (struct mail)); - m0->end = betoh64(0); - m0->date = betoh32(0); - m0->msgs = betoh32(1); - m0->child = betoh32(0); - m0->flags = betoh32(0); + m0->version = htobe32(MAIL0_VERSION); + m0->size = htobe32(sizeof (struct mail)); + m0->end = htobe64(0); + m0->date = htobe32(0); + m0->msgs = htobe32(1); + m0->child = htobe32(0); + m0->flags = htobe32(0); /* Unload the index */ index_unloadn(m, 1); return 0; @@ -147,7 +147,7 @@ void *base; int64_t end = betoh64(m0->end); - base = mmap(NULL, end, PROT_READ, MAP_PRIVATE, fd, 0); + base = mmap(NULL, (size_t)end, PROT_READ, MAP_PRIVATE, fd, 0); if (base == MAP_FAILED) { perror("mmap mbox"); return NULL; @@ -162,6 +162,6 @@ cstring_t base; { int64_t end = betoh64(m0->end); - if (munmap((void *)base, end)) + if (munmap((void *)base, (size_t)end)) perror("munmap mbox"); } |
From: David L. <d...@ad...> - 2005-01-29 12:05:30
|
On Fri, 28 Jan 2005, il...@pr... typed thusly: > Use the correct format specifier for size_t. > + printf("\t$FMTSZ = %zu;\n", sizeof (struct mail)); this is only portable to C99 systems. does that matter? -- David Leonard d...@ad... Ph:+61 404 844 850 |
From: <il...@pr...> - 2005-01-29 04:38:06
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23692 Modified Files: index.c index.h mail.inc mkill.c Log Message: Fixed machine portability of index file. Types are now explicitly sized and always treated as being big endian. Writing on a big endian machine and reading (using mail.inc) on a little endian machine works; the other way around hasn't been tested. Index: index.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/index.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- index.c 24 Nov 2003 05:57:18 -0000 1.3 +++ index.c 29 Jan 2005 04:37:45 -0000 1.4 @@ -46,6 +46,7 @@ { struct mail *m; struct mail0 *m0; + uint32_t version; m = mmap(NULL, msgs * sizeof (struct mail), readonly ? PROT_READ : PROT_READ|PROT_WRITE, @@ -55,9 +56,10 @@ return NULL; } m0 = (struct mail0 *)m; - if (msgs != 1 && m0->version != MAIL0_VERSION) { - fprintf(stderr, "index: bad version number %d, expected %d\n", - (int)m0->version, MAIL0_VERSION); + version = betoh32(m0->version); + if (msgs != 1 && version != MAIL0_VERSION) { + fprintf(stderr, "index: bad version number %ld, expected %d\n", + (long)version, MAIL0_VERSION); munmap(m, msgs * sizeof (struct mail)); return NULL; } @@ -83,8 +85,9 @@ struct mail *mail; { struct mail0 *m0 = (struct mail0 *)mail; + uint32_t msgs = betoh32(m0->msgs); - return index_unloadn(mail, m0->msgs); + return index_unloadn(mail, msgs); } /* Map all mail entries into memory */ @@ -94,13 +97,13 @@ int readonly; { struct mail0 *m0; - int msgs; + uint32_t msgs; /* Map just the first record to get the number of messages */ m0 = (struct mail0 *)index_loadn(fd, 1, readonly); if (m0 == NULL) return NULL; - msgs = m0->msgs; + msgs = betoh32(m0->msgs); /* Now, map the lot */ index_unloadn((struct mail *)m0, 1); return index_loadn(fd, msgs, readonly); @@ -123,13 +126,13 @@ return -1; /* Initialise the mail0 record */ m0 = (struct mail0 *)m; - m0->version = MAIL0_VERSION; - m0->size = sizeof (struct mail); - m0->end = 0; - m0->date = 0; - m0->msgs = 1; - m0->child = 0; - m0->flags = 0; + m0->version = betoh32(MAIL0_VERSION); + m0->size = betoh32(sizeof (struct mail)); + m0->end = betoh64(0); + m0->date = betoh32(0); + m0->msgs = betoh32(1); + m0->child = betoh32(0); + m0->flags = betoh32(0); /* Unload the index */ index_unloadn(m, 1); return 0; @@ -142,8 +145,9 @@ int fd; { void *base; + int64_t end = betoh64(m0->end); - base = mmap(NULL, m0->end, PROT_READ, MAP_PRIVATE, fd, 0); + base = mmap(NULL, end, PROT_READ, MAP_PRIVATE, fd, 0); if (base == MAP_FAILED) { perror("mmap mbox"); return NULL; @@ -157,6 +161,7 @@ struct mail0 *m0; cstring_t base; { - if (munmap((void *)base, m0->end)) + int64_t end = betoh64(m0->end); + if (munmap((void *)base, end)) perror("munmap mbox"); } Index: index.h =================================================================== RCS file: /cvsroot/meshdb/src/mailt/index.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- index.h 10 Aug 2002 03:45:14 -0000 1.1.1.1 +++ index.h 29 Jan 2005 04:37:45 -0000 1.2 @@ -5,35 +5,40 @@ * The first record (mail0) is treated specially. */ -typedef unsigned long msgid_t; +#include <sys/types.h> +#include <inttypes.h> + +#include "../geo/compat/compat.h" + +typedef uint32_t msgid_t; typedef const char *cstring_t; typedef char *string_t; struct mail { - size_t hdrlen; /* incl. last blank line */ - size_t bodylen; - off_t pos; /* start of headers in file */ - time_t date; + uint32_t hdrlen; /* incl. last blank line */ + uint32_t bodylen; + int64_t pos; /* start of headers in file */ + uint32_t date; char from[40]; /* Sender's name */ char subject[60]; /* Subject text */ msgid_t parent, child, sibling; /* Thread tree */ - int flags; + uint32_t flags; #define FLAGS_KILLED 0x0001 /* Message has been killed */ }; /* First entry */ struct mail0 { - size_t size; /* size of each entry */ - size_t version; /* version check */ + uint32_t size; /* size of each entry */ + uint32_t version; /* version check */ #define MAIL0_VERSION 1 - off_t end; /* total size of mbox */ - time_t date; /* index update time */ + int64_t end; /* total size of mbox */ + uint32_t date; /* index update time */ char ign4[40]; char ign5[60]; msgid_t msgs; /* number of messages */ msgid_t child; /* first unparented child */ msgid_t ign8; - int flags; + uint32_t flags; }; int index_create(int fd); Index: mail.inc =================================================================== RCS file: /cvsroot/meshdb/src/mailt/mail.inc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- mail.inc 10 Aug 2002 03:45:14 -0000 1.1.1.1 +++ mail.inc 29 Jan 2005 04:37:45 -0000 1.2 @@ -3,15 +3,20 @@ /* Utility functions to access mail indices */ - $FMT = "Lhdrlen/Lbodylen/Lpos/Ldate/a40from" - ."/a60subject/Lparent/Lchild/Lsibling/Lflags"; - $FMT0 = "Lsize/Lversion/Lend/Ldate/a40ign4" - ."/a60ign5/Lmsgs/Lchild/Lign8/Lflags"; - $FMTSZ = 132; + $FMT = "Nhdrlen/Nbodylen/Nposhi/Nposlo/Ndate/a40from" + ."/a60subject/Nparent/Nchild/Nsibling/Nflags"; + $FMT0 = "Nsize/Nversion/Nendhi/Nendlo/Ndate/a40ign4" + ."/a60ign5/Nmsgs/Nchild/Nign8/Nflags"; + $FMTSZ = 136; $KILLED = 1; - /* off_t is a 64-bit value. (php probably doesnt handle it) */ - function quad($lo, $hi) { + /* Construct a 64 bit value from two 32 bit values. This + * should work on systems where PHP's int is 64 bits, and + * won't cause any problems on 32 bit machines as long as the + * high word is 0. PHP doesn't have an integral type that we + * can safely hold 64 bits in, let alone have unpack() support + * it. */ + function quad($hi, $lo) { return ($hi << 32) | $lo; } @@ -27,7 +32,7 @@ || $m0['version'] != 1) { die("$index: bad format"); } - /* $m0["end"] = quad($m0["endlo"], $m0["endhi"]); */ + $m0["end"] = quad($m0["endhi"], $m0["endlo"]); fseek($idxf, 0); $idx = fread($idxf, $FMTSZ * $m0["msgs"]); fclose($idxf); @@ -50,7 +55,7 @@ if ($i < 1 || $i >= $o["m0"]["msgs"]) die("bad message ID ".$i); $m = unpack($FMT, substr($o["idx"], $FMTSZ * $i, $FMTSZ)); - /* $m["pos"] = quad($m["poslo"], $m["poshi"]); */ + $m["pos"] = quad($m["poshi"], $m["poslo"]); $m["o"] = $o; return $m; } Index: mkill.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/mkill.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mkill.c 24 Nov 2003 06:23:01 -0000 1.2 +++ mkill.c 29 Jan 2005 04:37:45 -0000 1.3 @@ -22,6 +22,7 @@ struct open o; struct mail0 *m0; struct mail *m; + uint32_t msgs; msgid_t i, kid, *sp, lasti; cstring_t mbox, mid, midend; int error = 0; @@ -68,6 +69,7 @@ if (mid == NULL) { /* List killed messages */ + msgs = betoh32(m0->msgs); for (i = 1; i < m0->msgs; i++) if (m[i].flags & FLAGS_KILLED) { if (nflag) |
From: <il...@pr...> - 2005-01-29 04:33:52
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22815 Modified Files: size.c Log Message: Use the correct format specifier for size_t. Index: size.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/size.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- size.c 24 Nov 2003 06:19:54 -0000 1.2 +++ size.c 29 Jan 2005 04:33:40 -0000 1.3 @@ -8,7 +8,7 @@ case 2: printf("n%s", #n); break; \ case 4: printf("L%s", #n); break; \ case 8: printf("L%shi/L%slo", #n, #n); break; \ - default: printf("a%d%s", sizeof ((struct t *)0)->n, #n); \ + default: printf("a%zu%s", sizeof ((struct t *)0)->n, #n); \ } int main() @@ -37,7 +37,7 @@ P(mail0, ign8); putchar('/'); P(mail0, flags); printf("\";\n"); - printf("\t$FMTSZ = %d;\n", sizeof (struct mail)); + printf("\t$FMTSZ = %zu;\n", sizeof (struct mail)); printf("\t$KILLED = %d;\n", FLAGS_KILLED); exit(0); } |
From: <il...@pr...> - 2005-01-29 02:12:24
|
Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28318 Modified Files: open.c Log Message: Better portability by looking for undefinedness directly. Index: open.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/open.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- open.c 12 Mar 2004 11:33:38 -0000 1.3 +++ open.c 29 Jan 2005 02:12:14 -0000 1.4 @@ -9,7 +9,7 @@ #include "index.h" #include "open.h" -#ifndef __FreeBSD__ +#ifndef O_EXLOCK #define O_EXLOCK 0 #endif |
From: <le...@pr...> - 2005-01-28 07:16:35
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24883 Modified Files: Tag: leonard-dev view.php Log Message: use onclick instead of onchange; other minor fixes Index: view.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/view.php,v retrieving revision 1.16.2.5 retrieving revision 1.16.2.6 diff -u -d -r1.16.2.5 -r1.16.2.6 --- view.php 23 Jan 2005 11:48:44 -0000 1.16.2.5 +++ view.php 28 Jan 2005 07:16:27 -0000 1.16.2.6 @@ -114,9 +114,6 @@ function edithelp($text) { } - function isnan($s) { - return ("x".strtolower($s) == "xnan"); - } /* Computes a map of useful calculations about two physloc records */ function elev($loc1, $loc2) { @@ -259,7 +256,9 @@ <table width="100%"> <tr><td> <ul> -<li><a href="edit.php?nodeid=<?=$nodeid?>">Edit this node entry</a> +<? if (!$READONLY) { ?> + <li><a href="edit.php?nodeid=<?=$nodeid?>">Edit this node entry</a> +<? } ?> <li><a href="index.php">Return to index</a> </ul> <td><div align=right> @@ -447,7 +446,7 @@ foreach ($layers as $l) { print "<nobr>" ."<input type=checkbox name=\"BOX".$l["name"]."\" checked" - ." onchange=\"return blah(this)\"" + ." onclick=\"return blah(this)\"" /* ." onChange=\"setMapLayerVisibility(" ."'FORM1', '" @@ -459,7 +458,9 @@ <tr><td class="caption"><? zoomlinks($zoom); foreach ($layers as $l) { - print "<br>". $l["info"]; + if ($l["info"]) { + print "<br><i>".$l["name"]." info:</i> ".$l["info"]; + } } ?> </td></tr> <? } @@ -491,7 +492,8 @@ $mapinfo = "Ground height at site: " . "<strong>$localt</strong> AHD est.<br>" . "Range: low <font color=blue>$minalt</font>m" - . " high <font color=green>$maxalt</font>m"; + . " high <font color=green>$maxalt</font>m<br>" + . " Blue shows predicted visible area"; } |
From: <le...@pr...> - 2005-01-23 12:04:42
|
Update of /cvsroot/meshdb/src/geo/alt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22052 Modified Files: Tag: leonard-dev main.c Log Message: blending and catch some limit excesses Index: main.c =================================================================== RCS file: /cvsroot/meshdb/src/geo/alt/main.c,v retrieving revision 1.3.2.7 retrieving revision 1.3.2.8 diff -u -d -r1.3.2.7 -r1.3.2.8 --- main.c 23 Jan 2005 01:52:23 -0000 1.3.2.7 +++ main.c 23 Jan 2005 12:04:34 -0000 1.3.2.8 @@ -88,7 +88,7 @@ { struct alt alt; int x, y; - rgb_t rgb; + rgba_t rgba; float fmin, fmax; int ch; int error = 0; @@ -244,7 +244,7 @@ 1.0/scale, 1.0/scale); } else { /* generate PNG output */ - image_set_type(IMAGE_TYPE_PNM); + image_set_type(IMAGE_TYPE_PNG); image_begin(w, h); } @@ -346,7 +346,9 @@ for (n = 1; n < nmax; n++) { int p; - for (y = -n; y <= n; y++) { + for (y = -n; y <= n; y++) + if (-h2 <= y && y < h2) + { float d = sqrt(n*n + y*y); float aze = (H(n,y)-h0) / d; float azw = (H(-n,y)-h0) / d; @@ -366,7 +368,7 @@ VISIBLE(-n,y) = (azw >= shadow_w); } - for (y = -h2; y < h2; y++) { + for (y = -h2; y <= h2; y++) { float yr = y * n / (float)h2; int yrI = floor(yr); float yrM = yr - yrI; @@ -380,7 +382,9 @@ wall_w[y+h2+1] = azw; } - for (x = -n; x <= n; x++) { + for (x = -n; x <= n; x++) + if (-w2 <= x && x < w2) + { float d = sqrt(n*n + x*x); float azn = (H(x,n)-h0) / d; float azs = (H(x,-n)-h0) / d; @@ -400,7 +404,7 @@ VISIBLE(x,-n) = (azs >= shadow_s); } - for (x = -w2; x < w2; x++) { + for (x = -w2; x <= w2; x++) { float xr = x * n / (float)w2; int xrI = floor(xr); float xrM = xr - xrI; @@ -467,19 +471,24 @@ /* Crosses (and circles in red) */ if (iscross) { if (iscross == 1) { - rgb[0] = 255; - rgb[1] = rgb[2] = 0; + rgba[0] = 255; + rgba[1] = 0; + rgba[2] = 0; } else { - rgb[0] = 255; - rgb[1] = 0; - rgb[2] = 128; + rgba[0] = 255; + rgba[1] = 0; + rgba[2] = 128; } + rgba[3] = 255; goto plot; } + rgba[3] = 64; + if (isnanf(f)) { - /* Unknown data (sea) is black */ - rgb[0] = rgb[1] = rgb[2] = 0; + /* Unknown data (sea) is grey/trans */ + rgba[0] = rgba[1] = rgba[2] = 128; + rgba[3] = 0; goto plot; } @@ -490,20 +499,23 @@ shade = (f - H(x-1,y-1)) / ((fmax-fmin) * 0.3) + 0.5; if (shade < 0) shade = 0; if (shade > 1) shade = 1; + if (isnanf(H(x-1,y-1))) shade = 0.5; - rgb[0] = rgb[1] = rgb[2] = 255 * shade; + rgba[0] = rgba[1] = rgba[2] = 255 * shade; /* Tinge with blue if visible */ - if (lflag && VISIBLE(x,y)) - rgb[2] = 255 - (255-rgb[2])/4; + if (lflag && VISIBLE(x,y)) { + rgba[2] = 255 - (255-rgba[2])/4; + rgba[3] = 96; + } /* -fprintf(stderr, "[%d,%d] = %lf,%lf -> %f -> <%u,%u,%u>\n", -x,y,lon,lat,f,rgb[0],rgb[1],rgb[2]); +fprintf(stderr, "[%d,%d] = %lf,%lf -> %f -> <%u,%u,%u,%u>\n", +x,y,lon,lat,f,rgba[0],rgba[1],rgba[2],rgba[3]); */ plot: - image_write_rgb(&rgb); + image_write_rgba(&rgba); } } if (vflag) |
From: <le...@pr...> - 2005-01-23 11:48:54
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18169 Modified Files: Tag: leonard-dev view.php Log Message: put back the usemap on the layered images Index: view.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/view.php,v retrieving revision 1.16.2.4 retrieving revision 1.16.2.5 diff -u -d -r1.16.2.4 -r1.16.2.5 --- view.php 23 Jan 2005 11:26:29 -0000 1.16.2.4 +++ view.php 23 Jan 2005 11:48:44 -0000 1.16.2.5 @@ -434,15 +434,15 @@ $layers = array(); - function printlayeredmaps($layers,$w,$h) { + function printlayeredmaps($layers,$w,$h,$zoom) { if (count($layers)) { ?> <tr><th class="minor">Integrated maps</th></tr> <tr><th class="figure"><table><tr><td><div id=integrated style="position: relative"><? foreach ($layers as $l) { print "<div id=\"MAP". $l["name"] ."\" style=\"position: absolute\">" - ."<img src=\"".$l["url"]."\" width=$w height=$h></div>\n"; + ."<img style=\"border:none\" usemap=\"#nodes\" src=\"".$l["url"]."\" width=$w height=$h></div>\n"; } - print "</div><img src=\"white.gif\" width=$w height=$h></td><td>"; + print "</div><img style=\"border:none\" src=\"white.gif\" width=$w height=$h></td><td>"; print "<form name=\"FORM1\">"; foreach ($layers as $l) { print "<nobr>" @@ -500,7 +500,7 @@ ?> <tr><th class="minor"><?=$mapname?></th></tr> <tr><td class="figure"><img width=<?=$w?> height=<?=$h?> - usemap="$nodes" src="<?=$mapurl?>" title="<?=$mapdesc?>"</td></tr> + usemap="#nodes" src="<?=$mapurl?>" title="<?=$mapdesc?>"</td></tr> <tr><td class="caption"><?=zoomlinks($zoom)?> <? if ($mapinfo) { print "<br>".$mapinfo; } ?> </td></tr> @@ -513,7 +513,7 @@ "info" => $mapinfo)); } } else { - printlayeredmaps($layers,$w,$h); + printlayeredmaps($layers,$w,$h,$zoom); $layers = array(); } @@ -652,7 +652,7 @@ <? } } /* foreach maptype */ - printlayeredmaps($layers,$w,$h); + printlayeredmaps($layers,$w,$h,$zoom); ?> </table> </td> |
From: <le...@pr...> - 2005-01-23 11:39:03
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16195 Modified Files: Tag: leonard-dev map4b.php Log Message: correct string placement to match location plots Index: map4b.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/map4b.php,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- map4b.php 9 May 2004 03:32:30 -0000 1.4 +++ map4b.php 23 Jan 2005 11:38:55 -0000 1.4.2.1 @@ -53,7 +53,7 @@ ImageLine($im, $x-1, $y-1, $x+1, $y+1, $col); ImageLine($im, $x+1, $y-1, $x-1, $y+1, $col); if ($shownumbers) - ImageString($im, 1, $x+2, $y+2, $name, $namecol); + ImageString($im, 1, $x+4, $y-4, $name, $namecol); } /* Clip x1 to lie between 0 and maxx */ @@ -70,16 +70,18 @@ return array($x1, $y1); } -$im = @ImageCreate($w, $h) - or die("ImageCreate"); +$im = @ImageCreateTrueColor($w, $h) + or die("ImageCreateTrueColor"); +ImageAlphaBlending($im, FALSE); +ImageSaveAlpha($im, TRUE); -$BLACK = ImageColorAllocate($im, 0, 0, 0); -$WHITE = ImageColorAllocate($im, 255, 255, 255); -$BLUE = ImageColorAllocate($im, 64, 64, 255); -$RED = ImageColorAllocate($im, 255, 0, 0); -$GREY = ImageColorAllocate($im, 128, 128, 128); -$LIGHTGREY = ImageColorAllocate($im, 255, 220, 220); -$LIGHTBLUE = ImageColorAllocate($im, 220, 220, 255); +$BLACK = ImageColorAllocateAlpha($im, 0, 0, 0, 128); +$WHITE = ImageColorAllocateAlpha($im, 255, 255, 255, 255); +$BLUE = ImageColorAllocateAlpha($im, 64, 64, 255, 128); +$RED = ImageColorAllocateAlpha($im, 255, 0, 0, 128); +$GREY = ImageColorAllocateAlpha($im, 128, 128, 128, 128); +$LIGHTGREY = ImageColorAllocateAlpha($im, 255, 220, 220, 128); +$LIGHTBLUE = ImageColorAllocateAlpha($im, 220, 220, 255, 128); ImageFilledRectangle($im, 0, 0, $w, $h, $WHITE); |
From: <le...@pr...> - 2005-01-23 11:27:25
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13785 Added Files: Tag: leonard-dev white.gif Log Message: a white pixel needed for the "background" map --- NEW FILE: white.gif --- (This appears to be a binary file; contents omitted.) |
From: <le...@pr...> - 2005-01-23 11:26:52
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13660 Modified Files: Tag: leonard-dev view.php Log Message: initial work on integrated (blended) maps Index: view.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/view.php,v retrieving revision 1.16.2.3 retrieving revision 1.16.2.4 diff -u -d -r1.16.2.3 -r1.16.2.4 --- view.php 8 Nov 2004 14:16:15 -0000 1.16.2.3 +++ view.php 23 Jan 2005 11:26:29 -0000 1.16.2.4 @@ -15,6 +15,10 @@ if ($nodeid == "") die("no nodeid"); + /* + * Returns an URL to this page, merging the array $a + * into the current _GET array + */ function selfurl($a) { $oa = array(); $defvars = array("nodeid", "peerid", "zoom"); @@ -31,6 +35,8 @@ return "view.php?" . $url; } + /* Returns a global value, named as "<name>[<key>]" or "name". + * This is called by every val* function below. */ function valof($name) { if (substr($name, strlen($name) - 1, 1) == "]") { $zz = split('\[', substr($name, 0, strlen($name) - 1)); @@ -38,35 +44,41 @@ $kn = $zz[1]; return $GLOBALS[$an][$kn]; } else - return $$name; + return $$name; /* XXX $GLOBALS[$name] ? */ } + + /* Protects and returns a normal variable in HTML */ function val($name, $attr = "") { /* convert @ to @ as spam bots mightn't see them */ return str_replace("@", "@", htmlspecialchars(valof($name))); } + /* Returns a plain URL variable as HTML */ function valurl($name, $attr = "") { $v = valof($name); if ($v == "") return ""; return "<a href=\"$v\">". htmlspecialchars($v) . "</a>"; } - function valimgurl($name, $attr = "") { + /* Returns an image URL variable as HTML */ + function valimgurl($name, $attr = "", $alt="Site image") { $v = valof($name); if ($v == "") return ""; - return "<a href=\"$v\"><img src=\"$v\" alt=\"Site image\"></a>"; + return "<a href=\"$v\"><img src=\"$v\" alt=\"" + .htmlspecialchars($alt)."\"></a>"; } - + /* Return a multiline text variable in HTML */ function valtext($name, $attr = "") { + /* Replace 'node #nn' with a hyperlink */ $markeduptext = eregi_replace("(node #?([0-9]+))", "<a href=\"view.php?nodeid=\\2\">\\1</a>", htmlspecialchars(valof($name))); return "<span class=\"text\">$markeduptext</span>"; } - + /* Return a code-like variable in HTML */ function valcode($name, $attr = "") { return "<code>".htmlspecialchars(valof($name))."</code>"; } - + /* Return a nodeid variable as a pull-down HTML */ function valnodeid($name, $attr = "") { global $db; global $PREF; @@ -89,14 +101,13 @@ $v .= " <strong>(invalid)</strong>"; return $v; } - + /* Return a boolean variable as Yes or No */ function valyesno($name, $attr = "") { if (valof($name)) return "Yes"; else return "No"; } - function selectval($name, $options, $attr = "") { return htmlspecialchars($options[valof($name)]); } @@ -107,8 +118,9 @@ return ("x".strtolower($s) == "xnan"); } + /* Computes a map of useful calculations about two physloc records */ function elev($loc1, $loc2) { - global $ZONE, $SHIFTFILE, $ALTFILE; + global $ZONE, $SHIFTFILE, $ALTFILE, $BINDIR; $e1 = doubleval($loc1["e"]); $n1 = doubleval($loc1["n"]); @@ -151,6 +163,7 @@ "isclear" => $isclear); } + /* Returns an URL to an elevation diagram for two locs */ function elevurl($loc1, $loc2, $w, $h) { $e1 = doubleval($loc1["e"]); $n1 = doubleval($loc1["n"]); @@ -212,6 +225,32 @@ <link rel="start" href="index.php"> <link rel="icon" href="favicon.ico"> <title>View node #<?=$nodeid?>: <?=val("admin[nodename]")?></title> + + <script lang="javascript"> + function getVisString(b) { + return b ? "visible" : "hidden"; + } + var setMapLayerVisibility; + if (document.getElementById) setMapLayerVisibility = + function(n,b) { + document.getElementById(n).style.visibility = getVisString(b); + }; + else if (document.all) setMapLayerVisibility = + function(n,b) { document.all[n].style.visibility = getVisString(b); }; + else if (document.layers) setMapLayerVisibility = + function(n,b) { document[n].visibility = getVisString(b); }; + else setMapLayerVisibility = + function(n,b) { + alert("Can't figure out how to change visibility; report this error!"); + }; + + function blah(chk) { + var name = chk.name.substring(3); + setMapLayerVisibility("MAP"+name, chk.checked); + return false; + } + </script> + </head> <body> <h1>View node #<?=$nodeid?>: <?=val("admin[nodename]")?></h1> @@ -356,24 +395,17 @@ $paramb .= "&t[$nodeid]=X"; if ($peerid) $paramb .= "&t[$peerid]=o"; $paramb .= "&maxage=".$PREF["maxnodeage"]; - if ($s < 0.008) $paramb .= "&nonumbers=1"; $param = htmlspecialchars($param); $paramb = htmlspecialchars($paramb); ?> <td> + <map name="nodes"><?=$mapdef?></map> <table class="maps"> <tr><th class="major">Maps</th></tr> <? - foreach ($maps as $maptype) { - if ($maptype == "net") { ?> - <tr><th class="minor">Network</th></tr> - <tr><td class="figure"><img width=<?=$w?> height=<?=$h?> - usemap="#nodes" - src="map4b.php?<?=$paramb?>" - alt="Network connection map"></td></tr> - <tr><td class="caption"> -<? + + /* Returns an URL that zooms in/out */ function zoomlink($desired, $current) { if ($desired < 1) $desiredtext = round(1 / -$desired); @@ -384,6 +416,7 @@ else print $desiredtext . "x"; } + /* Prints HTML that provides zoom in/out choices */ function zoomlinks($current) { ?> zoom: @@ -398,40 +431,93 @@ <a href="<?=selfurl(array("zoom"=>$current/2))?>">out</a> <? } - zoomlinks($zoom); -?> - <br> - <font color=blue>-</font> active, - <font color=gray>-</font> inactive, - <font color=gray>O</font> multipeer - </td></tr> - <? } else if ($maptype == "loc") { ?> - <tr><th class="minor">Location</th></tr> - <tr><td class="figure"><map name="nodes"><?=$mapdef?> - </map><img width=<?=$w?> height=<?=$h?> - usemap="#nodes" - src="map2b.php?<?=$paramb?>" - alt="location map"></td></tr> - <tr><td class="caption"> - <?=zoomlinks($zoom)?> - <br> - </td></tr> - <? } else if ($maptype == "ter") { ?> - <tr><th class="minor">Terrain</th></tr> - <tr><td class="figure"><img width=<?=$w?> height=<?=$h?> - usemap="#nodes" - src="map3b.php?<?=$paramb?>" - alt="terrain map"></td></tr> - <tr><td class="caption"> - <?=zoomlinks($zoom)?> - <br> - Ground height at site: - <strong><?=$localt?></strong> AHD est.<br> - Map range: low <font color=blue><?=$minalt?></font>m, - high <font color=green><?=$maxalt?></font>m - </td></tr> - <? } else if ($maptype == "elev") { ?> + $layers = array(); + + function printlayeredmaps($layers,$w,$h) { + if (count($layers)) { ?> + <tr><th class="minor">Integrated maps</th></tr> + <tr><th class="figure"><table><tr><td><div id=integrated style="position: relative"><? + foreach ($layers as $l) { + print "<div id=\"MAP". $l["name"] ."\" style=\"position: absolute\">" + ."<img src=\"".$l["url"]."\" width=$w height=$h></div>\n"; + } + print "</div><img src=\"white.gif\" width=$w height=$h></td><td>"; + print "<form name=\"FORM1\">"; + foreach ($layers as $l) { + print "<nobr>" + ."<input type=checkbox name=\"BOX".$l["name"]."\" checked" + ." onchange=\"return blah(this)\"" + /* + ." onChange=\"setMapLayerVisibility(" + ."'FORM1', '" + . $l["name"] . "');return false;\" + */ + .">" . $l["name"] . "</nobr><br>"; + } + print "</form></td></tr></table></td></tr>"; ?> + <tr><td class="caption"><? + zoomlinks($zoom); + foreach ($layers as $l) { + print "<br>". $l["info"]; + } ?> + </td></tr> <? + } + } + + foreach ($maps as $maptype) { + $mapname = ""; + $mapdesc = ""; + $mapurl = ""; + $mapinfo = ""; + + if ($maptype == "net") { + $mapname = "Network"; + $mapdesc = "Active node-to-node links"; + $mapurl = "map4b.php?$paramb"; + $mapinfo = "Key: <font color=blue>-</font> active," + ." <font color=gray>-</font> inactive," + ."<font color=gray>O</font> multipeer"; + + } else if ($maptype == "loc") { + $mapname = "Location"; + $mapdesc = "Street directory features"; + $mapurl = "map2b.php?$paramb"; + + } else if ($maptype == "ter") { + $mapname = "Terrain"; + $mapdesc = "Surface altitude and visibility"; + $mapurl = "map3b.php?$paramb&nodeid=$nodeid"; + $mapinfo = "Ground height at site: " + . "<strong>$localt</strong> AHD est.<br>" + . "Range: low <font color=blue>$minalt</font>m" + . " high <font color=green>$maxalt</font>m"; + } + + + if ($mapname) { + if ($nolayers) { + ?> + <tr><th class="minor"><?=$mapname?></th></tr> + <tr><td class="figure"><img width=<?=$w?> height=<?=$h?> + usemap="$nodes" src="<?=$mapurl?>" title="<?=$mapdesc?>"</td></tr> + <tr><td class="caption"><?=zoomlinks($zoom)?> + <? if ($mapinfo) { print "<br>".$mapinfo; } ?> + </td></tr> + <? + } else { + array_push($layers, array( + "name" => $mapname, + "desc" => $mapdesc, + "url" => $mapurl, + "info" => $mapinfo)); + } + } else { + printlayeredmaps($layers,$w,$h); + $layers = array(); + } + + if ($maptype == "elev") { ?> <tr><th class="minor">Elevation diagram</th></tr> <tr><td><form action="view.php"> Peer node: @@ -566,6 +652,7 @@ <? } } /* foreach maptype */ + printlayeredmaps($layers,$w,$h); ?> </table> </td> |
From: <le...@pr...> - 2005-01-23 05:08:01
|
Update of /cvsroot/meshdb/src/vpf/gdps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3395 Modified Files: Tag: leonard-dev draw.c main.c Log Message: more alpha channel support Index: draw.c =================================================================== RCS file: /cvsroot/meshdb/src/vpf/gdps/draw.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -d -r1.6 -r1.6.2.1 --- draw.c 25 Nov 2003 07:10:34 -0000 1.6 +++ draw.c 23 Jan 2005 05:07:52 -0000 1.6.2.1 @@ -49,10 +49,11 @@ int col; gdImageSetThickness(gs->im, gs->linewidth); - col = gdImageColorAllocate(gs->im, + col = gdImageColorAllocateAlpha(gs->im, 255 * (gs->color.r), 255 * (gs->color.g), - 255 * (gs->color.b)); + 255 * (gs->color.b), + 255 * (gs->color.a)); return col; } Index: main.c =================================================================== RCS file: /cvsroot/meshdb/src/vpf/gdps/main.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- main.c 22 Oct 2003 06:26:58 -0000 1.4 +++ main.c 23 Jan 2005 05:07:52 -0000 1.4.2.1 @@ -28,6 +28,7 @@ char *s; int ch; int error = 0; + gdImagePtr image; /* Parse command line arguments */ while ((ch = getopt(argc, argv, "dg:")) != -1) @@ -55,8 +56,13 @@ exit(1); } + /* Create an image buffer */ + image = gdImageCreateTrueColor(width, height); + gdImageSaveAlpha(image, 1); /* keep alpha vlaues in output */ + gdImageAlphaBlending(image, 0); + /* Set up initial global state and erase the page */ - gstate_init(&gs, gdImageCreate(width, height)); + gstate_init(&gs, image); run_name(&gs, "erasepage"); /* Run standard input */ |
From: <le...@pr...> - 2005-01-23 04:58:57
|
Update of /cvsroot/meshdb/src/vpf/gdps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1402 Modified Files: Tag: leonard-dev gstate.c gstate.h operator.c Log Message: Add some alpha blending operators mentioned in http://www.cs.wisc.edu/~ghost/doc/cvs/Language.htm#Transparency Index: gstate.c =================================================================== RCS file: /cvsroot/meshdb/src/vpf/gdps/gstate.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- gstate.c 18 Sep 2002 03:22:46 -0000 1.2 +++ gstate.c 23 Jan 2005 04:58:47 -0000 1.2.2.1 @@ -32,6 +32,7 @@ gs->color.r = 0; gs->color.g = 0; gs->color.b = 0; + gs->color.a = 1; gs->linewidth = 1; gs->font = NULL; Index: gstate.h =================================================================== RCS file: /cvsroot/meshdb/src/vpf/gdps/gstate.h,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- gstate.h 18 Sep 2002 03:22:46 -0000 1.2 +++ gstate.h 23 Jan 2005 04:58:47 -0000 1.2.2.1 @@ -8,7 +8,7 @@ double a,b,c,d,tx,ty; } ctm; struct { - double r,g,b; + double r,g,b,a; } color; double linewidth; object_t *font; Index: operator.c =================================================================== RCS file: /cvsroot/meshdb/src/vpf/gdps/operator.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -d -r1.6 -r1.6.2.1 --- operator.c 25 Nov 2003 21:11:37 -0000 1.6 +++ operator.c 23 Jan 2005 04:58:47 -0000 1.6.2.1 @@ -911,6 +911,23 @@ } static void +setopacityalpha(gs) + struct gstate *gs; +{ + double a = real(gs); + + if (a < 0 || a > 1) die(".setopacityalpha: bad alpha %f", a); + gs->color.a = a; +} + +static void +currentopacityalpha(gs) + struct gstate *gs; +{ + PUSH(real_new(gs->color.a)); +} + +static void findfont(gs) struct gstate *gs; { @@ -1062,6 +1079,9 @@ { "setgray", setgray }, { "setlinewidth",setlinewidth }, + { ".setopacityalpha",setopacityalpha }, + { ".currentopacityalpha",currentopacityalpha }, + { "clip", notimpl }, { "findfont", findfont }, |
From: <le...@pr...> - 2005-01-23 01:52:42
|
Update of /cvsroot/meshdb/src/geo/alt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24905 Modified Files: Tag: leonard-dev main.c Log Message: replace stupid neighbour algorithm with a more realstic projection algorithm Index: main.c =================================================================== RCS file: /cvsroot/meshdb/src/geo/alt/main.c,v retrieving revision 1.3.2.6 retrieving revision 1.3.2.7 diff -u -d -r1.3.2.6 -r1.3.2.7 --- main.c 22 Jan 2005 09:51:37 -0000 1.3.2.6 +++ main.c 23 Jan 2005 01:52:23 -0000 1.3.2.7 @@ -264,7 +264,7 @@ hm = (float *)malloc((w+2) * (h+2) * sizeof (float)); /* Shift hm so that H[-h2-1,-w2-1] == h[0] (step of w+1) */ -#define MAP(m,x,y) (m)[(x) + (w+2)*(y) - (w+2)*(h+2)/2] +#define MAP(m,x,y) (m)[((x) + (w2+1)) + (w+2)*((y) + (h2+1))] #define H(x,y) MAP(hm,x,y) /* Compute the height map */ @@ -272,61 +272,149 @@ n = n0 - y / scale; for (x = -w2 -1; x <= w2; x++) { e = e0 + x / scale; - H(x,y) = alt_fastat(&alt, e, n); +#if 1 + H(x,y) = alt_fastat(&alt, e, n); +#else + /* Synthetic test features */ + { + float d = sqrtf((float)x * x + (float)y * y); + float h = 0; + float th = atan2f(y,x); + + if ((0.5 < th && th < 0.7) || + (1.8 < th && th < 2.2)) { + if (75 < d && d <= 80) + h = 4 * (d-75); + else if (80 < d && d <= 85) + h = 4 * (85-d); + } + H(x,y) = h; + } +#endif } } if (lflag) { + /* + * The line-of-sight algorithm works like this: + * Imaging a vertical wall surrounding the + * grid. On this wall we mark the 'shadow' of + * processed cells. + * We process cells in (ractangular) rings. + * Each ring's cells are processed like this: + * Step 1. compute that cell's 'rise over run' + * r = (h(x,y)-h0)/sqrt(x^2+y^2) + * Step 2. Project the cell onto the wall to compare + * its r value against the previous ring's shadow. + * If r is bigger, then the cell is visible + * + * After processing all the cells in the ring, + * the next step is to re-process the wall shadow. + * Step 3. Project each wall cell onto the ring. + * Compute the projected point's rise/run (perhaps + * interpolating from the height map) + * Step 4. Update the wall shadow if the rise/run + * has increased. + * + * Unlike previous algorithms, this one retains + * directional precision. Also of benefit is that + * the running time is still O(n^2). + */ + int n, nmax = w2 > h2 ? w2 : h2; - azm = (float *)malloc((w+2) * (h+2) * sizeof (float)); - azmaxm = (float *)malloc((w+2) * (h+2) * sizeof (float)); + /* Initialise the wall to a r/r of ZENITH (-Inf) */ +#define ZENITH (-Inf) + float *wall_e = (float*)malloc((h+2) * sizeof (float)); + float *wall_w = (float*)malloc((h+2) * sizeof (float)); + float *wall_n = (float*)malloc((h+2) * sizeof (float)); + float *wall_s = (float*)malloc((h+2) * sizeof (float)); + float *az_e = (float *)malloc((h+2) * sizeof (float)); + float *az_w = (float *)malloc((h+2) * sizeof (float)); + float *az_n = (float *)malloc((w+2) * sizeof (float)); + float *az_s = (float *)malloc((w+2) * sizeof (float)); + + for (x = -w2-1; x < w2+1; x++) + wall_n[x+w2+1] = wall_s[x+w2+1] = ZENITH; + for (y = -h2-1; y < h2+1; y++) + wall_e[y+h2+1] = wall_w[y+h2+1] = ZENITH; + visiblem = (char *)malloc((w+2) * (h+2) * sizeof (char)); -#define AZ(x,y) MAP(azm,x,y) -#define AZMAX(x,y) MAP(azmaxm,x,y) #define VISIBLE(x,y) MAP(visiblem,x,y) -#define ZENITH (-Inf) - AZ(0,0) = AZMAX(0,0) = ZENITH; VISIBLE(0,0) = 1; - for (n = 1; n < nmax; n++) { int p; - float d; -#define LOS(x,y,xp,yp,xq,yq) \ - if (-w2<(x) && (x)<w2 && -h2<(y) && (y)<h2) { \ - float az, azprev, azmaxprev; \ - az = (H(x,y) - h0) / d; \ - if (isnanf(az)) az = ZENITH; \ - azprev = AZ(xp,yp)*(p/n) + \ - AZ(xq,yq)*(1-p/n); \ - azmaxprev = AZMAX(xp,yp)*(p/n) + \ - AZMAX(xq,yq)*(1-p/n); \ - if (az < azmaxprev) { \ - AZMAX(x,y) = azmaxprev; \ - VISIBLE(x,y) = 0; \ - } else { \ - AZMAX(x,y) = az; \ - VISIBLE(x,y) = 1; \ - } \ - AZ(x,y) = az; \ - } + for (y = -n; y <= n; y++) { + float d = sqrt(n*n + y*y); + float aze = (H(n,y)-h0) / d; + float azw = (H(-n,y)-h0) / d; + float yp = y * h2 / (float)n; + int ypI = floor(yp); + float ypM = yp - ypI; + float shadow_e = wall_e[ypI+h2+1] * (1-ypM) + + wall_e[ypI+h2+1+1] * ypM; + float shadow_w = wall_w[ypI+h2+1] * (1-ypM) + + wall_w[ypI+h2+1+1] * ypM; + + if (isnanf(aze)) aze = ZENITH; + if (isnanf(azw)) azw = ZENITH; + az_e[y+h2+1] = aze; + az_w[y+h2+1] = azw; + VISIBLE(n,y) = (aze >= shadow_e); + VISIBLE(-n,y) = (azw >= shadow_w); + } + + for (y = -h2; y < h2; y++) { + float yr = y * n / (float)h2; + int yrI = floor(yr); + float yrM = yr - yrI; + float aze = az_e[yrI+h2+1] * (1-yrM) + + az_e[yrI+h2+1+1] * yrM; + float azw = az_w[yrI+h2+1] * (1-yrM) + + az_w[yrI+h2+1+1] * yrM; + if (wall_e[y+h2+1] < aze) + wall_e[y+h2+1] = aze; + if (wall_w[y+h2+1] < azw) + wall_w[y+h2+1] = azw; + } + + for (x = -n; x <= n; x++) { + float d = sqrt(n*n + x*x); + float azn = (H(x,n)-h0) / d; + float azs = (H(x,-n)-h0) / d; + float xp = x * w2 / (float)n; + int xpI = floor(xp); + float xpM = xp - xpI; + float shadow_n = wall_n[xpI+w2+1] * (1-xpM) + + wall_n[xpI+w2+1+1] * xpM; + float shadow_s = wall_s[xpI+w2+1] * (1-xpM) + + wall_s[xpI+w2+1+1] * xpM; + + if (isnanf(azn)) azn = ZENITH; + if (isnanf(azs)) azs = ZENITH; + az_n[x+w2+1] = azn; + az_s[x+w2+1] = azs; + VISIBLE(x,n) = (azn >= shadow_n); + VISIBLE(x,-n) = (azs >= shadow_s); + } + + for (x = -w2; x < w2; x++) { + float xr = x * n / (float)w2; + int xrI = floor(xr); + float xrM = xr - xrI; + float azn = az_n[xrI+w2+1] * (1-xrM) + + az_n[xrI+w2+1+1] * xrM; + float azs = az_s[xrI+w2+1] * (1-xrM) + + az_s[xrI+w2+1+1] * xrM; + if (wall_n[x+w2+1] < azn) + wall_n[x+w2+1] = azn; + if (wall_s[x+w2+1] < azs) + wall_s[x+w2+1] = azs; + } + - for (p = 1; p <= n; p++) { - d = sqrt(n*n + p*p); - LOS(n,p,n-1,p-1,n-1,p) /* ESE */ - LOS(-p,n,-(p-1),n-1,-p,n-1) /* SSW */ - LOS(-n,-p,-(n-1),-(p-1),-(n-1),-p) /* WNW */ - LOS(p,-n,p-1,-(n-1),p,-(n-1)) /* NNE */ - } - for (p = 0; p < n; p++) { - d = sqrt(n*n + p*p); - LOS(n,-p,n-1,-(p-1),n-1,-p) /* ENE */ - LOS(p,n,p-1,n-1,p,n-1) /* SSE */ - LOS(-n,p,-(n-1),p-1,-(n-1),p) /* WSW */ - LOS(-p,-n,-(p-1),-(n-1),-p,-(n-1)) /* NNW */ - } } } @@ -355,7 +443,7 @@ dy = y - cross[i].y; if ((dx == dy || dx == -dy) && (-CROSS2 < dx && dx < CROSS2)) - iscross = 1; + iscross = 2; break; case 'x': @@ -378,8 +466,14 @@ /* Crosses (and circles in red) */ if (iscross) { - rgb[0] = 255; - rgb[1] = rgb[2] = 0; + if (iscross == 1) { + rgb[0] = 255; + rgb[1] = rgb[2] = 0; + } else { + rgb[0] = 255; + rgb[1] = 0; + rgb[2] = 128; + } goto plot; } |