this is my php code:
PHP Code:
<?
// ---------------- CONFIGURABLE SECTION -----------------
// Please modify the following or it will not work on your website.
// Relative to this .php file, ie. This file should not be in "thisotfolder".
// Make sure that the path you put below ends with a directory slash ("/"). The script below assumes it.
$rtadir = "videos/" ;
// Valid Referers
// Do not put any trailing slashes ("/") nor any "http://" prefixes.
$validprefixes = array (
"forums.mywebsite.com",
"mywebsite.com",
) ;
// Website Root
// Where people will be sent if you dont include the file name.
$homepage = "http://www.mywebsite.com/";
// What is your email address?
// Remove '//' and edit email to enable bad referer notification.
//$email = "yourname@yourdomain.com" ;
// ------------ END OF CONFIGURABLE SECTION ------------
//Shouldn't need editing from here on down
function isreferrerokay ( $referrer, $validprefixes )
{
$validreferrer = 0 ;
$authreferrer = current( $validprefixes );
while ($authreferrer) {
if (eregi( "^https?://$authreferrer/", $referrer )) {
$validreferrer = 1 ;
break ;
}
$authreferrer = next( $validprefixes );
}
return $validreferrer ;
}
//----------------------- main program -----------------------
//File from URL
$rta = $_GET['rta'] ;
//Referer
$referrer = getenv( "HTTP_REFERER" );
//Gets file extension
$split= explode(".", $rta);
$textcount= substr_count($rta, ".")+1;
$ttype =$split[$nextcount];
//link to ot including path + filename
$path = $rtadir . $rta ;
//If File doesnt exist
if (!file_exists($path)) {
echo "The file '$rta' does not exist";
exit;
}
if (isset($_GET['rta'])) {
if (isreferrerokay($referrer, $validprefixes)) {
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($path));
header('Content-Disposition: attachment; filename=' . basename($path));
@readfile($path);
}
else {
if (isset($email)) {
mail( $email, "Bandwidth Theft Alert",
"WARNING:\n\n$referrer\ntried to access\n$rta\n",
"From: RTA Anti-Leech <$email>" );
}
echo "Invalid file.";
}
}
else {
header( "Location: $homepage" );
}
?>
this code worked for a while and now it doesn't...at least for me.
i was able to click on the link and it gave me a dialog window to download the video from my forum.
now it won't give me that dialog window to download when i click on the link. it'll give the "invalid file" error.
but users on my board are still able to click on the link with no problem except for me.
sometimes it works and sometimes it doesn't like if the code is unstable.
what gives???
i'm not much of a php coder.
this file was given to me by someone i know.
i'm having troubles getting a hold of this person.
is there anyway that i can optimize this file?
any one of you can tell me why it stopped working and it allows my other members to download?
any help on how to fix this issue will be greatly appreciated.
thanks in advance.