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.27 by pjm2, Sat Mar 17 22:03:33 2001 UTC vs.
Revision 1.41 by tdb, Tue May 21 16:47:15 2002 UTC

# Line 1 | Line 1
1   <?php
2  
3 + #
4 + # i-scream central monitoring system
5 + # http://www.i-scream.org.uk
6 + # Copyright (C) 2000-2002 i-scream
7 + #
8 + # This program is free software; you can redistribute it and/or
9 + # modify it under the terms of the GNU General Public License
10 + # as published by the Free Software Foundation; either version 2
11 + # of the License, or (at your option) any later version.
12 + #
13 + # This program is distributed in the hope that it will be useful,
14 + # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 + # GNU General Public License for more details.
17 + #
18 + # You should have received a copy of the GNU General Public License
19 + # along with this program; if not, write to the Free Software
20 + # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 + #
22 +
23   # Navigation for the i-scream reports.
24   # pjm2@ukc.ac.uk
25   #
# Line 22 | Line 42 | function showStat($title, $value, $input) {
42  
43      $report = $value;
44  
45 <    preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches);
46 <    $value = $matches[1];
27 <    if (empty($value)) {
45 >    $value = getPregMatch($value, $input);
46 >    if (!isset($value)) {
47          $value = "<i><font color=\"#999999\">not sent</font></i>";
48      }
49      ?>
# Line 53 | Line 72 | EOT;
72   }
73  
74  
75 + # show all disk information.
76 + function showDisks($diskRoot, $units, $input) {
77 +    include("latest_config.inc.php");
78 +
79 +    $i = 0;
80 +    while(1) {
81 +        $name = getPregMatch("$diskRoot.p$i.attributes.name", $input);
82 +        $mount = getPregMatch("$diskRoot.p$i.attributes.mount", $input);
83 +        if ($name || $mount) {
84 +            $used = "$diskRoot.p$i.attributes.used";
85 +            $kbytes = "$diskRoot.p$i.attributes.kbytes";
86 +            showBar("$name<br>($mount)", $used, $kbytes, $units, $input);
87 +        }
88 +        else {
89 +            break;
90 +        }
91 +        $i++;
92 +    }
93 + }
94 +
95 + # Return a preg_match result.
96 + function getPregMatch($value, $input) {
97 +    preg_match("/$value=([^\,\}]*)[\,\}]/", $input, $matches);
98 +    return $matches[1];
99 + }
100 +
101 +
102   # show a bar-represented value.
103   function showBar($title, $value, $max, $units, $input, $arrange='normal') {
104  
# Line 60 | Line 106 | function showBar($title, $value, $max, $units, $input,
106  
107      $report = $value;
108  
109 <    preg_match("/$value=([^\,]*)\,/", $input, $matches);
64 <    $value = $matches[1];
109 >    $value = getPregMatch($value, $input);
110      if (!is_int($max)) {
111 <        preg_match("/$max=([^\,]*)\,/", $input, $matches);
67 <        $max = $matches[1];
111 >        $max = getPregMatch($max, $input);
112      }
113 <    if (empty($value) || empty($max)) {
113 >    if (!isset($value) || !isset($max)) {
114          return;
115      }
116  
# Line 74 | Line 118 | function showBar($title, $value, $max, $units, $input,
118          $value = $max - $value;
119      }
120  
121 <    $width = intval($max_width * $value / $max);
121 >    if(empty($max)) {
122 >        $width = 1;
123 >    }
124 >    else {
125 >        $width = intval($max_width * $value / $max);
126 >        if ($width < 1) {
127 >            $width = 1;
128 >        }
129 >    }
130  
131      ?>
132          <table border="0" cellpadding="0" cellspacing="0" align="center">
# Line 131 | Line 183 | function showBar($title, $value, $max, $units, $input,
183         clearstatcache();
184         $data_age = time() - $last_modified;
185  
186 <       $last_modified = date("l jS F - g:ia", $last_modified);
186 >       $last_modified = date("l jS F Y - g:ia", $last_modified);
187  
188         if ($data_age > $warning_age) {
189             $warning = <<<EOT
# Line 166 | Line 218 | EOT;
218             $input = $input[0];
219         }
220  
221 <       if (empty($input)) {
221 >       if (!isset($input)) {
222             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.";
223         }
224         else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines