cvs: phpweb /include ip-to-country.inc
| From: | Gabor Hojtsy | Date: | Thu, 18 Sep 2003 15:24:59 +0000 |
| Subject: | cvs: phpweb /include ip-to-country.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-21080@lists.php.net to get a copy of this message | ||
goba Thu Sep 18 11:24:59 2003 EDT
Modified files:
/phpweb/include ip-to-country.inc
Log:
Give priority to HTTP_CLIENT_IP over REMOTE_ADDR and
HTTP_X_FORWARDED_FOR, suggested by Nuno Lopes.
Index: phpweb/include/ip-to-country.inc
diff -u phpweb/include/ip-to-country.inc:1.18 phpweb/include/ip-to-country.inc:1.19
--- phpweb/include/ip-to-country.inc:1.18 Tue May 27 12:40:05 2003
+++ phpweb/include/ip-to-country.inc Thu Sep 18 11:24:58 2003
@@ -1,6 +1,6 @@
<?php // -*- C++ -*-
-// $Id: ip-to-country.inc,v 1.18 2003/05/27 16:40:05 goba Exp $
+// $Id: ip-to-country.inc,v 1.19 2003/09/18 15:24:58 goba Exp $
/*
@@ -188,6 +188,11 @@
// if any IP is found behind a firewall)
$ip = FALSE;
+ // If HTTP_CLIENT_IP is set, then give it priority
+ if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
+ $ip = $_SERVER["HTTP_CLIENT_IP"];
+ }
+
// User is behind a proxy and check that we discard RFC1918 IP addresses
// if they are behind a proxy then only figure out which IP belongs to the
// user. Might not need any more hackin if there is a squid reverse proxy
@@ -196,6 +201,7 @@
// Put the IP's into an array which we shall work with shortly.
$ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
+ if ($ip) { array_unshift($ips, $ip); $ip = FALSE; }
for ($i = 0; $i < count($ips); $i++) {
// Skip RFC 1918 IP's 10.0.0.0/8, 172.16.0.0/12 and