%s\n", $name, $checked, $text); printf("
"); printf(" \n"); printf("    \n"); } function StatusQuery($name, $needs) { $var = $name . "Status"; $txt = ""; switch ($_GET[$var]) { case 0: $txt .= ""; break; case 1: $txt .= "NOT (IsNull(" . $name . ") OR " . $name . "='1970-01-01 00:00:00') AND "; break; case 2: $txt .= "IsNull(" . $name . ") AND IsNull(fStartTime) AND IsNull(fFailedTime) AND NOT IsNull(" . $needs[$name] . ") AND "; break; case 3: $txt .= $name ."='1970-01-01 00:00:00' AND "; break; case 4: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval 12 hour) < fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break; case 5: $txt .= " (IsNull(" . $name . ") AND NOT IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND NOT IsNull(" . $needs[$name] . ")) AND "; break; case 6: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval 12 hour) > fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break; // case 6: $txt .= "crashed"; break; case 7: $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 PrintText($result0) { header("Content-type: application/octet"); header("Content-Disposition: attachment; filename=query-result.txt"); while ($row0 = mysql_fetch_assoc($result0)) { foreach ($row0 as $key => $element) printf("%s\t", $element); printf("\n"); } } function PrintSubmittedQuery($query0, $html, $db, $old) { //diplay query on old websites if (empty($old)) printf(""); else printf(""); printf("DB: %s
", $db); if ($html=="1") printf("submitted query:
%s
", htmlspecialchars($query0)); printf(""); } function Checkbox($value, $text) { if ($_GET[$value]=="On") $checked = "checked"; else $checked = ""; printf(" %s\n", $value, $checked, $text); } function CheckWhere($column, $_GET) { foreach ($_GET as $key => $element) { if ($key==$column) { if ($element>0) printf ("FIXED: %s
", $column); return $element; } } return 0; } function CheckGroup($column, $_GET) { foreach ($_GET as $key => $element) { if ($key==$column) { //if ($element==-1) // printf ("GROUP: %s
", $column); return $element; } } return 0; } function CheckStatusGroup($column, $_GET) { foreach ($_GET as $key => $element) if ($key==$column) if ($element==7) return -1; return 0; } function CheckEnumGroup($column, $_GET) { foreach ($_GET as $key => $element) if ($key==$column) if ($element==3) return -1; return 0; } function CreateMenu($rows) { $menu = ""; if (empty($_GET["fNumResults"])) return; if ($_GET["fNumStart"]!=0) { $uri = htmlspecialchars($_SERVER["REQUEST_URI"]); $pos = strpos($uri, "fNumStart"); $amp3=FALSE; if ($pos!=FALSE) { $amp1 = substr($uri, 0, $pos-1); $amp2 = substr($uri, $pos); $amp3 = strchr($amp2, "&"); $uri = $amp1; } $pos = $_GET["fNumStart"]-$rows; if ($pos<0) $pos=0; $uri .= "&fNumStart=" . $pos; if ($amp3!=FALSE) $uri .= $amp3; $menu .= "<<< Prev\n"; } $menu .= "   --- "; $menu .= $_GET["fNumStart"]; $menu .= " ---   \n"; if ($rows==$_GET["fNumResults"]) { $uri = $_SERVER["REQUEST_URI"]; $pos = strpos($uri, "fNumStart"); $amp3=FALSE; if ($pos!=FALSE) { $amp1 = substr($uri, 0, $pos-1); $amp2 = substr($uri, $pos); $amp3 = strchr($amp2, "&"); $uri = $amp1; } $uri .= "&fNumStart=" . ($_GET["fNumStart"]+$rows); if ($amp3!=FALSE) $uri .= $amp3; $menu .= "Next >>>\n"; } return $menu; } function RemoveSortBy() { $menu = ""; $uri = $_SERVER["REQUEST_URI"]; $pos = strpos($uri, "fSortBy"); $amp3=FALSE; if ($pos!=FALSE) { $amp1 = substr($uri, 0, $pos-1); $amp2 = substr($uri, $pos); $amp3 = strchr($amp2, "&"); $uri = $amp1; } return $uri; } function FindAlias($alias, $search) { foreach ($alias as $key => $element) if ($element==$search) return $key; return ""; } function PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $_GET) { $col = FALSE; $first = TRUE; $sigma = array ( 5 => "#FF9900", 3 => "#FFFF66", 2 => "#33CC00", 1 => "#006600", ); $offlimitcolour="#FF0000"; $menu = CreateMenu(mysql_num_rows($result0)); printf("\n
\n"); if (empty($_GET["fPrintTable"])) printf("

%s

\n", $menu); printf("\n"); while ($row0 = mysql_fetch_assoc($result0)) { if ($first) { printf(" \n"); $first = FALSE; foreach ($row0 as $key => $element) { $col = FindAlias($alias, $key); $ord="-"; $issort = ""; if (!empty($_GET["fSortBy"]) && substr($_GET["fSortBy"], 0, -1)==$col) { if (substr($_GET["fSortBy"], -1)=="-") { $ord="+"; $issort=" "; } else $issort=" "; } printf(" \n", htmlspecialchars(RemoveSortBy()), $col, $ord, $key, $issort); } printf(" \n\n"); } if (!$col) printf(" \n"); else printf(" \n"); $col = !$col; foreach ($row0 as $key => $element) { if (empty($rightalign[$key])) printf(" \n", str_replace("&ws;", " ", str_replace(" ", " ", $element))); } printf(" \n"); } printf("
 %s%s 
"); else printf(" "); //determine color of text in cell if (!empty($limitsmean)) { foreach($limitsmean as $key2 => $element2) { $mean=$key2 . "Mean"; $rms2=$key2 . "Rms"; if ($key==$alias[$element2] && !empty($_GET[$mean])) { if (!empty($_GET[$rms2])) { $colour=$offlimitcolour; foreach ($sigma as $margin => $newcolour) { $min=$_GET[$mean] - ($margin * $_GET[$rms2]); $max=$_GET[$mean] + ($margin * $_GET[$rms2]); if ($min < $element && $element < $max) $colour=$newcolour; } printf("", $colour); } } } } if (!empty($limitsmin)) { foreach($limitsmin as $key2 => $element2) { $limit1=$key2 . "1"; $limit2=$key2 . "2"; if ($key==$alias[$element2] && !empty($_GET[$limit1])) { $colour=$offlimitcolour; if ($_GET[$limit1] <= $element) $colour=$sigma[1]; else { if (!empty($_GET[$limit2])) { if ($_GET[$limit2] <= $element) $colour=$sigma[5]; } } printf("", $colour); } } } if (!empty($limitsmax)) { foreach($limitsmax as $key2 => $element2) { $limit1=$key2 . "1"; $limit2=$key2 . "2"; if ($key==$alias[$element2] && !empty($_GET[$limit1])) { $colour=$offlimitcolour; if ($_GET[$limit1] >= $element) $colour=$sigma[1]; else { if (!empty($_GET[$limit2])) { if ($_GET[$limit2] >= $element) $colour=$sigma[5]; } } printf("", $colour); } } } //fill text in cell printf(" %s 
\n"); /* $info = mysql_info(); if (!empty($info)) printf("%s
\n", $info); */ printf("

Number of displayed results: %d

\n", mysql_num_rows($result0)); if (empty($_GET["fPrintTable"])) printf("%s\n", $menu); printf("

\n"); printf("

\n"); printf("\n"); printf("\n"); } ?>