Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/authenticate.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/authenticate.php	(revision 42995)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/authenticate.php	(revision 42996)
@@ -9,6 +9,6 @@
 
 // XXX TODO use mysql
-$auth_user="SET_ME";
-$auth_passwd="SET_ME";
+$auth_user="ps1sc";
+$auth_passwd="skysurveys";
 
 $alt_user="SET_ME";
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/dblogin.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/dblogin.php	(revision 42996)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/dblogin.php	(revision 42996)
@@ -0,0 +1,36 @@
+<?php
+
+// set up a connection to the desired database
+function dblogin($database)
+{
+  global $DS_HOSTNAME, $DS_USERNAME, $DS_PASSWORD, $DS_DATABASE;
+  global $PS_HOSTNAME, $PS_USERNAME, $PS_PASSWORD, $PS_DATABASE;
+
+  $db_hostname = "";
+
+  if ($database == "PSTAMP") {
+    $db_hostname = $PS_HOSTNAME;
+    $db_database = $PS_DATABASE;
+    $db_username = $PS_USERNAME;
+    $db_password = $PS_PASSWORD;
+  }
+  if ($database == "DATASTORE") {
+    $db_hostname = $DS_HOSTNAME;
+    $db_database = $DS_DATABASE;
+    $db_username = $DS_USERNAME;
+    $db_password = $DS_PASSWORD;
+  }
+
+  if ($db_hostname == "") {
+    die("database selection ill-defined");
+  }
+
+  $conn = mysqli_connect($db_hostname, $db_username, $db_password, $db_database);
+
+  if (!$conn) {
+    die("Connection failed: " . mysqli_connect_error());
+  }
+
+  return $conn;
+}
+?>
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/dsroot.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/dsroot.php	(revision 42995)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/dsroot.php	(revision 42996)
@@ -1,8 +1,7 @@
 <?php // upload.php
 
-// get the locatl configuration variables
+// get the local configuration variables
 require "pstamp.php";
 require "dblogin.php";
-
 
 $user = $_SERVER['PHP_AUTH_USER'];
@@ -22,5 +21,5 @@
     s.innerHTML = s.innerHTML - 1;
     if (s.innerHTML == 0)
-  //    window.location = 'http://pstamp.ipp.ifa.hawaii.edu/dsroot.php';
+      // window.location = 'http://pstamp.ipp.ifa.hawaii.edu/dsroot.php';
       location.reload();
     else
@@ -40,10 +39,10 @@
 echo "<body>\n";
 echo "The page will NOW refresh in <span id='timer'> 20</span> mins";
-$dbserver = dblogin();
+$dbconnection = dblogin("DATASTORE");
 
 $query = "SELECT prod_name, last_fs, last_update, type, description FROM dsProduct ORDER BY type, prod_id";
-$result = mysqli_query($dbserver, $query);
+$result = mysqli_query($dbconnection, $query);
 if (!$result) {
-    die("Database access failed: " . mysqli_error($dbserver));
+    die("Database access failed: " . mysqli_error($dbconnection));
 }
 
@@ -58,11 +57,6 @@
     $prod_name = $row[0];
     echo "<td>";
-    // echo "<a href=\"http://datastore.ipp.ifa.hawaii.edu/$prod_name\">$prod_name</a>";
-    //$prod_link = "http://datastore.ipp.ifa.hawaii.edu/$prod_name";
-    $prod_link = "http://datastore.ipp.ifa.hawaii.edu/ds/$prod_name";
-
-    // $prod_link "<a href=\"http://datastore.ipp.ifa.hawaii.edu/$prod_name\">$prod_name</a>";
+    $prod_link = "$DS_URL/$prod_name";
     echo "<a href=\"$prod_link\">$prod_name</a>";
