View Full Version : passback from 2CO .. how to know?
salehwar 07-11-2004, 04:38 PM Hi,
Please I want PHP code can be used to verify that the passback to to my site was initiated by 2Checkout?
There is 1 in 2CO .. but its in perl .. i want in php please
Thank ypu
Sharif 07-11-2004, 10:53 PM I don't know it myself but PHP code for it exists! Try contacting 2CO for it.
Burhan 07-12-2004, 02:45 AM $valid_domains = array("www.2checkout.com", "2checkout.com", "www2.2checkout.com");
$invalid = false;
if ($_SERVER['HTTP_REFERER'] != "")
{
$bits = parse_url($_SERVER['HTTP_REFERER']);
if (!in_array($bits['host'],$valid_domains)) { $invalid = true; }
}
$invalid = true;
if ($invalid) { echo "Referer doesn't match"; }
salehwar 07-12-2004, 03:28 AM Thank you alot
salehwar 07-12-2004, 06:19 AM I tried your code ,,, but it always do the command echo "Referer doesn't match";
I don't know why?!
armadillo 07-12-2004, 06:24 AM Does the domain that is being passed back from (the 2 checkout domain) match the ones that are listed in the first array of the code?
salehwar 07-12-2004, 06:28 AM it is :
https://www.2checkout.com/cgi-bin/crbuyers/recpurchase1.2c
Burhan 07-12-2004, 06:30 AM Take out the $invalid = true; line before the if() condition.
xelav 07-12-2004, 07:03 AM IMO there is no sense to check HTTP_REFERER, because this environment variable generates by browser, and a "hacker" can change it as he want.
barrywien 07-12-2004, 07:14 AM Its a superglobal, so cant be hacked.
$_SERVER['HTTP_REFERER']
http://www.php.net/manual/en/reserved.variables.php
salehwar 07-12-2004, 07:58 AM what is the best way?
barrywien 07-12-2004, 08:00 AM Use the code fyrestrtr has mentioned, it will work. Getting into passback is not a simple task, it requires a lot of time and effort to get it working the way you require but once it works, it works well!
Burhan 07-12-2004, 08:22 AM Originally posted by barrywien
Its a superglobal, so cant be hacked.
$_SERVER['HTTP_REFERER']
http://www.php.net/manual/en/reserved.variables.php
This is a very wrong way of thinking. Just because a variable is a super-global doesn't mean that it can't be compromised.
HTTP_REFERER is set by the browser. Some browsers allow you to change/customize this setting. Any competent programmer can send you a fake HTTP_REFERER header by simply opening a socket to your server.
salehwar 07-12-2004, 11:53 AM I taked out $invalid = true;
and when it works.. i tried using my browser FILENAME.php?credit_card_processed=Y
and it doesn't appearse Referer doesn't match.. it continue like the browser was from 2checkout site..
So .. there is something wrong in the code
Burhan 07-12-2004, 12:32 PM I don't think you understand how referer works.
Replace all the code with echo "<pre>"; print_r($_SERVER['HTTP_REFERER']); echo "</pre>"; to find out what actually is in the array.
lwknet 07-13-2004, 03:40 PM i've never seen anyone checking HTTP_REFERER for serious stuff...
i do not use 2co myself but i do believe in the POST there will be some params you can specify in the 2co website to validate it comes from 2co but not others, validate using ips are also non-sense since ips can be spoofed just like HTTP_REFERER
paypal does this in a more robust way, you receive the notification from paypal, POST it back to paypal, and paypal will send you a status code like OK/FAILED
|