Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Firstly let me clarify a few things up.</p> <p>When your on localhost your not using your ISP To fetch a webpage, thus you would use an internal ip of <code>127.0.0.1</code> or <code>::1</code> for ipv6.</p> <p>If your fetching the page from over a local network via a router of some kind, you will have an ip assigned by the router such as <code>192.168.1.90</code></p> <p>if your site is hosted outside the network then you ask your ISP to fetch the site for you, meaning you get use the IP specified by whatsmyip.</p> <p>if your using a DNS Server such as Opendns then your asking your ISP to ask Opendns to fetch the site for you, and open dns uses a set of ip's that are different to yours for obvious reasons.</p> <p>there may be some sort of proxy that may be interfering, so what you should do is counter for that, a standard proxy site should forward the clients IP on to the server incase of any direct connections required and for several other reasons.</p> <p>This being said you can usually find the IP by checking several other params before you check <code>REMOTE_ADDR</code>, here is a class I have created for one of my projects but you can just take what you need:</p> <p><a href="https://github.com/AdminSpot/ASDDL/blob/master/system/classes/http/request.php" rel="nofollow">https://github.com/AdminSpot/ASDDL/blob/master/system/classes/http/request.php</a></p> <pre><code>foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) { if (array_key_exists($key, $_SERVER) === true) { foreach (explode(',', $_SERVER[$key]) as $ip) { if (filter_var($ip, FILTER_VALIDATE_IP) !== false) { $this-&gt;ip = $ip; break; } } } } </code></pre> <p>As you can see the order of the array is very important:</p> <ul> <li>HTTP_CLIENT_IP</li> <li>HTTP_X_FORWARDED_FOR</li> <li>HTTP_X_FORWARDED</li> <li>HTTP_X_CLUSTER_CLIENT_IP</li> <li>HTTP_FORWARDED_FOR</li> <li>HTTP_FORWARDED</li> <li>REMOTE_ADDR</li> </ul> <p>notice the <code>REMOTE_ADDR</code> comes last, this is because this is the last resort and most of the time is incorrect.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload