1
0
mirror of https://github.com/php/web-php.git synced 2026-04-27 08:58:12 +02:00

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.
This commit is contained in:
Gabor Hojtsy
2002-12-21 21:11:15 +00:00
parent e4ccd673c7
commit 1b9cbb2c30
+64 -60
View File
@@ -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) {
// Maintain previous country code information
$prevcc = 'aa';
if ($murl=='0') {
continue;
}
// Go through all mirror sites and print out download links
$MURLS = array_keys($MIRRORS);
foreach ($MURLS as $murl) {
if(in_array($murl, $no_download)) {
continue;
}
// If the mirror is not all right, skip it
if (mirror_status($murl) != MIRROR_OK) { 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>';
}
// 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 bgcolor="' . ($MYSITE==$murl ? '#ffffcc' : '#e0e0e0') . '">';
// Highlight this mirror if it is the current one
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>';
// 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>';
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 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>';
echo '<td><small>';
echo $mdata[1];
echo '</small><br></td>';
// Print out mirror provider's name
echo '<td><small>';
echo mirror_provider($murl);
echo '</small><br /></td>';
echo '</tr>';
$mprevious = $mdata[0];
}
// End row for this mirror
echo '</tr>';
// Maintain previous country code
$prevcc = $country;
}
?>
</table>
</p>
<?php commonFooter(); ?>