Gossamer Forum
Home : General : Perl Programming :

add.cgi referrer check fails with Windows NT systems

Quote Reply
add.cgi referrer check fails with Windows NT systems
Hi,

The following code in add.cgi which I enabled a few weeks ago after I started receiving submissions from people posting data from external forms, give an error to WINDOWS NT users.

# Check the referer.
# if (@db_referers and $ENV{'HTTP_REFERER'}) {
if (@db_referers) {
$found = 0;
foreach (@db_referers) {
$ENV{'HTTP_REFERER'} =~ /$_/i and $found++ and last;
}
if (!$found) {
&site_html_login_add_failure ("You will need to visit our website to add your entry.");
return;
}
}


Is there a fix for this so I can stop external users from submitting forms but don't want to lose clients visting our site but are using NT systems?

Thanks
Quote Reply
Re: [socrates] add.cgi referrer check fails with Windows NT systems In reply to
Hi,

It could be a header issue. Try;

Code:
if (!$found) {
print "Content-Type: text/html \n\n";
&site_html_login_add_failure ("You will need to visit our website to add your entry.");
return;
}


Hope that helps.

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] add.cgi referrer check fails with Windows NT systems In reply to
Andy,

I am not sure if you understood my issue.

Windows NT users get the error message even when they add a listing by visiting my site. They are able to see the error message but they just can't get through the form. I want them to be able to add the listing while they are filling the form on my site.

Thanks
Quote Reply
Re: [socrates] add.cgi referrer check fails with Windows NT systems In reply to
Ah, I understand now =)

Code:
# Check the referer.
if (@db_referers) {

$found = 0;
foreach (@db_referers) {
if ($ENV{'HTTP_REFERER'} =~ /$_/i) { $found++; last; }
}
if (!$found) {
my $ref = $ENV{'HTTP_REFERER'};
&site_html_login_add_failure ("You will need to visit our website to add your entry. (sent from $ref)");
return;
}

}

This should then at least give them the value of $ENV{'HTTP_REFERER'}, so that they can pass this onto you, for more debugging information.

Other than that... its a bit hard to know why/how its failing with NT users :(

Cheers

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!