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

Comparing projects/cms/source/reports/php/historical/browser.php (file contents):
Revision 1.7 by pjm2, Sun Feb 4 14:25:47 2001 UTC vs.
Revision 1.41 by tdb, Sat May 18 18:15:57 2002 UTC

# Line 1 | Line 1
1   <?php
2  
3 < // A test navigation thingy.
4 < // pjm2@ukc.ac.uk
3 > #
4 > # i-scream central monitoring system
5 > # Copyright (C) 2000-2002 i-scream
6 > #
7 > # This program is free software; you can redistribute it and/or
8 > # modify it under the terms of the GNU General Public License
9 > # as published by the Free Software Foundation; either version 2
10 > # of the License, or (at your option) any later version.
11 > #
12 > # This program is distributed in the hope that it will be useful,
13 > # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 > # GNU General Public License for more details.
16 > #
17 > # You should have received a copy of the GNU General Public License
18 > # along with this program; if not, write to the Free Software
19 > # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 > #
21  
22 + # Navigation for the i-scream reports.
23 + # pjm2@ukc.ac.uk
24 + #
25 + # CONFIGURABLE CONSTANTS: -
26  
27 < function getdirArray($dir='./',$sort='asort') {
28 <    global $dir_file_count;
29 <    if ( is_dir($dir) ) {
30 <        $fd = @opendir($dir);
31 <        while ( ($part = @readdir($fd)) == TRUE ) {
32 <            clearstatcache();
33 <            if ($part != "." && $part != "..") {
34 <                $dir_array[] = $part;
35 <            }
36 <        }
37 <        if($fd == TRUE) {
38 <            closedir($fd);
39 <        }
20 <        if (is_array($dir_array)) {
21 <            $sort($dir_array);
22 <            $dir_file_count = count($dir_array);
23 <            Return $dir_array;
24 <        } else {
25 <            Return FALSE;
26 <        }
27 <    } else {
28 <        Return FALSE;
27 > include("browser_config.inc.php");
28 >
29 > #
30 > # END CONFIGURATION
31 >
32 >
33 >
34 >
35 >
36 > # Used to return whether or not a report data file is empty.
37 > function isReportEmpty($filename, $minFileSize) {
38 >    if (filesize($filename) < $minFileSize) {
39 >        return TRUE;
40      }
41 +    return FALSE;
42   }
43  
32    include("day.inc");
44  
45 + include("iutils.inc.php");
46 +
47   ?>
48  
49 < <html>
37 < <body bgcolor="#ffffff">
49 > <? include($titleHTML); ?>
50  
51 < <table border="0" align="center" cellpadding="2" cellspacing="5">
40 < <tr>
41 <   <td valign="top">
42 <    <? include("left.inc"); ?>
43 <   </td>
44 <   <td>
45 <    <? include("title.inc"); ?>
51 > <hr weight="1" color="<? echo $lineColor ?>">
52  
53 + <b>Most recent reports available</b>
54 + <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
55 + <?
56  
57 <    <font face="arial, sans-serif" size="2">
58 <    <b>View reports for <? echo "$day" ?></b>
59 <    </font>
57 >    $file_array = getdirArray($reportDirectory,'rsort');
58 >    print "<select size=\"1\" name=\"day\">";
59 >    if ($day) { ?>
60 >        <option selected value="<? echo $day ?>"><? echo $day ?></option>
61 >        <option value="">----------------</option>
62 >    <? }
63 >    foreach($file_array as $file_name) {
64 >        #if (is_dir($file_name)) {
65 >        if (preg_match("/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/", $file_name)) {
66 >            $i++;
67 >            print "<option value=\"$file_name\">$file_name</option>";
68 >        }
69 >        if ($i >= $maxDaysShown) {
70 >            break;
71 >        }
72 >    }
73 >    print "</select>";
74  
75 <    <p>
75 > ?>
76 > <input type="submit" name="submit" value="Go">
77 > </form>
78  
79 <    <form method="GET" action="">
79 > <hr weight="1" color="<? echo $lineColor ?>">
80 >
81 > <? if ($day) { ?>
82 >
83 >    <b>Available reports for <? echo $day ?></b>
84 >
85 >    <form method="<? echo $formMethod ?>" action="<? echo $thisPage ?>">
86       <select size="1" name="machine_name">
87 <      <option selected value=""></option>
88 <      <? include("machine_name.inc"); ?>
87 >      <? if ($machine_name) { ?>
88 >        <option selected value="<? echo $machine_name ?>"><? echo $machine_name ?></option>
89 >        <option value="">----------------</option>
90 >      <? } else { ?>
91 >        <option selected value="">[select machine]</option>
92 >      <? } ?>
93 >      <? include("$reportDirectory/$day/$machineNameHTML"); ?>
94       </select>
95  
96       <select size="1" name="report">
97 <      <option selected value=""></option>
98 <      <? include("report.inc"); ?>
97 >      <? if ($report) { ?>
98 >        <option selected value="<? echo $report ?>"><? echo $report ?></option>
99 >        <option value="">----------------</option>
100 >      <? } else { ?>
101 >        <option selected value="">[select report]</option>
102 >      <? } ?>
103 >      <? include("$reportDirectory/$day/$reportHTML"); ?>
104       </select>
105  
106 <     <input type="submit" name="submit" value="bung">
106 >     <input type="hidden" name="day" value="<? echo $day ?>">
107 >     <input type="submit" name="submit" value="Show">
108      </form>
109 +    
110 +    <hr weight="1" color="<? echo $lineColor ?>">
111 +    
112 + <? } ?>
113  
114      </p>
115  
116  
117   <?
118 <    if ($submit == "bung") {
119 <        $url = escapeshellcmd("$day/$machine_name/$report/chart.gif");
120 <        if (file_exists($url)) {
121 <            echo "<p><b>[$machine_name] - $report</b><br><img src=\"$url\" width=\"500\" height=\"250\"><br><img src=\"24hour.gif\" width=\"500\" height=\"39\"></p>";
118 >    if ($submit == "Show" && $machine_name && $report) {
119 >        
120 >        $url = "$webRoot/$day/$machine_name/$report/$reportChartFile";
121 >        if (isReportEmpty("$reportDirectory/$day/$machine_name/$report/$reportChartDataFile", $minFileSize)) {
122 >            echo "Host <b>$machine_name</b> did not send any information about <b>$report</b> on <b>$day</b>.  Please select another report.";
123          }
124 <        else {
78 <            echo "<p>The report could not be found.</p>";
79 <        }
80 <    }
81 <    
82 < ?>
124 >        else if (file_exists("$reportDirectory/$day/$machine_name/$report/$reportChartFile")) {  
125  
126 < <hr>
126 >            include("$reportDirectory/$day/$machine_name/$report/$reportLimitsFile");
127 >            
128 >            ?>
129 >            
130 >            <center><b>[<? echo $machine_name; ?>] - <? echo $report; ?></b></center>
131 >          
132 >            <table border="0" cellpadding="0" cellspacing="0">
133 >             <tr>
134 >              <td align="right" valign="top">
135 >               <font size="2"><? printf("%.1f", $max_value);  ?></font>
136 >              </td>
137 >              <td rowspan="2">
138 >               <img src="<? echo $url; ?>" width="500" height="250">
139 >              </td>
140 >             </tr>
141 >             <tr>
142 >              <td align="right" valign="bottom">
143 >               <font size="2"><? echo $min_value; ?></font>
144 >              </td>
145 >             </tr>
146 >             <tr>
147 >              <td>&nbsp;</td>
148 >              <td><img src="<? echo $scaleImage ?>" width="500" height="39"></td>
149 >             </tr>
150 >            </table>
151 >            
152 >            <hr weight="1" color="<? echo $lineColor ?>">
153 >            
154 >            <b>Latest data</b>
155 >            <p>
156 >            Latest set of data received from
157 >            <a href="<? echo "latest.php?machine=$machine_name"; ?>"><?=$machine_name?></a>
158 >            <br>
159 >            Alerts for <a href="alerts.php?machine=<?=$machine_name?>"><?=$machine_name?></a>
160  
86 <p>
87 <font face="arial, sans-serif" size="2">
88 <b>Or browse all dates</b>
89 </font>
90 </p>
161  
162 < <?
163 <
164 <    $file_array = getdirArray('/home/cut/pjm2/webpages/reports','asort');
165 <    print "<ul>";
166 <    foreach($file_array as $file_name) {
167 <        if (is_dir($file_name)) {
168 <            print "<li><a href=\"$file_name\">$file_name</a>";
162 >            <hr weight="1" color="<? echo $lineColor ?>">
163 >            
164 >            <b>Extra data</b>
165 >            <p>
166 >            <a href="<? echo "$webRoot/$day/$machine_name/$report/$reportChartDataFile" ?>">Raw plot data</a><br>
167 >            <a href="<? echo "$webRoot/$day/$machine_name/$report/$reportChartFile" ?>">GIF chart</a><br>
168 >            <a href="<? echo "$webRoot/$day/$machine_name/$report/$reportLimitsFile" ?>">PHP y-axis limits include</a>
169 >            
170 >        <? }
171 >        else {
172 >            echo "<p>The report could not be found.  Somebody must have deleted it!</p>";
173          }
174 +        echo "<hr weight=\"1\" color=\"$lineColor\">";
175      }
176 <    print "</ul>";
102 <
176 >    
177   ?>
178  
179 < <? include("bottom.inc"); ?>
106 <
107 < </body>
108 < </html>
179 > <? include($bottomHTML); ?>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines