1 |
|
<?php |
2 |
|
|
3 |
< |
// Navigation for the i-scream reports. |
4 |
< |
// pjm2@ukc.ac.uk |
3 |
> |
# Navigation for the i-scream reports. |
4 |
> |
# pjm2@ukc.ac.uk |
5 |
> |
# |
6 |
> |
# CONFIGURABLE CONSTANTS |
7 |
> |
# |
8 |
|
|
9 |
+ |
# The report directory, and the number of days to display. |
10 |
+ |
$reportDirectory = "/home/cut/pjm2/webpages/reports"; |
11 |
+ |
$maxDaysShown = 7; |
12 |
|
|
13 |
+ |
# Page appearance. |
14 |
+ |
$scaleImage = "24hour.gif"; |
15 |
+ |
$lineColor = "#9999ff"; |
16 |
+ |
|
17 |
+ |
# Files to include |
18 |
+ |
$titleHTML = "title.inc"; |
19 |
+ |
$bottomHTML = "bottom.inc"; |
20 |
+ |
$machineNameHTML = "machine_name.inc"; |
21 |
+ |
$reportHTML = "report.inc"; |
22 |
+ |
|
23 |
+ |
# What are the names of the report files? |
24 |
+ |
$reportLimitsFile = "i-maxmin.txt"; |
25 |
+ |
$reportChartFile = "i-chart.gif"; |
26 |
+ |
$reportChartDataFile = "i-data.txt"; |
27 |
+ |
|
28 |
+ |
# Submission details. |
29 |
+ |
$formMethod = "GET"; |
30 |
+ |
$thisPage = "browser.php"; |
31 |
+ |
|
32 |
+ |
# Leave this alone unless you know what you're doing ;) |
33 |
+ |
$minFileSize = 33; |
34 |
+ |
|
35 |
+ |
# |
36 |
+ |
# END CONFIGURATION |
37 |
+ |
|
38 |
+ |
|
39 |
+ |
function isReportEmpty($filename) { |
40 |
+ |
if (filesize($filename) < minFileSize) { |
41 |
+ |
return TRUE; |
42 |
+ |
} |
43 |
+ |
return FALSE; |
44 |
+ |
} |
45 |
+ |
|
46 |
|
function getdirArray($dir='./',$sort='asort') { |
47 |
|
global $dir_file_count; |
48 |
|
if ( is_dir($dir) ) { |
70 |
|
|
71 |
|
?> |
72 |
|
|
73 |
< |
<? include("title.inc"); ?> |
73 |
> |
<? include($titleHTML); ?> |
74 |
|
|
75 |
< |
<hr weight="1" color="#9999ff"> |
75 |
> |
<hr weight="1" color="<? echo $lineColor ?>"> |
76 |
|
|
77 |
|
<b>Most recent reports available</b> |
78 |
|
<form method="GET" action="browser.php"> |
79 |
|
<? |
80 |
|
|
81 |
< |
$file_array = getdirArray('/home/cut/pjm2/webpages/reports','rsort'); |
81 |
> |
$file_array = getdirArray($reportDirectory,'rsort'); |
82 |
|
print "<select size=\"1\" name=\"day\">"; |
83 |
|
foreach($file_array as $file_name) { |
84 |
|
if (is_dir($file_name)) { |
85 |
|
$i++; |
86 |
|
print "<option value=\"$file_name\">$file_name</option>"; |
87 |
|
} |
88 |
< |
if ($i >= 20) { |
88 |
> |
if ($i >= $maxDaysShown) { |
89 |
|
break; |
90 |
|
} |
91 |
|
} |
95 |
|
<input type="submit" name="submit" value="Go"> |
96 |
|
</form> |
97 |
|
|
98 |
< |
<hr weight="1" color="#9999ff"> |
98 |
> |
<hr weight="1" color="<? echo $lineColor ?>"> |
99 |
|
|
100 |
|
<? if ($day) { ?> |
101 |
|
|
103 |
|
|
104 |
|
<form method="GET" action="browser.php"> |
105 |
|
<select size="1" name="machine_name"> |
106 |
< |
<option selected value="">[select machine]</option> |
106 |
> |
<? if ($machine_name) { ?> |
107 |
> |
<option selected value="<? echo $machine_name ?>"><? echo $machine_name ?></option> |
108 |
> |
<option value="">----------------</option> |
109 |
> |
<? } else { ?> |
110 |
> |
<option selected value="">[select machine]</option> |
111 |
> |
<? } ?> |
112 |
|
<? include("$day/machine_name.inc"); ?> |
113 |
|
</select> |
114 |
|
|
115 |
|
<select size="1" name="report"> |
116 |
< |
<option selected value="">[select report]</option> |
116 |
> |
<? if ($report) { ?> |
117 |
> |
<option selected value="<? echo $report ?>"><? echo $report ?></option> |
118 |
> |
<option value="">----------------</option> |
119 |
> |
<? } else { ?> |
120 |
> |
<option selected value="">[select report]</option> |
121 |
> |
<? } ?> |
122 |
|
<? include("$day/report.inc"); ?> |
123 |
|
</select> |
124 |
|
|
126 |
|
<input type="submit" name="submit" value="Show"> |
127 |
|
</form> |
128 |
|
|
129 |
< |
<hr weight="1" color="#9999ff"> |
129 |
> |
<hr weight="1" color="<? echo $lineColor ?>"> |
130 |
|
|
131 |
|
<? } ?> |
132 |
|
|
139 |
|
include("$day/$machine_name/$report/i-maxmin.txt"); |
140 |
|
|
141 |
|
$url = escapeshellcmd("$day/$machine_name/$report/i-chart.gif"); |
142 |
< |
if (file_exists($url)) { ?> |
142 |
> |
if (isReportEmpty("$day/$machine_name/$report/i-data.txt")) { |
143 |
> |
echo "Host <b>$machine_name</b> did not send any information about <b>$report</b> on <b>$day</b>. Please select another report."; |
144 |
> |
} |
145 |
> |
else if (file_exists($url)) { ?> |
146 |
|
|
147 |
|
<center><b>[<? echo $machine_name; ?>] - <? echo $report; ?></b></center> |
148 |
|
|
162 |
|
</tr> |
163 |
|
<tr> |
164 |
|
<td> </td> |
165 |
< |
<td><img src="24hour.gif" width="500" height="39"></td> |
165 |
> |
<td><img src="<? echo $scaleImage ?>" width="500" height="39"></td> |
166 |
|
</tr> |
167 |
|
</table> |
168 |
|
|
169 |
< |
<hr weigth="1" color="#9999ff"> |
169 |
> |
<hr weigth="1" color="<? echo $lineColor ?>"> |
170 |
|
|
171 |
|
<b>Extra data</b> |
172 |
|
<p> |
176 |
|
|
177 |
|
<? } |
178 |
|
else { |
179 |
< |
echo "<p>The report could not be found.</p>"; |
179 |
> |
echo "<p>The report could not be found. Somebody must have deleted it!</p>"; |
180 |
|
} |
181 |
< |
echo "<hr weight=\"1\" color=\"#9999ff\">"; |
181 |
> |
echo "<hr weight=\"1\" color=\"$lineColor\">"; |
182 |
|
} |
183 |
|
|
184 |
|
?> |
185 |
|
|
186 |
< |
<? include("bottom.inc"); ?> |
186 |
> |
<? include("bottom.inc"); ?> |