HTTP_REFERER

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gimenei
Forum Newbie
Posts: 1
Joined: Wed Dec 31, 2003 1:19 am

HTTP_REFERER

Post by gimenei »

Hello!

I'm building a payment gateway between my e-commerce site and 2checkout.com.

I'm using following Perl code to check that user is refered from 2Checkout.com.

I'm trying to write a similar code in PHP. Everything works fine when referer is a regular site, but when the referer is secure site (ex. https://www.2checkout.com), HTTP_REFERER variable is just empty!!

Could someone please help me with it? Any ideas?

Thank You!
Janno

@referers=("www.2checkout.com","2checkout.com");
&check_url;
sub check_url {
local($check_referer) = 0;
if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
$check_referer = 1;
last;
}
}
}
else {
$check_referer = 1;
}

if ($check_referer != 1) {
print "Bad Referrer - Merchant should put in code to write to a log or mail themselves a
note to verify order was billed in 2Checkout.com system"; }
}
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Basing my answer from this:
http://www.mail-archive.com/e-gold-tech ... 00350.html

You might be able to do something similar.

Here's what the dude suggested:
http://www.mail-archive.com/e-gold-tech ... 00351.html
Post Reply