Index: /other-projects/nightly-tasks/crons-and-scripts/caveat-emptor/files.php
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/caveat-emptor/files.php	(revision 32968)
+++ /other-projects/nightly-tasks/crons-and-scripts/caveat-emptor/files.php	(revision 32968)
@@ -0,0 +1,11 @@
+<?php
+header("Content-Type: text/plain");
+
+$handle = opendir(".");
+if ( $handle === false ) return;
+
+while ( $file = readdir($handle) ) if ( !preg_match("/^\./", $file) )  {
+	echo "$file\n";
+}
+
+closedir($handle);
Index: /other-projects/nightly-tasks/crons-and-scripts/caveat-emptor/index.php
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/caveat-emptor/index.php	(revision 32968)
+++ /other-projects/nightly-tasks/crons-and-scripts/caveat-emptor/index.php	(revision 32968)
@@ -0,0 +1,275 @@
+<html>
+<head>
+	<title>Caveat Emptor</title>
+	<style type="text/css">
+		body { font-family: monospace; }
+		td { padding: 0 20px 0 0; text-align:right; }
+		td:first-child { text-align: left; }
+		h1,h2,h3,h4,h5,h6 { margin-bottom: .2em; }
+
+/* CSS to display an cross-out icon if the URL contains "diffcol-FAIL". 
+Based on:
+
+http://www.devwebpro.com/developer-icon-sets-collection-of-the-best-free-to-both-personal-commercial-use-icon-sets/
+http://www.electrictoolbox.com/add-offsite-link-icon-after-external-links-css/
+http://webcodertools.com/imagetobase64converter
+http://www.greywyvern.com/code/php/binary2base64
+Use this tool to create data streams for embedding images (or any type of file) in (X)HTML, CSS and XML.
+http://stackoverflow.com/questions/49368/css2-attribute-selectors-with-regex
+http://tools.css3.info/selectors-test/test.html
+http://tools.css3.info/selectors-test/test-attribute-contains.html#attribute-contains
+*/
+		    a[href*="diffcol-FAIL-"] {
+		    background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAMCAYAAAC0qUeeAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB90LDQYPCR0HlEQAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAB20lEQVQozwXBT0hTcQDA8e/v9/bb1uZWY2mjqI6RXZK6dg+pLhVBh7KDGP0xIqOOdQmCTMv8AwVBnvqLWF3qnl2iUNAwJSc2nJvP7W3v7b239/br8xE69DWeT9+FHo52HUZJA0MHVEtrKEOwuLzK4MRzyHYgtG3rB/03uHv5CjJoApra2l+kvYVjVdDRNKOv33B/+gPiYW+fHui5xPz3Gbwtk4jfZGciTr20xu5cB8UNC5nLMfRpGqFnfujZr1+IRkO045DwBMmowmpUqJoVcm27CKIJyqk40i0WSWqNWy5x8NxZRNhi06zyezlP1+07BHYNv1wk7TeRnuvQ8hxink/+5ST7eq8yt1Kge3iE8ru3xI0GKjRJ6DpyeyaD13DIpNpoODbvB25yZmyE+VeTLBX+UXFrtLSP0QqQTatORERYNzdYXP3D6bHHLEy+oPPieZrJbTgqjkpn8T2FJKJwwxCQnBp8RH78KeWVJb49e8Kxa9dRsSiFSo2alohfQ+N6c26WlG+REiFGRICMUKu7KKXYLBfI7N2P2HMAI428d+RQJ9RtHNOEIMSzLHYYMVqeS1t7FjraGf34GaGrdd3ffZxbJ04SbqwjgwAZtNC2jVYGbibJ8NQUEz8X+A8Zn+eqFS9aTQAAAABJRU5ErkJggg==) center left no-repeat;
+		      padding-left: 13px;
+		    }
+	</style>
+</head>
+<body>
+
+<?php
+
+	  //chdir("/greenstone/greenstone.org/base/caveat-emptor");
+if ( $_GET['latest'] ) {
+  chdir("/greenstone/greenstone.org/base/caveat-emptor/latest");
+ } else {
+  chdir("/greenstone/greenstone.org/base/caveat-emptor");
+ }
+$handle = opendir( "." );
+if ( $handle === false ) exit;
+$todayFiles = array();
+
+if ( $_GET['offset']) {
+	$todayStart = strtotime(date("Y-m-d",strtotime($_GET['offset'] . " days")));
+} else {
+	$todayStart = strtotime(date("Y-m-d"));
+}
+$tomorrowStart = strtotime("+1 days", $todayStart );
+
+$today = date("Y.m.d", $todayStart);
+$todayWithHyphens = date("Y-m-d", $todayStart);
+
+$nextRelease2 = trim(file_get_contents("/greenstone/greenstone.org/base/next-release.txt"));
+$nextRelease3 = trim(file_get_contents("/greenstone/greenstone.org/base/next-release-greenstone3.txt"));
+
+while ( ($file = readdir($handle)) !== false ) {
+	if ( substr($file,0,1) == "." ) continue;
+	if ( $file === "index.php" ) continue;
+	if ( $_GET['latest'] ) {	  
+	  $todayFiles[$file] = true;
+	  continue;
+	}
+   
+	if ( filemtime($file) >= $todayStart && filemtime($file) < $tomorrowStart ) {
+	
+	  $todayFiles[$file] = true;
+	}
+}
+closedir( $handle );
+
+// sort array keys (filenames) in ascending order (array values are true/false)
+// see http://www.php.net/manual/en/function.ksort.php
+ksort($todayFiles);
+
+define( 'TOTAL_COLS', 3 );
+function heading( $text, $level = 3 ) {
+	?>
+<tr>
+<td colspan="<?php echo TOTAL_COLS; ?>">
+<?php echo "<h" . $level . ">"; ?>
+<?php echo $text; ?>
+<?php echo "</h" . $level . ">"; ?>
+</td>
+</tr>
+<?php
+}
+
+function anchorheading( $text, $id, $level = 3 ) {
+	?>
+<tr>
+<td colspan="<?php echo TOTAL_COLS; ?>">
+<?php echo "<h" . $level . " id=\"".$id."\">"; ?>
+<?php echo $text; ?>
+<?php echo "</h" . $level . ">"; ?>
+</td>
+</tr>
+<?php
+}
+
+
+function gap() {
+        ?>
+
+<tr><td colspan="<?php echo TOTAL_COLS; ?>"><br/></td></tr>
+<?php
+}
+
+function show( $file, $forceShow, $extra_info, $rename ) {
+	global $todayFiles;
+
+	if ( $_GET['latest'] ) {
+	  //echo "XXX $file";
+
+	  $regex = preg_replace( "/\d{4}.\d{2}\.\d{2}/", "\d{4}.\d{2}.\d{2}", $file );
+	  $regex = preg_replace( "/\./", "\.", $regex );
+	  
+	  //echo " ZZZ $regex <br />";
+
+	  foreach( $todayFiles as $filename=>$notShown ) {
+	    if ( $notShown && preg_match( "/^$regex$/", $filename ) ) {
+	      //echo "BBB $filename<br />";
+	      //$todayFiles[$file] = false;
+	      $file = $filename;
+	      
+	    }
+	  }
+
+	}
+	$todayFiles[$file] = false;
+	//echo "CCC $file <br />";
+
+	if ( file_exists($file) || $forceShow ) {
+	  if ( $_GET['latest'] ) {
+
+	    $filepath="latest/".$file;
+	  } else {
+	    $filepath=$file;
+	  }
+		?>
+<tr>
+	    <td><a href="<?php echo $filepath; ?>"><?php if($rename) { echo $rename; } else { echo $file; } ?></a><?php if($extra_info) { echo " - ".$extra_info; } ?></td>
+	<td><?php echo date("h:ia",filemtime($file)); ?></td>
+	<td><?php echo formatBytes(filesize($file)); ?></td>
+</tr>
+<?php
+	} else {
+		?>
+<tr>
+	    <td><?php echo $file; ?><?php if($extra_info) { echo " - ".$extra_info; } ?></td>
+	<td>-</td>
+	<td>-</td>
+</tr>
+	<?php
+	}
+
+}
+function formatBytes($bytes, $precision = 2) {
+    $units = array('B', 'KB', 'MB', 'GB', 'TB');
+  
+    $bytes = max($bytes, 0);
+    $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
+    $pow = min($pow, count($units) - 1);
+  
+    $bytes /= pow(1024, $pow);
+  
+    return round($bytes, $precision) . ' ' . $units[$pow];
+} 
+
+function showAllMatching( $regex ) {
+	global $todayFiles;
+
+	// in the latest folder, display the bin/src link for any available date 
+	// (there should only be one)
+	if($_GET['latest']) {
+	  $regex = preg_replace( "/\d{4}.\d{2}\.\d{2}/", "\d{4}.\d{2}.\d{2}", $regex );
+	}
+
+	//echo "Regex: $regex<br />\n";
+
+
+	foreach( $todayFiles as $file=>$notShown ) {
+	  if ( $notShown && preg_match( "/$regex/", $file ) ) {
+	    show( $file );
+	  }
+	}
+}
+
+//show time machine
+if ($_GET['latest'] ) {
+  echo "latest ";
+} else {
+  echo "<a href=\"?latest=latest\">latest</a> ";
+}
+for ( $i=4; $i>=0; $i-- ) {
+        $d = date("Y-m-d",strtotime("-$i days"));
+        if ( $d == $todayWithHyphens && ! $_GET['latest']) {
+                echo $d;
+        } else {
+?>
+        <a href="?offset=-<?php echo $i; ?>"><?php echo $d; ?></a>
+<?php
+	}
+}
+
+echo "<br/><br/>";
+
+echo "<table>\n";
+heading( "Greenstone3 Binary Releases" );
+show("Greenstone-$nextRelease3-candidate-$today-linux");
+show("Greenstone-$nextRelease3-candidate-$today-linux-x64");
+show("Greenstone-$nextRelease3-candidate-$today-windows.exe");
+showAllMatching("Greenstone-$nextRelease3-candidate-$today-MacOS-intel.dmg", 0, "for (Snow) Leopards (v10.5-10.6)", "Greenstone-$nextRelease3-candidate-$today-Leopard-MacOS-intel.dmg");
+show("Greenstone-$nextRelease3-candidate-$today-Lion-MacOS-intel.dmg", 0, "for (Mountain) Lions (v10.7-10.8)");
+//this picks up similar releases of other version numbers lying around
+showAllMatching("Greenstone-3\..*-candidate-$today-linux$");
+showAllMatching("Greenstone-3\..*-candidate-$today-windows.exe$");
+showAllMatching("Greenstone-3\..*-candidate-$today-MacOS-intel.dmg$", 0, "for (Snow) Leopards (v10.5-10.6)");
+showAllMatching("Greenstone-3\..*-candidate-$today-Lion-MacOS-intel.dmg$", 0, "for (Mountain) Lions (v10.7-10.8)");
+gap();
+
+heading( "Greenstone3 Source Releases" );
+showAllMatching("Greenstone-3\..*-candidate-$today-source-distribution.tar.gz");
+showAllMatching("Greenstone-3\..*-candidate-$today-source-distribution.zip");
+showAllMatching("Greenstone-3\..*-candidate-$today-source-component.tar.gz");
+showAllMatching("Greenstone-3\..*-candidate-$today-source-component.zip");
+gap();
+
+heading( "Greenstone2 Binary Releases" );
+show("Greenstone-$nextRelease2-candidate-$today-linux");
+show("Greenstone-$nextRelease2-candidate-$today-linux-x64");
+show("Greenstone-$nextRelease2-candidate-$today-windows.exe");
+showAllMatching("Greenstone-$nextRelease2-candidate-$today-MacOS-intel.dmg", 0, "for (Snow) Leopards (v10.5-10.6)","Greenstone-$nextRelease2-candidate-$today-Leopard-MacOS-intel.dmg");
+show("Greenstone-$nextRelease2-candidate-$today-Lion-MacOS-intel.dmg", 0, "for (Mountain) Lions (v10.7-10.8)");
+
+showAllMatching("Greenstone-2\..*-candidate-$today-linux$");
+showAllMatching("Greenstone-2\..*-candidate-$today-linux-x64$");
+showAllMatching("Greenstone-2\..*-candidate-$today-windows.exe$");
+showAllMatching("Greenstone-2\..*-candidate-$today-MacOS-intel.dmg$", 0, "for Snow Leopards (v10.5-10.6)");
+showAllMatching("Greenstone-2\..*-candidate-$today-Lion-MacOS-intel.dmg$", 0, "for (Mountain) Lions (v10.7-10.8)");
+gap();
+
+heading( "Greenstone2 Source Releases" );
+showAllMatching("Greenstone-2\..*-candidate-$today-source-distribution.tar.gz");
+showAllMatching("Greenstone-2\..*-candidate-$today-source-distribution.zip");
+showAllMatching("Greenstone-2\..*-candidate-$today-source-component.tar.gz");
+showAllMatching("Greenstone-2\..*-candidate-$today-source-component.zip");
+gap();
+
+heading("Documented Examples" );
+show("Greenstone-documented-examples-$today.tar.gz");
+show("Greenstone-documented-examples-$today.zip");
+gap();
+
+if ( ! $_GET['latest'] ) {
+  heading("Nightly Build Logs");
+  showAllMatching("\.txt$");
+  gap();
+  anchorheading("Regression Test Reports", "regression");
+  showAllMatching("\.html?$");
+  gap();
+}
+
+heading( "Other Files" );
+foreach( $todayFiles as $file=>$notShown ) {
+	if ( $notShown ) show( $file );
+}
+show("IsisGdl.bin32", 1,"","IsisGdl.linux32"); // temporary
+show("IsisGdl.macleopard", 1); // temporary
+gap();
+
+echo "</table>\n";
+
+?>
+
+</body>
+</html>
