downloads stop before end

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

downloads stop before end

Post by benyboi »

I have this to stop hotlinking:

Code: Select all

<?php
$file=$_GET['file'];

$ref=($_SERVER['HTTP_REFERER']);
$valref=substr($ref, 0, 29);

if($valref == "http://www.xxxxx.com/"){


header('Content-type: video/x-msvideo');


header('Content-Disposition: attachment; filename=' . $file . '.avi');

readfile('D:/inetpub/www-xxxx.com/xxx/' . $file . '.avi');

} else {

if($valref == ""){

?>
There is a problem with your referer.<p>
This means your browser has not told us where you got this link from.<p>
Please check <a href="http://www.xxxxx.com/viewforum.php?f=64">help</a> for more info.

<?

} else {

// Your email address
$email = "info@xxxxx.com";

// The subject
$subject="Invalid referer for video download";

// The message
$comment=$ref;

// The message
$emailfrom= "info@xxxxx.com";

mail($email, $subject, $comment, "From: $emailfrom");

?>
Hotlinking? Tut tut.
<p>
We have recorded which website sent you here and will be taking action.
<p>
If this message has been received in error, please goto our <a href="http://www.xxxxx.com/viewforum.php?f=64">help</a> section to find out why.
<?
}
}

?>
but the downloads stop after a few minutes and say they are complete??

anyone know wy?

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What does your error log say?
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

this is the only line i can find relevant to the problem:

2007-03-10 20:26:03 W3SVC1809453639 87.106.82.193 GET /xxx/xxx/xxx.avi - 80 - 89.139.5.53 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+he;+rv:1.8.1.2)+Gecko/20070219+Firefox/2.0.0.2 401 3 5

i cant really understand. its an iis 6 log.
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

changed it a bit now, this time the download stops and times out.

Code: Select all

<?php
$file=$_GET['file'];

$ref=($_SERVER['HTTP_REFERER']);
$valref=substr($ref, 0, 29);

if($valref == "http://www.xxxxx.com/"){

header('Content-type: video/x-msvideo');

$stat=stat('D:/inetpub/xxx/' . $file . '.avi');
header('Content-Length: '.$stat[7]);  
header('Content-Disposition: attachment; filename=' . $file . '.avi');

readfile('D:/inetpub/xxx/' . $file . '.avi');

} else {

if($valref == ""){

?>
There is a problem with your referer.<p>
This means your browser has not told us where you got this link from.<p>
Please check <a href="http://www.xxxxx.com/viewforum.php?f=64">help</a> for more info.

<?

} else {

// Your email address
$email = "info@xxxxx.com";

// The subject
$subject="Invalid referer for video download";

// The message
$comment=$ref;

// The message
$emailfrom= "info@xxxxx.com";

mail($email, $subject, $comment, "From: $emailfrom");

?>
Hotlinking? Tut tut.
<p>
We have recorded which website sent you here and will be taking action.
<p>
If this message has been received in error, please goto our <a href="http://www.xxxxx.com/viewforum.php?f=64">help</a> section to find out why.
<?
}
}

?>
anyone?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

This is typically done with a .htaccess file:

http://www.htmlbasix.com/disablehotlinking.shtml
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

i didnt think you can use .htaccess on windows 2003? running IIS 6?
Post Reply