I am running a web server off of Windows XP home edition (the webserver is OmniHTTPd Professional), I have a php script that I want to use. Here is what the script is suppose to do, you click on a link on a html page and it is suppose to start a download and the script writes a log to a text file . It is not working, here is the message it gives me:
-----------------------
Warning: fopen("C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\log\download_log", ".txt") - No error in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 54
Warning: fputs(): supplied argument is not a valid File-Handle resource in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 55
Warning: fclose(): supplied argument is not a valid File-Handle resource in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 56
Warning: Cannot add header information - headers already sent by (output started at C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php:54) in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 66
Warning: Cannot add header information - headers already sent by (output started at C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php:54) in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 68
Warning: Cannot add header information - headers already sent by (output started at C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php:54) in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 69
Warning: readfile("C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\") - Permission denied in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 70
---------------------------------
Here is the script code:
---------------------
<?
# link your scripts like #
# http://yourdomain.com/download.php?id=1 #
# id=1 is the first file (firstfile.php) in this script #
$files = array(
1 => "test.txt",
2 => "iname.exe",
3 => "fire.exe"
); // files array. add more files like
// 4 => "mybestpic.gif";
// 5 => "firstscript.php"; #
#
$files_folder = "C:\\Documents and Settings\\Owner\\My Documents\\My Webs\\Edge-Games\\downloads\\"; // with slashes
#
$log_path = "C:\\Documents and Settings\\Owner\\My Documents\\My Webs\\Edge-Games\\log\\"; // with slashes
$log_file = "download_log"; // just your log file name
#
#
#####################################################################
if ($id > count($files)) // check if someone scratchs our id numbsers
{
echo "Hata"; // if the id number came from url higher than our total files
// give them an error message
}else{ // othervise do the work
# Find the real ip adress and host of downloader #
if (getenv('HTTP_X_FORWARDED_FOR'))
{
$ip = getenv('HTTP_X_FORWARDED_FOR');
}else {
$ip = getenv('REMOTE_ADDR');
}
$host = isset($REMOTE_HOST) ? $REMOTE_HOST : @gethostbyaddr($ip);
####################################################
$date = date("Y-m-d H:i:s"); // Today's date on 2001-05-22 18:15:16 format
#############################################################################################
$log = fopen($log_path.$log_file, ".txt"); // open log file
fputs($log, $id."\t".$ip."\t".$host."\t".$date."\n"); // write lo file
fclose($log); // close the log file
# Send the file to the downloaders browser #
$size = $files_folder . $files[$id];
if (detect_browser($HTTP_USER_AGENT) == "ie")
{
Header("Content-type: application/force-download");
}else{
Header("Content-Type: application/octet-stream");
}
Header("Content-Length: ".filesize($size));
Header("Content-Disposition: attachment; filename=$files[$id]");
readfile($size);
#########################################################################
}
function detect_browser($var)
{
if(eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})", $var))
{
$c = "ie";
}else{
$c = "nn";
}
return $c;
}
?>
---------
Can someone please help me fix this so it will work, please????
Thank You!
-David Cunningham
Need Help REALLY REALLY REALLY BAD??????
Moderator: General Moderators
-
Edge Games
- Forum Newbie
- Posts: 2
- Joined: Tue Jan 14, 2003 7:22 pm
Need Help REALLY REALLY REALLY BAD??????
Last edited by Edge Games on Tue Jan 14, 2003 8:07 pm, edited 1 time in total.
files should be in your webserver folder. on XP its generally
c:\Inetpub\wwwroot\file.php
Warning: fopen("C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\log\download_log", ".txt") - No error in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 54
Thats out of the webserver. Put that file somewhere in Inetpub.
see what happens then.
c:\Inetpub\wwwroot\file.php
Warning: fopen("C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\log\download_log", ".txt") - No error in C:\Documents and Settings\Owner\My Documents\My Webs\Edge-Games\downloads\download.php on line 54
Thats out of the webserver. Put that file somewhere in Inetpub.
see what happens then.
-
Edge Games
- Forum Newbie
- Posts: 2
- Joined: Tue Jan 14, 2003 7:22 pm
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
find this line:
then change it to:
Code: Select all
$log = fopen($log_path.$log_file, ".txt"); // open log fileCode: Select all
$log = fopen($log_path.$log_file.".txt", "a+"); // open log file