0)
printf(" Error-Number: %s
", mysql_errno());
if (mysql_error()!="")
printf(" Error-Message: %s
", mysql_error());
if (mysql_info()!="")
printf(" Mysql-Info: %s
", mysql_info());
mysql_free_result($marsresult);
if (empty($mars))
{
printf("Could not get information for latest Mars version from the database.");
return;
}
if (empty($_GET["insert"]))
{
$query0 = "SELECT SequenceProcessStatus.fSequenceFirst, ";
// $query0 .= "if (fCallisto " . " < '" . $date . "', 'to be resetted', ";
$query0 .= "if (fCallisto " . " < '" . $date . "', CONCAT('outdated (', (SELECT fMarsVersionName FROM MarsVersion WHERE fCallisto > fStartDate ORDER BY fMarsVersion DESC LIMIT 0,1), ')'), ";
$query0 .= "if (not isnull(fCallisto), 'up to date (" . $mars . ")', ";
$query0 .= "if (fStartTime > ADDDATE(Now(), INTERVAL -1 DAY) AND isnull(fFailedTime), 'running (" . $mars . ")',";
$query0 .= "if (isnull(fFailedTime), 'already resetted', ";
$query0 .= " 'crashed or failed')))) as 'calstat', ";
// $query0 .= "if (fStar " . " < '" . $date . "', 'to be resetted', ";
$query0 .= "if (fStar " . " < '" . $date . "', CONCAT('outdated (', (SELECT fMarsVersionName FROM MarsVersion WHERE fStar > fStartDate ORDER BY fMarsVersion DESC LIMIT 0,1), ')'), ";
$query0 .= "if (not isnull(fStar), 'up to date (" . $mars . ")', ";
$query0 .= "if (fStartTime > ADDDATE(Now(), INTERVAL -1 DAY) AND isnull(fFailedTime) AND not isnull(fCallisto), 'running (" . $mars . ")',";
$query0 .= "if (isnull(fFailedTime), 'already resetted', ";
$query0 .= " 'crashed or failed')))) as 'starstat', fProjectName, fRunStart ";
$query0 .= "FROM SequenceProcessStatus ";
$query0 .= "LEFT JOIN Sequences USING(fSequenceFirst,fTelescopeNumber) ";
$query0 .= "LEFT JOIN Project USING(fProjectKEY) ";
}
else
{
$query0 = "UPDATE SequenceProcessStatus SET ";
if ($_GET["step"]=="callisto")
$query0 .="fCallisto=NULL, fFillCallisto=NULL, fStar=NULL, fFillStar=NULL, ";
else
if ($_GET["step"]=="star")
$query0 .="fStar=NULL, fFillStar=NULL, ";
$query0 .="fStartTime=NULL, fFailedTime=NULL, fProgramId=NULL, fReturnCode=NULL ";
if ($_GET["step"]=="callisto")
$query0 .= " WHERE fCallisto " . " < '" . $date . "'";
else
if ($_GET["step"]=="star")
$query0 .= " WHERE fStar " . " < '" . $date . "'";
else
$query0 .= " WHERE (NOT ISNULL(fFailedTime) OR fStartTime < ADDDATE(Now(), INTERVAL -1 DAY))";
}
if (ereg("^([ ]*[0-9]{5,8}[ ]*[,])*[ ]*[0-9]{5,8}[ ]*$",$_GET["Seqs"]))
{
if (strpos($query0, " WHERE ")==FALSE || (strpos($query0, " CONCAT(")==TRUE && strpos($query0, " WHERE ")==TRUE))
$query0 .= " WHERE ";
else
$query0 .= " AND ";
$query0 .=" SequenceProcessStatus.fSequenceFirst IN (" . $_GET["Seqs"] . ")";
}
else
{
echo "You have to give the sequences, which you want to reset, in the correct format, i.e. sequence numbers separated by ','.
";
return;
}
if (empty($_GET["step"]))
{
echo "Please choose what you want to reset:
";
echo "crashed processes (i.e. running longer than 1 day or failed), callisto or star.
";
return;
}
$result0=mysql_query($query0);
if (mysql_errno()>0)
printf(" Errorno: %s
", mysql_errno());
if (mysql_error()!="")
printf(" Errormsg: %s
", mysql_error());
if (!empty($_GET["insert"]) && !empty($_GET["step"]))
{
printf("%s Sequences have been resetted.
\n", mysql_affected_rows());
if (mysql_info()!="")
printf("Mysql-Info: %s
\n", mysql_info());
}
else
{
if (mysql_affected_rows()==0)
{
echo "No sequence to reset.
";
echo "The sequences you listed are already resetted.
";
mysql_free_result($result0);
return;
}
// echo "The status of the sequences you entered:
\n";
$star="";
$callisto="";
$crashed="";
$calcolor='black';
$starcolor='black';
$style='normal';
$col = FALSE;
$bgcolor='#C0C0C0';
$checked=0;
printf("
\nSequence\n | \n", $bgcolor); printf("\n\nProjectName\n | \n"); printf("\nStatus Callisto\n | "); printf("\n\nStatus Star\n | \n"); printf("\n\nStarttime\n | \n"); printf("
---|---|---|---|---|
\n%s \n | \n", $bgcolor, $style, $row[0]); printf("\n %s \n | \n", $row[3]); printf("\n %s \n | \n", $calcolor, $row[1]); printf("\n %s \n | \n", $starcolor, $row[2]); printf("\n %s \n | \n", $row[4]); printf("