Reply to Re: Filtering by referer

Your name:

Reply:


Posted by ZeldorBlat on 11/18/05 05:26

>I am trying to figure out how to use the referer variable to check what
>domain the orignal request is coming from and if it's not from the domain
>where I placed the link then to deny the user access.
>I know this is not bulletproof security but it will make things a little
>more difficult for the user.

The only way it makes it more difficult for the user is that they have
to copy/paste the link into the address bar and hit enter -- which
typically doesn't (I think the spec even says it shouldn't) set the
referer in the request.

If you really wanted to do it, you could try this:

$validDomains = array('www.foo.com', 'www.bar.com', 'www.baz.com');
$isOk = false;
foreach($validDomains as $domain) {
if(stripos($_SERVER['HTTP_REFERER'], $domain)) {
$isOk = true;
break;
}
}
if(!$isOk) {
//redirect to somewhere else
}

That's untested and certainly not bulletproof.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация