HELP! I CANT GET THIS SCRIPT TO WORK with out errors!!!!!!!!

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
dougandnicci0
Guest





PostPosted: Sun Oct 06, 2002 3:08 am    Post subject: HELP! I CANT GET THIS SCRIPT TO WORK with out errors!!!!!!!! Reply with quote

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>&nbsp;</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>&nbsp;</p>
<p><font face=\"Arial\"><b>$message</b></font></p>
<p>&nbsp;</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]
Back to top
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Oct 06, 2002 10:10 pm    Post subject: Re: HELP! I CANT GET THIS SCRIPT TO WORK with out errors!!!! Reply with quote

Code:

$file = $_GET['file']

You have a missing ; at the end of the line.

Code:

cfunction die_nice($message){

And here there is an extra c at the beginning of the line. It should start with 'function'.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group