FIX Bad remote ip address when user is using a proxy

This commit is contained in:
Laurent Destailleur
2019-02-15 15:17:24 +01:00
parent 8d699c2b49
commit c480f4be68
2 changed files with 10 additions and 8 deletions

View File

@@ -2636,7 +2636,7 @@ function dol_print_ip($ip, $mode = 0)
* Return the IP of remote user.
* Take HTTP_X_FORWARDED_FOR (defined when using proxy)
* Then HTTP_CLIENT_IP if defined (rare)
* Then REMOTE_ADDR (not way to be modified by user but may be wrong if using proxy)
* Then REMOTE_ADDR (no way to be modified by user but may be wrong if user is using a proxy)
*
* @return string Ip of remote user.
*/

View File

@@ -185,10 +185,12 @@ class Stripe extends CommonObject
}
elseif ($createifnotlinkedtostripe)
{
$ipaddress = getUserRemoteIP();
$dataforcustomer = array(
"email" => $object->email,
"description" => $object->name,
"metadata" => array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']))
"metadata" => array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress)
);
$vatcleaned = $object->tva_intra ? $object->tva_intra : null;