Index: trunk/ippMonitor/def/detResidExp.d
===================================================================
--- trunk/ippMonitor/def/detResidExp.d	(revision 12835)
+++ trunk/ippMonitor/def/detResidExp.d	(revision 13241)
@@ -1,16 +1,26 @@
-TABLE detResidExp
+TABLE detResidExp, rawExp
 TITLE detResidExp
 FILE  detResidExp.php
 MENU  ipp.detrend.dat
 
-#     field        size    name       show    link to              extras
-FIELD det_id,        7,    Det ID,    value
-FIELD exp_tag, 	    15,    Exposure,  value,  rawImfile.php,       exp_tag=$exp_tag
-FIELD bg,            8,    backgnd,   value
-FIELD bg_mean_stdev, 8,    [stdev]
-FIELD bg_stdev,      8,    stdev,     value
-FIELD iteration,     5,    iter,      value
-FIELD *, 	     8,    image,     image=$path_base@PPIMAGE.JPEG2, detResidImfile.php, det_id=$det_id,iteration=$iteration,exp_tag=$exp_tag,image=$path_base@PPIMAGE.JPEG1
-FIELD accept,        4,    keep,      value
-FIELD path_base,    20,    path_base, none
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detResidExp.exp_tag = rawExp.exp_tag
+
+# define image names to be used below
+VALUE JPEG1 $detResidExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+#     field                   size    name       show    link to              extras
+FIELD detResidExp.det_id,        7,   Det ID,    value
+FIELD detResidExp.exp_tag, 	15,   Exposure,  value,  rawImfile.php,       exp_tag=$exp_tag
+FIELD detResidExp.bg,            8,   backgnd,   value
+FIELD detResidExp.bg_mean_stdev, 8,   [stdev]
+FIELD detResidExp.bg_stdev,      8,   stdev,     value
+FIELD detResidExp.iteration,     5,   iter,      value
+FIELD *,    	                 8,   image,     image=JPEG1, detResidImfile.php, det_id=$det_id,iteration=$iteration,exp_tag=$exp_tag,image=1
+FIELD detResidExp.accept,        4,   keep,      value
+FIELD detResidExp.path_base,    20,   path_base, none
+
 # FIELD recipe,     15,    recipe,    value
+
+# ipp_filename.pl --filerule $rule --basename $name --camera $camera --class_id $class_id
+# getimage.php name=$1 rule=$2 camera=$3 class_id=$4
Index: trunk/ippMonitor/raw/getimage.php
===================================================================
--- trunk/ippMonitor/raw/getimage.php	(revision 12835)
+++ trunk/ippMonitor/raw/getimage.php	(revision 13241)
@@ -20,26 +20,30 @@
 
 # $basename may contain filename@filerule
-$basename = strtok($_GET[name],"@");
-$filerule = strtok("@");
+$basename = $_GET[name];
+$filerule = $_GET[rule];
+$camera   = $_GET[camera];
+$class_id = $_GET[class_id];
 
+# $filerule = strtok("@");
 # echo "basename: $basename<br>";
 # echo "filerule: $filerule<br>";
 
 # need to supply the camera as well...
-# exec ("ipp_filerule.pl --site=$SITE $basename", $output, $status);
 
-if ($filerule) {
-  if ($filerule == "PPIMAGE.JPEG1") {
-    $basename = "$basename.b1.jpg";
-  }
-  if ($filerule == "PPIMAGE.JPEG2") {
-    $basename = "$basename.b2.jpg";
-  }
-}
+# if ($filerule) {
+#   if ($filerule == "PPIMAGE.JPEG1") {
+#     $basename = "$basename.b1.jpg";
+#   }
+#   if ($filerule == "PPIMAGE.JPEG2") {
+#     $basename = "$basename.b2.jpg";
+#   }
+# }
+# exec ("ipp_datapath.pl --site=$SITE $basename", $output, $status);
 
+# do I need to do this to the output result as well?
 $basename = escapeshellarg($basename);
 $basename = str_replace ('..','',$basename);
 
-exec ("ipp_datapath.pl --site=$SITE $basename", $output, $status);
+exec ("ipp_filename.pl --site=$SITE --basename $basename --filerule $filerule --camera $camera --class_id $class_id", $output, $status);
 
 $filename = $output[0];
@@ -50,5 +54,4 @@
 if (0) {
   echo "basename: $basename<br>";
-  echo "result:   $result<br>";
   echo "output:   $output[0]<br>";
   echo "status:   $status<br>";
@@ -59,4 +62,5 @@
 $file = fopen ($filename, "r");
 if ($file) {
+  # do I need to use image/jpg? can I modify this to image/png, etc, based on the type?
   header ('Content-Type: image/jpg');
   fpassthru ($file);
Index: trunk/ippMonitor/raw/getlog.php
===================================================================
--- trunk/ippMonitor/raw/getlog.php	(revision 13241)
+++ trunk/ippMonitor/raw/getlog.php	(revision 13241)
@@ -0,0 +1,66 @@
+<?php
+
+### these need to be set to the correct locations!!
+$PERLLIB = "/home/kiawe/eugene/psconfig/dev.linux/lib";
+$BINDIR = "/home/kiawe/eugene/psconfig/dev.linux/bin";
+$SITE = "/home/kiawe/eugene/.ipprc";
+$MISSING = "missing.png";
+
+// load an image file from the image directory
+// validate request
+if ($_SERVER[REQUEST_METHOD] != 'GET') { 
+  exit ();
+}
+
+putenv("PERL5LIB=$PERLLIB:");
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+# echo "args: $args<br>";
+
+# $basename may contain filename@filerule
+$basename = strtok($_GET[name],"@");
+$filerule = strtok("@");
+
+# echo "basename: $basename<br>";
+# echo "filerule: $filerule<br>";
+
+# need to supply the camera as well...
+
+# if ($filerule) {
+#   if ($filerule == "PPIMAGE.JPEG1") {
+#     $basename = "$basename.b1.jpg";
+#   }
+#   if ($filerule == "PPIMAGE.JPEG2") {
+#     $basename = "$basename.b2.jpg";
+#   }
+# }
+# exec ("ipp_datapath.pl --site=$SITE $basename", $output, $status);
+
+# do I need to do this to the output result as well?
+$basename = escapeshellarg($basename);
+$basename = str_replace ('..','',$basename);
+
+exec ("ipp_filename.pl --site=$SITE --basename $basename --camera $camera --class_id $class_id", $output, $status);
+
+$filename = $output[0];
+if ($status) {
+  $filename = $MISSING;
+}
+
+if (0) {
+  echo "basename: $basename<br>";
+  echo "output:   $output[0]<br>";
+  echo "status:   $status<br>";
+  echo "filename: $filename<br>";
+  exit ();
+}
+
+$file = fopen ($filename, "r");
+if ($file) {
+  # do I need to use image/jpg? can I modify this to image/png, etc, based on the type?
+  header ('Content-Type: image/jpg');
+  fpassthru ($file);
+}
+exit ();
+?>
