dougandnicci0 Guest
|
Posted: Sun Oct 06, 2002 3:08 am Post subject: HELP! I CANT GET THIS SCRIPT TO WORK with out errors!!!!!!!! |
|
|
it is a download script and that this is what happens when i try a test of one http://12.245.70.91/download.php?file=6.zip i keep getting errors, :evil:
Here is the SCRIPT CODE:
// Author:
// E-mail:
//
// This program simply displays a notice before
// letting the visitor download the file.
// Call it like: download.php?file=filename
//
// You must put all the files you are making available
// for download in one directory.
//
// The template file is loaded and.....
// [FILENAME] is replaced with the name of the file.
// [FILESIZE] is replaced with the size of the file.
// [MODIFIEDDATE] is replaced with the last modifed date of the file
// [DOWNLOAD] is replaced with the url and filename.
/////////////////////////////////////
//////////// Begin Setup ////////////
/////////////////////////////////////
// The URL to the directory where all the files are located.
// Do not add a / at the end of the url.
$filedirectory = 'http://12.245.70.91/downloads';
// The Path to the directory where all files are located.
// Do not add a / at the end of the path.
$filepath = 'C:\\Program Files\\Abyss Web Server\\htdocs\\downloads';
// The template filename. Place in same directory as the download.php file.
$template = 'C:\\Program Files\\Abyss Web Server\\htdocs\\download_template.htm';
$file = $_GET['file']
///////////////////////////////////
//////////// End setup ////////////
///////////////////////////////////
// For our error messages
cfunction die_nice($message){
die("
<html><head><title>ERROR!!</title></head><body>
<p> </p>
<center>
<table border=\"1\" width=\"400\" bordercolor=\"#FF0000\" cellspacing=\"0\" cellpadding=\"3\">
<tr>
<td><font color=\"#000080\" face=\"Arial\">The program encountered an Error!!</font></td>
</tr>
<tr>
<td><p> </p>
<p><font face=\"Arial\"><b>$message</b></font></p>
<p> </p></td>
</tr>
</table>
</center>
</body></html>
");
}
// Check to see if the program was called correctly
if (!$_GET['file']) die_nice("Program was called incorrectly, it should be called like:<br>download.php?file=filename");
// Check to see if the file the want to download exists
if ( !file_exists("$filepath/$file") ) die_nice("The file you are trying to download does not exist:<br>$file");
// read in the template file
$fp = fopen ("$template", "r") or die_nice("Could not open template file: $template");
$contents = fread ($fp, filesize ($template));
fclose ($fp);
// replace the macros
$contents = str_replace("[FILENAME]", $file, $contents);
$contents = str_replace("[FILESIZE]", number_format(filesize("$filepath/$file")), $contents);
$contents = str_replace("[MODIFIEDDATE]", date("F j Y", filemtime("$filepath/$file")), $contents);
$contents = str_replace("[DOWNLOAD]", "${filedirectory}/$file", $contents);
// Now display the template
print stripslashes($contents);
[/code] |
|