-    
     echo "</td>";
 
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/findskycell.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/findskycell.php	(revision 42996)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/findskycell.php	(revision 42996)
@@ -0,0 +1,129 @@
+<?php // upload.php
+
+// get the locatl configuration variables
+require "pstamp.php";
+// require "submitted.php";
+
+
+$user = $_SERVER['PHP_AUTH_USER'];
+$passwd = $_SERVER['PHP_AUTH_PW'];
+?>
+
+<HTML>
+<head>
+    <title>
+        PS1 skycell locator
+    </title>
+</head>
+<body>
+<H1 align=left>
+Find the IPP Skycell containing a given set of coordinates
+</h1>
+
+<?php
+
+welcomeHeader($auth_user, 0, 0);
+
+// echo "Hello $user $passwd";
+
+$rvar_tess_id = "";
+$rvar_skycell_id = "";
+$rvar_ra = "";
+$rvar_dec = "";
+$rvar_user_tess_id = "";
+import_request_variables("p", "rvar_");
+
+$error_string = "";
+
+if (strcmp($rvar_ra, "") && strcmp($rvar_dec, "")) {
+    if (is_numeric($rvar_ra) && is_numeric($rvar_dec)) {
+        $command = "$SCRIPT whichimage --listchipcoords $rvar_ra $rvar_dec";
+        if ($rvar_user_tess_id) {
+            $command .= " --tess_id $rvar_user_tess_id";
+        }
+    } else {
+        if (!is_numeric($rvar_ra)) {
+            $error_string .= "<br>$rvar_ra is not a valid number";
+            $rvar_ra = "";
+        }
+        if (!is_numeric($rvar_dec)) {
+            $error_string .= "<br>$rvar_dec is not a valid number";
+            $rvar_dec = "";
+        }
+    }
+}
+
+?>
+
+<br/>
+<br/>
+<br/>
+    <h3>Enter coordinates (in degrees):</h3>
+    <form method="post" enctype="multipart/form-data" action="">
+        <b>RA:&nbsp</b>
+        <input type="text" name="ra"  value= <?php echo $rvar_ra; ?> >
+        &nbsp; &nbsp; &nbsp;
+        <b>DEC:&nbsp</b>
+        <input type="text" name="dec" value= <?php echo $rvar_dec; ?> >
+        &nbsp; &nbsp; &nbsp;
+        <b>tess_id:&nbsp</b> (optional)
+        <input type="text" name="user_tess_id" value= <?php echo $rvar_user_tess_id; ?> >
+        &nbsp; &nbsp; &nbsp;
+        <input type="submit" value="Get Skycell" >
+        &nbsp; &nbsp; &nbsp;
+        <br />
+
+<?php
+
+if ($error_string != "") {
+    echo $error_string;
+}
+
+#echo "<br />SCRIPT is <br />$SCRIPT";
+if ($command) {
+    $command = escapeshellcmd($command);
+//    echo "<br />command:<br />$command";
+    echo "<br />";
+    echo "<br />";
+    $output = array();
+    exec($command, $output, $command_status);
+    if ($command_status == 0) {
+        // it worked!
+ //       echo "$output[0]<br />";
+        $len = count($output);
+        echo "<h3>Skycells containing ra = $rvar_ra dec = $rvar_dec</h3>\n";
+        echo "<table align=left border=2 cellspacing=1 cellpadding=10>\n";
+        echo "<thead>\n";
+        echo "<tr><td><b>tess_id</b></td><td><b>skycell_id</b></td><td>image X</td><td>image Y</td></tr>\n";
+        echo "</thead>\n";
+        for ($i=0; $i < $len; $i++) {
+            list($ra2, $dec2, $tess_id, $skycell_id, $x, $y) = explode(" ", $output[$i]);
+            echo "<tr><td>$tess_id</td><td>$skycell_id</td><td>$x</td><td>$y</td></tr>\n";
+        }
+        echo "</table>\n";
+    } else if ($rvar_user_tess_id) {
+        echo "Coordinates not found in tessellation $rvar_user_tess_id<br/>";
+    } else {
+        echo "Unexpected Error.<br /> whichimage command returned $command_status<br />";
+    }
+} else {
+    $tess_id = "";
+    $skycell_id = "";
+}
+echo "<br />";
+?>
+
+<input type="hidden" name="tess_id" value=<?php echo $tess_id;?>>
+<input type="hidden" name="skycell_id" value=<?php echo $skycell_id;?>>
+
+</form>
+
+<?php
+// print lots of information
+// phpinfo(-1);
+// print the most useful variables
+// phpinfo(32);
+
+echo "</body></html>";
+
+?>
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/getinfo.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/getinfo.php	(revision 42996)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/getinfo.php	(revision 42996)
@@ -0,0 +1,4 @@
+<?php
+    // uncomment this line to dump the php information page
+    phpinfo(32);
+?>
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/index.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/index.php	(revision 42996)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/index.php	(revision 42996)
@@ -0,0 +1,3 @@
+<?php
+include "pshome.php"
+?>
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pshome.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pshome.php	(revision 42996)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pshome.php	(revision 42996)
@@ -0,0 +1,54 @@
+<?php // pshome.php
+
+// get the local configuration variables
+require "pstamp.php";
+
+$user = $_SERVER['PHP_AUTH_USER'];
+$passwd = $_SERVER['PHP_AUTH_PW'];
+?>
+
+<HTML>
+<head>
+    <title>
+        IPP PS1 Postage Stamp Server
+    </title>
+    <script type='text/javascript'>
+    setTimeout('countdown()', 100);
+ 
+    function countdown() {
+    var s = document.getElementById('timer');
+    s.innerHTML = s.innerHTML - 1;
+    if (s.innerHTML == 0)
+//    window.location = 'http://pstamp.ipp.ifa.hawaii.edu/pshome.php';
+    location.reload();
+    else
+    setTimeout('countdown()', 1000*60);
+    }
+    </script>
+</head>
+<body>
+<H1 align=left>
+        IPP PS1 Postage Stamp Server
+</h1>
+
+<?php
+welcomeHeader($auth_user, "", "");
+?>
+
+<p>
+Welcome to the home page of the IPP PS1 Postage Stamp Server.
+Follow the links above to access the prototype web interface.
+<p>
+There are three ways to submit a postage stamp request. 
+<li>Posting a Data Store file set on a data store product being polled by the server.</li>
+<li>Uploading a request fits table with the upload page.</li>
+<li>Entering the paramaters for a single request on the request form.</li>
+<p>
+Note that the prototype web interface is somehat primitive and buggy. 
+The request form does not provide full functionality of the request
+specification.
+<p>
+More information about postage stamp requests may be found on the
+<a href="http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PostageStampServer">IPP wiki</a>.
+<p>
+The page will refresh in <span id='timer'> 20</span> mins
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstamp.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstamp.php	(revision 42995)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstamp.php	(revision 42996)
@@ -1,2 +1,3 @@
+
 <?php
 
