WordPress.org

Forums

Visitor Country
[resolved] Getting IP through proxy using HTTP_X_FORWARD_FOR (4 posts)

  1. ade11
    Member
    Posted 2 years ago #

    We ran into an issue with one of our servers. We believe in your LoadVisitorData() function, the $_SERVER variable 'HTTP_X_FORWARD_FOR' should be 'HTTP_X_FORWARDED_FOR' ?

    Also, some servers will use HTTP_CLIENT_IP. And some configurations will return a list of IP addresses. One of our senior developers submitted this snippet, which would solve all these problems;

    // Get the visitor IP
    $ip=$_SERVER['REMOTE_ADDR'];
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {               // check ip from share internet
    	$ip=$_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {   // to check ip is pass from proxy
    	$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    $ips = explode(",", $ip);
    $this->mIP=$ips[0];

    Please can this or similar be incorporated in your next release?

    Many thanks!

    http://wordpress.org/extend/plugins/visitor-country/

  2. Bombdogs
    Member
    Posted 2 years ago #

    +1 for this request.

  3. Izhaki
    Member
    Plugin Author

    Posted 2 years ago #

    Implemented in 1.0.1.

  4. ade11
    Member
    Posted 2 years ago #

    many thanks!

    works perfectly!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.