To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
Code CritiqueHaving someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.
the other script checks for the existence of this session variable before spitting out the file that was requested. If the session variable does not exist then the second script spits out a file that displays hot linker on the person's screen instead of the requested file.
It is weak due to the use of session variables. I have another one written that uses $_SERVER['HTTP_REFERER'] instead which is a bit stronger but could fail if the http_referer is blank for any reason. I'll be working up a third version in the near future that puts both methods together. It is for a series of articles for my web site.
Cool man,
do you have a login script, like say someone is not a member on your site.
Any link he clicks it well say something like "Hey guest, click here to login, etc"? Where can i get a script like this or do you already have one? Thanks bro.
if (($File != @fopen ($_GET['File'], "br") || strpos($HTTP_REFERRER, $MySiteName) === false))
// If the file can't be opened, or the http_referrer is not from your site.
{
// Open the 'NotFound' file and change the filesize accordingly
$FileLength = filesize("Images/NotFound.gif");
$File = fopen ("Images/NotFound.gif");
// The 'notFound' file had better exist, otherwise the image will show as a red X!
}
else
{
// get the filesize of the file that we're loading
$FileLength = filesize($_GET['File']);
}
$File2 = fread($File, $FileLength);
fclose ($File);
// Get the contents of the file and then close it.
echo $File;
// print out the contents of the file.
?>
This is just something that I came up with off the top of my head to do a similar thing.
edit: this is probably riddled with errors, I didn't check anything on the PHP manual before I posted, but the comments should give you the general idea.
what we do is, have the page that SHOULD HAVE refered it set a session or other variable. if this variable isn't present/correct when the user tries to download the file, deny access.