@@ -4,3 +5,43 @@
 require_once "authenticate.php";
 
+function request_var($key, $filter = FILTER_DEFAULT, $default = null, $options = null) {
+  $raw = $_POST[$key] ?? $_GET[$key] ?? null;
+
+  // Treat missing or empty as null
+  if ($raw === '' || $raw === null) {
+    return $default;
+  }
+
+  // Apply validation
+  $val = filter_var($raw, $filter, $options ?? []);
+
+  if ($val === false) {
+    http_response_code(400);
+    die("Invalid value for key '$key'");
+  }
+  return $val;
+}
+
+//  $val = filter_input(INPUT_GET, $key, $filter, $options);
+//  if ($val === false) {
+//    http_response_code(400);
+//    echo "<b> invalid GET key $key </b><br>";
+//    die ("invalid GET key $key");
+//  }
+//  if ($val !== null) {
+//    return $val;
+//  }
+//
+//  $val = filter_input(INPUT_POST, $key, $filter, $options);
+//  if ($val === false) {
+//    http_response_code(400);
+//    echo "<b> invalid POST key $key </b><br>";
+//    die ("invalid POST key $key");
+//  }
+//  if ($val !== null) {
+//    return $val;
+//  }
+//  return $default;
+// }
+
 ?>
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstamp_links.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstamp_links.php	(revision 42996)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstamp_links.php	(revision 42996)
@@ -0,0 +1,17 @@
+<?php
+echo "<a href=\"./pshome.php\">Pstamp Home</a> ";
+echo "&nbsp;&nbsp;&nbsp;&nbsp\n";
+
+echo "<a href=\"./status.php\">Pstamp Server Status</a> ";
+echo "&nbsp;&nbsp;&nbsp;&nbsp\n";
+
+echo "<a href=\"./upload.php\">Upload Request File</a> ";
+echo "&nbsp;&nbsp;&nbsp;&nbsp\n";
+
+echo "<a href=\"./request.php\">Postage Stamp Request Form</a> ";
+echo "&nbsp;&nbsp;&nbsp;&nbsp\n";
+
+echo "<a href=\"./findskycell.php\">Skycell calculator</a> ";
+echo "&nbsp;&nbsp;&nbsp;&nbsp\n";
+echo "<a href=\"./dsroot.php\">Data Store</a> ";
+?>
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstampconfig.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstampconfig.php	(revision 42995)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstampconfig.php	(revision 42996)
@@ -2,11 +2,24 @@
 // BEGIN Local configuration
 
