Index: trunk/ippMonitor/Makefile
===================================================================
--- trunk/ippMonitor/Makefile	(revision 8979)
+++ trunk/ippMonitor/Makefile	(revision 8980)
@@ -4,16 +4,40 @@
 
 SRC     =       src
+DEF	=	def
+RAW	=	raw
 DESTBIN =       /var/www/kiawe/phpipp
 
 INSTALL = \
-$(DESTBIN)/menu.php \
-$(DESTBIN)/menu.dat \
 $(DESTBIN)/ipp.css \
+$(DESTBIN)/ipp.php \
+$(DESTBIN)/ipp.menu.dat \
 $(DESTBIN)/Login.php \
 $(DESTBIN)/SelectProject.php \
-$(DESTBIN)/ScienceStats.php \
-$(DESTBIN)/DetrendStats.php \
-$(DESTBIN)/RawImfile.php \
-$(DESTBIN)/phptest.php 
+$(DESTBIN)/phptest.php \
+$(DESTBIN)/detInputExp.php \
+$(DESTBIN)/detMasterFrame.php \
+$(DESTBIN)/detMasterImfile.php \
+$(DESTBIN)/detNormalizedImfile.php \
+$(DESTBIN)/detNormalizedStatImfile.php \
+$(DESTBIN)/detProcessedImfile.php \
+$(DESTBIN)/detResidExp.php \
+$(DESTBIN)/detResidImfile.php \
+$(DESTBIN)/detRun.php \
+$(DESTBIN)/detRunSummary.php \
+$(DESTBIN)/detStackedImfile.php \
+$(DESTBIN)/newExp.php \
+$(DESTBIN)/newImfile.php \
+$(DESTBIN)/p1PendingExp.php \
+$(DESTBIN)/p2PendingExp.php \
+$(DESTBIN)/p2PendingImfile.php \
+$(DESTBIN)/p2ProcessedExp.php \
+$(DESTBIN)/p2ProcessedImfile.php \
+$(DESTBIN)/p3PendingExp.php \
+$(DESTBIN)/pzPendingExp.php \
+$(DESTBIN)/pzPendingImfile.php \
+$(DESTBIN)/rawDetrendExp.php \
+$(DESTBIN)/rawImfile.php \
+$(DESTBIN)/rawScienceExp.php \
+$(DESTBIN)/summitExp.php
 
 PICTURES = \
@@ -25,4 +49,24 @@
 # .PRECIOUS: %.$(ARCH).o
 # .PRECIOUS: $(BIN)/%.$(ARCH)
+
+$(SRC)/%.php: $(DEF)/%.d $(DEF)/autocode.php
+	@if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
+	./generate $< $(DEF)/autocode.php $@
+
+$(SRC)/%.php: $(RAW)/%.php
+	@if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
+	cp $< $@
+
+$(SRC)/%.css: $(RAW)/%.css
+	@if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
+	cp $< $@
+
+$(SRC)/%.dat: $(RAW)/%.dat
+	@if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
+	cp $< $@
+
+$(SRC)/%.jpg: $(RAW)/%.jpg
+	@if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
+	cp $< $@
 
 $(DESTBIN)/%.php: $(SRC)/%.php
@@ -52,2 +96,7 @@
 	rm -f `find . -name "*~"`
 	rm -f `find . -name "#*"`
