source: other-projects/nightly-tasks/crons-and-scripts/caveat-emptor/index.php@ 32968

Last change on this file since 32968 was 32968, checked in by ak19, 5 years ago

Kathy noticed that the links to the nightly binaries on the page called latest at caveat-emptor did not have latest/ in their filepath. I've fixed that, and found the php file was not on trac. So I'm now adding it.

File size: 9.2 KB
Line 
1<html>
2<head>
3 <title>Caveat Emptor</title>
4 <style type="text/css">
5 body { font-family: monospace; }
6 td { padding: 0 20px 0 0; text-align:right; }
7 td:first-child { text-align: left; }
8 h1,h2,h3,h4,h5,h6 { margin-bottom: .2em; }
9
10/* CSS to display an cross-out icon if the URL contains "diffcol-FAIL".
11Based on:
12
13http://www.devwebpro.com/developer-icon-sets-collection-of-the-best-free-to-both-personal-commercial-use-icon-sets/
14http://www.electrictoolbox.com/add-offsite-link-icon-after-external-links-css/
15http://webcodertools.com/imagetobase64converter
16http://www.greywyvern.com/code/php/binary2base64
17Use this tool to create data streams for embedding images (or any type of file) in (X)HTML, CSS and XML.
18http://stackoverflow.com/questions/49368/css2-attribute-selectors-with-regex
19http://tools.css3.info/selectors-test/test.html
20http://tools.css3.info/selectors-test/test-attribute-contains.html#attribute-contains
21*/
22 a[href*="diffcol-FAIL-"] {
23 background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAMCAYAAAC0qUeeAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB90LDQYPCR0HlEQAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAB20lEQVQozwXBT0hTcQDA8e/v9/bb1uZWY2mjqI6RXZK6dg+pLhVBh7KDGP0xIqOOdQmCTMv8AwVBnvqLWF3qnl2iUNAwJSc2nJvP7W3v7b239/br8xE69DWeT9+FHo52HUZJA0MHVEtrKEOwuLzK4MRzyHYgtG3rB/03uHv5CjJoApra2l+kvYVjVdDRNKOv33B/+gPiYW+fHui5xPz3Gbwtk4jfZGciTr20xu5cB8UNC5nLMfRpGqFnfujZr1+IRkO045DwBMmowmpUqJoVcm27CKIJyqk40i0WSWqNWy5x8NxZRNhi06zyezlP1+07BHYNv1wk7TeRnuvQ8hxink/+5ST7eq8yt1Kge3iE8ru3xI0GKjRJ6DpyeyaD13DIpNpoODbvB25yZmyE+VeTLBX+UXFrtLSP0QqQTatORERYNzdYXP3D6bHHLEy+oPPieZrJbTgqjkpn8T2FJKJwwxCQnBp8RH78KeWVJb49e8Kxa9dRsSiFSo2alohfQ+N6c26WlG+REiFGRICMUKu7KKXYLBfI7N2P2HMAI428d+RQJ9RtHNOEIMSzLHYYMVqeS1t7FjraGf34GaGrdd3ffZxbJ04SbqwjgwAZtNC2jVYGbibJ8NQUEz8X+A8Zn+eqFS9aTQAAAABJRU5ErkJggg==) center left no-repeat;
24 padding-left: 13px;
25 }
26 </style>
27</head>
28<body>
29
30<?php
31
32 //chdir("/greenstone/greenstone.org/base/caveat-emptor");
33if ( $_GET['latest'] ) {
34 chdir("/greenstone/greenstone.org/base/caveat-emptor/latest");
35 } else {
36 chdir("/greenstone/greenstone.org/base/caveat-emptor");
37 }
38$handle = opendir( "." );
39if ( $handle === false ) exit;
40$todayFiles = array();
41
42if ( $_GET['offset']) {
43 $todayStart = strtotime(date("Y-m-d",strtotime($_GET['offset'] . " days")));
44} else {
45 $todayStart = strtotime(date("Y-m-d"));
46}
47$tomorrowStart = strtotime("+1 days", $todayStart );
48
49$today = date("Y.m.d", $todayStart);
50$todayWithHyphens = date("Y-m-d", $todayStart);
51
52$nextRelease2 = trim(file_get_contents("/greenstone/greenstone.org/base/next-release.txt"));
53$nextRelease3 = trim(file_get_contents("/greenstone/greenstone.org/base/next-release-greenstone3.txt"));
54
55while ( ($file = readdir($handle)) !== false ) {
56 if ( substr($file,0,1) == "." ) continue;
57 if ( $file === "index.php" ) continue;
58 if ( $_GET['latest'] ) {
59 $todayFiles[$file] = true;
60 continue;
61 }
62
63 if ( filemtime($file) >= $todayStart && filemtime($file) < $tomorrowStart ) {
64
65 $todayFiles[$file] = true;
66 }
67}
68closedir( $handle );
69
70// sort array keys (filenames) in ascending order (array values are true/false)
71// see http://www.php.net/manual/en/function.ksort.php
72ksort($todayFiles);
73
74define( 'TOTAL_COLS', 3 );
75function heading( $text, $level = 3 ) {
76 ?>
77<tr>
78<td colspan="<?php echo TOTAL_COLS; ?>">
79<?php echo "<h" . $level . ">"; ?>
80<?php echo $text; ?>
81<?php echo "</h" . $level . ">"; ?>
82</td>
83</tr>
84<?php
85}
86
87function anchorheading( $text, $id, $level = 3 ) {
88 ?>
89<tr>
90<td colspan="<?php echo TOTAL_COLS; ?>">
91<?php echo "<h" . $level . " id=\"".$id."\">"; ?>
92<?php echo $text; ?>
93<?php echo "</h" . $level . ">"; ?>
94</td>
95</tr>
96<?php
97}
98
99
100function gap() {
101 ?>
102
103<tr><td colspan="<?php echo TOTAL_COLS; ?>"><br/></td></tr>
104<?php
105}
106
107function show( $file, $forceShow, $extra_info, $rename ) {
108 global $todayFiles;
109
110 if ( $_GET['latest'] ) {
111 //echo "XXX $file";
112
113 $regex = preg_replace( "/\d{4}.\d{2}\.\d{2}/", "\d{4}.\d{2}.\d{2}", $file );
114 $regex = preg_replace( "/\./", "\.", $regex );
115
116 //echo " ZZZ $regex <br />";
117
118 foreach( $todayFiles as $filename=>$notShown ) {
119 if ( $notShown && preg_match( "/^$regex$/", $filename ) ) {
120 //echo "BBB $filename<br />";
121 //$todayFiles[$file] = false;
122 $file = $filename;
123
124 }
125 }
126
127 }
128 $todayFiles[$file] = false;
129 //echo "CCC $file <br />";
130
131 if ( file_exists($file) || $forceShow ) {
132 if ( $_GET['latest'] ) {
133
134 $filepath="latest/".$file;
135 } else {
136 $filepath=$file;
137 }
138 ?>
139<tr>
140 <td><a href="<?php echo $filepath; ?>"><?php if($rename) { echo $rename; } else { echo $file; } ?></a><?php if($extra_info) { echo " - ".$extra_info; } ?></td>
141 <td><?php echo date("h:ia",filemtime($file)); ?></td>
142 <td><?php echo formatBytes(filesize($file)); ?></td>
143</tr>
144<?php
145 } else {
146 ?>
147<tr>
148 <td><?php echo $file; ?><?php if($extra_info) { echo " - ".$extra_info; } ?></td>
149 <td>-</td>
150 <td>-</td>
151</tr>
152 <?php
153 }
154
155}
156function formatBytes($bytes, $precision = 2) {
157 $units = array('B', 'KB', 'MB', 'GB', 'TB');
158
159 $bytes = max($bytes, 0);
160 $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
161 $pow = min($pow, count($units) - 1);
162
163 $bytes /= pow(1024, $pow);
164
165 return round($bytes, $precision) . ' ' . $units[$pow];
166}
167
168function showAllMatching( $regex ) {
169 global $todayFiles;
170
171 // in the latest folder, display the bin/src link for any available date
172 // (there should only be one)
173 if($_GET['latest']) {
174 $regex = preg_replace( "/\d{4}.\d{2}\.\d{2}/", "\d{4}.\d{2}.\d{2}", $regex );
175 }
176
177 //echo "Regex: $regex<br />\n";
178
179
180 foreach( $todayFiles as $file=>$notShown ) {
181 if ( $notShown && preg_match( "/$regex/", $file ) ) {
182 show( $file );
183 }
184 }
185}
186
187//show time machine
188if ($_GET['latest'] ) {
189 echo "latest ";
190} else {
191 echo "<a href=\"?latest=latest\">latest</a> ";
192}
193for ( $i=4; $i>=0; $i-- ) {
194 $d = date("Y-m-d",strtotime("-$i days"));
195 if ( $d == $todayWithHyphens && ! $_GET['latest']) {
196 echo $d;
197 } else {
198?>
199 <a href="?offset=-<?php echo $i; ?>"><?php echo $d; ?></a>
200<?php
201 }
202}
203
204echo "<br/><br/>";
205
206echo "<table>\n";
207heading( "Greenstone3 Binary Releases" );
208show("Greenstone-$nextRelease3-candidate-$today-linux");
209show("Greenstone-$nextRelease3-candidate-$today-linux-x64");
210show("Greenstone-$nextRelease3-candidate-$today-windows.exe");
211showAllMatching("Greenstone-$nextRelease3-candidate-$today-MacOS-intel.dmg", 0, "for (Snow) Leopards (v10.5-10.6)", "Greenstone-$nextRelease3-candidate-$today-Leopard-MacOS-intel.dmg");
212show("Greenstone-$nextRelease3-candidate-$today-Lion-MacOS-intel.dmg", 0, "for (Mountain) Lions (v10.7-10.8)");
213//this picks up similar releases of other version numbers lying around
214showAllMatching("Greenstone-3\..*-candidate-$today-linux$");
215showAllMatching("Greenstone-3\..*-candidate-$today-windows.exe$");
216showAllMatching("Greenstone-3\..*-candidate-$today-MacOS-intel.dmg$", 0, "for (Snow) Leopards (v10.5-10.6)");
217showAllMatching("Greenstone-3\..*-candidate-$today-Lion-MacOS-intel.dmg$", 0, "for (Mountain) Lions (v10.7-10.8)");
218gap();
219
220heading( "Greenstone3 Source Releases" );
221showAllMatching("Greenstone-3\..*-candidate-$today-source-distribution.tar.gz");
222showAllMatching("Greenstone-3\..*-candidate-$today-source-distribution.zip");
223showAllMatching("Greenstone-3\..*-candidate-$today-source-component.tar.gz");
224showAllMatching("Greenstone-3\..*-candidate-$today-source-component.zip");
225gap();
226
227heading( "Greenstone2 Binary Releases" );
228show("Greenstone-$nextRelease2-candidate-$today-linux");
229show("Greenstone-$nextRelease2-candidate-$today-linux-x64");
230show("Greenstone-$nextRelease2-candidate-$today-windows.exe");
231showAllMatching("Greenstone-$nextRelease2-candidate-$today-MacOS-intel.dmg", 0, "for (Snow) Leopards (v10.5-10.6)","Greenstone-$nextRelease2-candidate-$today-Leopard-MacOS-intel.dmg");
232show("Greenstone-$nextRelease2-candidate-$today-Lion-MacOS-intel.dmg", 0, "for (Mountain) Lions (v10.7-10.8)");
233
234showAllMatching("Greenstone-2\..*-candidate-$today-linux$");
235showAllMatching("Greenstone-2\..*-candidate-$today-linux-x64$");
236showAllMatching("Greenstone-2\..*-candidate-$today-windows.exe$");
237showAllMatching("Greenstone-2\..*-candidate-$today-MacOS-intel.dmg$", 0, "for Snow Leopards (v10.5-10.6)");
238showAllMatching("Greenstone-2\..*-candidate-$today-Lion-MacOS-intel.dmg$", 0, "for (Mountain) Lions (v10.7-10.8)");
239gap();
240
241heading( "Greenstone2 Source Releases" );
242showAllMatching("Greenstone-2\..*-candidate-$today-source-distribution.tar.gz");
243showAllMatching("Greenstone-2\..*-candidate-$today-source-distribution.zip");
244showAllMatching("Greenstone-2\..*-candidate-$today-source-component.tar.gz");
245showAllMatching("Greenstone-2\..*-candidate-$today-source-component.zip");
246gap();
247
248heading("Documented Examples" );
249show("Greenstone-documented-examples-$today.tar.gz");
250show("Greenstone-documented-examples-$today.zip");
251gap();
252
253if ( ! $_GET['latest'] ) {
254 heading("Nightly Build Logs");
255 showAllMatching("\.txt$");
256 gap();
257 anchorheading("Regression Test Reports", "regression");
258 showAllMatching("\.html?$");
259 gap();
260}
261
262heading( "Other Files" );
263foreach( $todayFiles as $file=>$notShown ) {
264 if ( $notShown ) show( $file );
265}
266show("IsisGdl.bin32", 1,"","IsisGdl.linux32"); // temporary
267show("IsisGdl.macleopard", 1); // temporary
268gap();
269
270echo "</table>\n";
271
272?>
273
274</body>
275</html>
Note: See TracBrowser for help on using the repository browser.