-$WORKDIR = "set to the location of pstamp working directory";
-$dsroot = "set to the root of the data store";
-$dbname = "set to the pstamp database name";
-$dbserver = "set to the pstamp database server";
+$WORKDIR = "/data/kukui.2/eugene/datastore.20260421/ps-out";
+$DS_ROOT = "/data/kukui.2/eugene/datastore.20260421/dsroot";
+$DS_URL  = "http://dstest.ifa.hawaii.edu";
+// $dbname = "set to the pstamp database name";
+// $dbserver = "set to the pstamp database server";
 
-$PSCONFDIR = "";
-$PSCONFIG  = "";
+# database info for the datastore
+$DS_HOSTNAME = "localhost";
+$DS_USERNAME = "ipp";
+$DS_PASSWORD = "ipp";
+$DS_DATABASE = "datastore";
+
+# database info for the pstamp
+$PS_HOSTNAME = "localhost";
+$PS_USERNAME = "ipp";
+$PS_PASSWORD = "ipp";
+$PS_DATABASE = "pstamp";
+
+$PSCONFDIR = "/home/kiawe/eugene/src/psconfig/";
+$PSCONFIG  = "ipp-pstamp-20260421";
 $PSBINDIR  = "$PSCONFDIR/$PSCONFIG.lin64/bin";
 
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/request.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/request.php	(revision 42995)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/request.php	(revision 42996)
@@ -22,5 +22,5 @@
 # this script sets up the environment to run IPP commands with current directory
 # $WORKDIR
-$SCRIPT    = "$PSBINDIR/pstamp_runcommand.sh $PSCONFDIR $PSCONFIG $WORKDIR";
+// $SCRIPT    = "$PSBINDIR/pstamp_runcommand.sh $PSCONFDIR $PSCONFIG $WORKDIR";
 
 // END of moved to pstampconfig.php
@@ -57,7 +57,4 @@
 $outFileset = "";
 
-// Initialize the request variables that we depend upon
-$rvar_project="";
-
 $gpc1_selected="";
 $gpc2_selected="";
@@ -67,37 +64,38 @@
 $require_component = 0;
 
