diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index c540cdd3030..065de28665d 100755 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -87,7 +87,7 @@ $SOURCE=GETPOST("source",'alpha'); $ref=$REF=GETPOST('ref','alpha'); $TAG=GETPOST("tag",'alpha'); $FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations -$SECUREKEY=GETPOST("securekey",'alpha'); // Secure key +$SECUREKEY=GETPOST("securekey"); // Secure key if (! empty($SOURCE)) { @@ -138,10 +138,35 @@ if (empty($PAYPAL_API_SIGNATURE)) return -1; } +// Check security token +$valid=true; +if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) +{ + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + { + if ($REF) $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $REF); // REF always defined if SOURCE is defined + else $token = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN); + } + else + { + $token = $conf->global->PAYPAL_SECURITY_TOKEN; + } + if ($SECUREKEY != $token) $valid=false; + + if (! $valid) + { + print '