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

From: Date: Tue, 02 Oct 2007 16:30:00 +0000
Subject: Re: Re: strpos error (I'm missing something obvious)
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-262645@lists.php.net to get a copy of this message
I didn't mean that the function was foolproof, only the match function itself. However, your suggestion to add the line start is simple and effective. Andrew Ballard wrote:
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 (#262645) next »