-$rvar_email = "";
-$rvar_select_by = "";
-$rvar_img_type = "";
-$rvar_id = "";
-$rvar_component = "";
-$rvar_survey = "bypass";
-$rvar_release = "";
-$rvar_data_group = "";
-$rvar_filter = "";
-
-$rvar_center_type = "";
-$rvar_range_type  = "";
-
-$rvar_RA = "";
-$rvar_DEC = "";
-$rvar_dRA = "";
-$rvar_dDEC = "";
-$rvar_X = "";
-$rvar_Y = "";
-$rvar_W = "";
-$rvar_H = "";
-
-$rvar_make_jpeg = "";
-$rvar_getall_roi = "";
-
-$rvar_cmd_mode = "";
-$rvar_last_cmd_mode = "";
-$rvar_request_id = 0;
-$rvar_last_request_id = 0;
+// Initialize the request variables that we depend upon
+
+// EAM: modern PHP has deprecated the function import_request_variables
+// I have created a wrapper function to filter_input to replace
+$rvar_project         = request_var ('project', FILTER_SANITIZE_STRING);
+$rvar_email           = request_var ('email',   FILTER_VALIDATE_EMAIL);
+$rvar_select_by       = request_var ('select_by', FILTER_SANITIZE_STRING);
+$rvar_img_type        = request_var ('img_type', FILTER_SANITIZE_STRING);
+$rvar_id              = request_var ('id', FILTER_SANITIZE_STRING);
+$rvar_component       = request_var ('component', FILTER_SANITIZE_STRING);
+$rvar_survey          = request_var ('survey', FILTER_SANITIZE_STRING, "bypass");
+$rvar_release         = request_var ('release', FILTER_SANITIZE_STRING);
+$rvar_data_group      = request_var ('data_group', FILTER_SANITIZE_STRING);
+$rvar_filter          = request_var ('filter', FILTER_SANITIZE_STRING);
+$rvar_center_type     = request_var ('center_type', FILTER_SANITIZE_STRING);
+$rvar_range_type      = request_var ('range_type', FILTER_SANITIZE_STRING);
+$rvar_RA              = request_var ('RA', FILTER_VALIDATE_FLOAT);
+$rvar_DEC             = request_var ('DEC', FILTER_VALIDATE_FLOAT);
+$rvar_dRA             = request_var ('dRA', FILTER_VALIDATE_FLOAT);
+$rvar_dDEC            = request_var ('dDEC', FILTER_VALIDATE_FLOAT);
+$rvar_X               = request_var ('X', FILTER_VALIDATE_FLOAT);
+$rvar_Y               = request_var ('Y', FILTER_VALIDATE_FLOAT);
+$rvar_W               = request_var ('W', FILTER_VALIDATE_FLOAT);
+$rvar_H               = request_var ('H', FILTER_VALIDATE_FLOAT);
+$rvar_make_jpeg       = request_var ('make_jpeg', FILTER_SANITIZE_STRING);
+$rvar_getall_roi      = request_var ('getall_roi', FILTER_SANITIZE_STRING);
+$rvar_cmd_mode        = request_var ('cmd_mode', FILTER_SANITIZE_STRING);
+$rvar_last_cmd_mode   = request_var ('last_cmd_mode', FILTER_SANITIZE_STRING);
+$rvar_request_id      = request_var ('request_id', FILTER_VALIDATE_INT, 0);
+$rvar_last_request_id = request_var ('last_request_id', FILTER_VALIDATE_INT, 0);
 
 // now get the values from this post
 
