Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9501)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9502)
@@ -29,4 +29,14 @@
    * datacenter/db/sequinfo-aio.php:
      - removed $_GET from some functions
+
+   * datacenter/db/db.php, datacenter/db/datasetinfo.php, 
+     datacenter/db/dbstatus.php, datacenter/db/findoffdata.php, 
+     datacenter/db/index.html, datacenter/db/index.php, 
+     datacenter/db/querycal.php, datacenter/db/queryseq.php, 
+     datacenter/db/querystar.php, datacenter/db/runinfo.php, 
+     datacenter/db/sequinfo.php, datacenter/db/statusrps.php, 
+     datacenter/db/statussps.php:
+     - removed 
+
 
 
Index: trunk/MagicSoft/Mars/datacenter/db/datasetinfo.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/datasetinfo.php	(revision 9501)
+++ 	(revision )
@@ -1,431 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
-    {
-        $fromtable="DataSets";
-
-        $groups = 0;
-        foreach ($checkgroup as $element)
-            if ($element==-1)
-                $groups++;
-
-        $statusgroups = 0;
-        foreach ($checkstatusgroup as $element)
-            if ($element==-1)
-                $statusgroups++;
-
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        if ($groups>0)
-        {
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
-            $query0 .= " COUNT(*) as '# Datasets' ";
-        }
-        else
-        {
-            if ($statusgroups>0)
-            {
-                foreach ($checkstatusgroup as $key => $element)
-                    if ($element==-1)
-                        $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-//                        $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-
-                $query0 .= " COUNT(*) as '# Datasets'";
-
-            }
-            else
-            {
-                $query0 .= " " . $fromtable . ".fDataSetNumber as '" . $alias["fDataSetNumber"] . "' ";
-                if (!empty($_GET["fLinks"]))
-                {
-                    $query0 .= ", CONCAT('<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/datasets/' , LEFT(LPAD(CONCAT(DataSets.fDataSetNumber, '.'), 9,'0'),5), '/dataset', LPAD(CONCAT(DataSets.fDataSetNumber , '.txt'), 12,'0') , '\">f</A>' ";
-                    $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/ganymed/' , LEFT(LPAD(CONCAT(DataSets.fDataSetNumber, '.'), 9,'0'),5), '/', LEFT(LPAD(CONCAT(DataSets.fDataSetNumber, '.'), 9,'0'), 8), '\">g</A>'";
-                    $query0 .= ", '&nbsp;<A&ws;HREF=\"ganymed.php?fDataSetNo=', DataSets.fDataSetNumber, '\">i</A>') ";
-                    $query0 .= " as 'Links'";
-                }
-
-                foreach ($_GET as $key => $element)
-                    if ($_GET[$key]=="On")
-                        if ($key!="fLinks")
-                            if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                                $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-            }
-        }
-
-        $query0 .= " FROM " . $fromtable;
-
-        $query0 .= " LEFT JOIN DataSetProcessStatus USING(fDataSetNumber) ";
-        $query0 .= " LEFT JOIN Ganymed USING(fDataSetNumber) ";
-
-        foreach ($_GET as $key => $element)
-            if (($_GET[$key]=="On" || $groups>0))// && !empty($joins[$key]))
-                $query0 .= GetJoin($fromtable,$key);
-
-        foreach ($checkwhere as $key => $element)
-        {
-            if (empty($element) || $element<=0)
-                continue;
-
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                if ($element!=-1)
-                    if (strrpos($query0, " AND ")!=strlen($query0)-5)
-                        $query0 .= " AND ";
-
-            if ($element!=-1)
-                $query0 .= GetCheck($fromtable, $key) . "=" . $element;
-        }
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= StatusQuery("fDataSetInserted", $needs, $timelimits);
-        $query0 .= StatusQuery("fStarFilesAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fGanymed", $needs, $timelimits);
-        $query0 .= StatusQuery("fFillGanymed", $needs, $timelimits);
-
-        if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
-            $query0 .= "DataSets.fDataSetNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-/*
-        if (!empty($_GET["fDate"]))
-            $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
-*/
-
-        if (!empty($_GET["fSourceN"]))
-            $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
-
-        if ($groups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $groups;
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= GetCheck($fromtable,$key);
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if ($statusgroups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $statusgroups;
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= $alias[$key];
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $val=substr($_GET["fSortBy"], 0, -1);
-            $query0 .= " ORDER BY " . GetTable($fromtable, $val) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
-            $query0 .= "ORDER BY DataSets.fDataSetNumber ASC ";
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="50";
-
-        if (empty($_GET["fLastUpdate"]))
-            $_GET["fLastUpdate"]="Off";
-
-        if (empty($_GET["fLinks"]))
-            $_GET["fLinks"]=$first?"On":"";
-
-        if (empty($_GET["fComment"]))
-            $_GET["fComment"]="Off";
-
-        if (empty($_GET["fWobble"]))
-            $_GET["fWobble"]=$first?"On":"";
-
-        if (empty($_GET["fExcessEvents"]))
-            $_GET["fExcessEvents"]=$first?"On":"";
-
-        if (empty($_GET["fExcessEvents*60/fEffOnTime"]))
-            $_GET["fExcessEvents*60/fEffOnTime"]=$first?"Off":"";
-
-        if (empty($_GET["fBackgroundEvents*60/fEffOnTime"]))
-            $_GET["fBackgroundEvents*60/fEffOnTime"]=$first?"On":"";
-
-        if (empty($_GET["fBackgroundEvents"]))
-            $_GET["fBackgroundEvents"]=$first?"On":"";
-
-        if (empty($_GET["fSignalEvents"]))
-            $_GET["fSignalEvents"]=$first?"On":"";
-
-        if (empty($_GET["fSignalEvents*60/fEffOnTime"]))
-            $_GET["fSignalEvents*60/fEffOnTime"]=$first?"Off":"";
-
-        if (empty($_GET["fSignificance"]))
-            $_GET["fSignificance"]=$first?"On":"";
-
-        if (empty($_GET["Round(fSignificance/Sqrt(fEffOnTime/3600),2)"]))
-            $_GET["Round(fSignificance/Sqrt(fEffOnTime/3600),2)"]=$first?"Off":"";
-
-        if (empty($_GET["fScaleFactor"]))
-            $_GET["fScaleFactor"]=$first?"On":"";
-
-        if (empty($_GET["fEffOnTime/3600"]))
-            $_GET["fEffOnTime/3600"]=$first?"On":"";
-
-        if (empty($_GET["fDataSetInserted"]))
-            $_GET["fDataSetInserted"]="Off";
-
-        if (empty($_GET["fDataSetInsertedStatus"]))
-            $_GET["fDataSetInsertedStatus"]="0";
-
-        if (empty($_GET["fStarFilesAvail"]))
-            $_GET["fStarFilesAvail"]="Off";
-
-        if (empty($_GET["fStarFilesAvailStatus"]))
-            $_GET["fStarFilesAvailStatus"]="0";
-
-        if (empty($_GET["fGanymed"]))
-            $_GET["fGanymed"]=$first?"On":"";
-
-        if (empty($_GET["fGanymedStatus"]))
-            $_GET["fGanymedStatus"]="0";
-
-        if (empty($_GET["fFillGanymed"]))
-            $_GET["fFillGanymed"]="Off";
-
-        if (empty($_GET["fFillGanymedStatus"]))
-            $_GET["fFillGanymedStatus"]="0";
-
-        if (empty($_GET["fSourceName"]))
-            $_GET["fSourceName"]=$first?"On":"";
-
-        if (empty($_GET["fLastUpdate"]))
-            $_GET["fLastUpdate"]="Off";
-
-        if (empty($_GET["fStartTime"]))
-            $_GET["fStartTime"]="Off";
-
-        if (empty($_GET["fFailedTime"]))
-            $_GET["fFailedTime"]="Off";
-
-        if (empty($_GET["fReturnCode"]))
-            $_GET["fReturnCode"]="Off";
-
-        if (empty($_GET["fProgramId"]))
-            $_GET["fProgramId"]="Off";
-
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"datasetinfo.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fWobble",           "Wobble");
-        CheckBox("fComment",          "Comment");
-        CheckBox("fScaleFactor",      "Scale");
-        CheckBox("fEffOnTime/3600",   "EffOnTime");
-        CheckBox("fLinks",             "Links");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fExcessEvents",     "ExcEvts");
-        CheckBox("fBackgroundEvents", "BgEvts");
-        CheckBox("fSignalEvents",     "SignEvts");
-        CheckBox("fSignificance",     "Sign");
-
-        printf("  </tr><tr>\n");       
-
-        CheckBox("fExcessEvents*60/fEffOnTime",                   "ExcRate");
-        CheckBox("fBackgroundEvents*60/fEffOnTime",               "BgRate");
-        CheckBox("fSignalEvents*60/fEffOnTime",                   "SignRate");
-        CheckBox("Round(fSignificance/Sqrt(fEffOnTime/3600),2)",  "SignfRate");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fStartTime",     "StartTime");
-        CheckBox("fFailedTime",    "FailedTime");
-        CheckBox("fReturnCode",    "RetCode");
-        CheckBox("fProgramId",     "ProgramId");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        printf("  <td>\n");
-        PrintStatusMenu("fDataSetInserted", "DataSet Inserted");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fStarFilesAvail",  "FilesAvail");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fGanymed",         "Ganymed");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fFillGanymed",     "FillGanymed");
-
-        printf("  </td></tr><tr><td>\n");
-
-        PrintPullDown($host, $user, $pw, $db, "Source",      "fSourceName",      "fSourceKEY", "Source Name");
-
-        printf("  </td></tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fDataSetNumber", "DataSets", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fDataSetNumber", "DataSets", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-/*
-        printf("Date&nbsp;(yyyy-mm-dd)&nbsp;<input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
-        if (!empty($_GET["fDate"]))
-            printf("%s", $_GET["fDate"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-*/
-
-        printf("Source&nbsp;(<A HREF=\"regexp.html\">regexp</A>)&nbsp;<input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
-        if (!empty($_GET["fSourceN"]))
-            printf("%s", $_GET["fSourceN"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-
-        printf("DataSets&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"datasetinfo.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1" || $html=="2")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        if (empty($_GET["fPrintTable"]))
-            PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-        {
-            if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-            else
-                PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-        }
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/dbstatus.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/dbstatus.php	(revision 9501)
+++ 	(revision )
@@ -1,414 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $needs)
-    {
-        $joins = array
-            (
-             "fSourceName"                       => " LEFT JOIN Source USING(fSourceKEY) ",
-            );
-
-        $checkwhere = array
-            (
-             "fSourceName"                       => CheckWhere("fSourceKEY",                       $_GET),
-            );
-        $checkgroup = array
-            (
-             "fSourceName"                       => CheckGroup("fSourceKEY",                       $_GET),
-            );
-
-        $checkstatusgroup = array
-            (
-             "fAllFilesAvail"                    => CheckStatusGroup("fAllFilesAvailStatus",       $_GET),
-             "fCallisto"                         => CheckStatusGroup("fCallistoStatus",            $_GET),
-             "fFillCallisto"                     => CheckStatusGroup("fFillCallistoStatus",        $_GET),
-             "fStar"                             => CheckStatusGroup("fStarStatus",                $_GET),
-             "fFillStar"                         => CheckStatusGroup("fFillStarStatus",            $_GET),
-            );
-
-        $check = array
-            (
-             "fSourceName"                       => " Sequences.fSourceKEY",
-            );
-
-        $table = array
-            (
-             "fSourceName"                       => "Source.fSourceName",
-             "fAllFilesAvail"                    => "SequenceProcessStatus.fAllFilesAvail",
-             "fCallisto"                         => "SequenceProcessStatus.fCallisto",
-             "fFillCallisto"                     => "SequenceProcessStatus.fFillCallisto",
-             "fStar"                             => "SequenceProcessStatus.fStar",
-             "fFillStar"                         => "SequenceProcessStatus.fFillStar",
-             );
-
-        $groups = 0;
-        foreach ($checkgroup as $element)
-            if ($element==-1)
-                $groups++;
-
-        $statusgroups = 0;
-        foreach ($checkstatusgroup as $element)
-            if ($element==-1)
-                $statusgroups++;
-
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        if ($groups>0)
-        {
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
-            //--------------------------------------------------
-            $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
-            //--------------------------------------------------
-            $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
-            $query0 .= " Min(fZenithDistanceMin) as '" . $alias["Min(fZenithDistanceMin)"] . "', ";
-            $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', ";
-            $query0 .= " COUNT(*) as 'Sequence#' ";
-        }
-        else
-        {
-            if ($statusgroups>0)
-            {
-                foreach ($checkstatusgroup as $key => $element)
-                    if ($element==-1)
-                        $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-//                        $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-
-                $query0 .= " count(*) as 'Sequence#'";
-
-            }
-            else
-            {
-                if (!empty($_GET["fSendTxt"]))
-                    $query0 .= " Sequences.fSequenceFirst ";
-                else
-                    $query0 .= " CONCAT('<A&ws;HREF=\"runinfo.php?',  'fRunStart=On', '&fZenithDistance=On', '&fRunMin=', Sequences.fSequenceFirst, '&fMeanTriggerRate=On', '&fRunTypeName=On', '&fRunMax=', fSequenceLast, '&fNumEvents=On', '&fSourceName=On&', 'fExcludedFDAKEY=1', '&fSequenceFirst=On', '&fRawFileAvail=On', '&fCCFileAvail=On', '&fCaCoFileAvail=On\">', Sequences.fSequenceFirst, '</A>') ";
-                $query0 .= " as 'Sequence#' ";
-
-                foreach ($_GET as $key => $element)
-                    if ($_GET[$key]=="On")
-                        if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                            $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-            }
-        }
-
-        $query0 .= " FROM Sequences ";
-
-        $query0 .= " LEFT JOIN SequenceProcessStatus USING(fSequenceFirst,fTelescopeNumber) ";
-        $query0 .= " LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) ";
-        $query0 .= " LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) ";
-
-        foreach ($_GET as $key => $element)
-            if (($_GET[$key]=="On" || $groups>0) && !empty($joins[$key]))
-                $query0 .= $joins[$key];
-
-        foreach ($checkwhere as $key => $element)
-        {
-            if (empty($element) || $element<=0)
-                continue;
-
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                if ($element!=-1)
-                    if (strrpos($query0, " AND ")!=strlen($query0)-5)
-                        $query0 .= " AND ";
-
-            if ($element!=-1)
-                $query0 .= $check[$key] . "=" . $element;
-        }
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= StatusQuery("fSequenceFileWritten", $needs, $timelimits);
-        $query0 .= StatusQuery("fAllFilesAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fCallisto", $needs, $timelimits);
-        $query0 .= StatusQuery("fFillCallisto", $needs, $timelimits);
-        $query0 .= StatusQuery("fStar", $needs, $timelimits);
-        $query0 .= StatusQuery("fFillStar", $needs, $timelimits);
-
-        if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
-            $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-        else
-            $query0 = substr($query0, 0, -6);
-
-/*
-        if (!empty($_GET["fDate"]))
-            $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
-*/
-
-        if (!empty($_GET["fSourceN"]))
-            $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
-
-        if (!empty($_GET["fStartDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $startdate=substr($_GET["fStartDate"], 0, 10);
-            if ($startdate=="0000-00-00")
-                $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
-            else
-                $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
-        }
-
-        if (!empty($_GET["fStopDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $stopdate=substr($_GET["fStopDate"], 0, 10);
-            $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
-        }
-
-        if ($groups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $groups;
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= $check[$key];
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if ($statusgroups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $statusgroups;
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= $alias[$key];
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $val=substr($_GET["fSortBy"], 0, -1);
-            $query0 .= " ORDER BY " . GetTable($fromtable, $val) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
-            $query0 .= "ORDER BY Sequences.fSequenceFirst ASC ";
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fSourceName"]))
-            $_GET["fSourceName"]=$first?"On":"";
-
-        if (empty($_GET["fAllFilesAvail"]))
-            $_GET["fAllFilesAvail"]="On";
-
-        if (empty($_GET["fAllFilesAvailStatus"]))
-            $_GET["fAllFilesAvailStatus"]=$first?"7":"";
-
-        if (empty($_GET["fCallisto"]))
-            $_GET["fCallisto"]="On";
-
-        if (empty($_GET["fCallistoStatus"]))
-            $_GET["fCallistoStatus"]=$first?"7":"";
-
-        if (empty($_GET["fFillCallisto"]))
-            $_GET["fFillCallisto"]="Off";
-
-        if (empty($_GET["fFillCallistoStatus"]))
-            $_GET["fFillCallistoStatus"]="0";
-
-        if (empty($_GET["fStar"]))
-            $_GET["fStar"]=$first?"On":"";
-
-        if (empty($_GET["fStarStatus"]))
-            $_GET["fStarStatus"]=$first?"7":"";
-
-        if (empty($_GET["fFillStar"]))
-            $_GET["fFillStar"]="Off";
-
-        if (empty($_GET["fFillStarStatus"]))
-            $_GET["fFillStarStatus"]="0";
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"dbstatus.php\" METHOD=\"GET\">\n");
-        printf(" <table><tr><td>\n");
-
-        PrintStatusMenu("fAllFilesAvail",       "Files avail");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fCallisto",            "Callisto");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fStar",                "Star");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fFillCallisto",        "Fillcallisto");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fFillStar",            "Fillstar");
-
-        printf("</td></tr> </table>\n");
-        printf(" <p>\n");
-
-        // pull down boxes
-
-        printf(" <table>\n");
-        printf("  <tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Source",      "fSourceName",      "fSourceKEY", "Source Name");
-        printf("  </td><td>\n");
-
-        printf("&nbsp;&nbsp;&nbsp;Source&nbsp;(<A HREF=\"regexp.html\">regexp</A>)&nbsp;<input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
-        if (!empty($_GET["fSourceN"]))
-            printf("%s", $_GET["fSourceN"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-
-        printf("  </td></tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fStartDate"]))
-            $timemin = GetMin("fRunStart", "Sequences", $host, $user, $pw, $db);
-        else
-            $timemin = $_GET["fStartDate"];
-
-        if (empty($_GET["fStopDate"]))
-            $timemax = GetMax("fRunStart", "Sequences", $host, $user, $pw, $db);
-        else
-            $timemax = $_GET["fStopDate"];
-
-        printf("Night&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
-        printf("to&nbsp;<input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">&nbsp;&nbsp;&nbsp;&nbsp;\n", $timemax);
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-        printf("Sequences&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"dbstatus.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $needs)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $alias = array
-            (
-             "fSourceName"                      => "Source",
-             "fAllFilesAvail"                   => "FilesAvail",
-             "fCallisto"                        => "Callisto",
-             "fStar"                            => "Star",
-             "fFillCallisto"                    => "FillCal",
-             "fFillStar"                        => "FillStar",
-            );
-        $rightalign = array
-            (
-            );
-
-        $query0 = CreateQuery($_GET, $alias, $needs);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1" || $html=="2")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        if (empty($_GET["fPrintTable"]))
-            PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-        {
-            if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $host, $user, $pw, $db, $needs);
-            else
-                PrintPage("2", $host, $user, $pw, $db, $needs);
-        }
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/findoffdata.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/findoffdata.php	(revision 9501)
+++ 	(revision )
@@ -1,469 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
-    {
-        $fromtable="Sequences";
-
-        $groups = 0;
-        foreach ($checkgroup as $element)
-            if ($element==-1)
-                $groups++;
-
-        $statusgroups = 0;
-        foreach ($checkstatusgroup as $element)
-            if ($element==-1)
-                $statusgroups++;
-
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        if ($groups>0)
-        {
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
-            //--------------------------------------------------
-            $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
-            //--------------------------------------------------
-            $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
-            $query0 .= " Min(fZenithDistanceMin) as '" . $alias["Min(fZenithDistanceMin)"] . "', ";
-            $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', ";
-            $query0 .= " COUNT(*) as 'Sequence' ";
-        }
-        else
-        {
-            if ($statusgroups>0)
-            {
-                foreach ($checkstatusgroup as $key => $element)
-                    if ($element==-1)
-                        $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-//                        $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-
-                $query0 .= " count(*) as 'Sequence'";
-
-            }
-            else
-            {
-                if (!empty($_GET["fSendTxt"]))
-                    $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
-                else
-                {
-                    $query0 .= " CONCAT('<A&ws;HREF=\"runinfo.php?',  'fRunStart=On', '&fZenithDistance=On', '&fRunMin=', Sequences.fSequenceFirst, '&fMeanTriggerRate=On', '&fRunTypeName=On', '&fRunMax=', fSequenceLast, '&fNumEvents=On', '&fSourceName=On&', 'fExcludedFDAKEY=1', '&fSequenceFirst=On', '&fRawFileAvail=On', '&fCCFileAvail=On', '&fCaCoFileAvail=On', '&fNumResults=500\">', Sequences.fSequenceFirst, '</A>') ";
-                    $query0 .= " as " . $alias["fSequenceFirst"];
-                    if (!empty($_GET["fLinks"]))
-                    {
-                        $query0 .= ", CONCAT('<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'callisto', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">cl</A>'";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">c</A>'";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'star', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">sl</A>'";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">s</A>'";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/sequences/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/sequence', LPAD(CONCAT(Sequences.fSequenceFirst , '.txt'), 12,'0') , '\">', 'f </A>') ";
-                        $query0 .= " as 'Links'";
-                    }
-                }
-
-                foreach ($_GET as $key => $element)
-                    if ($_GET[$key]=="On")
-                        if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff")
-                            if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                                $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-            }
-        }
-
-        $query0 .= " FROM " . $fromtable;
-
-        $query0 .= " LEFT JOIN SequenceProcessStatus USING(fSequenceFirst,fTelescopeNumber) ";
-        $query0 .= " LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) ";
-        $query0 .= " LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) ";
-
-        foreach ($_GET as $key => $element)
-            if (($_GET[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key)))
-                $query0 .= GetJoin($fromtable,$key);
-
-        if ($_GET["fOff"]=="Off")
-        {
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                $query0 .= " AND ";
-
-            $query0 .= " NOT (fSourceName like '%Off%')";
-        }
-
-        if ($_GET["fOnlyOff"]=="On")
-        {
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                $query0 .= " AND ";
-
-            $query0 .= " fSourceName like '%Off%'";
-        }
-
-        foreach ($checkwhere as $key => $element)
-        {
-            if (empty($element) || $element<=0)
-                continue;
-
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                if ($element!=-1)
-                    if (strrpos($query0, " AND ")!=strlen($query0)-5)
-                        $query0 .= " AND ";
-
-            if ($element!=-1)
-                $query0 .= GetCheck($fromtable, $key) . "=" . $element;
-        }
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= StatusQuery("fStar", $needs, $timelimits);
-
-        if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
-            $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-        else
-            $query0 = substr($query0, 0, -4);
-
-        if ((!empty($_GET["fZDMin"]) || $_GET["fZDMin"]==0) && !empty($_GET["fZDMax"]))
-            $query0 .= "AND (fZenithDistanceMin >= " . $_GET["fZDMin"] . " AND fZenithDistanceMax <= " . $_GET["fZDMax"] . ") ";
-
-        if (!empty($_GET["fSourceN"]))
-            $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
-
-        if (!empty($_GET["fStartDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $startdate=substr($_GET["fStartDate"], 0, 10);
-            if ($startdate=="0000-00-00")
-                $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
-            else
-                $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
-        }
-
-        if (!empty($_GET["fStopDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $stopdate=substr($_GET["fStopDate"], 0, 10);
-            $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
-        }
-
-        if (!empty($_GET["fStarStart"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $starstart=substr($_GET["fStarStart"], 0, 10);
-            $query0 .=" fStar >= '" . $starstart . " 00:00:00' ";
-        }
-
-        if (!empty($_GET["fStarStop"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $starstop=substr($_GET["fStarStop"], 0, 10);
-            $query0 .= " fStar < '" . $starstop . " 23:59:59' ";
-        }
-
-        if ($groups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $groups;
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= GetCheck($fromtable,$key);
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if ($statusgroups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $statusgroups;
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= $alias[$key];
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $val=substr($_GET["fSortBy"], 0, -1);
-            $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
-            $query0 .= "ORDER BY Sequences.fSequenceFirst ASC ";
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="50";
-
-        if (empty($_GET["fRunStart"]))
-            $_GET["fRunStart"]=$first?"On":"";
-
-        if (empty($_GET["fRunTime/60"]))
-            $_GET["fRunTime/60"]=$first?"On":"";
-
-        if (empty($_GET["fLinks"]))
-            $_GET["fLinks"]=$first?"On":"";
-
-        if (empty($_GET["fOff"]))
-            $_GET["fOff"]=$first?"On":"";
-
-        if (empty($_GET["fOnlyOff"]))
-            $_GET["fOnlyOff"]=$first?"Off":"";
-
-        if (empty($_GET["fZenithDistanceMin"]))
-            $_GET["fZenithDistanceMin"]=$first?"On":"";
-
-        if (empty($_GET["fZenithDistanceMax"]))
-            $_GET["fZenithDistanceMax"]=$first?"On":"";
-
-        if (empty($_GET["fSourceName"]))
-            $_GET["fSourceName"]="On";
-
-        if (empty($_GET["fLightConditionsName"]))
-            $_GET["fLightConditionsName"]=$first?"On":"";
-
-        if (empty($_GET["fStarStatus"]))
-            $_GET["fStarStatus"]=$first?"1":"";
-
-        if (empty($_GET["fUnsuitableInner"]))
-            $_GET["fUnsuitableInner"]=$first?"On":"";
-
-        if (empty($_GET["fMeanPedRmsInner"]))
-            $_GET["fMeanPedRmsInner"]=$first?"On":"";
-
-        if (empty($_GET["fArrTimeRmsInner"]))
-            $_GET["fArrTimeRmsInner"]=$first?"On":"";
-
-        if (empty($_GET["fConvFactorInner"]))
-            $_GET["fConvFactorInner"]=$first?"On":"";
-
-        if (empty($_GET["fPSF"]))
-            $_GET["fPSF"]=$first?"On":"";
-
-        if (empty($_GET["fEffOnTime"]))
-            $_GET["fEffOnTime"]=$first?"On":"";
-
-        if (empty($_GET["fEffOnTime/fRunTime"]))
-            $_GET["fEffOnTime/fRunTime"]=$first?"On":"";
-
-        if (empty($_GET["fMuonRate"]))
-            $_GET["fMuonRate"]=$first?"On":"";
-
-        if (empty($_GET["fInhomogeneity"]))
-            $_GET["fInhomogeneity"]="On";
-
-        if (empty($_GET["fDataRate"]))
-            $_GET["fDataRate"]=$first?"On":"";
-
-        InitFindOffData($_GET, $first);
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias)
-    {
-        printf("<center>\n");
-        printf("<form action=\"findoffdata.php\" METHOD=\"GET\">\n");
-
-        printf(" <table>\n");
-        printf("  <tr><td align='center' valign='top'>\n");
-
-        PrintSequInfoMenu();
-        printf(" <p>\n");
-        PrintCalMenu();
-        printf(" <p>\n");
-        PrintStarMenu();
-        printf(" <p>\n");
-
-        printf(" <table><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Source",                      "fSourceName",                      "fSourceKEY",                      "Source Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "LightConditions",             "fLightConditionsName",             "fLightConditionsKEY",             "Light Conditions");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable", "fDiscriminatorThresholdTableName", "fDiscriminatorThresholdTableKEY", "DT Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "ManuallyChanged",             "fManuallyChangedName",             "fManuallyChangedKEY",             "Manually changed");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fStar",                "Star");
-        printf("</td></tr> </table>\n");
-        printf(" <p>\n");
-
-        printf(" <table>\n");
-        printf("  <tr><td colspan='3'>\n");
-
-        if (empty($_GET["fStarStart"]))
-            $starmin = GetMin("fStar", "SequenceProcessStatus", $host, $user, $pw, $db);
-        else
-            $starmin = $_GET["fStarStart"];
-
-        if (empty($_GET["fStarStop"]))
-            $starmax = GetMax("fStar", "SequenceProcessStatus", $host, $user, $pw, $db);
-        else
-            $starmax = $_GET["fStarStop"];
-
-        printf("StarDone&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStarStart\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $starmin);
-        printf("to&nbsp;<input name=\"fStarStop\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">&nbsp;&nbsp;&nbsp;&nbsp;\n", $starmax);
-        printf("  </td></tr><tr><td><br></td></tr><tr>\n");
-
-        CheckBox("fLinks",    "Links");
-        CheckBox("fOff",      "incl. offsources");
-        CheckBox("fOnlyOff",  "only offsources");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-
-        printf(" <p>\n");
-
-        PrintZdRangeMenu($host,$user,$pw,$db);
-        printf("<p>\n");
-        PrintSequRangeMenu($host,$user,$pw,$db);
-        printf("<p>\n");
-        PrintSourceMenu($host,$user,$pw,$db);
-        printf("<p>\n");
-        PrintNightRangeMenu($host,$user,$pw,$db, "Sequences");
-        printf("<p>\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"findoffdata.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-
-        printf("  </td><td valign='top'>\n");
-
-        PrintLimitsMenu($limitsmean, $limitsmin, $limitsmax, $alias, "yes");
-
-        printf("  </td></tr>\n");
-        printf(" </table>\n");
-
-        printf("</form>\n");
-        printf("</center>\n");
-
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-
-        printf("</td>\n");
-        printf("</tr>\n");
-
-
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1" || $html=="2")
-                PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("menu.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        if (empty($_GET["fPrintTable"]))
-            PrintForm($_GET, $host, $user, $pw, $db, $limitsmean, $limitsmin, $limitsmax, $alias);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-        {
-            if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
-            else
-                PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limitsmean, $limitsmin, $limitsmax, $needs);
-        }
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/index.html
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/index.html	(revision 9501)
+++ 	(revision )
@@ -1,150 +1,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<meta name="Author" content="Thomas Bretz">
-<meta http-equiv="refresh" content="0; URL=http://www.astro.uni-wuerzburg.de/wiki/Database_Websites">
-<title>Magic Database</title>
-<link rel="stylesheet" type="text/css" href="mars.css">
-</head>
-
-<body background="background.gif" text="#000000" bgcolor="#000099" link="#1122FF" vlink="#8888FF" alink="#FF0000">
-&nbsp;
-<center>
-<table class="Main" CELLPADDING=0>
-<tr><td class="Edge">
-<img SRC="ecke.gif" ALT="">
-</td>
-<td class="Header">
-<font size=+1><B>Magic Database</B></font><BR>
-</td>
-</tr>
-
-<tr>
-<td COLSPAN=2 BGCOLOR="#FFFFFF">
-<hr SIZE=1 NOSHADE WIDTH="80%">
-<center>
-<table class="Inner" CELLPADDING=15>
-
-<tr class="Block">
-<td>
-<br>
-If you are not redirected automatically, you can find the new database websites on: 
-<a href='http://www.astro.uni-wuerzburg.de/wiki/Database_Websites'>www.astro.uni-wuerzburg.de/wiki/Database_Websites</a>
-<br>
-<br>
-<hr width="100%" size="2">
-<p>
-Some useful queries:<p>
-<ul>
-<li><A HREF="runinfo-aio.php">Run Information</A></li>
-<li><A HREF="sequinfo-aio.php">Sequence Information</A> (including find-off-data functionalities)</li>
-<li><A HREF="queryrbk.php">Runbook Database</A></li>
-<li><A HREF="datasetinfo-aio.php">Dataset Information</A> 
-(<A HREF="http://datacenter.astro.uni-wuerzburg.de/datasets/">dataset files</A>)</li>
-<li><A HREF="ganymed.php">Results of the Automatic Analysis</A> </li>
-<li><A HREF="sequence.php">Sequence(s)</A>: all information of one sequence in one table </li>
-<li><A HREF="sources.php">Sources - list of sources</A> (possibility to ex/include test- and off-sources)</li>
-<li><A HREF="statussbs.php">Sequence Build Status</A>: querying only the information from the table SequenceBuildStatus </li>
-<li><A HREF="builddatasets.php">Build Datasets</A>: webtool to build datasets for the automatic analysis
-(for more information mail to: <a href='mailto:datacenter@astro.uni-wuerzburg.de'>datacenter@a...</a>)</li>
-</li>
-<li><A HREF="resetseq.php">Reset Sequences</A>: reset sequences in the database for the automatic processing with the current Mars release</li>
-</ul>
-<p>
-Plots:<p>
-<ul>
-<li><A HREF="http://datacenter.astro.uni-wuerzburg.de/datacheck">Evolution of quality parameter</A>
-plots for quality parameter from callisto and star for all data since 21.8.2004</li>
-<li><A HREF="plotdb.php">Plots</A>: plot values from the database yourself online</li>
-<li><A HREF="showplots.php">All plots of one sequence</A>: click through all calib, signal and star plot of one sequence</li>
-<li><A HREF="showplots-ds.php">All plots of one dataset</A>: click through all sequences of one dataset (all plots of calib, signal and star can be viewed)</li>
-<li><A HREF="showplots-seq.php">All plots of one source / sequence range</A>: similar to the previous one, but the sequences are not given by a dataset, but by choosing a source and/or a sequence range. </li>
-</ul>
-<p>
-Documentation: <p>
-<ul>
-<li><a href="http://datacenter.astro.uni-wuerzburg.de/instructions/intern/errorcoding.txt">error coding</a></li>
-<li><A HREF="http://datacenter.astro.uni-wuerzburg.de/index.html#db">old documentation</A></li>
-</ul>
-<p>
-<br>
-<p>
-<u>Old websites:</u> <br>
-(remark: these websites are not supported anymore)<p>
-Some useful queries:<p>
-<ul>
-<li><A HREF="runinfo.php">Run Information</A></li>
-<li><A HREF="sequinfo.php">Sequence Information</A></li>
-<li><A HREF="queryrbk.php">Runbook Database</A></li>
-<li><A HREF="datasetinfo.php">Dataset Information</A> 
-(<A HREF="http://datacenter.astro.uni-wuerzburg.de/datasets/">dataset files</A>)</li>
-<li><A HREF="ganymed.php">Results of the Automatic Analysis</A> 
-</ul>
-Other queries:<p>
-<ul>
-<li><A HREF="culminating.php">Sequences with Culmination</A> 
-(<A HREF="http://www.astro.uni-wuerzburg.de/results/culmination.html">information about 'culmination problem'</A>)</li>
-<li><A HREF="sequence.php">Sequence(s)</A>: all information of one sequence in one table </li>
-<li><A HREF="sources.php">Sources - list of sources</A> (possibility to ex/include test- and off-sources)</li>
-<li><A HREF="datacheck.php">DataCheck</A>: datacheck values from sinope </li>
-<li><A HREF="findoffdata.php">Find Offdata</A>: find appropriate (off)data </li>
-</ul>
-Query Status:<p>
-<ul>
-<li><A HREF="statussbs.php">Sequence Build Status</A>: querying only the information from the table SequenceBuildStatus </li>
-<li><A HREF="statusrps.php">Run Process Status</A>: querying only the information from the table RunProcessStatus </li>
-<li><A HREF="statussps.php">Sequence Process Status</A>: querying only the information from the table SequenceProcessStatus </li>
-<li><A HREF="printtable.php?fTable=MarsVersion">Mars Versions in the DC</A>: querying all information from the table MarsVersions </li>
-<li><A HREF="dbstatus.php?fAllFilesAvailStatus=0&fCallisto=On&fCallistoStatus=7&fStar=On&fStarStatus=7&fFillCallistoStatus=0&fFillStarStatus=0&fSourceName=On&fSourceKEY=0">Processing status</A> (a simplified version of sequinfo.php)</li>
-</ul>
-Some very simple queries:<p>
-<ul>
-<li><A HREF="index.php">Run Database</A>: querying only the information from the table RunData </li>
-<li><A HREF="queryseq.php">Sequence Database</A>: querying only the information from the table Sequences </li>
-<li><A HREF="querycal.php">Calibration Database</A>: querying only the information from the table Calibration </li>
-<li><A HREF="querystar.php">Star Database</A>: querying only the information from the table Star </li>
-</ul>
-<P>
-</td>
-</tr>
-
-</table>
-</center>
-
-<center>
-<hr NOSHADE WIDTH="80%"><i><font color="#000099"><font size=-1>This Web Site is 
-hosted by Apache for OS/2 and done by <a href="mailto:tbretz@astro.uni-wuerzburg.de">Thomas&nbsp;Bretz</a> and <a href="mailto:dorner@astro.uni-wuerzburg.de">Daniela&nbsp;Dorner</a> .</font></font></i><BR>
-&nbsp;<BR>
-<a href="http://validator.w3.org/check/referer"><img border="0"
-   src="../../valid-html40.png" alt="Valid HTML 4.0!" height="20" width="66"></a>
-</center>&nbsp;
-</tr>
-</table>
-
-<BR>
-
-<table class="Main">
-<tr>
-<!-- This is the old stylish counter....
-  <td ALIGN=RIGHT VALIGN=TOP>NedStat - website access statistics:&nbsp;<a href="http://de.nedstat.net/viewstat.asp?name=magicmars" onMouseover="status='Statistics on Web Access by NedStat.de';return true;" onMouseout="status='';return true;"><img SRC="http://de.nedstat.net/scripts/nedstat.dll?name=magicmars" ALT="STAT" BORDER=0 height=18 width=18 align=TEXTTOP></a></td>
--->
-<td ALIGN=RIGHT VALIGN=MIDDLE><FONT COLOR="#FFFFFF">NedStat - website access statistics:&nbsp;</FONT>
-<!--<script language='JavaScript' src="http://m1.nedstatbasic.net/basic.js" type="text/javascript"></script>-->
-<script language="JavaScript" type="text/javascript">          
-<!--
-  nedstatbasic("AAGh1A6qQKZFLpl2rXaOC3LPo1OA", 0);
-// -->
-</script>
-<!--<noscript>-->
-<a target="_self" href="http://v1.nedstatbasic.net/stats?AAGh1A6qQKZFLpl2rXaOC3LPo1OA" onMouseover="status='Statistics on Web Access by NedStat.de';return true;" onMouseout="status='';return true;"></a>
-<!--</noscript>-->
-</td>
-
-</tr>
-</table>
-</center>
-
-</body>
-</html>
-
Index: trunk/MagicSoft/Mars/datacenter/db/index.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/index.php	(revision 9501)
+++ 	(revision )
@@ -1,425 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup)
-    {
-        $fromtable="RunData";
-
-        $groups = 0;
-        foreach ($checkgroup as $element)
-            if ($element==-1)
-                $groups++;
-
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        if ($groups>0)
-        {
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
-            //--------------------------------------------------
-            //$query0 .= " TIMEDIFF(fRunStop, fRunStart), ";
-            // Only available in MySQL>4.1.1
-            $query0 .= "SUM(if(TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)<0, " .
-                "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)+24*60*60, " .
-                "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)))/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
-            //--------------------------------------------------
-            $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
-            $query0 .= " Min(fZenithDistance) as '" . $alias["Min(fZenithDistance)"] . "', ";
-            $query0 .= " Max(fZenithDistance) as '" . $alias["Max(fZenithDistance)"] . "', ";
-            $query0 .= " COUNT(*) as '# Runs' ";
-        }
-        else
-        {
-            $query0 .= " fRunNumber as 'Run#' ";
-
-            foreach ($_GET as $key => $element)
-                if ($_GET[$key]=="On")
-                    if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                        $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-        }
-
-        $query0 .= " FROM RunData ";
-
-        foreach ($_GET as $key => $element)
-            if (($_GET[$key]=="On" || $groups>0))// && !empty($joins[$key]))
-                $query0 .= GetJoin($fromtable, $key);
-
-        foreach ($checkwhere as $key => $element)
-        {
-            if (empty($element) || $element<=0)
-                continue;
-
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                if ($element!=-1)
-                    if (strrpos($query0, " AND ")!=strlen($query0)-5)// this if clause doesn't work
-                        $query0 .= " AND ";
-
-            if ($element!=-1)
-                $query0 .= GetCheck($fromtable, $key) . "=" . $element;
-        }
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
-            $query0 .= "fRunNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-/*
-        if (!empty($_GET["fDate"]))
-            $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
-*/
-
-
-        if (!empty($_GET["fStartDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $startdate=substr($_GET["fStartDate"], 0, 10);
-            if ($startdate=="0000-00-00")
-                $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
-            else
-                $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
-        }
-
-        if (!empty($_GET["fStopDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $stopdate=substr($_GET["fStopDate"], 0, 10);
-            $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
-        }
-
-        if (!empty($_GET["fSequenceNo"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $query0 .= " fSequenceFirst = '" . $_GET["fSequenceNo"] . "' ";
-        }
-
-
-        if ($groups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $groups;
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= GetCheck($fromtable, $key);
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        /*
-         if (empty($_GET["fRawFileKEY"]))
-         $_GET["fRawFileKEY"]="Off";
-         */
-
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="20";
-            
-        if (empty($_GET["fLastUpdate"]))
-            $_GET["fLastUpdate"]="Off";
-
-        if (empty($_GET["fFormatVersion"]))
-            $_GET["fFormatVersion"]="Off";
-
-        if (empty($_GET["fNumEvents"]))
-            $_GET["fNumEvents"]=$first?"On":"";
-
-        if (empty($_GET["fRunStart"]))
-            $_GET["fRunStart"]=$first?"On":"";
-
-        if (empty($_GET["fRunStop"]))
-            $_GET["fRunStop"]="Off";
-
-        if (empty($_GET["fAzimuth"]))
-            $_GET["fAzimuth"]="Off";
-
-        if (empty($_GET["fZenithDistance"]))
-            $_GET["fZenithDistance"]=$first?"On":"";
-
-        if (empty($_GET["fRunTypeName"]))
-            $_GET["fRunTypeName"]=$first?"On":"";
-
-        if (empty($_GET["fMagicNumberName"]))
-            $_GET["fMagicNumberName"]="Off";
-
-        if (empty($_GET["fSourceName"]))
-            $_GET["fSourceName"]=$first?"On":"";
-
-        if (empty($_GET["fProjectName"]))
-            $_GET["fProjectName"]="Off";
-
-        if (empty($_GET["fL1TriggerTableName"]))
-            $_GET["fL1TriggerTableName"]="Off";
-
-        if (empty($_GET["fL2TriggerTableName"]))
-            $_GET["fL2TriggerTableName"]="Off";
-
-        if (empty($_GET["fMeanTriggerRate"]))
-            $_GET["fMeanTriggerRate"]=$first?"On":"";
-
-        if (empty($_GET["fHvSettingsName"]))
-            $_GET["fHvSettingsName"]="Off";
-
-        if (empty($_GET["fCalibrationScriptName"]))
-            $_GET["fCalibrationScriptName"]="Off";
-
-        if (empty($_GET["fDiscriminatorThresholdTableName"]))
-            $_GET["fDiscriminatorThresholdTableName"]="Off";
-
-        if (empty($_GET["fTriggerDelayTableName"]))
-            $_GET["fTriggerDelayTableName"]="Off";
-
-        if (empty($_GET["fLightConditionsName"]))
-            $_GET["fLightConditionsName"]="Off";
-
-        if (empty($_GET["fTestFlagName"]))
-            $_GET["fTestFlagName"]="Off";
-
-        if (empty($_GET["fDaqStoreRate"]))
-            $_GET["fDaqStoreRate"]="Off";
-
-        if (empty($_GET["fDaqTriggerRate"]))
-            $_GET["fDaqTriggerRate"]="Off";
-
-        if (empty($_GET["fL2RatePresc"]))
-            $_GET["fL2RatePresc"]="Off";
-
-        if (empty($_GET["fL2RateUnpresc"]))
-            $_GET["fL2RateUnpresc"]="Off";
-
-        if (empty($_GET["fExcludedFDAName"]))
-            $_GET["fExcludedFDAName"]=$first?"On":"";
-
-        if (empty($_GET["fSequenceFirst"]))
-            $_GET["fSequenceFirst"]="Off";
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"index.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fRunStart",         "Run start time");
-        CheckBox("fL2RatePresc",      "L2 presc Rate");
-        CheckBox("fDaqStoreRate",     "DAQ Storage Rate");
-        CheckBox("fAzimuth",          "Azimuth");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fRunStop",          "Run stop time");
-        CheckBox("fL2RateUnpresc",    "L2 unpresc Rate");
-        CheckBox("fDaqTriggerRate",   "DAQ Trigger Rate");
-        CheckBox("fZenithDistance",   "Zenith distance");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fFormatVersion",    "File format");
-        CheckBox("fNumEvents",        "Num of events");
-        CheckBox("fMeanTriggerRate",  "Mean Trigger rate");
-        CheckBox("fSequenceFirst",    "Sequence Number");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-         printf(" <p>\n");
-
-        // pull down boxes
-
-        printf(" <table>\n");
-        printf("  <tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "RunType",     "fRunTypeName",     "fRunTypeKEY", "Run type");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Source",      "fSourceName",      "fSourceKEY", "Source Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "HvSettings",  "fHvSettingsName",  "fHvSettingsKEY", "HV Settings");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "L1TriggerTable", "fL1TriggerTableName", "fL1TriggerTableKEY", "L1 Trigger Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TestFlag",  "fTestFlagName",  "fTestFlagKEY", "Test Flag");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Project",     "fProjectName",     "fProjectKEY", "Project Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable",  "fDiscriminatorThresholdTableName",  "fDiscriminatorThresholdTableKEY", "DT Table");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "L2TriggerTable", "fL2TriggerTableName", "fL2TriggerTableKEY", "L2 Trigger Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "ExcludedFDA", "fExcludedFDAName", "fExcludedFDAKEY", "Exclusions");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "LightConditions",  "fLightConditionsName",  "fLightConditionsKEY", "Light Conditions");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "CalibrationScript",  "fCalibrationScriptName",  "fCalibrationScriptKEY", "Cal Script");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TriggerDelayTable",  "fTriggerDelayTableName",  "fTriggerDelayTableKEY", "Trigger Delay Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "MagicNumber", "fMagicNumberName", "fMagicNumberKEY", "Magic Number");
-        printf(" </td></tr></table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fStartDate"]))
-            $timemin = GetMin("fRunStart", "RunData", $host, $user, $pw, $db);
-        else
-            $timemin = $_GET["fStartDate"];
-
-        if (empty($_GET["fStopDate"]))
-            $timemax = GetMax("fRunStart", "RunData", $host, $user, $pw, $db);
-        else
-            $timemax = $_GET["fStopDate"];
-
-        printf("Night&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
-        printf("to&nbsp;<input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">&nbsp;&nbsp;&nbsp;&nbsp;\n", $timemax);
-
-/*
-        printf("Date&nbsp;(yyyy-mm-dd)&nbsp;<input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
-        if (!empty($_GET["fDate"]))
-            printf("%s", $_GET["fDate"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-*/
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fRunNumber", "RunData", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fRunNumber", "RunData", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-        printf("Runs&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf("Sequ#&nbsp;<input name=\"fSequenceNo\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"");
-        if (!empty($_GET["fSequenceNo"]))
-            printf("%s", $_GET["fSequenceNo"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500", "1000", "2000");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"index.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-        mysql_query("SET BIG_TABLES=1"); // necessary for mySQL <= 4
-
-
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors",   "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-            PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup);
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors",   "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/querycal.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/querycal.php	(revision 9501)
+++ 	(revision )
@@ -1,270 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkwhere)
-    {
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS fSequenceFirst as 'Sequence#' ";
-
-        foreach ($_GET as $key => $element)
-            if ($_GET[$key]=="On")
-                if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                    $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-
-        $query0 .= " FROM Calibration ";
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= "fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="20";
-
-        if (empty($_GET["fLastUpdate"]))
-            $_GET["fLastUpdate"]="Off";
-
-        if (empty($_GET["fUnreliableInner"]))
-            $_GET["fUnreliableInner"]=$first?"On":"";
-
-        if (empty($_GET["fUnsuitableOuter"]))
-            $_GET["fUnsuitableOuter"]=$first?"On":"";
-
-        if (empty($_GET["fUnsuitable50"]))
-            $_GET["fUnsuitable50"]=$first?"On":"";
-
-        if (empty($_GET["fUnsuitable01"]))
-            $_GET["fUnsuitable01"]=$first?"On":"";
-
-        if (empty($_GET["fUnsuitableMax"]))
-            $_GET["fUnsuitableMax"]=$first?"On":"";
-
-        if (empty($_GET["fDeadMax"]))
-            $_GET["fDeadMax"]=$first?"On":"";
-
-        if (empty($_GET["fUnreliableOuter"]))
-            $_GET["fUnreliableOuter"]=$first?"On":"";
-
-        if (empty($_GET["fUnsuitableInner"]))
-            $_GET["fUnsuitableInner"]=$first?"On":"";
-
-        if (empty($_GET["fIsolatedInner"]))
-            $_GET["fIsolatedInner"]=$first?"On":"";
-
-        if (empty($_GET["fIsolatedOuter"]))
-            $_GET["fIsolatedOuter"]=$first?"On":"";
-
-        if (empty($_GET["fMeanPedRmsInner"]))
-            $_GET["fMeanPedRmsInner"]=$first?"On":"";
-
-        if (empty($_GET["fMeanPedRmsOuter"]))
-            $_GET["fMeanPedRmsOuter"]=$first?"On":"";
-
-        if (empty($_GET["fIsolatedMaxCluster"]))
-            $_GET["fIsolatedMaxCluster"]=$first?"On":"";
-
-        if (empty($_GET["fArrTimeMeanInner"]))
-            $_GET["fArrTimeMeanInner"]=$first?"On":"";
-
-        if (empty($_GET["fArrTimeMeanOuter"]))
-            $_GET["fArrTimeMeanOuter"]=$first?"On":"";
-
-        if (empty($_GET["fArrTimeRmsInner"]))
-            $_GET["fArrTimeRmsInner"]=$first?"On":"";
-
-        if (empty($_GET["fArrTimeRmsOuter"]))
-            $_GET["fArrTimeRmsOuter"]=$first?"On":"";
-
-        if (empty($_GET["fMeanSignalInner"]))
-            $_GET["fMeanSignalInner"]=$first?"Off":"";
-
-        if (empty($_GET["fMeanSignalOuter"]))
-            $_GET["fMeanSignalOuter"]=$first?"Off":"";
-
-        if (empty($_GET["fPulsePosMean"]))
-            $_GET["fPulsePosMean"]=$first?"Off":"";
-
-        if (empty($_GET["fConvFactorInner"]))
-            $_GET["fConvFactorInner"]=$first?"On":"";
-
-        if (empty($_GET["fConvFactorOuter"]))
-            $_GET["fConvFactorOuter"]=$first?"On":"";
-
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"querycal.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fUnsuitableInner",     "Unsuitable inner");
-        CheckBox("fUnsuitableOuter",     "Unsuitable outer");
-        CheckBox("fUnreliableInner",     "Unreliable inner");
-        CheckBox("fUnreliableOuter",     "Unreliable outer");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fUnsuitable50",        "Unsuitable (50%)");
-        CheckBox("fUnsuitable01",        "Unsuitable (1%)");
-        CheckBox("fUnsuitableMax",       "Unsuitable (99.9%)");
-        CheckBox("fDeadMax",             "DeadMax");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fIsolatedInner",       "Isolated inner");
-        CheckBox("fIsolatedOuter",       "Isolated outer");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fIsolatedMaxCluster",  "IsolatedMaxCluster");
-        CheckBox("fArrTimeMeanInner",    "ArrTimeMean inner ");
-        CheckBox("fArrTimeMeanOuter",    "ArrTimeMean outer ");
-        CheckBox("fArrTimeRmsInner",     "ArrTimeRms inner ");
-        CheckBox("fArrTimeRmsOuter",     "ArrTimeRms outer ");
-        CheckBox("fPulsePosMean",        "Mean PulsePos");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fConvFactorInner",     "Conv inner ");
-        CheckBox("fConvFactorOuter",     "Conv outer ");
-        CheckBox("fMeanPedRmsInner",     "MeanPedRms inner");
-        CheckBox("fMeanPedRmsOuter",     "MeanPedRms outer");
-        CheckBox("fMeanSignalInner",     "MeanSignal inner");
-        CheckBox("fMeanSignalOuter",     "MeanSignal outer");
-
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-
-        printf("Sequences&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"querycal.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $query0 = CreateQuery($_GET, $alias, $checkwhere);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-            PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere);
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/queryseq.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/queryseq.php	(revision 9501)
+++ 	(revision )
@@ -1,367 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup)
-    {
-        $fromtable="Sequences";
-
-        $groups = 0;
-        foreach ($checkgroup as $element)
-            if ($element==-1)
-                $groups++;
-
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        if ($groups>0)
-        {
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
-            //--------------------------------------------------
-            $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
-            //--------------------------------------------------
-            $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
-            $query0 .= " Min(fZenithDistanceMin) as '" . $alias["Min(fZenithDistanceMin)"] . "', ";
-            $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', ";
-            $query0 .= " COUNT(*) as '# Sequ' ";
-        }
-        else
-        {
-            if (!empty($_GET["fSendTxt"]))
-                $query0 .= " SELECT fSequenceFirst ";
-            else
-                $query0 .= " CONCAT('<A&ws;HREF=\"index.php?',  'fRunStart=On', '&fZenithDistance=On', '&fRunMin=', fSequenceFirst, '&fMeanTriggerRate=On', '&fRunTypeName=On', '&fRunMax=', fSequenceLast, '&fNumEvents=On', '&fSourceName=On&', 'fExcludedFDAKEY=1', '&fSequenceFirst=On', '&fNumResults=500\">', fSequenceFirst, '</A>') ";
-            $query0 .= " as 'Sequence#' ";
-
-            foreach ($_GET as $key => $element)
-                if ($_GET[$key]=="On")
-                    if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                        $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-        }
-
-        $query0 .= " FROM Sequences ";
-
-        foreach ($_GET as $key => $element)
-            if (($_GET[$key]=="On" || $groups>0))// && !empty($joins[$key]))
-                $query0 .= GetJoin($fromtable, $key);
-
-        foreach ($checkwhere as $key => $element)
-        {
-            if (empty($element) || $element<=0)
-                continue;
-
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                if ($element!=-1)
-                    if (strrpos($query0, " AND ")!=strlen($query0)-5)
-                        $query0 .= " AND ";
-
-            if ($element!=-1)
-                $query0 .= GetCheck($fromtable, $key) . "=" . $element;
-        }
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
-            $query0 .= "fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-/*
-        if (!empty($_GET["fDate"]))
-            $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
-*/
-
-        if (!empty($_GET["fStartDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $startdate=substr($_GET["fStartDate"], 0, 10);
-            if ($startdate=="0000-00-00")
-                $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
-            else
-                $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
-        }
-
-        if (!empty($_GET["fStopDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $stopdate=substr($_GET["fStopDate"], 0, 10);
-            $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
-        }
-
-        if ($groups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $groups;
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= GetCheck($fromtable,$key);
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fSortBy"]) && $groups==0)
-            $query0 .= "ORDER BY fSequenceFirst ASC ";
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="20";
-
-        if (empty($_GET["fLastUpdate"]))
-            $_GET["fLastUpdate"]="Off";
-
-        if (empty($_GET["fNumEvents"]))
-            $_GET["fNumEvents"]=$first?"On":"";
-
-        if (empty($_GET["fRunStart"]))
-            $_GET["fRunStart"]=$first?"On":"";
-
-        if (empty($_GET["fRunTime/60"]))
-            $_GET["fRunTime/60"]=$first?"On":"";
-
-        if (empty($_GET["fSequenceLast"]))
-            $_GET["fSequenceLast"]=$first?"On":"";
-
-        if (empty($_GET["fAzimuthMin"]))
-            $_GET["fAzimuthMin"]="Off";
-
-        if (empty($_GET["fAzimuthMax"]))
-            $_GET["fAzimuthMax"]="Off";
-
-        if (empty($_GET["fZenithDistanceMin"]))
-            $_GET["fZenithDistanceMin"]=$first?"On":"";
-
-        if (empty($_GET["fZenithDistanceMax"]))
-            $_GET["fZenithDistanceMax"]="Off";
-
-        if (empty($_GET["fManuallyChangedName"]))
-            $_GET["fManuallyChangedName"]="Off";
-
-        if (empty($_GET["fSourceName"]))
-            $_GET["fSourceName"]=$first?"On":"";
-
-        if (empty($_GET["fProjectName"]))
-            $_GET["fProjectName"]="Off";
-
-        if (empty($_GET["fTriggerTableName"]))
-            $_GET["fTriggerTableName"]="Off";
-
-        if (empty($_GET["fHvSettingsName"]))
-            $_GET["fHvSettingsName"]="Off";
-
-        if (empty($_GET["fDiscriminatorThresholdTableName"]))
-            $_GET["fDiscriminatorThresholdTableName"]="Off";
-
-        if (empty($_GET["fTriggerDelayTableName"]))
-            $_GET["fTriggerDelayTableName"]="Off";
-
-        if (empty($_GET["fLightConditionsName"]))
-            $_GET["fLightConditionsName"]="Off";
-
-        if (empty($_GET["fTestFlagName"]))
-            $_GET["fTestFlagName"]="Off";
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"queryseq.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fSequenceLast",      "Last run");
-        CheckBox("fRunStart",          "Start time");
-        CheckBox("fAzimuthMin",        "Azimuth min");
-        CheckBox("fAzimuthMax",        "Azimuth max");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fNumEvents",         "Num of events");
-        CheckBox("fRunTime/60",        "Duration");
-        CheckBox("fZenithDistanceMin", "Zenith distance min");
-        CheckBox("fZenithDistanceMax", "Zenith distance max");
-
-        printf(" </table>\n");
-         printf(" <p>\n");
-
-        // pull down boxes
-
-        printf(" <table>\n");
-        printf("  <tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Source",      "fSourceName",      "fSourceKEY", "Source Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TriggerTable", "fTriggerTableName", "fTriggerTableKEY", "Trigger Table");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TriggerDelayTable",  "fTriggerDelayTableName",  "fTriggerDelayTableKEY", "Trigger Delay Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Project",     "fProjectName",     "fProjectKEY", "Project Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "HvSettings",  "fHvSettingsName",  "fHvSettingsKEY", "HV Settings");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable",  "fDiscriminatorThresholdTableName",  "fDiscriminatorThresholdTableKEY", "DT Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TestFlag",  "fTestFlagName",  "fTestFlagKEY", "Test Flag");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "LightConditions",  "fLightConditionsName",  "fLightConditionsKEY", "Light Conditions");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "ManuallyChanged", "fManuallyChangedName", "fManuallyChangedKEY", "Manually changed");
-        printf("  </td></tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fStartDate"]))
-            $timemin = GetMin("fRunStart", "RunData", $host, $user, $pw, $db);
-        else
-            $timemin = $_GET["fStartDate"];
-
-        if (empty($_GET["fStopDate"]))
-            $timemax = GetMax("fRunStart", "RunData", $host, $user, $pw, $db);
-        else
-            $timemax = $_GET["fStopDate"];
-
-        printf("Night&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
-        printf("to&nbsp;<input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">&nbsp;&nbsp;&nbsp;&nbsp;\n", $timemax);
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-/*
-        printf("Date&nbsp;(yyyy-mm-dd)&nbsp;<input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
-        if (!empty($_GET["fDate"]))
-            printf("%s", $_GET["fDate"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-*/
-
-        printf("Sequences&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"queryseq.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-            PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup);
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/querystar.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/querystar.php	(revision 9501)
+++ 	(revision )
@@ -1,213 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkwhere)
-    {
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS fSequenceFirst as 'Sequence#' ";
-
-        foreach ($_GET as $key => $element)
-            if ($_GET[$key]=="On")
-                if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                    $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-
-        $query0 .= " FROM Star ";
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= "fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="20";
-
-        if (empty($_GET["fLastUpdate"]))
-            $_GET["fLastUpdate"]="Off";
-
-        if (empty($_GET["fMeanNumberIslands"]))
-            $_GET["fMeanNumberIslands"]=$first?"On":"";
-
-        if (empty($_GET["fPSF"]))
-            $_GET["fPSF"]=$first?"On":"";
-
-        if (empty($_GET["fRatio"]))
-            $_GET["fRatio"]=$first?"On":"";
-
-        if (empty($_GET["fMuonNumber"]))
-            $_GET["fMuonNumber"]=$first?"On":"";
-
-        if (empty($_GET["fEffOnTime"]))
-            $_GET["fEffOnTime"]=$first?"On":"";
-
-        if (empty($_GET["fMuonRate"]))
-            $_GET["fMuonRate"]=$first?"On":"";
-
-        if (empty($_GET["fInhomogeneity"]))
-            $_GET["fInhomogeneity"]=$first?"On":"";
-
-        if (empty($_GET["fDataRate"]))
-            $_GET["fDataRate"]=$first?"On":"";
-
-        if (empty($_GET["fMaxHumidity"]))
-            $_GET["fMaxHumidity"]=$first?"On":"";
-
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"querystar.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fMeanNumberIslands",  "MeanNumIslands");
-        CheckBox("fPSF",                "PSF");
-        CheckBox("fRatio",              "Ratio");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fMuonRate",           "MuonRate");
-        CheckBox("fMuonNumber",         "MuonNumber");
-        CheckBox("fEffOnTime",          "EffOnTime");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fMaxHumidity",        "MaxHumidity");
-        CheckBox("fDataRate",           "CleanedEvtRate");
-        CheckBox("fInhomogeneity",      "Inhomogeneity");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-
-        printf("Sequences&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"querystar.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $query0 = CreateQuery($_GET, $alias, $checkwhere);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-            PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere);
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/runinfo.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/runinfo.php	(revision 9501)
+++ 	(revision )
@@ -1,574 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
-    {
-        $fromtable="RunData";
-
-        $groups = 0;
-        foreach ($checkgroup as $element)
-            if ($element==-1)
-                $groups++;
-
-        $statusgroups = 0;
-        foreach ($checkstatusgroup as $element)
-            if ($element==-1)
-                $statusgroups++;
-
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        if ($groups>0)
-        {
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
-            //--------------------------------------------------
-            //$query0 .= " TIMEDIFF(fRunStop, fRunStart), ";
-            // Only available in MySQL>4.1.1
-            $query0 .= "SUM(if(TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)<0, " .
-                "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)+24*60*60, " .
-                "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)))/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
-            //--------------------------------------------------
-            $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
-            $query0 .= " Min(fZenithDistance) as '" . $alias["Min(fZenithDistance)"] . "', ";
-            $query0 .= " Max(fZenithDistance) as '" . $alias["Max(fZenithDistance)"] . "', ";
-            $query0 .= " COUNT(*) as '# Runs' ";
-        }
-        else
-        {
-            if ($statusgroups>0)
-            {
-                foreach ($checkstatusgroup as $key => $element)
-                    if ($element==-1)
-                        $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-//                        $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-
-                $query0 .= " count(*) as '# Runs'";
-
-            }
-            else
-            {
-                $query0 .= " RunData.fRunNumber as 'Run#' ";
-
-                foreach ($_GET as $key => $element)
-                    if ($_GET[$key]=="On" && $key!="fTest")
-                        if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                            $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-            }
-        }
-
-        $query0 .= " FROM RunData ";
-
-        $query0 .= " LEFT JOIN RunProcessStatus USING(fRunNumber,fTelescopeNumber,fFileNumber) ";
-
-        foreach ($_GET as $key => $element)
-            if (($_GET[$key]=="On" || $groups>0))// && !empty($joins[$key]))
-                $query0 .= GetJoin($fromtable,$key);
-
-        if ($_GET["fTest"]!="On")
-        {
-            if ($_GET["fSourceName"]!="On")
-                $query0 .= " LEFT JOIN Source USING(fSourceKEY) ";
-            $query0 .= " WHERE fTest='no'";
-        }
-
-        foreach ($checkwhere as $key => $element)
-        {
-            if (empty($element) || $element<=0)
-                continue;
-
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                if ($element!=-1)
-                    if (strrpos($query0, " AND ")!=strlen($query0)-5)// this if clause doesn't work
-                        $query0 .= " AND ";
-
-            if ($element!=-1)
-                $query0 .= GetCheck($fromtable, $key) . "=" . $element;
-        }
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= StatusQuery("fCCFileAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fCaCoFileAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fCaCoFileFound", $needs, $timelimits);
-        $query0 .= StatusQuery("fRawFileAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fDataCheckDone", $needs, $timelimits);
-        $query0 .= StatusQuery("fTimingCorrection", $needs, $timelimits);
-
-        if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
-            $query0 .= "RunData.fRunNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-/*
-        if (!empty($_GET["fDate"]))
-            $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
-*/
-
-        if (!empty($_GET["fSourceN"]))
-            $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
-
-        if (!empty($_GET["fStartDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $startdate=substr($_GET["fStartDate"], 0, 10);
-            if ($startdate=="0000-00-00")
-                $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
-            else
-                $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
-        }
-
-        if (!empty($_GET["fStopDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $stopdate=substr($_GET["fStopDate"], 0, 10);
-            $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
-        }
-
-        if (!empty($_GET["fSequenceNo"]) || $_GET["fSequenceNo"]=="0")
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $query0 .= " fSequenceFirst = '" . $_GET["fSequenceNo"] . "' ";
-        }
-
-
-        if ($groups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $groups;
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= GetCheck($fromtable,$key);
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if ($statusgroups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $statusgroups;
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= $alias[$key];
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $val=substr($_GET["fSortBy"], 0, -1);
-            $query0 .= " ORDER BY " . GetTable($fromtable, $val) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        /*
-         if (empty($_GET["fRawFileKEY"]))
-         $_GET["fRawFileKEY"]="Off";
-         */
-
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="20";
-
-        if (empty($_GET["fLastUpdate"]))
-            $_GET["fLastUpdate"]="Off";
-
-        if (empty($_GET["fTest"]))
-            $_GET["fTest"]=$first?"On":"";
-
-        if (empty($_GET["fFormatVersion"]))
-            $_GET["fFormatVersion"]="Off";
-
-        if (empty($_GET["fNumEvents"]))
-            $_GET["fNumEvents"]=$first?"On":"";
-
-        if (empty($_GET["fRunStart"]))
-            $_GET["fRunStart"]=$first?"On":"";
-
-        if (empty($_GET["fRunStop"]))
-            $_GET["fRunStop"]="Off";
-
-        if (empty($_GET["fAzimuth"]))
-            $_GET["fAzimuth"]="Off";
-
-        if (empty($_GET["fZenithDistance"]))
-            $_GET["fZenithDistance"]=$first?"On":"";
-
-        if (empty($_GET["fRunTypeName"]))
-            $_GET["fRunTypeName"]=$first?"On":"";
-
-        if (empty($_GET["fMagicNumberName"]))
-            $_GET["fMagicNumberName"]="Off";
-
-        if (empty($_GET["fSourceName"]))
-            $_GET["fSourceName"]=$first?"On":"";
-
-        if (empty($_GET["fProjectName"]))
-            $_GET["fProjectName"]="Off";
-
-        if (empty($_GET["fL1TriggerTableName"]))
-            $_GET["fL1TriggerTableName"]="Off";
-
-        if (empty($_GET["fL2TriggerTableName"]))
-            $_GET["fL2TriggerTableName"]="Off";
-
-        if (empty($_GET["fMeanTriggerRate"]))
-            $_GET["fMeanTriggerRate"]=$first?"On":"";
-
-        if (empty($_GET["fHvSettingsName"]))
-            $_GET["fHvSettingsName"]="Off";
-
-        if (empty($_GET["fCalibrationScriptName"]))
-            $_GET["fCalibrationScriptName"]="Off";
-
-        if (empty($_GET["fDiscriminatorThresholdTableName"]))
-            $_GET["fDiscriminatorThresholdTableName"]="Off";
-
-        if (empty($_GET["fTriggerDelayTableName"]))
-            $_GET["fTriggerDelayTableName"]="Off";
-
-        if (empty($_GET["fLightConditionsName"]))
-            $_GET["fLightConditionsName"]="Off";
-
-        if (empty($_GET["fTestFlagName"]))
-            $_GET["fTestFlagName"]="Off";
-
-        if (empty($_GET["fDaqStoreRate"]))
-            $_GET["fDaqStoreRate"]="Off";
-
-        if (empty($_GET["fDaqTriggerRate"]))
-            $_GET["fDaqTriggerRate"]="Off";
-
-        if (empty($_GET["fL2RatePresc"]))
-            $_GET["fL2RatePresc"]="Off";
-
-        if (empty($_GET["fL2RateUnpresc"]))
-            $_GET["fL2RateUnpresc"]="Off";
-
-        if (empty($_GET["fExcludedFDAName"]))
-            $_GET["fExcludedFDAName"]=$first?"On":"";
-
-        if (empty($_GET["fSequenceFirst"]))
-            $_GET["fSequenceFirst"]="Off";
-
-        if (empty($_GET["fSequenceNo"]))
-            $_GET["fSequenceNo"]="";
-
-        if (empty($_GET["fDataCheckDone"]))
-            $_GET["fDataCheckDone"]="Off";
-
-        if (empty($_GET["fDataCheckDoneStatus"]))
-            $_GET["fDataCheckDoneStatus"]="0";
-
-        if (empty($_GET["fCCFileAvail"]))
-            $_GET["fCCFileAvail"]=$first?"On":"";
-
-        if (empty($_GET["fCCFileAvailStatus"]))
-            $_GET["fCCFileAvailStatus"]="0";
-
-        if (empty($_GET["fCaCoFileAvail"]))
-            $_GET["fCaCoFileAvail"]=$first?"On":"";
-
-        if (empty($_GET["fCaCoFileAvailStatus"]))
-            $_GET["fCaCoFileAvailStatus"]="0";
-
-        if (empty($_GET["fCaCoFileFound"]))
-            $_GET["fCaCoFileFound"]="Off";
-
-        if (empty($_GET["fCaCoFileFoundStatus"]))
-            $_GET["fCaCoFileFoundStatus"]="0";
-
-        if (empty($_GET["fRawFileAvail"]))
-            $_GET["fRawFileAvail"]=$first?"On":"";
-
-        if (empty($_GET["fRawFileAvailStatus"]))
-            $_GET["fRawFileAvailStatus"]="0";
-
-        if (empty($_GET["fTimingCorrection"]))
-            $_GET["fTimingCorrection"]=$first?"On":"";
-
-        if (empty($_GET["fTimingCorrectionStatus"]))
-            $_GET["fTimingCorrectionStatus"]="0";
-
-        if (empty($_GET["fStartTime"]))
-            $_GET["fStartTime"]="Off";
-
-        if (empty($_GET["fFailedTime"]))
-            $_GET["fFailedTime"]="Off";
-
-        if (empty($_GET["fReturnCode"]))
-            $_GET["fReturnCode"]="Off";
-
-        if (empty($_GET["fProgramId"]))
-            $_GET["fProgramId"]="Off";
-
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"runinfo.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fRunStart",         "Run start time");
-        CheckBox("fL2RatePresc",      "L2 presc Rate");
-        CheckBox("fDaqStoreRate",     "DAQ Storage Rate");
-        CheckBox("fAzimuth",          "Azimuth");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fRunStop",          "Run stop time");
-        CheckBox("fL2RateUnpresc",    "L2 unpresc Rate");
-        CheckBox("fDaqTriggerRate",   "DAQ Trigger Rate");
-        CheckBox("fZenithDistance",   "Zenith distance");
-
-        printf("  </tr><tr>\n");
-
-//        CheckBox("fFormatVersion",    "File format");
-        CheckBox("fNumEvents",        "Num of events");
-        CheckBox("fMeanTriggerRate",  "Mean Trigger rate");
-        CheckBox("fSequenceFirst",    "Sequence Number");
-        CheckBox("fTest",             "incl. TestSources");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-        printf(" <table>\n");
-        printf("  <tr><td>\n");
-
-        PrintStatusMenu("fCCFileAvail",    "CC File available");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fCaCoFileAvail",  "Caco File available");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fRawFileAvail",   "Rawfile available");
-
-        printf("  </td></tr><tr><td>\n");
-
-        PrintStatusMenu("fTimingCorrection",  "Timing Correction");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fCaCoFileFound",     "Caco File");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fDataCheckDone",        "DataCheck");
-
-        printf(" </td></tr></table>\n");
-        printf(" <p>\n");
-
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fStartTime",     "StartTime");
-        CheckBox("fFailedTime",    "FailedTime");
-        CheckBox("fReturnCode",    "RetCode");
-        CheckBox("fProgramId",     "ProgramId");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        // pull down boxes
-
-        printf(" <table>\n");
-        printf("  <tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "RunType",     "fRunTypeName",     "fRunTypeKEY", "Run type");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Source",      "fSourceName",      "fSourceKEY", "Source Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "HvSettings",  "fHvSettingsName",  "fHvSettingsKEY", "HV Settings");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "L1TriggerTable", "fL1TriggerTableName", "fL1TriggerTableKEY", "L1 Trigger Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TestFlag",  "fTestFlagName",  "fTestFlagKEY", "Test Flag");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Project",     "fProjectName",     "fProjectKEY", "Project Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable",  "fDiscriminatorThresholdTableName",  "fDiscriminatorThresholdTableKEY", "DT Table");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "L2TriggerTable", "fL2TriggerTableName", "fL2TriggerTableKEY", "L2 Trigger Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "ExcludedFDA", "fExcludedFDAName", "fExcludedFDAKEY", "Exclusions");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "LightConditions",  "fLightConditionsName",  "fLightConditionsKEY", "Light Conditions");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "CalibrationScript",  "fCalibrationScriptName",  "fCalibrationScriptKEY", "Cal Script");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TriggerDelayTable",  "fTriggerDelayTableName",  "fTriggerDelayTableKEY", "Trigger Delay Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "MagicNumber", "fMagicNumberName", "fMagicNumberKEY", "Magic Number");
-        printf(" </td></tr></table>\n");
-
-        printf(" <p>\n");
-
-        if (empty($_GET["fStartDate"]))
-            $timemin = GetMin("fRunStart", "RunData", $host, $user, $pw, $db);
-        else
-            $timemin = $_GET["fStartDate"];
-
-        if (empty($_GET["fStopDate"]))
-            $timemax = GetMax("fRunStart", "RunData", $host, $user, $pw, $db);
-        else
-            $timemax = $_GET["fStopDate"];
-
-        printf("Sequ#&nbsp;<input name=\"fSequenceNo\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"");
-        if (!empty($_GET["fSequenceNo"]))
-            printf("%s", $_GET["fSequenceNo"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-
-        printf("Night&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
-        printf("to&nbsp;<input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">&nbsp;&nbsp;&nbsp;&nbsp;\n", $timemax);
-
-/*
-        printf("Date&nbsp;(yyyy-mm-dd)&nbsp;<input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
-        if (!empty($_GET["fDate"]))
-            printf("%s", $_GET["fDate"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-*/
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fRunNumber", "RunData", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fRunNumber", "RunData", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-        printf("Runs&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf("Source&nbsp;(<A HREF=\"regexp.html\">regexp</A>)&nbsp;<input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
-        if (!empty($_GET["fSourceN"]))
-            printf("%s", $_GET["fSourceN"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500", "1000", "2000");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"runinfo.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-        mysql_query("SET BIG_TABLES=1"); // necessary for mySQL <= 4
-
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1" || $html=="2")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors",   "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        if (empty($_GET["fPrintTable"]))
-            PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-        {
-            if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-            else
-                PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-        }
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors",   "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/sequinfo.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/sequinfo.php	(revision 9501)
+++ 	(revision )
@@ -1,687 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
-    {
-        $fromtable="Sequences";
-
-        $groups = 0;
-        foreach ($checkgroup as $element)
-            if ($element==-1)
-                $groups++;
-
-        $statusgroups = 0;
-        foreach ($checkstatusgroup as $element)
-            if ($element==-1)
-                $statusgroups++;
-
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        if ($groups>0)
-        {
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
-            //--------------------------------------------------
-            $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
-            //--------------------------------------------------
-            $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', ";
-            $query0 .= " Min(fZenithDistanceMin) as '" . $alias["Min(fZenithDistanceMin)"] . "', ";
-            $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', ";
-            $query0 .= " COUNT(*) as '# Sequ' ";
-        }
-        else
-        {
-            if ($statusgroups>0)
-            {
-                foreach ($checkstatusgroup as $key => $element)
-                    if ($element==-1)
-                        $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-//                        $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-
-                $query0 .= " COUNT(*) as '# Sequ'";
-
-            }
-            else
-            {
-                if (!empty($_GET["fSendTxt"]))
-                    $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
-                else
-                {
-                    $query0 .= " CONCAT('<A&ws;HREF=\"runinfo.php?',  'fRunStart=On', '&fZenithDistance=On', '&fRunMin=', Sequences.fSequenceFirst, '&fMeanTriggerRate=On', '&fTest=On', '&fRunTypeName=On', '&fRunMax=', fSequenceLast, '&fNumEvents=On', '&fSourceName=On&', 'fExcludedFDAKEY=1', '&fSequenceFirst=On', '&fRawFileAvail=On', '&fCCFileAvail=On', '&fCaCoFileAvail=On', '&fNumResults=500\">', Sequences.fSequenceFirst, '</A>') ";
-                    $query0 .= " as " . $alias["fSequenceFirst"];
-                    if (!empty($_GET["fLinks"]))
-                    {
-                        $query0 .= ", CONCAT('<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'callisto', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">cl</A>'";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">c</A>'";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'star', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">sl</A>'";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">s</A>'";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/sequences/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/sequence', LPAD(CONCAT(Sequences.fSequenceFirst , '.txt'), 12,'0') , '\">', 'f </A>' ";
-                        $query0 .= ", '&nbsp;<A&ws;HREF=\"sequence.php?fSequenceNo=', Sequences.fSequenceFirst , '&fAll=On\">i</A>') ";
-                        $query0 .= " as 'Links'";
-                    }
-                }
-
-                foreach ($_GET as $key => $element)
-                    if ($_GET[$key]=="On")
-                        if ($key!="fLinks" && $key!="fTest")
-                            if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                                $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-            }
-        }
-
-        $query0 .= " FROM " . $fromtable;
-
-        $query0 .= " LEFT JOIN SequenceProcessStatus USING(fSequenceFirst,fTelescopeNumber) ";
-        $query0 .= " LEFT JOIN Calibration USING(fSequenceFirst,fTelescopeNumber) ";
-        $query0 .= " LEFT JOIN Star USING(fSequenceFirst,fTelescopeNumber) ";
-
-//        foreach ($_GET as $key => $element)
-//            if (($_GET[$key]=="On" || $groups>0) && !empty($joins[$key]))
-//                $query0 .= $joins[$key];
-
-        foreach ($_GET as $key => $element)
-            if (($_GET[$key]=="On" || $groups>0))// && !empty(GetJoin($fromtable,$key)))
-                $query0 .= GetJoin($fromtable,$key);
-
-        if ($_GET["fTest"]!="On")
-        {
-            if ($_GET["fSourceName"]!="On")
-                $query0 .= " LEFT JOIN Source ON USING(fSourceKEY) ";
-            $query0 .= " WHERE fTest='no'";
-        }
-
-        foreach ($checkwhere as $key => $element)
-        {
-            if (empty($element) || $element<=0)
-                continue;
-
-            if (strpos($query0, " WHERE ")==FALSE)
-                $query0 .= " WHERE ";
-            else
-                if ($element!=-1)
-                    if (strrpos($query0, " AND ")!=strlen($query0)-5)
-                        $query0 .= " AND ";
-
-            if ($element!=-1)
-                $query0 .= GetCheck($fromtable, $key) . "=" . $element;
-        }
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= StatusQuery("fSequenceFileWritten", $needs, $timelimits);
-        $query0 .= StatusQuery("fAllFilesAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fCallisto", $needs, $timelimits);
-        $query0 .= StatusQuery("fFillCallisto", $needs, $timelimits);
-        $query0 .= StatusQuery("fStar", $needs, $timelimits);
-        $query0 .= StatusQuery("fFillStar", $needs, $timelimits);
-
-        if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
-            $query0 .= "Sequences.fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-        else
-            $query0 = substr($query0, 0, -4);
-
-/*
-        if (!empty($_GET["fDate"]))
-            $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
-*/
-
-        if (!empty($_GET["fSourceN"]))
-            $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
-
-        if (!empty($_GET["fStartDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $startdate=substr($_GET["fStartDate"], 0, 10);
-            if ($startdate=="0000-00-00")
-                $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
-            else
-                $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
-        }
-
-        if (!empty($_GET["fStopDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0 || !strpos(strrev($query0), " DNA "))
-                $query0 .= " AND ";
-
-            $stopdate=substr($_GET["fStopDate"], 0, 10);
-            $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
-        }
-
-        if ($groups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $groups;
-            foreach ($checkgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= GetCheck($fromtable,$key);
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if ($statusgroups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $statusgroups;
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= $alias[$key];
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $val=substr($_GET["fSortBy"], 0, -1);
-            $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fSortBy"]) && $groups==0 && $statusgroups==0)
-            $query0 .= "ORDER BY Sequences.fSequenceFirst ASC ";
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="20";
-
-        if (empty($_GET["fLastUpdate"]))
-            $_GET["fLastUpdate"]="Off";
-
-        if (empty($_GET["fNumEvents"]))
-            $_GET["fNumEvents"]="Off";
-
-        if (empty($_GET["fRunStart"]))
-            $_GET["fRunStart"]=$first?"On":"";
-
-        if (empty($_GET["fRunTime/60"]))
-            $_GET["fRunTime/60"]=$first?"On":"";
-
-        if (empty($_GET["fSequenceLast"]))
-            $_GET["fSequenceLast"]="Off";
-
-        if (empty($_GET["fLinks"]))
-            $_GET["fLinks"]=$first?"On":"";
-
-        if (empty($_GET["fTest"]))
-            $_GET["fTest"]="Off";
-
-        if (empty($_GET["fAzimuthMin"]))
-            $_GET["fAzimuthMin"]="Off";
-
-        if (empty($_GET["fAzimuthMax"]))
-            $_GET["fAzimuthMax"]="Off";
-
-        if (empty($_GET["fZenithDistanceMin"]))
-            $_GET["fZenithDistanceMin"]=$first?"On":"";
-
-        if (empty($_GET["fZenithDistanceMax"]))
-            $_GET["fZenithDistanceMax"]="Off";
-
-        if (empty($_GET["fManuallyChangedName"]))
-            $_GET["fManuallyChangedName"]="Off";
-
-        if (empty($_GET["fSourceName"]))
-            $_GET["fSourceName"]=$first?"On":"";
-
-        if (empty($_GET["fProjectName"]))
-            $_GET["fProjectName"]="Off";
-
-        if (empty($_GET["fL1TriggerTableName"]))
-            $_GET["fL1TriggerTableName"]="Off";
-
-        if (empty($_GET["fL2TriggerTableName"]))
-            $_GET["fL2TriggerTableName"]="Off";
-
-        if (empty($_GET["fHvSettingsName"]))
-            $_GET["fHvSettingsName"]="Off";
-
-        if (empty($_GET["fDiscriminatorThresholdTableName"]))
-            $_GET["fDiscriminatorThresholdTableName"]="Off";
-
-        if (empty($_GET["fTriggerDelayTableName"]))
-            $_GET["fTriggerDelayTableName"]="Off";
-
-        if (empty($_GET["fLightConditionsName"]))
-            $_GET["fLightConditionsName"]="Off";
-
-        if (empty($_GET["fTestFlagName"]))
-            $_GET["fTestFlagName"]="Off";
-
-        if (empty($_GET["fSequenceFileWritten"]))
-            $_GET["fSequenceFileWritten"]="Off";
-
-        if (empty($_GET["fSequenceFileWrittenStatus"]))
-            $_GET["fSequenceFileWrittenStatus"]="0";
-
-        if (empty($_GET["fAllFilesAvail"]))
-            $_GET["fAllFilesAvail"]="Off";
-
-        if (empty($_GET["fAllFilesAvailStatus"]))
-            $_GET["fAllFilesAvailStatus"]="0";
-
-        if (empty($_GET["fCallisto"]))
-            $_GET["fCallisto"]="Off";
-
-        if (empty($_GET["fCallistoStatus"]))
-            $_GET["fCallistoStatus"]="0";
-
-        if (empty($_GET["fFillCallisto"]))
-            $_GET["fFillCallisto"]="Off";
-
-        if (empty($_GET["fFillCallistoStatus"]))
-            $_GET["fFillCallistoStatus"]="0";
-
-        if (empty($_GET["fStar"]))
-            $_GET["fStar"]=$first?"On":"";
-
-        if (empty($_GET["fStarStatus"]))
-            $_GET["fStarStatus"]="0";
-
-        if (empty($_GET["fFillStar"]))
-            $_GET["fFillStar"]="Off";
-
-        if (empty($_GET["fFillStarStatus"]))
-            $_GET["fFillStarStatus"]="0";
-
-        if (empty($_GET["fUnreliableInner"]))
-            $_GET["fUnreliableInner"]="Off";
-
-        if (empty($_GET["fUnsuitableOuter"]))
-            $_GET["fUnsuitableOuter"]="Off";
-
-        if (empty($_GET["fUnreliableOuter"]))
-            $_GET["fUnreliableOuter"]="Off";
-
-        if (empty($_GET["fUnsuitableInner"]))
-            $_GET["fUnsuitableInner"]="Off";
-
-        if (empty($_GET["fIsolatedInner"]))
-            $_GET["fIsolatedInner"]="Off";
-
-        if (empty($_GET["fIsolatedOuter"]))
-            $_GET["fIsolatedOuter"]="Off";
-
-        if (empty($_GET["fMeanPedRmsInner"]))
-            $_GET["fMeanPedRmsInner"]="Off";
-
-        if (empty($_GET["fMeanPedRmsOuter"]))
-            $_GET["fMeanPedRmsOuter"]="Off";
-
-        if (empty($_GET["fIsolatedMaxCluster"]))
-            $_GET["fIsolatedMaxCluster"]="Off";
-
-        if (empty($_GET["fArrTimeMeanInner"]))
-            $_GET["fArrTimeMeanInner"]="Off";
-
-        if (empty($_GET["fArrTimeMeanOuter"]))
-            $_GET["fArrTimeMeanOuter"]="Off";
-
-        if (empty($_GET["fArrTimeRmsInner"]))
-            $_GET["fArrTimeRmsInner"]="Off";
-
-        if (empty($_GET["fArrTimeRmsOuter"]))
-            $_GET["fArrTimeRmsOuter"]="Off";
-
-        if (empty($_GET["fMeanSignalInner"]))
-            $_GET["fMeanSignalInner"]=$first?"Off":"";
-
-        if (empty($_GET["fMeanSignalOuter"]))
-            $_GET["fMeanSignalOuter"]=$first?"Off":"";
-
-        if (empty($_GET["fPulsePosMean"]))
-            $_GET["fPulsePosMean"]=$first?"Off":"";
-
-        if (empty($_GET["fConvFactorInner"]))
-            $_GET["fConvFactorInner"]=$first?"On":"";
-
-        if (empty($_GET["fConvFactorOuter"]))
-            $_GET["fConvFactorOuter"]="Off";
-
-        if (empty($_GET["fMeanNumberIslands"]))
-            $_GET["fMeanNumberIslands"]="Off";
-
-        if (empty($_GET["fPSF"]))
-            $_GET["fPSF"]=$first?"On":"";
-
-        if (empty($_GET["fRatio"]))
-            $_GET["fRatio"]=$first?"On":"";
-
-        if (empty($_GET["fMuonNumber"]))
-            $_GET["fMuonNumber"]=$first?"On":"";
-
-        if (empty($_GET["fEffOnTime"]))
-            $_GET["fEffOnTime"]="Off";
-
-        if (empty($_GET["fEffOnTime/fRunTime"]))
-            $_GET["fEffOnTime/fRunTime"]="Off";
-
-        if (empty($_GET["fMuonRate"]))
-            $_GET["fMuonRate"]="Off";
-
-        if (empty($_GET["fInhomogeneity"]))
-            $_GET["fInhomogeneity"]="Off";
-
-        if (empty($_GET["fDataRate"]))
-            $_GET["fDataRate"]="Off";
-
-        if (empty($_GET["fMaxHumidity"]))
-            $_GET["fMaxHumidity"]="Off";
-
-        if (empty($_GET["fStartTime"]))
-            $_GET["fStartTime"]="Off";
-
-        if (empty($_GET["fFailedTime"]))
-            $_GET["fFailedTime"]="Off";
-
-        if (empty($_GET["fReturnCode"]))
-            $_GET["fReturnCode"]="Off";
-
-        if (empty($_GET["fProgramId"]))
-            $_GET["fProgramId"]="Off";
-
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"sequinfo.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fRunStart",          "Start time");
-        CheckBox("fAzimuthMin",        "Azimuth min");
-        CheckBox("fAzimuthMax",        "Azimuth max");
-        CheckBox("fZenithDistanceMin", "Zenith distance min");
-        CheckBox("fZenithDistanceMax", "Zenith distance max");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fNumEvents",         "Num of events");
-        CheckBox("fRunTime/60",        "Duration");
-        CheckBox("fSequenceLast",      "Last run");
-        CheckBox("fLinks",             "Links");
-        CheckBox("fTest",              "incl. TestSources");
-
-        printf("  </tr></table>\n");
-        printf(" <p>\n");
-        printf(" <table><tr><td>\n");
-
-        PrintStatusMenu("fSequenceFileWritten", "Sequfile");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fAllFilesAvail",       "Files avail");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fCallisto",            "Callisto");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fStar",                "Star");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fFillCallisto",        "Fillcallisto");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fFillStar",            "Fillstar");
-
-        printf("</td></tr> </table>\n");
-//        printf(" <p>\n");
-
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fStartTime",     "StartTime");
-        CheckBox("fFailedTime",    "FailedTime");
-        CheckBox("fReturnCode",    "RedCode");
-        CheckBox("fProgramId",     "ProgramId");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fUnsuitableInner",     "Unsuitable inner");
-        CheckBox("fUnsuitableOuter",     "Unsuitable outer");
-        CheckBox("fUnreliableInner",     "Unreliable inner");
-        CheckBox("fUnreliableOuter",     "Unreliable outer");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fIsolatedInner",       "Isolated inner");
-        CheckBox("fIsolatedOuter",       "Isolated outer");
-        CheckBox("fIsolatedMaxCluster",  "IsolatedMaxCluster");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fArrTimeMeanInner",    "ArrTimeMean inner ");
-        CheckBox("fArrTimeMeanOuter",    "ArrTimeMean outer ");
-        CheckBox("fArrTimeRmsInner",     "ArrTimeRms inner ");
-        CheckBox("fArrTimeRmsOuter",     "ArrTimeRms outer ");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fMeanPedRmsInner",     "MeanPedRms inner");
-        CheckBox("fMeanPedRmsOuter",     "MeanPedRms outer");
-        CheckBox("fMeanSignalInner",     "MeanSignal inner");
-        CheckBox("fMeanSignalOuter",     "MeanSignal outer");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fConvFactorInner",     "Conv inner ");
-        CheckBox("fConvFactorOuter",     "Conv outer ");
-        CheckBox("fPulsePosMean",        "Mean PulsePos");
-
-        printf(" </tr></table>\n");
-//        printf(" <p>\n");
-
-        printf(" <table>\n");
-        printf("  <tr>\n");
-
-        CheckBox("fDataRate",           "CleanedEvtRate");
-        CheckBox("fMeanNumberIslands",  "MeanNumIslands");
-        CheckBox("fMaxHumidity",        "MaxHumidity");
-        CheckBox("fInhomogeneity",      "Inhomogeneity");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fMuonRate",           "MuonRate");
-        CheckBox("fMuonNumber",         "MuonNumber");
-        CheckBox("fRatio",              "Ratio");
-        CheckBox("fPSF",                "PSF");
-
-        printf("  </tr><tr>\n");
-
-        CheckBox("fEffOnTime",          "EffOnTime");
-        CheckBox("fEffOnTime/fRunTime", "RelOnTime");
-
-        printf("  </tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        // pull down boxes
-
-        printf(" <table>\n");
-        printf("  <tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Source",                      "fSourceName",                      "fSourceKEY",                      "Source Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "L1TriggerTable",              "fL1TriggerTableName",              "fL1TriggerTableKEY",              "L1Trigger Table");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "L2TriggerTable",              "fL2TriggerTableName",              "fL2TriggerTableKEY",              "L2Trigger Table");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TriggerDelayTable",           "fTriggerDelayTableName",           "fTriggerDelayTableKEY",           "Trigger Delay Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "LightConditions",             "fLightConditionsName",             "fLightConditionsKEY",             "Light Conditions");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "Project",                     "fProjectName",                     "fProjectKEY",                     "Project Name");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "HvSettings",                  "fHvSettingsName",                  "fHvSettingsKEY",                  "HV Settings");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "DiscriminatorThresholdTable", "fDiscriminatorThresholdTableName", "fDiscriminatorThresholdTableKEY", "DT Table");
-        printf("  </td></tr><tr><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "ManuallyChanged",             "fManuallyChangedName",             "fManuallyChangedKEY",             "Manually changed");
-        printf("  </td><td>\n");
-        PrintPullDown($host, $user, $pw, $db, "TestFlag",                    "fTestFlagName",                    "fTestFlagKEY",                    "Test Flag");
-        printf("  </td></tr>\n");
-        printf(" </table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fStartDate"]))
-            $timemin = GetMin("fRunStart", "Sequences", $host, $user, $pw, $db);
-        else
-            $timemin = $_GET["fStartDate"];
-
-        if (empty($_GET["fStopDate"]))
-            $timemax = GetMax("fRunStart", "Sequences", $host, $user, $pw, $db);
-        else
-            $timemax = $_GET["fStopDate"];
-
-        printf("Night&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
-        printf("to&nbsp;<input name=\"fStopDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">&nbsp;&nbsp;&nbsp;&nbsp;\n", $timemax);
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fSequenceFirst", "Sequences", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-/*
-        printf("Date&nbsp;(yyyy-mm-dd)&nbsp;<input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
-        if (!empty($_GET["fDate"]))
-            printf("%s", $_GET["fDate"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-*/
-
-        printf("Sequences&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf("Source&nbsp;(<A HREF=\"regexp.html\">regexp</A>)&nbsp;<input name=\"fSourceN\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"");
-        if (!empty($_GET["fSourceN"]))
-            printf("%s", $_GET["fSourceN"]);
-        printf("\">&nbsp;&nbsp;&nbsp;\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"sequinfo.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1" || $html=="2")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        if (empty($_GET["fPrintTable"]))
-            PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-        {
-            if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-            else
-                PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
-        }
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/statusrps.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/statusrps.php	(revision 9501)
+++ 	(revision )
@@ -1,256 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs)
-    {
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        $statusgroups = 0;
-        foreach ($checkstatusgroup as $element)
-            if ($element==-1)
-                $statusgroups++;
-
-        if ($statusgroups>0)
-        {
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-//                    $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $key . "', ";
-
-            $query0 .= " count(*) as '# Runs'";
-
-        }
-        else
-        {
-            $query0 .= "fRunNumber as '# Runs' ";
-
-            foreach ($_GET as $key => $element)
-                if ($_GET[$key]=="On")
-                    if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                        $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-        }
-
-        $query0 .= " FROM RunProcessStatus ";
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= StatusQuery("fCCFileAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fCaCoFileAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fCaCoFileFound", $needs, $timelimits);
-        $query0 .= StatusQuery("fRawFileAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fDataCheckDone", $needs, $timelimits);
-        $query0 .= StatusQuery("fTimingCorrection", $needs, $timelimits);
-
-        $query0 .= "fRunNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-        if ($statusgroups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $statusgroups;
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= $alias[$key];
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="20";
-
-        if (empty($_GET["fDataCheckDone"]))
-            $_GET["fDataCheckDone"]="Off";
-
-        if (empty($_GET["fDataCheckDoneStatus"]))
-            $_GET["fDataCheckDoneStatus"]="0";
-
-        if (empty($_GET["fCCFileAvail"]))
-            $_GET["fCCFileAvail"]=$first?"On":"";
-
-        if (empty($_GET["fCCFileAvailStatus"]))
-            $_GET["fCCFileAvailStatus"]="0";
-
-        if (empty($_GET["fCaCoFileAvail"]))
-            $_GET["fCaCoFileAvail"]=$first?"On":"";
-
-        if (empty($_GET["fCaCoFileAvailStatus"]))
-            $_GET["fCaCoFileAvailStatus"]="0";
-
-        if (empty($_GET["fCaCoFileFound"]))
-            $_GET["fCaCoFileFound"]="Off";
-
-        if (empty($_GET["fCaCoFileFoundStatus"]))
-            $_GET["fCaCoFileFoundStatus"]="0";
-
-        if (empty($_GET["fRawFileAvail"]))
-            $_GET["fRawFileAvail"]=$first?"On":"";
-
-        if (empty($_GET["fRawFileAvailStatus"]))
-            $_GET["fRawFileAvailStatus"]="0";
-
-        if (empty($_GET["fTimingCorrection"]))
-            $_GET["fTimingCorrection"]=$first?"On":"";
-
-        if (empty($_GET["fTimingCorrectionStatus"]))
-            $_GET["fTimingCorrectionStatus"]="0";
-
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"statusrps.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr><td>\n");
-
-        PrintStatusMenu("fCCFileAvail",      "CC File available");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fCaCoFileAvail",    "Caco File available");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fRawFileAvail",     "Rawfile available");
-
-        printf("  </td></tr><tr><td>\n");
-
-        PrintStatusMenu("fTimingCorrection", "Timing Correction");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fCaCoFileFound",    "Caco File");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fDataCheckDone",    "Datacheck");
-
-        printf(" </td></tr></table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fRunNumber", "RunProcessStatus", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fRunNumber", "RunProcessStatus", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-
-        printf("Runs&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"statusrps.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $query0 = CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-            PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs);
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
Index: trunk/MagicSoft/Mars/datacenter/db/statussps.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/statussps.php	(revision 9501)
+++ 	(revision )
@@ -1,245 +1,0 @@
-<?php
-{
-    function CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs)
-    {
-        $statusgroups = 0;
-        foreach ($checkstatusgroup as $element)
-            if ($element==-1)
-                $statusgroups++;
-
-        $query0 = "SELECT SQL_CALC_FOUND_ROWS ";
-
-        if ($statusgroups>0)
-        {
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                    $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-//                    $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
-
-            $query0 .= " count(*) as '# Sequ'";
-
-        }
-        else
-        {
-            if (!empty($_GET["fSendTxt"]))
-                $query0 .= " fSequenceFirst ";
-            else
-                $query0 .= " CONCAT('<A&ws;HREF=\"index.php?', 'fRunStart=On', '&fZenithDistance=On', '&fMeanTriggerRate=On', '&fRunTypeName=On', '&fNumEvents=On', '&fSourceName=On&', 'fExcludedFDAKEY=1', '&fSequenceFirst=On', '&fSequenceNo=', fSequenceFirst, '&fNumResults=500\">', fSequenceFirst, '</A>') ";
-            $query0 .= " as 'Sequence#' ";
-
-            foreach ($_GET as $key => $element)
-                if ($_GET[$key]=="On")
-                if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                    $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-        }
-
-        $query0 .= " FROM SequenceProcessStatus ";
-
-        if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
-        else
-            $query0 .= " AND ";
-
-        $query0 .= StatusQuery("fSequenceFileWritten", $needs, $timelimits);
-        $query0 .= StatusQuery("fAllFilesAvail", $needs, $timelimits);
-        $query0 .= StatusQuery("fCallisto", $needs, $timelimits);
-        $query0 .= StatusQuery("fFillCallisto", $needs, $timelimits);
-        $query0 .= StatusQuery("fStar", $needs, $timelimits);
-        $query0 .= StatusQuery("fFillStar", $needs, $timelimits);
-
-        $query0 .= "fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-        if ($statusgroups>0)
-        {
-            $query0 .= " GROUP BY ";
-            $num = $statusgroups;
-            foreach ($checkstatusgroup as $key => $element)
-                if ($element==-1)
-                {
-                    $query0 .= $alias[$key];
-                    if ($num-->1)
-                        $query0 .= ", ";
-                }
-        }
-
-        if (!empty($_GET["fSortBy"]))
-        {
-            $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
-            if (substr($_GET["fSortBy"], -1)=="-")
-                $query0 .= "DESC";
-        }
-
-        if (empty($_GET["fSortBy"]) && $statusgroups==0)
-            $query0 .= "ORDER BY fSequenceFirst ASC ";
-
-        if (empty($_GET["fNumStart"]))
-            $_GET["fNumStart"]=0;
-
-        if (empty($_GET["fSendTxt"]))
-            $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"];
-
-        return $query0;
-    }
-
-    function InitGet($_GET)
-    {
-        // Find out whether it is the first call to the php script
-        $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]);
-
-        if (empty($_GET["fNumResults"]))
-            $_GET["fNumResults"]="20";
-
-        if (empty($_GET["fSequenceFileWritten"]))
-            $_GET["fSequenceFileWritten"]=$first?"On":"";
-
-        if (empty($_GET["fAllFilesAvail"]))
-            $_GET["fAllFilesAvail"]=$first?"On":"";
-
-        if (empty($_GET["fCallisto"]))
-            $_GET["fCallisto"]=$first?"On":"";
-
-        if (empty($_GET["fStar"]))
-            $_GET["fStar"]=$first?"On":"";
-
-        if (empty($_GET["fFillCallisto"]))
-            $_GET["fFillCallisto"]="Off";
-
-        if (empty($_GET["fFillStar"]))
-            $_GET["fFillStar"]="Off";
-
-    }
-
-    function PrintForm($_GET, $host, $user, $pw, $db)
-    {
-        printf("<center>\n");
-        printf("<form action=\"statussps.php\" METHOD=\"GET\">\n");
-        printf(" <table>\n");
-        printf("  <tr><td>\n");
-
-        PrintStatusMenu("fSequenceFileWritten", "Sequencefile written");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fCallisto",            "Callisto");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fStar",                "Star");
-
-        printf("  </td></tr><tr><td>\n");
-
-        PrintStatusMenu("fAllFilesAvail",       "All files available");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fFillCallisto",        "Fillcallisto");
-        printf("  </td><td>\n");
-        PrintStatusMenu("fFillStar",            "Fillstar");
-
-        printf("</td></tr> </table>\n");
-        printf(" <p>\n");
-
-        if (empty($_GET["fRunMin"]))
-            $min = GetMin("fSequenceFirst", "SequenceProcessStatus", $host, $user, $pw, $db);
-        else
-            $min = $_GET["fRunMin"];
-
-        if (empty($_GET["fRunMax"]))
-            $max = GetMax("fSequenceFirst", "SequenceProcessStatus", $host, $user, $pw, $db);
-        else
-            $max = $_GET["fRunMax"];
-
-
-        printf("Sequences&nbsp;from&nbsp;<input name=\"fRunMin\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">\n", $min);
-        printf("to&nbsp;<input name=\"fRunMax\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"%s\">&nbsp;&nbsp;&nbsp;\n", $max);
-
-        printf(" <P>\n");
-
-        printf(" Results:\n");
-        printf(" <select name=\"fNumResults\">\n");
-
-        $numres = array("10", "20", "50", "100", "200", "500");
-        foreach ($numres as $element)
-        {
-            if ($element==$_GET["fNumResults"])
-                printf("<option value=\"%s\" selected>%3s</option>\n", $element, $element);
-            else
-                printf("<option value=\"%s\">%3s</option>\n", $element, $element);
-        }
-        printf(" </select>\n");
-        printf(" &nbsp;&nbsp;&nbsp;\n");
-
-        ini_set("mysql.trace_mode", "Off");
-        ini_set("display_errors", "Off");
-
-        printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
-        printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"statussps.php\"'>&nbsp;&nbsp;&nbsp;\n");
-        if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
-            printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
-        printf("</form>\n");
-        printf("</center>\n");
-        printf("</td>\n");
-        printf("</tr>\n");
-        printf("<tr class='Block'>\n");
-        printf("<td>\n");
-    }
-
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs)
-    {
-        $db_id = mysql_connect($host, $user, $pw);
-        if ($db_id==FALSE)
-        {
-            printf("mysql_connect returned the following error: %s\n", mysql_error());
-            die("");
-        }
-        mysql_select_db($db);
-
-        $query0 = CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs);
-
-        $result0 = mysql_query($query0, $db_id);
-        $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
-
-        if ($result0)
-        {
-            if ($html=="1")
-                PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
-            else
-                PrintText($result0);
-
-            mysql_free_result($result0);
-            mysql_free_result($result1);
-        }
-        mysql_close($db_id);
-
-        PrintSubmittedQuery($query0, $html, $db, "old");
-    }
-
-    include ("include.php");
-    include ("db.php");
-    include ("magicdefs.php");
-
-    ini_set("display_errors", "On");
-    ini_set("mysql.trace_mode", "On");
-
-    if (!empty($_GET["fSendTxt"]))
-    {
-        header("Content-type: application/octet");
-        header("Content-Disposition: attachment; filename=query-result.txt");
-
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs);
-    }
-    else
-    {
-        echo (file_get_contents("index-header.html"));
-
-        $environment = sizeof($_GET);
-
-        InitGet($_GET);
-        PrintForm($_GET, $host, $user, $pw, $db);
-
-        if ($environment==0)
-            printf("No query submitted yet.<BR>");
-        else
-            PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs);
-
-        echo (file_get_contents("index-footer.html"));
-    }
-
-    ini_set("display_errors", "Off");
-    ini_set("mysql.trace_mode", "Off");
-}
-?>
