ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/php/latest/latest.php
(Generate patch)

Comparing projects/cms/source/reports/php/latest/latest.php (file contents):
Revision 1.1 by pjm2, Thu Mar 8 21:22:05 2001 UTC vs.
Revision 1.20 by pjm2, Tue Mar 13 20:08:53 2001 UTC

# Line 10 | Line 10 | include("latest_config.inc.php");
10   #
11   # END CONFIGURATION
12  
13 + include("iutils.inc.php");
14  
15 < # return an array of subdirectories from a directory.
16 < function getdirArray($dir='./',$sort='asort') {
17 <    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 <    }
15 > function printLine($title) {
16 >    echo "<hr style=\"color:#9999ff;\">";
17 >    echo "<b>$title</b>";
18   }
19  
20  
21   function showStat($title, $value, $input) {
22 <    preg_match("/$value=([^\,]*)\,/", $input, $matches);
22 >    preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches);
23      $value = $matches[1];
24      if (empty($value)) {
25 <        $value = "<i>unknown</i>";
25 >        $value = "<i><font color=\"#999999\">not sent</font></i>";
26      }
27      ?>
28          <table border="0" width="100%">
29            <tr>
30 <            <td width="50%" align="right"><b><?=$title?></b></td>
31 <            <td width="50%" align="left"><?=$value?></td>
30 >            <td width="50%" align="right" valign="top"><b><?=$title?></b></td>
31 >            <td width="50%" align="left" valign="top"><?=$value?></td>
32            </tr>
33          </table>
34      <?
35   }
36  
37  
38 + function linkToHistory($report) {
39 +    global $machine;
40 +    $yesterday = date("Y-m-d", time() - 86400);
41 +    echo <<<EOT
42 +        <a href="browser.php?machine_name=$machine&report=$report&day=$yesterday&submit=Show"><img src="historical.gif" width="20" height="20" border="0"></a>
43 + EOT;
44 + }
45 +
46 +
47   # show a bar-represented value.
48 < function showBar($title, $value, $max, $input) {
48 > function showBar($title, $value, $max, $units, $input) {
49  
50      include("latest_config.inc.php");
51  
# Line 73 | Line 62 | function showBar($title, $value, $max, $input) {
62      $width = intval($max_width * $value / $max);
63  
64      ?>
65 <        <table border="0" cellpadding="0" cellspacing="0">
65 >        <table border="0" cellpadding="0" cellspacing="0" align="center">
66            <tr>
67 <            <td colspan="2"><b><?=$title?></b></td>
67 >            <td colspan="2"><b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td>
68            </tr>
69            <tr>
70              <td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td>
# Line 84 | Line 73 | function showBar($title, $value, $max, $input) {
73              <td colspan="2"><img src="<?=$scaleImage?>" border="0" height="11" width="<?=$max_width?>"></td>
74            </tr>
75            <tr>
76 <            <td align="left">0</td>
77 <            <td align="right"><?=$max?></td>
76 >            <td align="left">0<?=$units?></td>
77 >            <td align="right"><?=$max?><?=$units?></td>
78            </tr>
79 +          <tr>
80 +            <td colspan="2">&nbsp;</td>
81 +          </tr>
82          </table>
83      <?
84   }
# Line 96 | Line 88 | function showBar($title, $value, $max, $input) {
88  
89   <? include($titleHTML); ?>
90  
91 < <hr weight="1" color="<? echo $lineColor ?>">
91 > <? printLine("Display the latest information received from a host"); ?>
92  
101 <b>Display the latest information received from a host</b>
93   <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
94   <?
95  
96 <    $file_array = getdirArray($latestDirectory,'rsort');
96 >    $file_array = getdirArray($latestDirectory,'asort');
97      print "<select size=\"1\" name=\"machine\">";
98      if ($machine) { ?>
99          <option selected value="<? echo $machine ?>"><? echo $machine ?></option>
100          <option value="">----------------</option>
101      <? }
102      foreach($file_array as $file_name) {
103 <        if (is_dir($file_name)) {
113 <            $i++;
103 >        #if (is_dir($file_name)) {
104              print "<option value=\"$file_name\">$file_name</option>";
105 <        }
105 >        #}
106      }
107      print "</select>";
108  
# Line 120 | Line 110 | function showBar($title, $value, $max, $input) {
110   <input type="submit" name="submit" value="Display">
111   </form>
112  
123 <hr weight="1" color="<? echo $lineColor ?>">
124
113   <? if ($machine) {
114  
115 +       $last_modified = filemtime("$latestDirectory/$machine/$latestData");
116 +       clearstatcache();
117 +       $data_age = time() - $last_modified;
118 +
119 +       $last_modified = date("l jS F - g:ia", $last_modified);
120 +
121 +       if ($data_age > $warning_age) {
122 +           $warning = <<<EOT
123 +               <br>
124 +               <font color="red"><b>
125 +                   Warning:
126 +               </b></font>
127 +                   This realtime report is too old to be considered recent
128 + EOT;
129 +       }
130 +
131 + echo <<<EOT
132 +       <table border="0" bgcolor="#000066" cellpadding="3" cellspacing="1">
133 +         <tr>
134 +           <td bgcolor="#000066">
135 +             &nbsp;
136 +           </td>
137 +           <td bgcolor="#ffffcc">
138 +             <font face="arial,sans-serif" size="2">
139 +               <b>Recipt date:</b> $last_modified
140 +               $warning
141 +             </font>
142 +           </td>
143 +         </tr>
144 +       </table>
145 + EOT;
146 +
147         # Read the file.
148         #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,";
149 <       $input = file("$latestDirectory/$machine/latest_data");
149 >       $input = file("$latestDirectory/$machine/$latestData");
150         # All we need is the first line if there is more than one line.
151         $input = $input[0];
152  
# Line 141 | Line 161 | function showBar($title, $value, $max, $input) {
161  
162   ?>
163  
164 + <? printLine(""); ?>
165  
166   <? include($bottomHTML); ?>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines