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!
I have a script which hides the location of a file, but once the file has been downloaded it is unreadable. whereas if i just download without the script it is fine?
<?php
$file=$_GET['file'];
$ref=($_SERVER['HTTP_REFERER']);
$valref=substr($ref, 0, 29);
if($valref == "http://www.xxxxx.com/"){
$stat=stat('D:/inetpub/www-xxxxx/' . $file . '.avi');
header('Content-Disposition: attachment; filename=' . $file . '.avi');
header('Content-Length: '.$stat[7]);
readfile('D:/inetpub/www-xxxxx/' . $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.
<?
}
}
?>
thanks
Last edited by benyboi on Mon Mar 12, 2007 3:00 pm, edited 2 times in total.
Are the file sizes different with and without the script? If so, then you have extraneous characters entering the stream. They may be just prior to the script starting or just after the script finishing. To narrow down where to look you'll need to compare the two files to find the differences.