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

From: Date: Sat, 03 May 2003 15:33:16 +0000
Subject: cvs: phpweb /include ip-to-country.inc prepend.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17250@lists.php.net to get a copy of this message
goba Sat May 3 11:33:16 2003 EDT Modified files: /phpweb/include ip-to-country.inc prepend.inc Log: Let's have a var, named $COUNTRY which identifies the user's country (much like what $LANG 'does' for the language) Index: phpweb/include/ip-to-country.inc diff -u phpweb/include/ip-to-country.inc:1.3 phpweb/include/ip-to-country.inc:1.4 --- phpweb/include/ip-to-country.inc:1.3 Fri May 2 19:28:34 2003 +++ phpweb/include/ip-to-country.inc Sat May 3 11:33:16 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: ip-to-country.inc,v 1.3 2003/05/02 23:28:34 pollita Exp $ +// $Id: ip-to-country.inc,v 1.4 2003/05/03 15:33:16 goba Exp $ /* @@ -52,10 +52,13 @@ // cookie already storing this information) function i2c_go() { - global $_SERVER, $_COOKIE; + global $_SERVER, $_COOKIE, $COUNTRY; // User already has a country detected - if (!empty($_COOKIE['COUNTRY'])) { return TRUE; } + if (!empty($_COOKIE['COUNTRY'])) { + $COUNTRY = $_COOKIE['COUNTRY']; + return TRUE; + } // User is behind a proxy if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { @@ -73,8 +76,8 @@ // Search in the database from the given index $country = i2c_search_in_db($ipnum, $idx); - // Simulate cookie - $_COOKIE['COUNTRY'] = $country; + // Set global variable for futher usage + $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'); Index: phpweb/include/prepend.inc diff -u phpweb/include/prepend.inc:1.22 phpweb/include/prepend.inc:1.23 --- phpweb/include/prepend.inc:1.22 Fri May 2 16:05:46 2003 +++ phpweb/include/prepend.inc Sat May 3 11:33:16 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: prepend.inc,v 1.22 2003/05/02 20:05:46 goba Exp $ +// $Id: prepend.inc,v 1.23 2003/05/03 15:33:16 goba Exp $ // Start measuring time spent on page $page_creation_start = getmicrotime(); @@ -18,6 +18,7 @@ unset($SIDEBAR_DATA); unset($SEARCH_BASE); unset($LANG); +unset($COUNTRY); // Backward compatible array creation. After this point, the // PHP 4.1.0+ arrays can be used to access variables coming

« previous php.mirrors (#17250) next »