cvs: phpweb /include do-download.inc
| From: | Gabor Hojtsy | Date: | Sun, 07 Sep 2003 08:15:26 +0000 |
| Subject: | cvs: phpweb /include do-download.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-20872@lists.php.net to get a copy of this message | ||
goba Sun Sep 7 04:15:26 2003 EDT
Modified files:
/phpweb/include do-download.inc
Log:
Support the download of manual files via short URLs, and with
mirror selection, as discussed on the last docmeeting
Index: phpweb/include/do-download.inc
diff -u phpweb/include/do-download.inc:1.3 phpweb/include/do-download.inc:1.4
--- phpweb/include/do-download.inc:1.3 Sat Aug 9 07:54:51 2003
+++ phpweb/include/do-download.inc Sun Sep 7 04:15:25 2003
@@ -1,6 +1,6 @@
<?php
-// $Id: do-download.inc,v 1.3 2003/08/09 11:54:51 goba Exp $
+// $Id: do-download.inc,v 1.4 2003/09/07 08:15:25 goba Exp $
/*
This code redirects the user to the exact file to
@@ -11,9 +11,38 @@
// Download a file from a mirror site
function download_file($mirror, $file)
{
- // Quit if the requested file is not availabe localy
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file)) {
- exit("Invalid file requested for download!");
+ // Could be a normal download or a manual download file
+ $possible_files = array($file => TRUE, "manual/$file" => FALSE);
+
+ // Find out what is the exact file requested
+ $file = FALSE;
+ foreach ($possible_files as $name => $log) {
+ if (@file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' .
$name)) {
+ $file = $name;
+ break;
+ }
+ }
+
+ // No downloadable file found
+ if ($file === FALSE) {
+ site_header("Download not found");
+
+ // If user comes from a mirror selection page, provide a backlink
+ if (isset($_SERVER['HTTP_REFERER']) &&
preg_match("!/from/a/mirror$!", $_SERVER['HTTP_REFERER'])) {
+ $moreinfo = ", or <a
href=\"{$_SERVER['HTTP_REFERER']}\">reconsider your mirror
selection</a>";
+ } else { $moreinfo = ""; }
+
+ echo <<<EOT
+<h1>Download not found</h1>
+<p>
+ The file you requested is not found on this server. If this file is a
+ recent addition to our downloads, then it is possible that this
+ particular server is not yet updated to host that file for download.
+ Please come back to this server later{$moreinfo}.
+</p>
+EOT;
+ site_footer();
+ exit;
}
// Redirect to the particular file
@@ -31,7 +60,7 @@
// Log download on master server (may be a registered
// shutdown function to really run after the file is
// started to download)
- download_log($mirror, $file);
+ if ($log) { download_log($mirror, $file); }
}
// Log downloads on the master server