cvs: phpweb /include ip-to-country.inc

From: Date: Fri, 02 May 2003 20:05:09 +0000
Subject: cvs: phpweb /include ip-to-country.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17227@lists.php.net to get a copy of this message
goba Fri May 2 16:05:09 2003 EDT Modified files: /phpweb/include ip-to-country.inc Log: Drop out a few spaces, and simulate cookie setting for the first time the cookie is set Index: phpweb/include/ip-to-country.inc diff -u phpweb/include/ip-to-country.inc:1.1 phpweb/include/ip-to-country.inc:1.2 --- phpweb/include/ip-to-country.inc:1.1 Fri May 2 09:59:19 2003 +++ phpweb/include/ip-to-country.inc Fri May 2 16:05:09 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: ip-to-country.inc,v 1.1 2003/05/02 13:59:19 goba Exp $ +// $Id: ip-to-country.inc,v 1.2 2003/05/02 20:05:09 goba Exp $ /* @@ -53,26 +53,29 @@ function i2c_go() { global $_SERVER, $_COOKIE; - + // User already has a country detected if (!empty($_COOKIE['COUNTRY'])) { return TRUE; } - + // User is behind a proxy if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ipnum = i2c_ip2num($_SERVER['HTTP_X_FORWARDED_FOR']); } - + // This is the real IP of the user else { $ipnum = i2c_ip2num($_SERVER['REMOTE_ADDR']); } - + // Find the index to start search from $idx = i2c_search_in_index($ipnum); - + // Search in the database from the given index $country = i2c_search_in_db($ipnum, $idx); - + + // Simulate cookie + $_COOKIE['COUNTRY'] = $country; + // Set the country in a cookie for a week and for all *.php.net servers return setcookie("COUNTRY", $country, time() + 60*60*24*7, '/', '.php.net'); }

« previous php.mirrors (#17227) next »