-import_request_variables("gp", "rvar_");
+// import_request_variables("gp", "rvar_");
 
 if ($rvar_project == "gpc1") {
@@ -284,6 +282,4 @@
     global $rvar_survey, $rvar_release;
     global $command_line;
-    global $dbname;
-    global $dbserver;
     global $require_component;
     global $PSCONFDIR, $PSCONFIG, $WORKDIR;
@@ -314,5 +310,5 @@
 
     if ($dbname) {
-        $cmd .= " --dbname $dbname --dbserver $dbserver";
+        $cmd .= " --dbname $PS_DATABASE --dbserver $PS_HOSTNAME";
     }
 
@@ -455,7 +451,12 @@
     global $command_status;
 
-    // echo "<br>running $command_line\n<br>";
-
-    exec ("$command_line", $output_array, $command_status);
+    // EAM : testing:
+    echo "<br>running $command_line\n<br>";
+
+    // EAM : testing:
+    // exec ("$command_line", $output_array, $command_status);
+    http_response_code(400);
+    echo "<b> run command $command_line</b><br>";
+    die ("run command $command_line");
 
     $size = sizeof($output_array);
@@ -503,10 +504,8 @@
                 global $dsroot;
                 $dirName  = "$dsroot/$product/$req_name";
-                // XXX: TODO: make this a configuration parameter
-                //$filesetURL = "http://datastore.ipp.ifa.hawaii.edu/$product/$req_name";
-                $filesetURL = "http://datastore.ipp.ifa.hawaii.edu/ds/$product/$req_name";
+                $filesetURL = "$DS_URL/$product/$req_name";
 
                 $fullpath = "$dirName/$fileName";
-// echo "<pre>fullpath: $fullpath filesetURL: $filesetURL\n</pre>";
+		// echo "<pre>fullpath: $fullpath filesetURL: $filesetURL\n</pre>";
                 if (file_exists($dirName)) {
                     // this job is done, list the url as a link
@@ -551,5 +550,5 @@
   s.innerHTML = s.innerHTML - 1;
   if (s.innerHTML == 0)
-//    window.location = 'http://pstamp.ipp.ifa.hawaii.edu/request.php';
+ //    window.location = 'http://pstamp.ipp.ifa.hawaii.edu/request.php';
     location.reload();
   else
@@ -878,6 +877,5 @@
 <?php
     // echo "calling listRequests\n";
-    //listRequests("http://datastore.ipp.ifa.hawaii.edu", "pstamp_results_fileset");
-    listRequests("http://datastore.ipp.ifa.hawaii.edu/ds", "pstamp_results_fileset");
+    listRequests("$DS_URL", "pstamp_results_fileset");
 ?>
 
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/status.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/status.php	(revision 42996)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/status.php	(revision 42996)
@@ -0,0 +1,119 @@
+<?php // upload.php
+
+// get the locatl configuration variables
+require "pstamp.php";
+require "submitted.php";
+
+
+$user = $_SERVER['PHP_AUTH_USER'];
+$passwd = $_SERVER['PHP_AUTH_PW'];
+?>
+
+<HTML>
+<head>
+    <title>
+        Postage Stamp Server Status
+    </title>
+    <script type='text/javascript'>
+    setTimeout('countdown()', 100);
+
+    function countdown() {
+      var s = document.getElementById('timer');
+      s.innerHTML = s.innerHTML - 1;
+    if (s.innerHTML == 0)
+//      window.location = 'http://pstamp.ipp.ifa.hawaii.edu/status.php';
+      location.reload();
+    else
+      setTimeout('countdown()', 1000*60);
+    }
+    </script>
+</head>
+<body>
+<H1 align=center>
+Postage Stamp Server Status : Normal
+</h1>
+
+<?php
+
+// welcomeHeader($auth_user, "request.php", "Request Form");
+// welcomeHeader($auth_user, "pshome.php", "Postage Stamp Home");
+welcomeHeader($auth_user, 0, 0);
+// include "pstamp_links.php";
+
+echo "<br />";
+echo "<br />";
+echo "The page will refresh in <span id='timer'> 20</span> mins<br><br>";
+
+if (0) {
+// Top of the page is the contents of the "message of the day file"
+// This can be empty but must exist or the user sees an error.
+$motd_filename = "pstamp_motd.html";
+$file = fopen($motd_filename, "r");
+if ($file) {
+    fpassthru($file);
+}
+}
+
+// Display the currrent status page unless it is more than 5 minutes old
+// in that case generate it on the fly
+
+$too_old = 300;
+//$too_old = 30000;
+$now = time();
+
+$status_filename = "$WORKDIR/server_status/status.html";
+
+echo "WORKDIR: $WORKDIR<br>\n";
+echo "filename: $status_filename<br>\n";
+
+$modtime = filemtime($status_filename);
+if ($modtime) {
+
+   // echo "status file modified at: $modtime<br />\n";
+   // echo "current time             $now<br />\n";
+
+   $age = $now - $modtime;
+   // echo "age:                     $age<br /><br />\n";
+
+   if ($age < $too_old ) { 
+        $file = fopen($status_filename, "r");
+        if ($file) {
+            fpassthru($file);
+            exit;
+        }
+    } else {
+       // echo "status file too old: $age. Getting status directly.<br /><br />\n";
+    }
+}
+
+
+// status file is out of date fall through and get the status
+
+$command = "$SCRIPT pstamp_server_status";
+
+
+if ($command) {
+    $command = escapeshellcmd($command);
+   // echo "<br />command:<br />$command";
+    echo "<br />";
+    exec($command, $output, $command_status);
+    if ($command_status == 0) {
+        // it worked!
+//        echo "<pre>\n";
+        for ($i=0; $i< count($output); $i++) {
+            // echo "$output[$i]<br />\n";
+            echo "$output[$i]\n";
+        }
+    } else {
+        echo "Unexpected Error.<br /> status command returned $command_status<br \>";
+    }
+}
+
+// print lots of information
+// phpinfo(-1);
+// print the most useful variables
+// phpinfo(32);
+
+echo "</body></html>";
+
+?>
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/submitted.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/submitted.php	(revision 42995)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/submitted.php	(revision 42996)
@@ -72,6 +72,6 @@
         if ($id && ($req->state != "stop")) {
             // Get the current state of this request from the database
-            if (!$dbserver) {
-                $dbserver = dblogin();
+            if (!$dbconnection) {
+                $dbconnection = dblogin("PSTAMP");
             }
 
@@ -79,7 +79,7 @@
             // echo "<br />$query<br />";
 
-            $result  = mysqli_query($dbserver, $query);
+            $result  = mysqli_query($dbconnection, $query);
             if (!$result) {
-                die("Database access failed: " . mysqli_error($dbserver));
+                die("Database access failed: " . mysqli_error($dbconnection));
             }
 
@@ -128,7 +128,9 @@
 function listRequests($dataStoreRoot, $targetWindow)
 {
-    $debug_listing = 0;
-    $request_count = count($_SESSION['requests']);
-    // echo "request_count: $request_count<br />";
+  $debug_listing = 0;
+  $request_count = count($_SESSION['requests']);
+  $dbconnection = 0;
+  
+  // echo "request_count: $request_count<br />";
 
     for ($i = $request_count-1; $i >= 0; $i--) {
@@ -147,6 +149,6 @@
             // Request not done last time that we checked.
             // Get its current state of this request from the database
-            if (!$dbserver) {
-                $dbserver = dblogin();
+            if (!$dbconnection) {
+                $dbconnection = dblogin("PSTAMP");
             }
             $query = "SELECT pstampRequest.state, COUNT(job_id) as num_jobs, pstampRequest.fault, pstampRequest.outProduct FROM pstampRequest LEFT JOIN pstampJob USING(req_id) WHERE req_id = $id";
@@ -154,7 +156,7 @@
             // echo "<br />$query<br />";
 
-            $result  = mysqli_query($dbserver, $query);
+            $result  = mysqli_query($dbconnection, $query);
             if (!$result) {
-                die("Database access failed: " . mysqli_error($dbserver));
+                die("Database access failed: " . mysqli_error($dbconnection));
             }
 
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/upload.php
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/upload.php	(revision 42995)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/web/upload.php	(revision 42996)
@@ -72,5 +72,5 @@
            if ($size > 0) {
       //      echo "Uploaded $size bytes for '$type' file '$name' as '$tmp_name'<br />";
-            $command = "$SCRIPT pstamp_insert_request.pl --tmp_req_file $tmp_name --dbname $dbname --dbserver $dbserver --workdir $WORKDIR";
+            $command = "$SCRIPT pstamp_insert_request.pl --tmp_req_file $tmp_name --dbname $PS_DATABASE --dbserver $PS_HOSTNAME --workdir $WORKDIR";
             } else {
                 echo "Error: Received 0 bytes for file '$name' <br />\n";
@@ -134,6 +134,5 @@
 echo "<br />\n";
 
-// listRequests("http://datastore.ipp.ifa.hawaii.edu", "pstamp_results_fileset");
-listRequests("http://datastore.ipp.ifa.hawaii.edu/ds", "pstamp_results_fileset");
+listRequests($DS_URL, "pstamp_results_fileset");
 
 echo "<br />\n";
