Simple CGI Script - PLEASE HELP!!!

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch
I am trying to do a simple CGI script that checks the referer and if referrer is valid, displays one thing, if not, displays another (I know very little about cgi/perl, by the way). Now here's what i have so far:

#!/usr/bin/perl

if (($ENV{'HTTP_REFERER'} eq "http://www.top-dollars.com/blank.htm") ||
($ENV{'HTTP_REFERER'} eq "http://top-dollars.com/blank.htm"))
{
print "Content-type: text/html\n\n";
print "<html><head><title>Sucess!</title></head>
<body bgcolor=white>
<p></p><p><center><font face=\"Verdana, Arial\" color=red size=\"3\"><b>GOOD REFERER!</b></font></center></p>
</body></html>";
exit;
}
else {
print "Content-type: text/html\n\n";
print "<html><head><title>Error!</title></head>
<body bgcolor=white>
<p></p><p><center><font face=\"Verdana, Arial\" color=red size=\"3\"><b>Invalid referer</b></font></center></p>
</body></html>";
exit;
}
###############################

The problem is, it goes to the "else" page even if the refered is valid!? What am i missing??? Thanks.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Well my timing is a little off but if you're still having the problem, maybe something like this will help...

Code:
#!/usr/bin/perl


    if ( $ENV{HTTP_REFERER} =~ m/$http:\/\/www\.top-dollars\.com/i ) {

print <<HTML;
<html><head><title>Sucess!</title></head>
<body bgcolor=white>
<p></p><p><center><font face="Verdana, Arial" color=red size="3"><b>GOOD REFERER!</b></font></cen
ter></p>
</body></html>
HTML

    } else {

print <<HTML;
<html><head><title>Error!</title></head>
<body bgcolor=white>
<p></p><p><center><font face="Verdana, Arial" color=red size="3"><b>Invalid referer</b></font></center></p>
</body></html>
HTML

    }

That will match all links from your domain. You can tweak the url if you only want the referer to be a specific page or pages.

-Nitro
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back