CloudFlare Visitor Real IP Address Detection

  • 2015-12-05 04:55:47
  • Ekrem KAYA
  • E-Commerce
  • Tutorials
  • 0 comment(s)
  • 3190

If you are using CloudFlare, ip addresses of users who visit your site will give erroneous results. You will see incorrect results when you check Reports -> Customers -> Online Customers menu. When your customers login or checkout order IP address will be inserted incorrectly. This will cause the wrong ip address blocking or incorrect IP address is sent to payment gateway, you may experience problems with your order.

Opencart users can get rid of this problem with the following minor modifications.

index.php and admin/index.php open files.

FIND

$registry->set('cache', $cache);

ADD AFTER

$ipdetect = isset($request->server['REMOTE_ADDR']) ? $request->server['REMOTE_ADDR'] : '';

// Detect client IP is store is behind CloudFlare protection.
if (isset($request->server['HTTP_CF_CONNECTING_IP']) && filter_var($request->server['HTTP_CF_CONNECTING_IP'], FILTER_VALIDATE_IP)) {
	$ipdetect = $request->server['HTTP_CF_CONNECTING_IP'];
}

// Get real client IP is they are behind proxy server.
if (isset($request->server['HTTP_X_FORWARDED_FOR']) && filter_var($request->server['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) {
	$ipdetect = $request->server['HTTP_X_FORWARDED_FOR'];
}

$request->server['REMOTE_ADDR'] = $ipdetect;
    Loading...
Last Update: 2015-12-09 17:34:14

Ekrem KAYA

1985 Gemlik doğumlu, müzik ve yemek ayrımı yapmayan, maviye hayran, sabrının sınırlarını zorlayan, beyninde yüz bin baloncuk gezen, yengeç burcu bir dünyalı.

Related Articles

Loading...

Write a Comment

Reply

Note: HTML is not translated!

  • CloudFlare Visitor Real IP Address Detection
  • http://static.e-piksel.com/image/cache/catalog/articles/tutorials/cloudflare-visitor-real-ip-address-detect-500x350.jpg
  • 2015-12-05 04:55:47
  • 2015-12-09 17:34:14
  • If you are using CloudFlare, ip addresses of users who visit your site will give erroneous results. You will see incorrect results when you check Reports -> Customers -> Online Customers menu. When your customers login or checkout order IP address will be inserted incorrectly. This will cause the wrong ip address blocking or incorrect IP address is sent to payment gateway, you may experience problems with your order.

    Opencart users can get rid of this problem with the following minor modifications.

    index.php and admin/index.php open files.

    FIND

    $registry->set('cache', $cache);

    ADD AFTER

    $ipdetect = isset($request->server['REMOTE_ADDR']) ? $request->server['REMOTE_ADDR'] : '';
    
    // Detect client IP is store is behind CloudFlare protection.
    if (isset($request->server['HTTP_CF_CONNECTING_IP']) && filter_var($request->server['HTTP_CF_CONNECTING_IP'], FILTER_VALIDATE_IP)) {
    	$ipdetect = $request->server['HTTP_CF_CONNECTING_IP'];
    }
    
    // Get real client IP is they are behind proxy server.
    if (isset($request->server['HTTP_X_FORWARDED_FOR']) && filter_var($request->server['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) {
    	$ipdetect = $request->server['HTTP_X_FORWARDED_FOR'];
    }
    
    $request->server['REMOTE_ADDR'] = $ipdetect;