1 |
|
<?php |
2 |
|
|
3 |
< |
// A test navigation thingy. |
3 |
> |
// Navigation for the i-scream reports. |
4 |
|
// pjm2@ukc.ac.uk |
5 |
|
|
6 |
+ |
# CONSTANTS |
7 |
|
|
8 |
+ |
$minFileSize = 33; |
9 |
+ |
|
10 |
+ |
|
11 |
+ |
function isReportEmpty($filename) { |
12 |
+ |
if (filesize($filename) < minFileSize) { |
13 |
+ |
return TRUE; |
14 |
+ |
} |
15 |
+ |
return FALSE; |
16 |
+ |
} |
17 |
+ |
|
18 |
|
function getdirArray($dir='./',$sort='asort') { |
19 |
|
global $dir_file_count; |
20 |
|
if ( is_dir($dir) ) { |
40 |
|
} |
41 |
|
} |
42 |
|
|
32 |
– |
include("day.inc"); |
33 |
– |
|
43 |
|
?> |
44 |
|
|
45 |
< |
<html> |
37 |
< |
<body bgcolor="#ffffff"> |
45 |
> |
<? include("title.inc"); ?> |
46 |
|
|
47 |
< |
<table border="0" align="center" cellpadding="2" cellspacing="5"> |
40 |
< |
<tr> |
41 |
< |
<td valign="top"> |
42 |
< |
<? include("left.inc"); ?> |
43 |
< |
</td> |
44 |
< |
<td> |
45 |
< |
<? include("title.inc"); ?> |
47 |
> |
<hr weight="1" color="#9999ff"> |
48 |
|
|
49 |
+ |
<b>Most recent reports available</b> |
50 |
+ |
<form method="GET" action="browser.php"> |
51 |
+ |
<? |
52 |
|
|
53 |
< |
<font face="arial, sans-serif" size="2"> |
54 |
< |
<b>View reports for <? echo "$day" ?></b> |
55 |
< |
</font> |
53 |
> |
$file_array = getdirArray('/home/cut/pjm2/webpages/reports','rsort'); |
54 |
> |
print "<select size=\"1\" name=\"day\">"; |
55 |
> |
foreach($file_array as $file_name) { |
56 |
> |
if (is_dir($file_name)) { |
57 |
> |
$i++; |
58 |
> |
print "<option value=\"$file_name\">$file_name</option>"; |
59 |
> |
} |
60 |
> |
if ($i >= 20) { |
61 |
> |
break; |
62 |
> |
} |
63 |
> |
} |
64 |
> |
print "</select>"; |
65 |
|
|
66 |
< |
<p> |
66 |
> |
?> |
67 |
> |
<input type="submit" name="submit" value="Go"> |
68 |
> |
</form> |
69 |
|
|
70 |
< |
<form method="GET" action=""> |
70 |
> |
<hr weight="1" color="#9999ff"> |
71 |
> |
|
72 |
> |
<? if ($day) { ?> |
73 |
> |
|
74 |
> |
<b>Available reports for <? echo $day ?></b> |
75 |
> |
|
76 |
> |
<form method="GET" action="browser.php"> |
77 |
|
<select size="1" name="machine_name"> |
78 |
< |
<option selected value="">[select machine]</option> |
79 |
< |
<? include("machine_name.inc"); ?> |
78 |
> |
<? if ($machine_name) { ?> |
79 |
> |
<option selected value="<? echo $machine_name ?>"><? echo $machine_name ?></option> |
80 |
> |
<option value="">----------------</option> |
81 |
> |
<? } else { ?> |
82 |
> |
<option selected value="">[select machine]</option> |
83 |
> |
<? } ?> |
84 |
> |
<? include("$day/machine_name.inc"); ?> |
85 |
|
</select> |
86 |
|
|
87 |
|
<select size="1" name="report"> |
88 |
< |
<option selected value="">[select report]</option> |
89 |
< |
<? include("report.inc"); ?> |
88 |
> |
<? if ($report) { ?> |
89 |
> |
<option selected value="<? echo $report ?>"><? echo $report ?></option> |
90 |
> |
<option value="">----------------</option> |
91 |
> |
<? } else { ?> |
92 |
> |
<option selected value="">[select report]</option> |
93 |
> |
<? } ?> |
94 |
> |
<? include("$day/report.inc"); ?> |
95 |
|
</select> |
96 |
|
|
97 |
+ |
<input type="hidden" name="day" value="<? echo $day ?>"> |
98 |
|
<input type="submit" name="submit" value="Show"> |
99 |
|
</form> |
100 |
+ |
|
101 |
+ |
<hr weight="1" color="#9999ff"> |
102 |
+ |
|
103 |
+ |
<? } ?> |
104 |
|
|
105 |
|
</p> |
106 |
|
|
107 |
|
|
108 |
|
<? |
109 |
|
if ($submit == "Show" && $machine_name && $report) { |
110 |
< |
$url = escapeshellcmd("$day/$machine_name/$report/chart.gif"); |
111 |
< |
if (file_exists($url)) { |
112 |
< |
echo "<p><b>[$machine_name] - $report</b><br><img src=\"$url\" width=\"500\" height=\"250\"><br><img src=\"24hour.gif\" width=\"500\" height=\"39\"></p>"; |
110 |
> |
|
111 |
> |
include("$day/$machine_name/$report/i-maxmin.txt"); |
112 |
> |
|
113 |
> |
$url = escapeshellcmd("$day/$machine_name/$report/i-chart.gif"); |
114 |
> |
if (isReportEmpty("$day/$machine_name/$report/i-data.txt")) { |
115 |
> |
echo "Host <b>$machine_name</b> did not send any information about <b>$report</b> on <b>$day</b>. Please select another report."; |
116 |
|
} |
117 |
+ |
else if (file_exists($url)) { ?> |
118 |
+ |
|
119 |
+ |
<center><b>[<? echo $machine_name; ?>] - <? echo $report; ?></b></center> |
120 |
+ |
|
121 |
+ |
<table border="0" cellpadding="0" cellspacing="0"> |
122 |
+ |
<tr> |
123 |
+ |
<td align="right" valign="top"> |
124 |
+ |
<font size="2"><? printf("%.1f", $max_value); ?></font> |
125 |
+ |
</td> |
126 |
+ |
<td rowspan="2"> |
127 |
+ |
<img src="<? echo $url; ?>" width="500" height="250"> |
128 |
+ |
</td> |
129 |
+ |
</tr> |
130 |
+ |
<tr> |
131 |
+ |
<td align="right" valign="bottom"> |
132 |
+ |
<font size="2"><? echo $min_value; ?></font> |
133 |
+ |
</td> |
134 |
+ |
</tr> |
135 |
+ |
<tr> |
136 |
+ |
<td> </td> |
137 |
+ |
<td><img src="24hour.gif" width="500" height="39"></td> |
138 |
+ |
</tr> |
139 |
+ |
</table> |
140 |
+ |
|
141 |
+ |
<hr weigth="1" color="#9999ff"> |
142 |
+ |
|
143 |
+ |
<b>Extra data</b> |
144 |
+ |
<p> |
145 |
+ |
<a href="<? echo "$day/$machine_name/$report/i-data.txt" ?>">Raw plot data</a><br> |
146 |
+ |
<a href="<? echo "$day/$machine_name/$report/i-chart.gif" ?>">GIF chart</a><br> |
147 |
+ |
<a href="<? echo "$day/$machine_name/$report/i-maxmin.txt" ?>">PHP y-axis limits include</a> |
148 |
+ |
|
149 |
+ |
<? } |
150 |
|
else { |
151 |
< |
echo "<p>The report could not be found.</p>"; |
151 |
> |
echo "<p>The report could not be found. Somebody must have deleted it!</p>"; |
152 |
|
} |
153 |
+ |
echo "<hr weight=\"1\" color=\"#9999ff\">"; |
154 |
|
} |
155 |
|
|
156 |
|
?> |
157 |
|
|
84 |
– |
<hr> |
85 |
– |
|
86 |
– |
<p> |
87 |
– |
<font face="arial, sans-serif" size="2"> |
88 |
– |
<b>Or browse all dates</b> |
89 |
– |
</font> |
90 |
– |
</p> |
91 |
– |
|
92 |
– |
<? |
93 |
– |
|
94 |
– |
$file_array = getdirArray('/home/cut/pjm2/webpages/reports','rsort'); |
95 |
– |
print "<ul>"; |
96 |
– |
foreach($file_array as $file_name) { |
97 |
– |
if (is_dir($file_name)) { |
98 |
– |
print "<li><a href=\"$file_name\">$file_name</a>"; |
99 |
– |
} |
100 |
– |
} |
101 |
– |
print "</ul>"; |
102 |
– |
|
103 |
– |
?> |
104 |
– |
|
158 |
|
<? include("bottom.inc"); ?> |
106 |
– |
|
107 |
– |
</body> |
108 |
– |
</html> |