# | Line 10 | Line 10 | include("latest_config.inc.php"); | |
---|---|---|
10 | # | |
11 | # END CONFIGURATION | |
12 | ||
13 | + | include("iutils.inc.php"); |
14 | ||
14 | – | # return an array of subdirectories from a directory. |
15 | – | function getdirArray($dir='./',$sort='asort') { |
16 | – | global $dir_file_count; |
17 | – | if ( is_dir($dir) ) { |
18 | – | $fd = @opendir($dir); |
19 | – | while ( ($part = @readdir($fd)) == TRUE ) { |
20 | – | clearstatcache(); |
21 | – | if ($part != "." && $part != "..") { |
22 | – | $dir_array[] = $part; |
23 | – | } |
24 | – | } |
25 | – | if($fd == TRUE) { |
26 | – | closedir($fd); |
27 | – | } |
28 | – | if (is_array($dir_array)) { |
29 | – | $sort($dir_array); |
30 | – | $dir_file_count = count($dir_array); |
31 | – | Return $dir_array; |
32 | – | } else { |
33 | – | Return FALSE; |
34 | – | } |
35 | – | } else { |
36 | – | Return FALSE; |
37 | – | } |
38 | – | } |
39 | – | |
15 | function printLine($title) { | |
16 | < | echo "<hr color=\"#9999ff\">"; |
16 | > | echo "<hr style=\"color:#9999ff;\">"; |
17 | echo "<b>$title</b>"; | |
18 | } | |
19 | ||
20 | ||
21 | function showStat($title, $value, $input) { | |
22 | + | |
23 | + | $report = $value; |
24 | + | |
25 | preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches); | |
26 | $value = $matches[1]; | |
27 | if (empty($value)) { | |
# | Line 52 | Line 30 | function showStat($title, $value, $input) { | |
30 | ?> | |
31 | <table border="0" width="100%"> | |
32 | <tr> | |
33 | < | <td width="50%" align="right" valign="top"><b><?=$title?></b></td> |
34 | < | <td width="50%" align="left" valign="top"><?=$value?></td> |
33 | > | <td width="50%" align="right" valign="top"> |
34 | > | <b><?=$title?></b> |
35 | > | </td> |
36 | > | <td width="50%" align="left" valign="top"> |
37 | > | <? if (preg_match("/^[0-9]+\.?[0-9]*$/", $value)) { |
38 | > | linkToHistory($report); |
39 | > | } ?> |
40 | > | <?=$value?></td> |
41 | </tr> | |
42 | </table> | |
43 | <? | |
44 | } | |
45 | ||
46 | ||
47 | + | function linkToHistory($report) { |
48 | + | global $machine; |
49 | + | $yesterday = date("Y-m-d", time() - 86400); |
50 | + | echo <<<EOT |
51 | + | <a href="browser.php?machine_name=$machine&report=$report&day=$yesterday&submit=Show"><img src="minichart.gif" alt="View yesterday's 24-hour chart" width="20" height="20" border="0"></a> |
52 | + | EOT; |
53 | + | } |
54 | + | |
55 | + | |
56 | # show a bar-represented value. | |
57 | < | function showBar($title, $value, $max, $units, $input) { |
57 | > | function showBar($title, $value, $max, $units, $input, $arrange='normal') { |
58 | ||
59 | include("latest_config.inc.php"); | |
60 | ||
61 | + | $report = $value; |
62 | + | |
63 | preg_match("/$value=([^\,]*)\,/", $input, $matches); | |
64 | $value = $matches[1]; | |
65 | if (!is_int($max)) { | |
# | Line 75 | Line 70 | function showBar($title, $value, $max, $units, $input) | |
70 | return; | |
71 | } | |
72 | ||
73 | + | if ($arrange == 'swap') { |
74 | + | $value = $max - $value; |
75 | + | } |
76 | + | |
77 | $width = intval($max_width * $value / $max); | |
78 | ||
79 | ?> | |
80 | <table border="0" cellpadding="0" cellspacing="0" align="center"> | |
81 | <tr> | |
82 | < | <td colspan="2"><b><?=$title?></b></td> |
82 | > | <td colspan="2"><? linkToHistory($report); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td> |
83 | </tr> | |
84 | <tr> | |
85 | <td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td> | |
# | Line 92 | Line 91 | function showBar($title, $value, $max, $units, $input) | |
91 | <td align="left">0<?=$units?></td> | |
92 | <td align="right"><?=$max?><?=$units?></td> | |
93 | </tr> | |
94 | + | <tr> |
95 | + | <td colspan="2"> </td> |
96 | + | </tr> |
97 | </table> | |
98 | <? | |
99 | } | |
# | Line 123 | Line 125 | function showBar($title, $value, $max, $units, $input) | |
125 | <input type="submit" name="submit" value="Display"> | |
126 | </form> | |
127 | ||
126 | – | <hr weight="1" color="<? echo $lineColor ?>"> |
127 | – | |
128 | <? if ($machine) { | |
129 | ||
130 | $last_modified = filemtime("$latestDirectory/$machine/$latestData"); | |
131 | clearstatcache(); | |
132 | $data_age = time() - $last_modified; | |
133 | ||
134 | < | $last_modified = strftime("%a %d %b %Y at %T", $last_modified); |
134 | > | $last_modified = date("l jS F - g:ia", $last_modified); |
135 | ||
136 | if ($data_age > $warning_age) { | |
137 | $warning = <<<EOT | |
# | Line 144 | Line 144 | EOT; | |
144 | } | |
145 | ||
146 | echo <<<EOT | |
147 | < | <table border="0" bgcolor="#000066" cellpadding="3" cellspacing="1" align="center"> |
147 | > | <table border="0" bgcolor="#000066" cellpadding="3" cellspacing="1"> |
148 | <tr> | |
149 | <td bgcolor="#000066"> | |
150 | | |
151 | </td> | |
152 | <td bgcolor="#ffffcc"> | |
153 | <font face="arial,sans-serif" size="2"> | |
154 | < | <b>Recipt date:</b> $last_modified |
154 | > | <b>Receipt date:</b> $last_modified |
155 | $warning | |
156 | </font> | |
157 | </td> | |
# | Line 160 | Line 160 | echo <<<EOT | |
160 | EOT; | |
161 | ||
162 | # Read the file. | |
163 | < | #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,"; |
164 | < | $input = file("$latestDirectory/$machine/$latestData"); |
165 | < | # All we need is the first line if there is more than one line. |
166 | < | $input = $input[0]; |
163 | > | if (file_exists("$latestDirectory/$machine/$latestData")) { |
164 | > | $input = file("$latestDirectory/$machine/$latestData"); |
165 | > | # All we need is the first line if there is more than one line. |
166 | > | $input = $input[0]; |
167 | > | } |
168 | ||
169 | if (empty($input)) { | |
170 | < | echo "<br><br>There was an error reading from the latest packet received. Please notify your i-scream server administrator."; |
170 | > | echo "<br><br>There are currently no latest details about <b>$machine</b>. Please notify your i-scream server administrator if you believe this to be incorrect."; |
171 | } | |
172 | else { | |
173 | # Display the data specified in the display include. | |
174 | include("latest_display.inc.php"); | |
175 | } | |
175 | – | |
176 | – | printLine(""); |
176 | } | |
177 | ||
178 | ?> | |
179 | ||
180 | + | <? printLine(""); ?> |
181 | ||
182 | <? include($bottomHTML); ?> |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |