ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/php/historical/browser.php
Revision: 1.19
Committed: Fri Mar 2 09:41:49 2001 UTC (23 years, 3 months ago) by pjm2
Branch: MAIN
Changes since 1.18: +5 -5 lines
Log Message:
Colour of separator lines may now be configured.  This works only in newer
browsers, however, the colour is not crucial to the operation of the
reports and they thus work (and look) fine even in Netscape 3.

File Contents

# User Rev Content
1 pjm2 1.1 <?php
2    
3 pjm2 1.16 # Navigation for the i-scream reports.
4     # pjm2@ukc.ac.uk
5     #
6     # CONFIGURABLE CONSTANTS
7     #
8    
9     # The report directory, and the number of days to display.
10     $reportDirectory = "/home/cut/pjm2/webpages/reports";
11     $maxDaysShown = 7;
12    
13     # Page appearance.
14     $scaleImage = "24hour.gif";
15     $lineColor = "#9999ff";
16    
17     # Files to include
18     $titleHTML = "title.inc";
19     $bottomHTML = "bottom.inc";
20     $machineNameHTML = "machine_name.inc";
21     $reportHTML = "report.inc";
22    
23     # What are the names of the report files?
24     $reportLimitsFile = "i-maxmin.txt";
25     $reportChartFile = "i-chart.gif";
26     $reportChartDataFile = "i-data.txt";
27    
28     # Submission details.
29     $formMethod = "GET";
30     $thisPage = "browser.php";
31 pjm2 1.1
32 pjm2 1.16 # Leave this alone unless you know what you're doing ;)
33     $minFileSize = 33;
34 pjm2 1.15
35 pjm2 1.16 #
36     # END CONFIGURATION
37 pjm2 1.15
38 pjm2 1.1
39 pjm2 1.14 function isReportEmpty($filename) {
40 pjm2 1.15 if (filesize($filename) < minFileSize) {
41 pjm2 1.14 return TRUE;
42     }
43     return FALSE;
44     }
45    
46 pjm2 1.1 function getdirArray($dir='./',$sort='asort') {
47     global $dir_file_count;
48     if ( is_dir($dir) ) {
49     $fd = @opendir($dir);
50     while ( ($part = @readdir($fd)) == TRUE ) {
51     clearstatcache();
52     if ($part != "." && $part != "..") {
53     $dir_array[] = $part;
54     }
55     }
56     if($fd == TRUE) {
57     closedir($fd);
58     }
59     if (is_array($dir_array)) {
60     $sort($dir_array);
61     $dir_file_count = count($dir_array);
62     Return $dir_array;
63     } else {
64     Return FALSE;
65     }
66     } else {
67     Return FALSE;
68     }
69     }
70    
71     ?>
72    
73 pjm2 1.10 <? include("title.inc"); ?>
74 pjm2 1.6
75 pjm2 1.19 <hr weight="1" color="<? echo $lineColor ?>">
76 pjm2 1.11
77     <b>Most recent reports available</b>
78 pjm2 1.12 <form method="GET" action="browser.php">
79 pjm2 1.11 <?
80    
81 pjm2 1.17 $file_array = getdirArray($reportDirectory,'rsort');
82 pjm2 1.11 print "<select size=\"1\" name=\"day\">";
83     foreach($file_array as $file_name) {
84     if (is_dir($file_name)) {
85     $i++;
86     print "<option value=\"$file_name\">$file_name</option>";
87     }
88 pjm2 1.16 if ($i >= $maxDaysShown) {
89 pjm2 1.11 break;
90     }
91     }
92     print "</select>";
93    
94     ?>
95     <input type="submit" name="submit" value="Go">
96     </form>
97    
98 pjm2 1.19 <hr weight="1" color="<? echo $lineColor ?>">
99 pjm2 1.11
100     <? if ($day) { ?>
101    
102     <b>Available reports for <? echo $day ?></b>
103    
104 pjm2 1.12 <form method="GET" action="browser.php">
105 pjm2 1.6 <select size="1" name="machine_name">
106 pjm2 1.13 <? if ($machine_name) { ?>
107     <option selected value="<? echo $machine_name ?>"><? echo $machine_name ?></option>
108     <option value="">----------------</option>
109     <? } else { ?>
110     <option selected value="">[select machine]</option>
111     <? } ?>
112 pjm2 1.11 <? include("$day/machine_name.inc"); ?>
113 pjm2 1.6 </select>
114    
115     <select size="1" name="report">
116 pjm2 1.13 <? if ($report) { ?>
117     <option selected value="<? echo $report ?>"><? echo $report ?></option>
118     <option value="">----------------</option>
119     <? } else { ?>
120     <option selected value="">[select report]</option>
121     <? } ?>
122 pjm2 1.11 <? include("$day/report.inc"); ?>
123 pjm2 1.6 </select>
124 pjm2 1.1
125 pjm2 1.11 <input type="hidden" name="day" value="<? echo $day ?>">
126 pjm2 1.8 <input type="submit" name="submit" value="Show">
127 pjm2 1.6 </form>
128 pjm2 1.11
129 pjm2 1.19 <hr weight="1" color="<? echo $lineColor ?>">
130 pjm2 1.11
131     <? } ?>
132 pjm2 1.1
133 pjm2 1.6 </p>
134 pjm2 1.1
135 pjm2 1.2
136     <?
137 pjm2 1.8 if ($submit == "Show" && $machine_name && $report) {
138 pjm2 1.11
139     include("$day/$machine_name/$report/i-maxmin.txt");
140    
141 pjm2 1.12 $url = escapeshellcmd("$day/$machine_name/$report/i-chart.gif");
142 pjm2 1.14 if (isReportEmpty("$day/$machine_name/$report/i-data.txt")) {
143     echo "Host <b>$machine_name</b> did not send any information about <b>$report</b> on <b>$day</b>. Please select another report.";
144     }
145     else if (file_exists($url)) { ?>
146 pjm2 1.11
147     <center><b>[<? echo $machine_name; ?>] - <? echo $report; ?></b></center>
148    
149     <table border="0" cellpadding="0" cellspacing="0">
150     <tr>
151     <td align="right" valign="top">
152     <font size="2"><? printf("%.1f", $max_value); ?></font>
153     </td>
154     <td rowspan="2">
155     <img src="<? echo $url; ?>" width="500" height="250">
156     </td>
157     </tr>
158     <tr>
159     <td align="right" valign="bottom">
160     <font size="2"><? echo $min_value; ?></font>
161     </td>
162     </tr>
163     <tr>
164     <td>&nbsp;</td>
165 pjm2 1.18 <td><img src="<? echo $scaleImage ?>" width="500" height="39"></td>
166 pjm2 1.11 </tr>
167     </table>
168    
169 pjm2 1.19 <hr weigth="1" color="<? echo $lineColor ?>">
170 pjm2 1.11
171     <b>Extra data</b>
172     <p>
173     <a href="<? echo "$day/$machine_name/$report/i-data.txt" ?>">Raw plot data</a><br>
174     <a href="<? echo "$day/$machine_name/$report/i-chart.gif" ?>">GIF chart</a><br>
175     <a href="<? echo "$day/$machine_name/$report/i-maxmin.txt" ?>">PHP y-axis limits include</a>
176    
177     <? }
178 pjm2 1.2 else {
179 pjm2 1.15 echo "<p>The report could not be found. Somebody must have deleted it!</p>";
180 pjm2 1.2 }
181 pjm2 1.19 echo "<hr weight=\"1\" color=\"$lineColor\">";
182 pjm2 1.2 }
183    
184 pjm2 1.1 ?>
185 pjm2 1.6
186 pjm2 1.13 <? include("bottom.inc"); ?>