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.2
Committed: Thu Mar 8 21:40:45 2001 UTC (23 years, 8 months ago) by pjm2
Branch: MAIN
Changes since 1.1: +1 -1 lines
Log Message:
Modified the config so that the report data comes from the group file
space.  The latest.php file now also allows the report file name to be
configured... this is because Tim wrote the first lot with the wrong
filename ;)

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    
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     $i++;
114     print "<option value=\"$file_name\">$file_name</option>";
115     }
116     }
117     print "</select>";
118    
119     ?>
120     <input type="submit" name="submit" value="Display">
121     </form>
122    
123     <hr weight="1" color="<? echo $lineColor ?>">
124    
125     <? if ($machine) {
126    
127     # Read the file.
128     #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,";
129 pjm2 1.2 $input = file("$latestDirectory/$machine/$latestData");
130 pjm2 1.1 # All we need is the first line if there is more than one line.
131     $input = $input[0];
132    
133     if (empty($input)) {
134     echo "<br><br>There was an error reading from the latest packet received. Please notify your i-scream server administrator.";
135     }
136     else {
137     # Display the data specified in the display include.
138     include("latest_display.inc.php");
139     }
140     }
141    
142     ?>
143    
144    
145     <? include($bottomHTML); ?>