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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
> 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 |
|
|||
|
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 > > > > |
|
|||
|
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. |
|
|||
|
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 > > |