+
+.PRECIOUS: $(SRC)/%.php
+.PRECIOUS: $(SRC)/%.css
+.PRECIOUS: $(SRC)/%.dat
+.PRECIOUS: $(SRC)/%.jpg
Index: trunk/ippMonitor/def/autocode.php
===================================================================
--- trunk/ippMonitor/def/autocode.php	(revision 8980)
+++ trunk/ippMonitor/def/autocode.php	(revision 8980)
@@ -0,0 +1,66 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+menu('Login', 'ipp.css', $ID['link']);
+
+echo "<p> $TITLE </p>";
+
+$db = dbconnect();
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+
+// query the database
+if ($WHERE) {
+  $sql = "SELECT $FIELDS FROM $TABLE WHERE $WHERE LIMIT 20";
+} else {
+  $sql = "SELECT $FIELDS FROM $TABLE LIMIT 20";
+}
+
+$qry = $db->query($sql);
+if (DB::iserror($db)) {
+  echo "<b>error reading $TABLE table</b><br>\n";
+  menu_end();
+}
+
+// set up the table and form
+echo "<form action=\"$FILE\" method=\"POST\">\n";
+
+echo "<table class=list>\n";
+echo "<tr>\n";
+// ** TABLE HEADER **
+// echo "<th class=list> FIELD </th>\n";
+echo "</tr>\n";
+
+// list the results
+while ($qry->fetchInto($row)) {
+  // $link = "$FILE" . "?expID=" . $row[0] . "&" . $ID['link'];
+
+  echo "<tr>\n";
+  // ** TABLE DATA **
+  // echo "<td class=list><a href=\"$link\"> $row[0] </a></td>\n";
+  // echo "<td class=list> $row[1] </td>\n";
+  echo "</tr>\n";
+}
+
+// query restriction form
+echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY **
+echo "</tr>\n";
+
+// close the table and form
+echo "</table>\n";
+echo "<input type=\"submit\" name=\"constraints\" value=\"refine search\">\n";
+$pass = $ID['pass'];
+$proj = $ID['proj'];
+echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
+echo "<input type=\"hidden\" name=\"proj\" value=\"$proj\">\n";
+echo "</form>\n";
+
+menu_end();
+
+?>
Index: trunk/ippMonitor/def/detInputExp.d
===================================================================
--- trunk/ippMonitor/def/detInputExp.d	(revision 8980)
+++ trunk/ippMonitor/def/detInputExp.d	(revision 8980)
@@ -0,0 +1,9 @@
+TABLE detInputExp
+TITLE detInputExp
+FILE  detInputExp.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD iteration, iteration
+FIELD exp_id, exp_id
+FIELD include, include
Index: trunk/ippMonitor/def/detMasterFrame.d
===================================================================
--- trunk/ippMonitor/def/detMasterFrame.d	(revision 8980)
+++ trunk/ippMonitor/def/detMasterFrame.d	(revision 8980)
@@ -0,0 +1,8 @@
+TABLE detMasterFrame
+TITLE detMasterFrame
+FILE  detMasterFrame.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD iteration, iteration
+FIELD comment, comment
Index: trunk/ippMonitor/def/detMasterImfile.d
===================================================================
--- trunk/ippMonitor/def/detMasterImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/detMasterImfile.d	(revision 8980)
@@ -0,0 +1,9 @@
+TABLE detMasterImfile
+TITLE detMasterImfile
+FILE  detMasterImfile.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD class_id, class_id
+FIELD uri, uri
+FIELD recipe, recipe
Index: trunk/ippMonitor/def/detNormalizedImfile.d
===================================================================
--- trunk/ippMonitor/def/detNormalizedImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/detNormalizedImfile.d	(revision 8980)
@@ -0,0 +1,9 @@
+TABLE detNormalizedImfile
+TITLE detNormalizedImfile
+FILE  detNormalizedImfile.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD iteration, iteration
+FIELD class_id, class_id
+FIELD uri, uri
Index: trunk/ippMonitor/def/detNormalizedStatImfile.d
===================================================================
--- trunk/ippMonitor/def/detNormalizedStatImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/detNormalizedStatImfile.d	(revision 8980)
@@ -0,0 +1,9 @@
+TABLE detNormalizedStatImfile
+TITLE detNormalizedStatImfile
+FILE  detNormalizedStatImfile.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD iteration, iteration
+FIELD class_id, class_id
+FIELD norm, norm
Index: trunk/ippMonitor/def/detProcessedImfile.d
===================================================================
--- trunk/ippMonitor/def/detProcessedImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/detProcessedImfile.d	(revision 8980)
@@ -0,0 +1,13 @@
+TABLE detProcessedImfile
+TITLE detProcessedImfile
+FILE  detProcessedImfile.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD exp_id, exp_id
+FIELD class_id, class_id
+FIELD uri, uri
+FIELD recipe, recipe
+FIELD bg, bg
+FIELD bg_stdev, bg_stdev
+FIELD bg_mean_stdev, bg_mean_stdev
Index: trunk/ippMonitor/def/detResidExp.d
===================================================================
--- trunk/ippMonitor/def/detResidExp.d	(revision 8980)
+++ trunk/ippMonitor/def/detResidExp.d	(revision 8980)
@@ -0,0 +1,15 @@
+TABLE detResidExp
+TITLE detResidExp
+FILE  detResidExp.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD iteration, iteration
+FIELD exp_id, exp_id
+FIELD recipe, recipe
+FIELD bg, bg
+FIELD bg_stdev, bg_stdev
+FIELD bg_mean_stdev, bg_mean_stdev
+FIELD b1_uri, b1_uri
+FIELD b2_uri, b2_uri
+FIELD accept, accept
Index: trunk/ippMonitor/def/detResidImfile.d
===================================================================
--- trunk/ippMonitor/def/detResidImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/detResidImfile.d	(revision 8980)
@@ -0,0 +1,16 @@
+TABLE detResidImfile
+TITLE detResidImfile
+FILE  detResidImfile.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD iteration, iteration
+FIELD exp_id, exp_id
+FIELD class_id, class_id
+FIELD uri, uri
+FIELD recipe, recipe
+FIELD bg, bg
+FIELD bg_stdev, bg_stdev
+FIELD bg_mean_stdev, bg_mean_stdev
+FIELD b1_uri, b1_uri
+FIELD b2_uri, b2_uri
Index: trunk/ippMonitor/def/detRun.d
===================================================================
--- trunk/ippMonitor/def/detRun.d	(revision 8980)
+++ trunk/ippMonitor/def/detRun.d	(revision 8980)
@@ -0,0 +1,7 @@
+TABLE detRun
+TITLE detRun
+FILE  detRun.php
+
+#     field     name     link to     extras
+FIELD iteration, iteration
+FIELD det_type, det_type
Index: trunk/ippMonitor/def/detRunSummary.d
===================================================================
--- trunk/ippMonitor/def/detRunSummary.d	(revision 8980)
+++ trunk/ippMonitor/def/detRunSummary.d	(revision 8980)
@@ -0,0 +1,11 @@
+TABLE detRunSummary
+TITLE detRunSummary
+FILE  detRunSummary.php
+
+#     field    name    link to     extras
+FIELD det_id, det_id
+FIELD iteration, iteration
+FIELD bg, bg
+FIELD bg_stdev, bg_stdev
+FIELD bg_mean_stdev, bg_mean_stdev
+FIELD accept, accept
Index: trunk/ippMonitor/def/detStackedImfile.d
===================================================================
--- trunk/ippMonitor/def/detStackedImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/detStackedImfile.d	(revision 8980)
@@ -0,0 +1,14 @@
+TABLE detStackedImfile
+TITLE detStackedImfile
+FILE  detStackedImfile.php
+
+#     field     name     link to     extras
+FIELD det_id, det_id
+FIELD iteration, iteration
+FIELD class_id, class_id
+FIELD uri, uri
+FIELD recipe, recipe
+FIELD bg, bg
+FIELD bg_stdev, bg_stdev
+FIELD bg_mean_stdev, bg_mean_stdev
+FIELD normalize, normalize
Index: trunk/ippMonitor/def/newExp.d
===================================================================
--- trunk/ippMonitor/def/newExp.d	(revision 8980)
+++ trunk/ippMonitor/def/newExp.d	(revision 8980)
@@ -0,0 +1,10 @@
+TABLE newExp
+TITLE Raw Science Exposures
+FILE  newExp.php
+
+#        field          name           link to         extras
+FIELD    exp_id,	exposure ID
+FIELD    camera,	camera
+FIELD    telescope,	telescope
+FIELD    exp_type,	type
+FIELD    imfiles,	N imfiles
Index: trunk/ippMonitor/def/newImfile.d
===================================================================
--- trunk/ippMonitor/def/newImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/newImfile.d	(revision 8980)
@@ -0,0 +1,9 @@
+TABLE newImfile
+TITLE Raw Science Exposures
+FILE  newImfile.php
+
+#        field          name           link to         extras
+FIELD    exp_id,	exposure ID
+FIELD    class,		class
+FIELD    class_id,	class ID
+FIELD    uri,		URI
Index: trunk/ippMonitor/def/p1PendingExp.d
===================================================================
--- trunk/ippMonitor/def/p1PendingExp.d	(revision 8980)
+++ trunk/ippMonitor/def/p1PendingExp.d	(revision 8980)
@@ -0,0 +1,8 @@
+TABLE p1PendingExp
+TITLE p1PendingExp
+FILE  p1PendingExp.php
+
+#     field       name     link to     extras
+FIELD exp_id,     exposure ID
+FIELD recipe,	  recipe
+FIELD p1_version, p1 version
Index: trunk/ippMonitor/def/p2PendingExp.d
===================================================================
--- trunk/ippMonitor/def/p2PendingExp.d	(revision 8980)
+++ trunk/ippMonitor/def/p2PendingExp.d	(revision 8980)
@@ -0,0 +1,9 @@
+TABLE p2PendingExp
+TITLE p2PendingExp
+FILE  p2PendingExp.php
+
+#     field       name     link to     extras
+FIELD exp_id,	  exposure ID
+FIELD recipe,	  recipe
+FIELD p1_version, p1 version
+FIELD p2_version, p2 version
Index: trunk/ippMonitor/def/p2PendingImfile.d
===================================================================
--- trunk/ippMonitor/def/p2PendingImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/p2PendingImfile.d	(revision 8980)
@@ -0,0 +1,11 @@
+TABLE p2PendingImfile
+TITLE p2PendingImfile
+FILE  p2PendingImfile.php
+
+#     field     name     link to     extras
+FIELD exp_id,	exposure ID
+FIELD class_id, class ID
+FIELD uri,	URI
+FIELD recipe,	recipe
+FIELD p1_version, p1 version
+FIELD p2_version, p2 version
Index: trunk/ippMonitor/def/p2ProcessedExp.d
===================================================================
--- trunk/ippMonitor/def/p2ProcessedExp.d	(revision 8980)
+++ trunk/ippMonitor/def/p2ProcessedExp.d	(revision 8980)
@@ -0,0 +1,8 @@
+TABLE p2ProcessedExp
+TITLE p2ProcessedExp
+FILE  p2ProcessedExp.php
+
+#     field       name     link to     extras
+FIELD exp_id,     exposure ID
+FIELD p1_version, p1 version
+FIELD p2_version, p2 version
Index: trunk/ippMonitor/def/p2ProcessedImfile.d
===================================================================
--- trunk/ippMonitor/def/p2ProcessedImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/p2ProcessedImfile.d	(revision 8980)
@@ -0,0 +1,16 @@
+TABLE p2ProcessedImfile
+TITLE p2ProcessedImfile
+FILE  p2ProcessedImfile.php
+
+#     field          name         link to     extras
+FIELD exp_id,	     exposure ID
+FIELD class_id,	     class ID
+FIELD uri,	     URI
+FIELD recipe,	     recipe
+FIELD bg,	     background
+FIELD bg_stdev,	     background stdev
+FIELD bg_mean_stdev, mean background stdev
+FIELD b1_uri,	     URI small binned
+FIELD b2_uri,	     URI large binned
+FIELD p1_version,    p1 version 
+FIELD p2_version,    p2 version
Index: trunk/ippMonitor/def/p3PendingExp.d
===================================================================
--- trunk/ippMonitor/def/p3PendingExp.d	(revision 8980)
+++ trunk/ippMonitor/def/p3PendingExp.d	(revision 8980)
@@ -0,0 +1,8 @@
+TABLE p3PendingExp
+TITLE p3PendingExp
+FILE  p3PendingExp.php
+
+#     field       name          link to     extras
+FIELD exp_id,	  exposure ID
+FIELD p2_version, p2 version
+FIELD p3_version, p3 version
Index: trunk/ippMonitor/def/pzPendingExp.d
===================================================================
--- trunk/ippMonitor/def/pzPendingExp.d	(revision 8980)
+++ trunk/ippMonitor/def/pzPendingExp.d	(revision 8980)
@@ -0,0 +1,10 @@
+TABLE pzPendingExp
+TITLE pending exposures
+FILE  pzPendingExp.php
+
+#        field        name           link to         extras
+FIELD    exp_id,	exposures ID
+FIELD    camera, 	camera
+FIELD    telescope,	telescope
+FIELD    exp_type,	type
+FIELD    imfiles,	N files
Index: trunk/ippMonitor/def/pzPendingImfile.d
===================================================================
--- trunk/ippMonitor/def/pzPendingImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/pzPendingImfile.d	(revision 8980)
@@ -0,0 +1,11 @@
+TABLE pzPendingImfile
+TITLE Pending Image Files
+FILE  pzPendingImfile.php
+
+#        field        name           link to         extras
+FIELD    exp_id,	exposure ID
+FIELD    bytes,		number of bytes
+FIELD    md5sum,	checksum
+FIELD    class,		class
+FIELD    class_id,	class ID 
+FIELD    uri,		URI
Index: trunk/ippMonitor/def/rawDetrendExp.d
===================================================================
--- trunk/ippMonitor/def/rawDetrendExp.d	(revision 8980)
+++ trunk/ippMonitor/def/rawDetrendExp.d	(revision 8980)
@@ -0,0 +1,22 @@
+TABLE rawDetrendExp
+TITLE Raw Detrend Exposures
+FILE  rawDetrendExp.php
+
+#        field        name           link to         extras
+FIELD    exp_id,      exposure ID,   rawImfile.php,  exp_id=$exp_id,camera=$camera,foo=bar
+FIELD    telescope,   Telescope,     telescopes.php
+FIELD    camera,      Camera
+FIELD    exp_type,    Type    
+FIELD    filter,      FILTER
+# FIELD    imfiles, imfiles     
+# FIELD    airmass, airmass     
+# FIELD    ra, ra          
+# FIELD    decl, decl        
+# FIELD    exp_time, exp_time    
+# FIELD    bg, bg          
+# FIELD    bg_stdev, bg_stdev    
+# FIELD    bg_mean_stdev, bg_mean_stdev   
+# FIELD    alt, alt         
+# FIELD    az, az          
+# FIELD    ccd_temp, ccd_temp    
+# FIELD    posang, posang      
Index: trunk/ippMonitor/def/rawImfile.d
===================================================================
--- trunk/ippMonitor/def/rawImfile.d	(revision 8980)
+++ trunk/ippMonitor/def/rawImfile.d	(revision 8980)
@@ -0,0 +1,25 @@
+TABLE rawImfile
+TITLE Raw Image File
+FILE  rawImfile.php
+
+RESTRICT exp_id
+RESTRICT class_id
+
+#        field        name           link to         extras
+FIELD    exp_id,      Exposure ID
+FIELD    class,       Class
+FIELD    class_id,    Class ID
+# FIELD    uri, uri
+# FIELD    exp_type, exp_type
+# FIELD    filter, filter
+# FIELD    airmass, airmass
+# FIELD    ra, ra
+# FIELD    decl, decl
+# FIELD    exp_time, exp_time
+# FIELD    bg, bg
+# FIELD    bg_stdev, bg_stdev
+# FIELD    bg_mean_stdev, bg_mean_stdev
+# FIELD    alt, alt
+# FIELD    az, az
+# FIELD    ccd_temp, ccd_temp
+# FIELD    posang, posang
Index: trunk/ippMonitor/def/rawScienceExp.d
===================================================================
--- trunk/ippMonitor/def/rawScienceExp.d	(revision 8980)
+++ trunk/ippMonitor/def/rawScienceExp.d	(revision 8980)
@@ -0,0 +1,22 @@
+TABLE rawScienceExp
+TITLE Raw Science Exposures
+FILE  rawScienceExp.php
+
+#        field        name           link to         extras
+FIELD    exp_id,      exposure ID,   rawImfile.php,  exp_id=$exp_id,camera=$camera,foo=bar
+FIELD    telescope,   Telescope,     telescopes.php
+FIELD    camera,      Camera
+FIELD    exp_type,    Type    
+FIELD    filter,      FILTER
+# FIELD    imfiles, imfiles     
+# FIELD    airmass, airmass     
+# FIELD    ra, ra          
+# FIELD    decl, decl        
+# FIELD    exp_time, exp_time    
+# FIELD    bg, bg          
+# FIELD    bg_stdev, bg_stdev    
+# FIELD    bg_mean_stdev, bg_mean_stdev   
+# FIELD    alt, alt         
+# FIELD    az, az          
+# FIELD    ccd_temp, ccd_temp    
+# FIELD    posang, posang      
Index: trunk/ippMonitor/def/summitExp.d
===================================================================
--- trunk/ippMonitor/def/summitExp.d	(revision 8980)
+++ trunk/ippMonitor/def/summitExp.d	(revision 8980)
@@ -0,0 +1,10 @@
+TABLE summitExp
+TITLE Summit Exposures
+FILE  summitExp.php
+
+#        field        name           link to         extras
+FIELD    exp_id, 	exposure ID
+FIELD    camera, 	camera
+FIELD    telescope,	telescope
+FIELD    exp_type,	type
+FIELD    uri,		URI
Index: trunk/ippMonitor/generate
===================================================================
--- trunk/ippMonitor/generate	(revision 8980)
+++ trunk/ippMonitor/generate	(revision 8980)
@@ -0,0 +1,217 @@
+#!/usr/bin/env perl
+
+$VERBOSE = 0;
+if ($ARGV[0] eq "-v") { $VERBOSE = 1; shift @ARGV; }
+if (@ARGV != 3) { die "generate (schema) (template) (output)\n"; }
+
+$schema   = $ARGV[0];
+$template = $ARGV[1];
+$output   = $ARGV[2];
+
+&parse_schema;
+&parse_template;
+exit 0;
+
+sub parse_schema {
+    open (FILE, "$schema");
+    @list = <FILE>;
+    close (FILE);
+
+    &init_key ("TABLE");
+    &init_key ("TITLE");
+    &init_key ("FILE");
+    &init_key ("FIELDS");
+
+    foreach $line (@list) {
+	chop $line;
+	($key, $value) = split (" ", $line, 2);
+	
+	# strip white space from the following
+	if ($key eq "TABLE") { ($value) = $value =~ m|\s*(\S+)\s*|; }
+	if ($key eq "TYPE")  { ($value) = $value =~ m|\s*(\S+)\s*|; }
+
+	&set_keypair ($key, $value);
+
+	# list of the table fields
+ 	if ($key eq "FIELD") {
+	    ($field, $name, $link, $extras) = split (/,\s+/, $value, 4);
+	    # ($field) = $field =~ m|\s*(\S+)\s*|;
+
+	    if ($VERBOSE) { printf "%-20s %-20s %-20s %-20s\n", $field, $name, $link, $extras; }
+	    push @field,   $field;
+	    push @name,    $name;
+	    push @link,    $link;
+	    push @extras,  $extras;
+	}
+
+	# list of the table restrictions
+ 	if ($key eq "RESTRICT") {
+	    ($field) = split (/,\s+/, $value, 1);
+	    # ($field) = $field =~ m|\s*(\S+)\s*|;
+
+	    if ($VERBOSE) { printf "%-20s\n", $field; }
+	    push @restrict,   $field;
+	}
+    }
+    # define query string, add to keypairs
+    &define_query_fields;
+}
+
+sub parse_template {
+    open (FILE, $template);
+    @list = <FILE>;
+    close (FILE);
+
+    open (FILE, ">$output");
+
+    foreach $line (@list) {
+	
+	&check_keypairs;
+
+	print FILE $line;
+
+	# fill in table header
+	if ($line =~ m|// \*\* TABLE HEADER \*\*|) {
+	    &write_table_header;
+	}
+
+	# fill in table data
+	if ($line =~ m|// \*\* TABLE DATA \*\*|) {
+	    &write_table_data;
+	}
+
+	# fill in table query
+	if ($line =~ m|// \*\* TABLE QUERY \*\*|) {
+	    &write_table_query;
+	}
+
+	# fill in table restricts
+	if ($line =~ m|// \*\* TABLE RESTRICTIONS \*\*|) {
+	    &write_table_restrict;
+	}
+    }
+    close (FILE);
+}
+
+sub write_table_header {
+
+    for ($i = 0; $i < @field; $i++) {
+	printf FILE "echo \"<th class=\\\"list\\\"> $name[$i] </th>\\n\";\n";
+    }
+}
+
+sub write_table_restrict {
+
+    for ($i = 0; $i < @restrict; $i++) {
+	$value = $restrict[$i];
+	printf FILE "\$value = \$_GET['$value'];\n";
+	printf FILE "if (\$value) {\n";
+	printf FILE "  if (\$WHERE) {\n";
+	printf FILE "    \$WHERE = \$WHERE . \" AND $value = '\$value'\";\n";
+	printf FILE "  } else {\n";
+	printf FILE "    \$WHERE = \"$value = '\$value'\";\n";
+	printf FILE "  }\n";
+	printf FILE "}\n";
+    }
+}
+
+sub write_table_data {
+
+    for ($i = 0; $i < @field; $i++) {
+	# create the link variable if this entry should be linked
+	if ($link[$i]) {
+	    # create the basic link 
+	    printf FILE "  \$link = \"$link[$i]\" . \"?\" . \$ID['link'];\n";
+	    if ($extras[$i]) {
+		# examine the extras and parse the embedded fields
+		@extfields = split (/,/, $extras[$i]);
+		$N = @extfields;
+		if ($VERBOSE) { print STDERR "N extfields: $N\n"; }
+		for ($j = 0; $j < @extfields; $j++) {
+
+		    # search for embedded table fields and replace with row[N]
+		    $N = -1;
+		    $extline = $extfields[$j];
+		    if ($VERBOSE) { print STDERR "extfield: $extfields[$j]\n"; }
+		    for ($k = 0; ($k < @field) && ($N == -1); $k++) {
+			if ($extline =~ m|\$$field[$k]|) {
+			    $extline =~ s|\$$field[$k]||;
+			    $N = $k;
+			}
+		    }
+		    if ($N == -1) {
+			# no embedded field, print verbatim
+			printf FILE "  \$link = \$link . \"&$extline\";\n";
+		    } else {
+			# replace embedded field with row[N]
+			printf FILE "  \$link = \$link . \"&$extline\" . \$row[$N];\n";
+		    }
+		}
+
+	    } 
+	    # print the actual table cell line with the link...
+	    printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> \$row[$i] </a></td>\\n\";\n";
+	} else {
+	    # or without
+	    printf FILE "  echo \"<td class=\\\"list\\\"> \$row[$i] </td>\\n\";\n";
+	}
+    }
+}
+
+sub write_table_query {
+
+    for ($i = 0; $i < @field; $i++) {
+	printf FILE "echo \"<td class=\\\"list\\\"> <input type=\\\"text\\\" name=\\\"$field[$i]\\\"> </td>\\n\";\n";
+    }
+}
+
+sub define_query_fields {
+
+    $FIELDS = "$field[0]";
+    for ($i = 1; $i < @field; $i++) {
+	$FIELDS = "$FIELDS,$field[$i]";
+    }
+ 
+    set_keypair ("FIELDS", $FIELDS);
+}
+
+sub init_key {
+    my ($key)   = $_[0];
+
+    push @key, $key;
+    push @value, "";
+}
+
+sub set_keypair {
+    my ($i);
+    my ($key)   = $_[0];
+    my ($value) = $_[1];
+
+    for ($i = 0; $i < @key; $i++) {
+	if ($key eq $key[$i]) {
+	    if ($value[$i] ne "") { die "key is multiply defined\n"; }
+	    $value[$i] = $value;
+	    return;
+	}
+    }
+}
+
+sub check_keypairs {
+    my ($i);
+    for ($i = 0; $i < @key; $i++) {
+	# if ($VERBOSE) { print "$key[$i]  -- $value[$i]\n"; }
+	if ($line =~ m|\$$key[$i]|) {
+	    if ($value[$i] eq "") { die "missing value for required key $key[$i]\n"; }
+	    $line =~ s|\$$key[$i]|$value[$i]|g;
+	}
+    }
+}
+
+# we need to find the structure size, including padding 
+# i'm not sure I know the answer to this: it is probably 
+# the total number of bytes rounded up to the largest 
+# data item in the structure (ie, 8 for a double, etc)
+# if we have the size, then we can double check the structure
+# against the expectation at runtime.  for the moment,
+# calculate by hand and add to def.d file 
+
Index: trunk/ippMonitor/raw/Login.php
===================================================================
--- trunk/ippMonitor/raw/Login.php	(revision 8980)
+++ trunk/ippMonitor/raw/Login.php	(revision 8980)
@@ -0,0 +1,61 @@
+<?php 
+
+include 'ipp.php';
+
+if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
+  menu ('Login', 'ipp.css', '');
+  echo "Invalid Client Request<br>\n";
+  menu_end ();
+  exit ();
+}
+
+if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+
+  $ID = checkID ();
+
+  menu ('Login', 'ipp.css', $ID['link']);
+
+  $pass = $ID['pass'];
+  $name = $ID['name'];
+  echo "<p>You are currently logged in as $name.<br>\n";
+  echo "Click here to log out.\n";
+  echo "<form action=\"Login.php\" method=\"POST\">\n";
+  echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
+  echo "<input type=\"submit\" name=\"logout\" value=\"logout\">\n";
+  echo "</form></p>\n\n";
+  
+  menu_end ();
+  exit ();
+} 
+
+if ($_SERVER[REQUEST_METHOD] == 'POST') { 
+  if (key_exists (login, $_POST)) {
+
+    $ID = checkLogin ();
+
+    menu ('Login', 'ipp.css', $ID['link']);
+    echo "Login Accepted\n";
+    menu_end();
+    exit ();
+  }
+
+  if (key_exists (logout, $_POST)) {
+    menu ('Login', 'ipp.css', '');
+    echo "You are now logged out<br>\n";
+    logintext ();
+    loginform ();
+    menu_end ();
+    exit ();
+  }
+
+  // missing a valid POST state (login or logout)
+  menu ('Login', 'ipp.css', '');
+  echo "Invalid Client Post Request<br>\n";
+  foreach ($_POST as $key => $value) {
+    echo "$key : $value<br>\n";
+  }
+  menu_end ();
+  exit ();
+}
+
+?>
Index: trunk/ippMonitor/raw/SelectProject.php
===================================================================
--- trunk/ippMonitor/raw/SelectProject.php	(revision 8980)
+++ trunk/ippMonitor/raw/SelectProject.php	(revision 8980)
@@ -0,0 +1,46 @@
+
+<? function projectform () { ?>
+  <p>
+  Select the project of interest
+  </p>
+  <form action="<? $myPage ?>" method="POST">
+  Project: <input type="text" name="proj"><br>
+  <input type="submit" name="project">
+  </form>
+<? } ?>
+
+<?php 
+
+include 'menu.php';
+
+checkID ();
+
+if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    menu ('Project', 'ipp.css');
+    projectform ();
+    menu_end ();
+}
+
+if ($_SERVER[REQUEST_METHOD] != 'POST') { 
+  menu ('Project', 'ipp.css');
+  echo "Invalid Client Request<br>\n";
+  menu_end ();
+}
+
+if (key_exists (project, $_POST)) {
+  $myProj = $_POST[proj];
+  # validate the existence of the project
+  $_GET[proj] = $myProj;
+  menu ('Project', 'ipp.css');
+  echo "New project is : $myProj\n";
+  menu_end();
+}
+  
+menu ('Project', 'ipp.css');
+echo "Invalid Client Post Request<br>\n";
+foreach ($_POST as $key => $value) {
+  echo "$key : $value<br>\n";
+}
+menu_end ();
+
+?>
Index: trunk/ippMonitor/raw/ipp.css
===================================================================
--- trunk/ippMonitor/raw/ipp.css	(revision 8980)
+++ trunk/ippMonitor/raw/ipp.css	(revision 8980)
@@ -0,0 +1,78 @@
+
+/* internal link line: c0d0d0 : d8d0f0
+   external link line: 303070 
+   border:             0080c0
+ */
+
+body  { bgcolor: #a0d0e0; background-color: #a0d0e0; padding: 5px; margin: 5px }
+
+a:link, a:visited, a:active { text-decoration: underline; font-weight: bold; color: #ff0000 }
+
+a.menutop     { text-decoration: none; color: #ffffff; font-weight: bold }
+a.menuext     { text-decoration: none; color: #ffffff; font-weight: bold }
+a.menulink    { text-decoration: none; font-weight: normal; color: #000000}
+a.menuselect  { text-decoration: none; font-weight: normal; color: #0000ff}
+a.piclink     { text-decoration: none; font-weight: normal; color: #0080c0}
+
+td.menutop    { text-align: left; background: #0080c0; font-size: small; color: #ffffff; padding: 2px; }
+td.menuext    { text-align: left; background: #303070; font-size: small; color: #ffffff; padding: 2px; }
+td.menulink   { text-align: left; background: #d0d0ff; font-size: small; color: #000000; padding: 2px; font-weight: normal; text-indent: 0px; }
+td.menuselect { text-align: left; background: #d0d0ff; font-size: small; color: #ff0000; padding: 2px; font-weight: normal; text-indent: 0px; }
+td.menuline   { text-align: left; background: #d0d0ff; font-size: small; color: #000000; padding: 2px; font-weight: normal; text-indent: 0px; }
+
+td.picture    { text-align: left; background: #00ffff; font-size: small; color: #ff0000; padding: 0px; text-indent: 2px; font-weight: normal; }
+td.piclink    { text-align: left; background: #0080c0; font-size: small; color: #ff0000; padding: 0px; text-indent: 0px; font-weight: normal; }
+
+table.page { border: 0px solid #0080c0; background: #a0d0e0; padding: 0px}
+
+td.title { background-color: #ff0000; padding: 5px; font-size: x-large; text-align: left; vertical-align: top}
+
+td.body  { 
+           text-align: left; 
+           font-size: normal;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #d0d0ff; 
+	   background-color: #d0d0ff; 
+	   border: 3px solid #0080c0; 
+	   padding: 5px; 
+}
+
+table.menu { text-align: left; 
+             font-size: small; 
+	     font-weight: normal; 
+	     background: #ff0000; 
+	     border: 3px solid #0080c0; 
+	     padding: 0px; 
+}
+
+table.list { text-align: left; 
+             font-size: small; 
+	     font-weight: normal; 
+	     background: #d0d0ff; 
+	     border: 2px solid #ffffff; 
+	     padding: 0px; 
+}
+
+td.list  { 
+           text-align: left; 
+           font-size: normal;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #d0d0ff; 
+	   background-color: #d0d0ff; 
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+th.list  { 
+           text-align: left; 
+           font-size: normal;  
+           font-weight: bold;  
+           vertical-align: top;
+	   background: #d0d0ff; 
+	   background-color: #d0d0ff; 
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
Index: trunk/ippMonitor/raw/ipp.menu.dat
===================================================================
--- trunk/ippMonitor/raw/ipp.menu.dat	(revision 8980)
+++ trunk/ippMonitor/raw/ipp.menu.dat	(revision 8980)
@@ -0,0 +1,47 @@
+# style   | select-style | type    | menu line                    | link page       
+
+# we have four valid menu types: picture, piclink, link, plain
+# picture   | picture    | picture | PScolorlogo2.jpg             | none
+# piclink   | piclink    | piclink | PScolorlogo2.jpg             | http://panstarrs.ifa.hawaii.edu
+# menulink  | menuselect | link    | other page                   | notest.php     
+# menutop   | menutop    | plain   | foo bar                      | none            
+
+piclink   | piclink      | piclink | PScolorlogo2.jpg             | http://panstarrs.ifa.hawaii.edu
+menuext   | menuext      | link    | Pan-STARRS public            | http://panstarrs.ifa.hawaii.edu
+menuext   | menuext      | link    | Pan-STARRS project           | http://panstarrs.ifa.hawaii.edu/project
+menuext   | menuext      | link    | Pan-STARRS IPP               | http://panstarrs.ifa.hawaii.edu/project/IPP
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Login                        | Login.php     
+menulink  | menuselect   | link    | Select Project               | SelectProject.php     
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | detInputExp.php              | detInputExp.php                    
+menulink  | menuselect 	 | link    | detMasterFrame.php           | detMasterFrame.php            
+menulink  | menuselect 	 | link    | detMasterImfile.php          | detMasterImfile.php                   
+menulink  | menuselect 	 | link    | detNormalizedImfile.php      | detNormalizedImfile.php               
+menulink  | menuselect 	 | link    | detNormalizedStatImfile.php  | detNormalizedStatImfile.php           
+menulink  | menuselect 	 | link    | detProcessedImfile.php       | detProcessedImfile.php                
+menulink  | menuselect 	 | link    | detResidExp.php              | detResidExp.php                       
+menulink  | menuselect 	 | link    | detResidImfile.php           | detResidImfile.php            
+menulink  | menuselect 	 | link    | detRun.php                   | detRun.php                    
+menulink  | menuselect 	 | link    | detRunSummary.php            | detRunSummary.php             
+menulink  | menuselect 	 | link    | detStackedImfile.php         | detStackedImfile.php                  
+menulink  | menuselect 	 | link    | newExp.php                   | newExp.php                    
+menulink  | menuselect 	 | link    | newImfile.php                | newImfile.php                         
+menulink  | menuselect 	 | link    | p1PendingExp.php             | p1PendingExp.php              
+menulink  | menuselect 	 | link    | p2PendingExp.php             | p2PendingExp.php              
+menulink  | menuselect 	 | link    | p2PendingImfile.php          | p2PendingImfile.php                   
+menulink  | menuselect 	 | link    | p2ProcessedExp.php           | p2ProcessedExp.php            
+menulink  | menuselect 	 | link    | p2ProcessedImfile.php        | p2ProcessedImfile.php                 
+menulink  | menuselect 	 | link    | p3PendingExp.php             | p3PendingExp.php              
+menulink  | menuselect 	 | link    | pzPendingExp.php             | pzPendingExp.php              
+menulink  | menuselect 	 | link    | pzPendingImfile.php          | pzPendingImfile.php                   
+menulink  | menuselect 	 | link    | rawDetrendExp.php            | rawDetrendExp.php             
+menulink  | menuselect 	 | link    | rawImfile.php                | rawImfile.php                         
+menulink  | menuselect 	 | link    | rawScienceExp.php            | rawScienceExp.php             
+menulink  | menuselect 	 | link    | summitExp.php                | summitExp.php                         
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menutop   | menutop      | plain   | External Links               | none            
+menutop   | menutop      | link    | test page                    | phptest.php     
Index: trunk/ippMonitor/raw/ipp.php
===================================================================
--- trunk/ippMonitor/raw/ipp.php	(revision 8980)
+++ trunk/ippMonitor/raw/ipp.php	(revision 8980)
@@ -0,0 +1,177 @@
+<?php
+
+function logintext () {
+  echo '<p>Welcome to the IPP status pages.<br><br>', "\n";
+  echo 'From these pages, you may examine summary information about the IPP processing results.<br>', "\n";
+  echo 'In order to continue, it is necessary to login as an authorized IPP user.</p>', "\n\n";
+}
+
+function loginform () { 
+  echo '<form action="Login.php" method="POST">', "\n";
+  echo 'Username: <input type="text" name="username"><br>', "\n";
+  echo 'Password: <input type="text" name="password"><br>', "\n";
+  echo '<input type="submit" name="login" value="login">', "\n";
+  echo '</form>', "\n\n";
+}
+
+function dbconnect () {
+
+  // connect to the database
+  require_once('DB.php');
+  $db = DB::connect("mysql://ipp:ipp@localhost/ipp");
+  if (DB::iserror($db)) {
+    echo "<b>error accessing database</b><br>\n";
+    echo "<b>tried mysql://ipp:ipp@localhost/ipp</b><br>\n";
+    menu_end();
+  }
+  return $db;
+}
+
+// there are three pieces of data that are used to define a user:
+// - name (the username: available somewhere: db table?)
+// - proj (defines which database is being used)
+// - pass (NOT the same as the user password: randomly generated for the session and given a timeout) 
+
+function checkLogin () {
+
+  $username = $_POST[username];
+  $password = $_POST[password];
+
+  // make this a DB lookup
+  $success = (($username == "eugene") && ($password == "test"));
+
+  if (!$success) {  
+    menu ('Login', 'ipp.css', '');
+    echo "Login Failed, please try again<br>\n";
+    loginform ();
+    menu_end ();
+    exit ();
+  }
+  
+  // generate an random ephemeral ID
+  $ID['name'] = $username;
+  $ID['pass'] = "foobar";
+  $ID['proj'] = "";
+
+  // the link is attached to every nav link
+  $ID['link'] = "pass=" . $ID['pass'];
+  if ($ID['proj']) {
+    $ID['link'] = $link . "&proj=" . $ID['proj'];
+  }
+
+  return $ID;
+}
+
+function checkID () {
+
+  // check for valid server method
+  if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
+    menu ('Login', 'ipp.css', '');
+    echo "Invalid Client Request<br>\n";
+    menu_end ();
+    exit ();
+  }
+
+  // look for pass & proj in appropriate location
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $ID['pass'] = $_GET[pass];
+    $ID['proj'] = $_GET[proj];
+    echo "using GET: ", $ID['pass'], $ID['proj'];
+  }
+  if ($_SERVER[REQUEST_METHOD] == 'POST') { 
+    $ID['pass'] = $_POST[pass];
+    $ID['proj'] = $_POST[proj];
+    echo "using POST: ", $ID['pass'], $ID['proj'];
+  }
+
+  // user is not logged in at all
+  if ($ID['pass'] == "") {
+    menu('Login', 'ipp.css', '');
+    logintext ();    
+    loginform ();
+    menu_end ();
+  }
+
+  // user supplied an invalid pass
+  if ($ID['pass'] != "foobar") {
+    menu('Login', 'ipp.css', '');
+    echo "unknown user, please login again<br>\n";
+    loginform ();
+    menu_end ();
+  }
+
+  // use the pass value to find the corresponding user
+  $ID['name'] = "eugene";
+
+  // $link is attached to every nav link
+  $ID['link'] = "pass=" . $ID['pass'];
+  if ($ID['proj']) {
+    $ID['link'] = $link . "&proj=" . $ID['proj'];
+  }
+
+  return $ID;
+}
+
+function menu ($title, $sheet, $append) {
+
+  echo "<html><head><title> $title </title></head>\n\n";
+  echo "<link rel=\"STYLESHEET\" HREF=\"$sheet\">\n";
+  echo "<body>\n";
+
+  $root = "/phpipp";
+
+  $file = fopen ("ipp.menu.dat", "r");
+
+  echo "<table class=page cellspacing=10px><tr><td valign=top>\n";
+  echo "<table class=menu cellspacing=0px>\n";
+
+  while ($line = fgetcsv ($file, 1024, "|")) {
+    if (count($line) != 5) continue;
+    if (ereg ('^[:blank:]*#', $line[0])) continue;
+
+    $type = trim($line[2]);
+    $name = trim($line[3]);
+    $base = trim($line[4]);
+
+    if ($append) {
+      $link = $base . "?" . $append;
+    } else {
+      $link = $base;
+    }
+	
+    $this = $_SERVER[SCRIPT_NAME]; 
+    $page = "$root/" . $base;
+    if ($page == $this) {
+	$style = trim($line[1]);
+    } else { 
+	$style = trim($line[0]);
+    }       
+
+    switch ($type) { 
+      case 'plain':
+        echo "<tr><td class=\"$style\"> $name </td></tr>\n";  
+        break;
+      case 'picture':
+        echo "<tr><td class=\"$style\"> <img src=\"$name\"> </td></tr>\n";     
+        break;
+      case 'piclink':
+        echo "<tr><td class=\"$style\"> <a class=\"$style\" href=\"$link\"> <img class=\"$style\" src=\"$name\"> </a></td></tr>\n";     
+        break;
+      default:
+        echo "<tr><td class=\"$style\"> <a class=\"$style\" href=\"$link\"> $name </a></td></tr>\n";     
+        break;
+    } 
+  }
+  fclose ($file);
+  echo '</table></td><td class="body" valign=top>', "\n\n";
+}
+
+function menu_end () { 
+  echo "</td></tr></table>\n";
+  echo "</body></html>\n\n";
+  exit ();
+}
+
+// $myPage = $_SERVER[SCRIPT_NAME] . "?pass=$pass";
+
+?>
Index: trunk/ippMonitor/raw/phptest.php
===================================================================
--- trunk/ippMonitor/raw/phptest.php	(revision 8980)
+++ trunk/ippMonitor/raw/phptest.php	(revision 8980)
@@ -0,0 +1,26 @@
+<?php include 'ipp.php'; ?>
+
+<?php menu('test.page', 'ipp.css', ''); ?>
+
+<?
+
+$varlist = array ('SERVER_NAME', 'GATEWAY_INTERFACE', 'SERVER_PROTOCOL',
+'SERVER_PORT', 'REQUEST_METHOD', 'PATH_INFO', 'PATH_TRANSLATED', 'SCRIPT_NAME',
+'QUERY_STRING', 'REMOTE_HOST', 'REMOTE_ADDR', 'AUTH_TYPE', 'REMOTE_USER',
+'REMOTE_IDENT', 'CONTENT_TYPE', 'CONTENT_LENGTH');
+
+foreach ($varlist as $name) {
+  echo "$name : $_SERVER[$name]<br>\n";
+}
+
+echo "get list<br>\n";
+foreach ($_GET as $key => $value) {
+  echo "$key : $value<br>\n";
+}
+
+?>
+
+<?php menu_end(); ?>
+
+</body>
+</html>
