%s\n", $name, $checked, $text);
printf("
");
printf(" \n");
printf(" \n");
}
function StatusQuery($name, $timelimits)
{
if (empty($timelimits[$name]))
$timelimit="12";
else
$timelimit=$timelimits[$name];
$var = $name . "Status";
$txt = "";
switch ($_GET[$var])
{
case 0://all
$txt .= " ";
break;
case 1://done
$txt .= " NOT ISNULL(" . $name . "Status.fStartTime) AND "
." NOT ISNULL(" . $name . "Status.fStopTime) AND "
." ISNULL(" . $name . "Status.fReturnCode) AND ";
break;
case 2://not done
$txt .= " ISNULL(" . $name . "Status.fStartTime) AND "
." ISNULL(" . $name . "Status.fStopTime) AND "
." ISNULL(" . $name . "Status.fReturnCode) AND ";
break;
case 3://not to be done
$txt .= $name ."Status.fStartTime='1970-01-01 00:00:00' AND "
. $name ."Status.fStopTime='1970-01-01 00:00:00' AND ";
break;
case 4://running
$txt .= " NOT ISNULL(" . $name . "Status.fStartTime) AND "
." DATE_SUB(Now(),INTERVAL " . $timelimit . " HOUR) < " . $name . "Status.fStartTime AND "
." ISNULL(" . $name . "Status.fStopTime) AND "
." ISNULL(" . $name . "Status.fReturnCode) AND ";
break;
case 5://failed
$txt .= " NOT ISNULL(" . $name . "Status.fStartTime) AND "
." NOT ISNULL(" . $name . "Status.fStopTime) AND "
." NOT ISNULL(" . $name . "Status.fReturnCode) AND ";
break;
case 6://crashed
$txt .= " NOT ISNULL(" . $name . "Status.fStartTime) AND "
." DATE_SUB(Now(),INTERVAL " . $timelimit . " HOUR) > " . $name . "Status.fStartTime AND "
." ISNULL(" . $name . "Status.fStopTime) AND "
." ISNULL(" . $name . "Status.fReturnCode) AND ";
break;
case 7://group by
$txt .= "";
break;
}
return $txt;
}
function PrintStatusMenu($name, $text)
{
$var = $name . "Status";
if ($_GET[$name]=="On")
$checked = "checked";
else
$checked = "";
printf(" %s\n", $name, $checked, $text);
printf("
");
printf(" \n");
printf(" \n");
}
function PrintPullDown($host, $user, $pw, $db, $table, $name, $index, $descr)
{
$db_id = mysql_connect($host, $user, $pw);
if ($db_id==FALSE)
{
printf("mysql_connect returned the following error:
");
printf("%s
", mysql_error());
die("");
}
$query = "SELECT " . $index . ", " . $name . " FROM " . $db . "." . $table . " ORDER BY " . $name;
$result = mysql_query($query);
if (!$result)
{
printf("-N/A-");
return;
}
$numrows = mysql_num_rows($result);
if ($_GET[$name]=="On")
$checked = "checked";
else
$checked = "";
printf(" %s\n", $name, $checked, $table, $descr);
printf("
\n");
printf(" \n");
printf(" \n", $index);
mysql_free_result($result);
mysql_close($db_id);
}
function GetMin($field, $table, $host, $user, $pw, $db)
{
$db_id = mysql_connect($host, $user, $pw);
if ($db_id==FALSE)
{
printf("mysql_connect returned the following error:
");
printf("%s
", mysql_error());
die("");
}
$query = "SELECT MIN(" . $field . ") FROM " . $db . "." . $table;
$result = mysql_query($query);
if (!$result)
return "0";
$row = mysql_fetch_row($result);
$min = $row[0];
mysql_free_result($result);
mysql_close($db_id);
return $min;
}
function GetMax($field, $table, $host, $user, $pw, $db)
{
$db_id = mysql_connect($host, $user, $pw);
if ($db_id==FALSE)
{
printf("mysql_connect returned the following error:
");
printf("%s
", mysql_error());
die("");
}
$query = "SELECT MAX(" . $field . ") FROM " . $db . "." . $table;
$result = mysql_query($query);
if (!$result)
return "0";
$row = mysql_fetch_row($result);
$max = $row[0];
mysql_free_result($result);
mysql_close($db_id);
return $max;
}
function GetMaxDate($field, $table, $host, $user, $pw, $db)
{
$db_id = mysql_connect($host, $user, $pw);
if ($db_id==FALSE)
{
printf("mysql_connect returned the following error:
");
printf("%s
", mysql_error());
die("");
}
$query = "SELECT DATE_FORMAT(if(MAX(" . $field . ")<'13:00:00', MAX(" . $field . "), ADDDATE(MAX(" . $field . "), INTERVAL +1 DAY)), '%Y-%m-%d') FROM " . $db . "." . $table;
$result = mysql_query($query);
if (!$result)
return "0";
$row = mysql_fetch_row($result);
$maxdate = $row[0];
mysql_free_result($result);
mysql_close($db_id);
return $maxdate;
}
//for download of output
function PrintText($result0)
{
while ($row0 = mysql_fetch_assoc($result0))
{
foreach ($row0 as $key => $element)
printf("%s\t", $element);
printf("\n");
}
}
function PrintSubmittedQuery($query0, $db, $old)
{
//diplay query on old websites
if (empty($old))
printf("