Page 1 of 2
Bandwidth stealing block
Posted: Wed Sep 11, 2002 2:00 am
by codewarrior
Wasn't sure where to post this ... but here I'm
I'm looking for some code that would block bandwidth stealing... you know what people like pic on your site and use them on other sites or make a file linkable to other site without telling you ... hence the term Bandwidth stealing
Anyone know any code on it? or could guide me in the right direction.
THanks a million!

Posted: Wed Sep 11, 2002 2:02 am
by volka
Posted: Wed Sep 11, 2002 2:10 am
by codewarrior
Danke schön!
Posted: Wed Sep 11, 2002 2:13 am
by volka
de rien

Posted: Wed Sep 11, 2002 5:21 am
by Takuma
I don't know German.... BUt I can speak Japanese lol!
Can't you do this with PHP cos I can't edit Apache since it's not my own wb server...
doumo

Posted: Wed Sep 11, 2002 9:19 am
by qads
you could use something like:
last link = the link the user clicked before getting to the current page..
"if the last link = part of your site address then show image/file, else print error msg...."
does it make any sense? if it does't then i will make a script it to show what i mean :/
Posted: Wed Sep 11, 2002 9:27 am
by Coco
yeah just do a conditional on the referal url.... if it aint you they dont get the piccy
Posted: Wed Sep 11, 2002 9:32 am
by Takuma
But you can't do it to an image...
Posted: Wed Sep 11, 2002 9:36 am
by qads
why not? you only need a part of your own url, this could be sitename.com
forget the rest....
Posted: Wed Sep 11, 2002 12:26 pm
by sinewave
how would that actually stop someone from hotlinking it? how would you specify all pictures..and not block them from linking to you directly
Posted: Wed Sep 11, 2002 12:44 pm
by Takuma
Sorry forgot to say
Can't block images with PHP...
Posted: Wed Sep 11, 2002 1:41 pm
by ShrineMaster
Images are easy to block with php, just never link directly to the images on your own site and feed them through a PHP script that checks the referer.
Since some browsers don't send refering information to the server you only want to apply your referer check to those that actually show the referer.
Also when you do your referer check, make sure that the host name is located in the correct part of the refering url. if you don't check that, something like:
http://www.somesite.com/page.html?http: ... rpage.html
will show your images. I found this out when I noticed archives of my site on google were loading images off my server.
Code: Select all
if ($HTTP_REFERER) {
$referer = strtolower($HTTP_REFERER);
$host = strtolower($HTTP_HOST);
if (strpos($referer, "http://$host") != 0 || !stristr($referer, "http://$host")) {
readfile("./images/dontlinktothis.jpg");
exit;
}
}
Use the header() functions to tell the browser it is an image and use readfile() to pass the image data through.
Posted: Wed Sep 11, 2002 2:01 pm
by codewarrior
Yeah Images are easy, its the dang Files that people keep on stealing. I wouldn't mind if they just asked. But NO! They have to go out and be sneeky! I hate that!

I'll try the code which was proposed. I hope it works coz
BHD's Demo come out tomorrow!

Posted: Wed Sep 11, 2002 2:17 pm
by codewarrior
qads wrote:you could use something like:
last link = the link the user clicked before getting to the current page..
"if the last link = part of your site address then show image/file, else print error msg...."
does it make any sense? if it does't then i will make a script it to show what i mean :/
<====== Complete N00B here!

Went over me head! Would really appreciate a script

Thanks in advance.

Posted: Wed Sep 11, 2002 3:50 pm
by qads
if ($HTTP_REFERER) {
$referer = $HTTP_REFERER;
$host = "your.site";
if ($referer == '$host')
{
print("image, text, link to download file etc");
}
else
{
print("this is stealing!");
}
}
it is soemthing like that :/
if you put $host in a array and loop with each(); then you can have more then 1 domain allowed to load the files
i don't think the above code will work cos i have't tested it, but you should get the idea...