[Q] Block all incoming visitors from a referrer domain?

This is a discussion on [Q] Block all incoming visitors from a referrer domain? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Some guy on another site has placed a link to my site on his, and overnight my bandwidth usage shot ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-12-2003
Sir Loin of Beef
 
Posts: n/a
Default [Q] Block all incoming visitors from a referrer domain?

Some guy on another site has placed a link to my site on his, and
overnight my bandwidth usage shot up by 1 gb.

How can I block all visitors coming to my site from his? What options
do I have? Is htaccess the only way? How would I go about it?

I have found the following php code. However, besides redirecting the
browser, as in header("Location: http://www.idontlikeyou.net/"); what
other options are open to me? Can I just halt loading of the page, or
return a blank page instead of redirecting?



<?php
// simple referer check

// check is referrer exists
if ($HTTP_REFERRER){
// check if the referrer is on your noentry list
// if so redirect it to another page
if ($HTTP_REFERRER == www.katoots.com) {
header("Location: http://www.idontlikeyou.net/");
exit;
}
// shows the referrer and formats ur local harddrive
echo "You came from $HTTP_REFERRER";
}
?>


In addition, the above code only looks at 1 referrer. How can I block
entry from multiple referrers?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 12-12-2003
Lars Raube
 
Posts: n/a
Default Re: [Q] Block all incoming visitors from a referrer domain?


> if ($HTTP_REFERRER == www.katoots.com) {
> header("Location: http://www.idontlikeyou.net/");
> exit;
> }
> // shows the referrer and formats ur local harddrive
> echo "You came from $HTTP_REFERRER";
> }
> ?>


> In addition, the above code only looks at 1 referrer. How can I block
> entry from multiple referrers?


Where is the prob ? If you want es like this way make it with thr OR
operator

if (($HTTP_REFERRER == 'www.katoots.com') OR
($HTTP_REFFERRER=='www.pageb.com') OR ... )
{ ...

or make Switch....there are many differents ways to do it....

greetz

Lars




Reply With Quote
  #3 (permalink)  
Old 12-12-2003
Sir Loin of Beef
 
Posts: n/a
Default Re: [Q] Block all incoming visitors from a referrer domain?

Thanks.

Now I have another problem.

I have another php script on the page that runs before this code; this
script already creates the http header, so the referrer blocker code
creates an error when it attempts to echo the http header for the
second time.

Is there any way around this? Is there any way to prevent the page
from loading if the referrer is an undesired one, short of using a
http header redirector?


On Fri, 12 Dec 2003 13:01:29 +0100, you wrote:

>
>> if ($HTTP_REFERRER == www.katoots.com) {
>> header("Location: http://www.idontlikeyou.net/");
>> exit;
>> }
>> // shows the referrer and formats ur local harddrive
>> echo "You came from $HTTP_REFERRER";
>> }
>> ?>

>
>> In addition, the above code only looks at 1 referrer. How can I block
>> entry from multiple referrers?

>
>Where is the prob ? If you want es like this way make it with thr OR
>operator
>
>if (($HTTP_REFERRER == 'www.katoots.com') OR
>($HTTP_REFFERRER=='www.pageb.com') OR ... )
>{ ...
>
>or make Switch....there are many differents ways to do it....
>
>greetz
>
>Lars
>
>
>
>



"Lars Raube" <raube@rzr.de> wrote:

>
>> if ($HTTP_REFERRER == www.katoots.com) {
>> header("Location: http://www.idontlikeyou.net/");
>> exit;
>> }
>> // shows the referrer and formats ur local harddrive
>> echo "You came from $HTTP_REFERRER";
>> }
>> ?>

>
>> In addition, the above code only looks at 1 referrer. How can I block
>> entry from multiple referrers?

>
>Where is the prob ? If you want es like this way make it with thr OR
>operator
>
>if (($HTTP_REFERRER == 'www.katoots.com') OR
>($HTTP_REFFERRER=='www.pageb.com') OR ... )
>{ ...
>
>or make Switch....there are many differents ways to do it....
>
>greetz
>
>Lars
>
>
>
>


Reply With Quote
  #4 (permalink)  
Old 12-12-2003
Lars Raube
 
Posts: n/a
Default Re: [Q] Block all incoming visitors from a referrer domain?

?

Which code is complied before ? you only have to place the stuff at the
rigth place...

greetz

Lars


Reply With Quote
  #5 (permalink)  
Old 12-12-2003
Michel
 
Posts: n/a
Default Re: [Q] Block all incoming visitors from a referrer domain?

Uhm..... just excuse me for a sec....

Some guys is sending you traffic and you want to block it?

Doesn't make very much sense...

Michel

"Sir Loin of Beef" <NOSPAMmdknight@pacific.net.sg> wrote in message
news:3fd9a907.48119279@news.starhub.net.sg...
> Some guy on another site has placed a link to my site on his, and
> overnight my bandwidth usage shot up by 1 gb.
>
> How can I block all visitors coming to my site from his? What options
> do I have? Is htaccess the only way? How would I go about it?
>
> I have found the following php code. However, besides redirecting the
> browser, as in header("Location: http://www.idontlikeyou.net/"); what
> other options are open to me? Can I just halt loading of the page, or
> return a blank page instead of redirecting?
>
>
>
> <?php
> // simple referer check
>
> // check is referrer exists
> if ($HTTP_REFERRER){
> // check if the referrer is on your noentry list
> // if so redirect it to another page
> if ($HTTP_REFERRER == www.katoots.com) {
> header("Location: http://www.idontlikeyou.net/");
> exit;
> }
> // shows the referrer and formats ur local harddrive
> echo "You came from $HTTP_REFERRER";
> }
> ?>
>
>
> In addition, the above code only looks at 1 referrer. How can I block
> entry from multiple referrers?
>
> Thanks.



Reply With Quote
  #6 (permalink)  
Old 12-12-2003
Sir Loin of Beef
 
Posts: n/a
Default Re: [Q] Block all incoming visitors from a referrer domain?

The thing is, I have 2 php blocks in my html file, like this.



<?php block 1; send out http header ?>

<?php block 2; send out http header again?>

<html>

</html>


The thing is, I can't change block 1 as it's used by a message board
php script on my page. Is there any way to deny access without
changing the http headers?

>?
>
>Which code is complied before ? you only have to place the stuff at the
>rigth place...
>
>greetz
>
>Lars
>
>


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:30 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0