cvs: phpweb /include get-download.inc
| From: | Gabor Hojtsy | Date: | Sun, 07 Sep 2003 08:30:43 +0000 |
| Subject: | cvs: phpweb /include get-download.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-20874@lists.php.net to get a copy of this message | ||
goba Sun Sep 7 04:30:43 2003 EDT
Modified files:
/phpweb/include get-download.inc
Log:
Support manual file downloads (with mirror selection) via short URLs
and provide more human friendly error messages for rush downloaders,
who download stuff the same day we publish it (when not all mirrors have
the file)...
Index: phpweb/include/get-download.inc
diff -u phpweb/include/get-download.inc:1.2 phpweb/include/get-download.inc:1.3
--- phpweb/include/get-download.inc:1.2 Wed Aug 13 10:35:12 2003
+++ phpweb/include/get-download.inc Sun Sep 7 04:30:43 2003
@@ -1,17 +1,47 @@
<?php
-// $Id: get-download.inc,v 1.2 2003/08/13 14:35:12 goba Exp $
+// $Id: get-download.inc,v 1.3 2003/09/07 08:30:43 goba Exp $
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/mirrortable.inc';
// Try to make this page non-cached
header_nocache();
-// If there is no such file, then drop out an invalid file error message
-if (!isset($df) || !file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' .
$df)) {
- exit('Invalid file requested for download!');
+// No file to download
+if (!isset($df)) {
+ exit("No file requested for download");
+}
+
+// Could be a normal download or a manual download file
+$possible_files = array($df, "manual/$df");
+
+// Find out what is the exact file requested
+$file = FALSE;
+foreach ($possible_files as $name) {
+ if (@file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $name)) {
+ $file = $name;
+ break;
+ }
+}
+
+// No downloadable file found
+if ($file === FALSE) {
+ site_header("Download not found");
+ echo <<<EOT
+<h1>Download not found</h1>
+<p>
+ The file you requested (<strong>{$df}</strong>) is not found on
+ this server (<strong>{$MYSITE}</strong>). 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, or start the download from another
+ mirror site.
+</p>
+EOT;
+ site_footer();
+ exit;
}
// Set local file name
-$local_file = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $df;
+$local_file = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file;
// Print out common header
site_header('Get Download');