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.19
Committed: Tue Mar 13 19:57:51 2001 UTC (23 years, 3 months ago) by pjm2
Branch: MAIN
Changes since 1.18: +1 -1 lines
Log Message:
Used a style for the color of lines, as the color attribute is not a valid HTML4 attribute

File Contents

# User Rev Content
1 pjm2 1.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 pjm2 1.18 include("iutils.inc.php");
14 pjm2 1.1
15 pjm2 1.9 function printLine($title) {
16 pjm2 1.19 echo "<hr style=\"color:#9999ff;\">";
17 pjm2 1.9 echo "<b>$title</b>";
18 pjm2 1.6 }
19    
20 pjm2 1.1
21     function showStat($title, $value, $input) {
22 pjm2 1.7 preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches);
23 pjm2 1.1 $value = $matches[1];
24     if (empty($value)) {
25 pjm2 1.8 $value = "<i><font color=\"#999999\">not sent</font></i>";
26 pjm2 1.1 }
27     ?>
28     <table border="0" width="100%">
29     <tr>
30 pjm2 1.12 <td width="50%" align="right" valign="top"><b><?=$title?></b></td>
31     <td width="50%" align="left" valign="top"><?=$value?></td>
32 pjm2 1.1 </tr>
33     </table>
34     <?
35     }
36    
37    
38     # show a bar-represented value.
39 pjm2 1.13 function showBar($title, $value, $max, $units, $input) {
40 pjm2 1.1
41     include("latest_config.inc.php");
42    
43     preg_match("/$value=([^\,]*)\,/", $input, $matches);
44     $value = $matches[1];
45     if (!is_int($max)) {
46     preg_match("/$max=([^\,]*)\,/", $input, $matches);
47     $max = $matches[1];
48     }
49     if (empty($value) || empty($max)) {
50     return;
51     }
52    
53     $width = intval($max_width * $value / $max);
54    
55     ?>
56 pjm2 1.10 <table border="0" cellpadding="0" cellspacing="0" align="center">
57 pjm2 1.1 <tr>
58 pjm2 1.14 <td colspan="2"><b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td>
59 pjm2 1.1 </tr>
60     <tr>
61     <td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td>
62     </tr>
63     <tr>
64     <td colspan="2"><img src="<?=$scaleImage?>" border="0" height="11" width="<?=$max_width?>"></td>
65     </tr>
66     <tr>
67 pjm2 1.13 <td align="left">0<?=$units?></td>
68     <td align="right"><?=$max?><?=$units?></td>
69 pjm2 1.1 </tr>
70 pjm2 1.15 <tr>
71     <td colspan="2">&nbsp;</td>
72     </tr>
73 pjm2 1.1 </table>
74     <?
75     }
76    
77    
78     ?>
79    
80     <? include($titleHTML); ?>
81    
82 pjm2 1.12 <? printLine("Display the latest information received from a host"); ?>
83 pjm2 1.1
84     <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
85     <?
86    
87 pjm2 1.5 $file_array = getdirArray($latestDirectory,'asort');
88 pjm2 1.1 print "<select size=\"1\" name=\"machine\">";
89     if ($machine) { ?>
90     <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
91     <option value="">----------------</option>
92     <? }
93     foreach($file_array as $file_name) {
94 pjm2 1.3 #if (is_dir($file_name)) {
95 pjm2 1.1 print "<option value=\"$file_name\">$file_name</option>";
96 pjm2 1.3 #}
97 pjm2 1.1 }
98     print "</select>";
99    
100     ?>
101     <input type="submit" name="submit" value="Display">
102     </form>
103    
104     <? if ($machine) {
105    
106 pjm2 1.12 $last_modified = filemtime("$latestDirectory/$machine/$latestData");
107     clearstatcache();
108     $data_age = time() - $last_modified;
109    
110 pjm2 1.17 $last_modified = date("l jS F - g:ia", $last_modified);
111 pjm2 1.12
112     if ($data_age > $warning_age) {
113     $warning = <<<EOT
114     <br>
115     <font color="red"><b>
116     Warning:
117     </b></font>
118     This realtime report is too old to be considered recent
119     EOT;
120     }
121    
122     echo <<<EOT
123 pjm2 1.16 <table border="0" bgcolor="#000066" cellpadding="3" cellspacing="1">
124 pjm2 1.12 <tr>
125     <td bgcolor="#000066">
126     &nbsp;
127     </td>
128     <td bgcolor="#ffffcc">
129     <font face="arial,sans-serif" size="2">
130     <b>Recipt date:</b> $last_modified
131     $warning
132     </font>
133     </td>
134     </tr>
135     </table>
136     EOT;
137    
138 pjm2 1.1 # Read the file.
139     #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,";
140 pjm2 1.2 $input = file("$latestDirectory/$machine/$latestData");
141 pjm2 1.1 # All we need is the first line if there is more than one line.
142     $input = $input[0];
143    
144     if (empty($input)) {
145     echo "<br><br>There was an error reading from the latest packet received. Please notify your i-scream server administrator.";
146     }
147     else {
148     # Display the data specified in the display include.
149     include("latest_display.inc.php");
150     }
151 pjm2 1.9 }
152 pjm2 1.12
153 pjm2 1.1 ?>
154    
155 pjm2 1.16 <? printLine(""); ?>
156 pjm2 1.1
157     <? include($bottomHTML); ?>