ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/php/latest/latest.php
Revision: 1.4
Committed: Thu Mar 8 21:55:49 2001 UTC (23 years, 3 months ago) by pjm2
Branch: MAIN
Changes since 1.3: +1 -1 lines
Log Message:
The preg_match on the packet data now matches with an optional "}" at the
end of a value such that the last item in a packet is never forgotten
about

File Contents

# Content
1 <?php
2
3 # Navigation for the i-scream reports.
4 # pjm2@ukc.ac.uk
5 #
6 # CONFIGURABLE CONSTANTS: -
7
8 include("latest_config.inc.php");
9
10 #
11 # END CONFIGURATION
12
13
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
40
41 function showStat($title, $value, $input) {
42 preg_match("/$value=([^\,]*)[\,|\}]/", $input, $matches);
43 $value = $matches[1];
44 if (empty($value)) {
45 $value = "<i>unknown</i>";
46 }
47 ?>
48 <table border="0" width="100%">
49 <tr>
50 <td width="50%" align="right"><b><?=$title?></b></td>
51 <td width="50%" align="left"><?=$value?></td>
52 </tr>
53 </table>
54 <?
55 }
56
57
58 # show a bar-represented value.
59 function showBar($title, $value, $max, $input) {
60
61 include("latest_config.inc.php");
62
63 preg_match("/$value=([^\,]*)\,/", $input, $matches);
64 $value = $matches[1];
65 if (!is_int($max)) {
66 preg_match("/$max=([^\,]*)\,/", $input, $matches);
67 $max = $matches[1];
68 }
69 if (empty($value) || empty($max)) {
70 return;
71 }
72
73 $width = intval($max_width * $value / $max);
74
75 ?>
76 <table border="0" cellpadding="0" cellspacing="0">
77 <tr>
78 <td colspan="2"><b><?=$title?></b></td>
79 </tr>
80 <tr>
81 <td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td>
82 </tr>
83 <tr>
84 <td colspan="2"><img src="<?=$scaleImage?>" border="0" height="11" width="<?=$max_width?>"></td>
85 </tr>
86 <tr>
87 <td align="left">0</td>
88 <td align="right"><?=$max?></td>
89 </tr>
90 </table>
91 <?
92 }
93
94
95 ?>
96
97 <? include($titleHTML); ?>
98
99 <hr weight="1" color="<? echo $lineColor ?>">
100
101 <b>Display the latest information received from a host</b>
102 <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
103 <?
104
105 $file_array = getdirArray($latestDirectory,'rsort');
106 print "<select size=\"1\" name=\"machine\">";
107 if ($machine) { ?>
108 <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
109 <option value="">----------------</option>
110 <? }
111 foreach($file_array as $file_name) {
112 #if (is_dir($file_name)) {
113 print "<option value=\"$file_name\">$file_name</option>";
114 #}
115 }
116 print "</select>";
117
118 ?>
119 <input type="submit" name="submit" value="Display">
120 </form>
121
122 <hr weight="1" color="<? echo $lineColor ?>">
123
124 <? if ($machine) {
125
126 # Read the file.
127 #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,";
128 $input = file("$latestDirectory/$machine/$latestData");
129 # All we need is the first line if there is more than one line.
130 $input = $input[0];
131
132 if (empty($input)) {
133 echo "<br><br>There was an error reading from the latest packet received. Please notify your i-scream server administrator.";
134 }
135 else {
136 # Display the data specified in the display include.
137 include("latest_display.inc.php");
138 }
139 }
140
141 ?>
142
143
144 <? include($bottomHTML); ?>