Re: Re: strpos error (I'm missing something obvious)

From: Date: Tue, 02 Oct 2007 15:32:36 +0000
Subject: Re: Re: strpos error (I'm missing something obvious)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-262643@lists.php.net to get a copy of this message
I'd suggest the following *slight* enhancement to make sure that the HTTP_REFERER actually *begins* with the site name, not simply contains it. // prevents visits from pages like http://badsite.com/form.htm?http://www.wnc.edu if (strpos($referer, $site) === 0) { echo 'yes'; } (or, if you like the preg solution) if (preg_match("%^$site%", $referer)) { //.... } However, I'd argue that the effectiveness of checking the referrer itself could be considered "negligible", and hardly "foolproof". The header is easily spoofed in scripts, and may not even be sent at all by legitimate clients because of various browser and/or personal firewall options. Andrew

« previous php.general (#262643) next »