cvs: phpweb / get_download.php
| From: | Gabor Hojtsy | Date: | Sat, 21 Dec 2002 21:11:15 +0000 |
| Subject: | cvs: phpweb / get_download.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-14422@lists.php.net to get a copy of this message | ||
goba Sat Dec 21 16:11:15 2002 EDT
Modified files:
/phpweb get_download.php
Log:
Rework page:
- Add some comments
- Make output be XHTML instead of HTML.
And correct a <table which had no closing >
[How was that able to be displayed?]
- Explain why mirrors may be missing
- Only list working mirrors (the previous code listed
mirrors out of order, or outdated [probably
without the downloadable file])
- Be independent of the $MIRRORS array structure,
only the same dependency as in mirrors.php
The layout of this mirrors table is soon to be used
in mirrors.php, this looks much better ;) Now both of
the mirror listing show the same mirrors.
Index: phpweb/get_download.php
diff -u phpweb/get_download.php:1.2 phpweb/get_download.php:1.3
--- phpweb/get_download.php:1.2 Tue Sep 10 09:26:33 2002
+++ phpweb/get_download.php Sat Dec 21 16:11:15 2002
@@ -1,104 +1,108 @@
<?php
+include_once 'prepend.inc';
-require_once 'prepend.inc';
-
+// Try to make this page non-cached
header("Cache-Control: private");
header("Pragma: no-cache");
-
-// If there is no file, then drop out an invalid file error message
-
-if (!isset($df) || !file_exists('distributions/'.$df)) {
- exit('Invalid file requested for download!');
+// If there is no such file, then drop out an invalid file error message
+if (!isset($df) || !file_exists('distributions/' . $df)) {
+ exit('Invalid file requested for download!');
}
-
+// Print out common header
commonHeader('Get Download');
-$server = $SERVER_NAME;
?>
-<h1>Latest version of PHP</h1>
+<h1>Choose mirror site for download</h1>
<p>
You have chosen to download the following file:
</p>
<p align="center">
-<table border="0" cellpadding="10" cellspacing="1"
width="500"
+<table border="0" cellpadding="10" cellspacing="1"
width="500">
<tr bgcolor="#cccccc"><td align="center">
<?php
- echo '<b>' . $df . '</b><br>';
+echo '<b>' . $df . '</b><br />';
- if ($tmp = strrchr($df, '/')) {
- $local_file = substr($tmp, 1, strlen($tmp));
- } else {
- $local_file = 'distributions/' . $df;
- }
+// Get real file name
+if ($tmp = strrchr($df, '/')) {
+ $local_file = substr($tmp, 1, strlen($tmp));
+} else {
+ $local_file = 'distributions/' . $df;
+}
- $size = @filesize($local_file);
- if ($size) {
- echo '<small>' . number_format($size, 0, '.', ',') . '
bytes</small><br>';
- }
+// Try to get filesize to display
+$size = @filesize($local_file);
+if ($size) {
+ echo '<small>' . number_format($size, 0, '.', ',') . '
bytes</small><br />';
+}
?>
</td></tr></table>
</p>
<p>
-Please choose the mirror closest to you from which to download the file.
-The current mirror is highlighted in yellow, but you may have better luck
-with a different mirror, especially if the current mirror is busy.
+ Please choose the mirror closest to you from which to download the file.
+ The current mirror is highlighted in yellow, but you may have better luck
+ with a different mirror, especially if the current mirror is busy. Mirror
+ sites detected to be out of date or disfunctional are not listed for your
+ convinience.
</p>
-
<p align="center">
<table border="0" cellpadding="3" cellspacing="1"
width="500">
<?php
- $no_download = array('http://news.php.net/',
'http://bugs.php.net/');
-
- $mprevious = 'aa';
- foreach ($MIRRORS as $murl=>$mdata) {
-
- if ($murl=='0') {
- continue;
- }
-
- if(in_array($murl, $no_download)) {
- continue;
- }
-
- if ($mprevious != $mdata[0]) {
- echo '<tr><td colspan="3"></td></tr>';
- echo '<tr bgcolor="cccccc"><td width="40"
align="center">';
- print_image('flags/' . strtolower($mdata[0]) . '.png',
$COUNTRIES[$mdata[0]], false, 'CLASS="flag"' );
- echo '<br></td>';
- echo '<td colspan="2"><b>' . $COUNTRIES[$mdata[0]] .
'</b><br></td>';
- echo '</tr>';
- }
-
- echo '<tr bgcolor="' . ($MYSITE==$murl ? '#ffffcc' :
'#e0e0e0') . '">';
-
- echo '<td bgcolor="#ffffff" align="right">';
- print_image( ($MYSITE==$murl ? 'caret-r.gif' : 'caret-rg.gif') );
- echo '<br></td>';
-
- echo '<td><small>';
- $ps = strpos($murl, '//') + 2;
- print_link('/do_download.php?mr='.urlencode($murl) . '&df=' .
urlencode($df), substr($murl, $ps, -1) );
- echo '</small><br></td>';
-
- echo '<td><small>';
- echo $mdata[1];
- echo '</small><br></td>';
+
+// Maintain previous country code information
+$prevcc = 'aa';
+
+// Go through all mirror sites and print out download links
+$MURLS = array_keys($MIRRORS);
+foreach ($MURLS as $murl) {
+
+ // If the mirror is not all right, skip it
+ if (mirror_status($murl) != MIRROR_OK) { continue; }
+
+ // Get country code, print out a
+ // country header, if it is a new one
+ $country = mirror_country($murl);
+ if ($prevcc != $country) {
+ echo '<tr><td colspan="3"></td></tr>';
+ echo '<tr bgcolor="cccccc"><td width="40"
align="center">';
+ print_image('flags/' . strtolower($country) . '.png',
$COUNTRIES[$country], false, 'CLASS="flag"');
+ echo '<br /></td>';
+ echo '<td colspan="2"><b>' . $COUNTRIES[$country] .
'</b><br /></td>';
+ echo '</tr>';
+ }
- echo '</tr>';
+ // Highlight this mirror if it is the current one
+ echo '<tr bgcolor="' . ($MYSITE == $murl ? '#ffffcc' :
'#e0e0e0') . '">';
- $mprevious = $mdata[0];
+ // Print out caret (in bold if current mirror)
+ echo '<td bgcolor="#ffffff" align="right">';
+ print_image( ($MYSITE == $murl ? 'caret-r.gif' : 'caret-rg.gif') );
+ echo '<br /></td>';
+
+ // Print out mirror site download link
+ echo '<td><small>';
+ $ps = strpos($murl, '//') + 2;
+ print_link('/do_download.php?mr=' . urlencode($murl) . '&df=' .
urlencode($df), substr($murl, $ps, -1));
+ echo '</small><br /></td>';
+
+ // Print out mirror provider's name
+ echo '<td><small>';
+ echo mirror_provider($murl);
+ echo '</small><br /></td>';
- }
+ // End row for this mirror
+ echo '</tr>';
+ // Maintain previous country code
+ $prevcc = $country;
+}
?>
</table>
</p>
-
<?php commonFooter(); ?>