cvs: phpweb / do_download.php /error index.php /include do-download.inc

From: Date: Sat, 17 May 2003 13:54:59 +0000
Subject: cvs: phpweb / do_download.php /error index.php /include do-download.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17763@lists.php.net to get a copy of this message
goba Sat May 17 09:54:59 2003 EDT Added files: /phpweb/include do-download.inc Removed files: /phpweb do_download.php Modified files: /phpweb/error index.php Log: Move do-download code to the include dir, as we have no official direct interface for direct downloads, and it would be painfull to maintain one Also make the download code much more modern using $_SERVER and $_REQUEST vars, instead of globals, also use i2c_realip() for more accurate() IP detection Index: phpweb/error/index.php diff -u phpweb/error/index.php:1.112 phpweb/error/index.php:1.113 --- phpweb/error/index.php:1.112 Wed Apr 23 15:28:25 2003 +++ phpweb/error/index.php Sat May 17 09:54:59 2003 @@ -1,6 +1,6 @@ <?php -// $Id: index.php,v 1.112 2003/04/23 19:28:25 goba Exp $ +// $Id: index.php,v 1.113 2003/05/17 13:54:59 goba Exp $ /* @@ -105,7 +105,10 @@ // Some other mirror is selected else { $mr = "http://{$dlinfo[2]}/"; } - include_once "$DOCUMENT_ROOT/do_download.php"; + + // Start the download process + include "do-download.inc"; + download_file($mr, $df); exit; } Index: phpweb/include/do-download.inc +++ phpweb/include/do-download.inc <?php // $Id: do-download.inc,v 1.1 2003/05/17 13:54:59 goba Exp $ /* This code redirects the user to the exact file to download, and logs the download if it's something we would like to know about (PHP binary or source). */ // Download a file from a mirror site function download_file($mirror, $file) { global $_SERVER; // Quit if the requested file is not availabe localy if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file)) { exit("Invalid file requested for download!"); } // Redirect to the particular file if (!headers_sent()) { header('Location: ' . $mirror . 'distributions/' . $file); } else { exit("Unable to serve you the requested file for download"); } // Try to flush output, and make the browser // really download the file, even is $LOG_SERVER is down.. echo " "; flush(); // 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); } // Log downloads on the master server function download_log($mirror, $file) { global $_SERVER; // Set referer value $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '-'); // String to pass on as a query to the remote log $log_file = "http://master.php.net/log_download.php" . "?download_file=" . urlencode($file) . "&mirror=" . urlencode($mirror) . "&user_referer=" . urlencode($referer) . "&user_ip=" . urlencode(i2c_realip()); // Open the remote log and read some bytes $remote_log = @fopen($log_file, 'r'); if ($remote_log) { fread($remote_log, 1024); fclose($remote_log); } }

« previous php.mirrors (#17763) next »