Gossamer Forum
Home : General : Perl Programming :

checking referer

Quote Reply
checking referer
I'm having problems with a few clients ... but I can't get the reason. Some clients get an invalid referer message even if they are clicking from the same domain. Others are working correctly. ideas?

Code:
$REFERERCHECK = $ENV{'HTTP_REFERER'};
$REFERERCHECK =~ s/(http:\/\/|https:\/\/)//g;
@GETVALIDREF = split (/\//, $REFERERCHECK);
&results("Invalid Referer") unless ($ENV{'SERVER_NAME'} eq $GETVALIDREF[0]);

Thanks
Quote Reply
Re: [robyone] checking referer In reply to
>>
$REFERERCHECK =~ s/(http:\/\/|https:\/\/)//g;
<<

Could be:

$REFERERCHECK =~ s|http://||ig;

Hehe sorry I couldn't resist that. Anyway, if people are using a firewall they may not be sending a referer.

Try putting:

$ENV{'SERVER_NAME'} and $GETVALIDREF[0]

...in the error message and get people to tell you what it says.

Last edited by:

Paul: Sep 9, 2002, 2:44 AM
Quote Reply
Re: [robyone] checking referer In reply to
From previous experience, https:// servers don't send a HTTP_REFERER value....which is quite a bummer sometimes...

Your best bet is to print the value stored in $REFERERCHECK.

Hopefully I didn't repeat too much of what Paul said Tongue

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] checking referer In reply to
ok. thanks ... i did not consider firewalls settings.

:(

bye
Quote Reply
Re: [robyone] checking referer In reply to
Oops regarding that regex I posted, I didn't notice the https so you'd need:

$REFERERCHECK =~ s|https?://||ig;

But as Andy said, the referer won't be available using a secure connection (although it appears it is with NS but not IE)
Quote Reply
Re: [Paul] checking referer In reply to
In Reply To:
But as Andy said, the referer won't be available using a secure connection (although it appears it is with NS but not IE)

Hm. That's interesting. How did you discover this, or did you read it somewhere? I wander if it's available with Mozilla, Galleon, etc. etc.

- wil
Quote Reply
Re: [Wil] checking referer In reply to
I think Dan mentioned it in another thread.