cvs: phpweb / search.php /include ip-to-country.inc langchooser.inc site.inc

From: Date: Sat, 17 May 2003 12:45:51 +0000
Subject: cvs: phpweb / search.php /include ip-to-country.inc langchooser.inc site.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17758@lists.php.net to get a copy of this message
goba Sat May 17 08:45:51 2003 EDT Modified files: /phpweb search.php /phpweb/include ip-to-country.inc langchooser.inc site.inc Log: Add new mirror_setcookie() function to set a cookie for all mirror sites, and use it for country and last language cookies set by our code Also add code to remember the last search term and selected search option in a cookie (JS code will come to handle this on the client side) Index: phpweb/search.php diff -u phpweb/search.php:1.78 phpweb/search.php:1.79 --- phpweb/search.php:1.78 Thu May 15 19:22:13 2003 +++ phpweb/search.php Sat May 17 08:45:51 2003 @@ -1,5 +1,5 @@ <?php -/* $Id: search.php,v 1.78 2003/05/15 23:22:13 jacques Exp $ */ +/* $Id: search.php,v 1.79 2003/05/17 12:45:51 goba Exp $ */ include_once "prepend.inc"; @@ -91,6 +91,9 @@ // ============================================================================ // We received something to search for if (isset($pattern)) { + + // Remember the last search settings for a week + mirror_setcookie("LAST_SEARCH", "$show,$pattern", 60*60*24*7); // Mailing list search base URL $ml_url = "http://marc.theaimsgroup.com/"; Index: phpweb/include/ip-to-country.inc diff -u phpweb/include/ip-to-country.inc:1.9 phpweb/include/ip-to-country.inc:1.10 --- phpweb/include/ip-to-country.inc:1.9 Thu May 8 13:38:02 2003 +++ phpweb/include/ip-to-country.inc Sat May 17 08:45:51 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: ip-to-country.inc,v 1.9 2003/05/08 17:38:02 goba Exp $ +// $Id: ip-to-country.inc,v 1.10 2003/05/17 12:45:51 goba Exp $ /* @@ -95,8 +95,9 @@ // Set global variable for further usage $COUNTRY = $country; - // Set the country in a cookie for a week and for all *.php.net servers - return setcookie("COUNTRY", "$country,$ipnum", time() + 60*60*24*7, '/', '.php.net'); + // Set the country in a cookie for a week + return mirror_setcookie("COUNTRY", "$country,$ipnum", 60*60*24*7); + } // Find nearest index entry for IP number Index: phpweb/include/langchooser.inc diff -u phpweb/include/langchooser.inc:1.24 phpweb/include/langchooser.inc:1.25 --- phpweb/include/langchooser.inc:1.24 Sat May 17 05:14:42 2003 +++ phpweb/include/langchooser.inc Sat May 17 08:45:51 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: langchooser.inc,v 1.24 2003/05/17 09:14:42 goba Exp $ +// $Id: langchooser.inc,v 1.25 2003/05/17 12:45:51 goba Exp $ /* @@ -55,8 +55,8 @@ if (isset($_REQUEST['lang'])) { $explicitly_specified = language_add($_REQUEST['lang'], $languages); - // Set the language in a cookie for a year and for all *.php.net servers - setcookie("LAST_LANG", $_REQUEST['lang'], time() + 60*60*24*365, '/', '.php.net'); + // Set the language in a cookie for a year + mirror_setcookie("LAST_LANG", $_REQUEST['lang'], 60*60*24*365); } // Specified in a shortcut URL (eg. /en/echo or /pt_br/echo) @@ -83,8 +83,8 @@ $explicitly_specified = $flang; } - // Set the language in a cookie for a year and for all *.php.net servers - setcookie("LAST_LANG", $flang, time() + 60*60*24*365, '/', '.php.net'); + // Set the language in a cookie for a year + mirror_setcookie("LAST_LANG", $flang, 60*60*24*365); } // Honor the users own language setting (if available) Index: phpweb/include/site.inc diff -u phpweb/include/site.inc:1.246 phpweb/include/site.inc:1.247 --- phpweb/include/site.inc:1.246 Sat May 3 16:11:20 2003 +++ phpweb/include/site.inc Sat May 17 08:45:51 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: site.inc,v 1.246 2003/05/03 20:11:20 goba Exp $ +// $Id: site.inc,v 1.247 2003/05/17 12:45:51 goba Exp $ // Define $MIRRORS array, and some constants include_once 'mirrors.inc'; @@ -145,6 +145,18 @@ // Always exit (the page is not to be displayed) exit; +} + +// Set a cookie for all the .php.net sites for the root +// dir with $name and $content. Provide $exptime relatively +// to the current time! +function mirror_setcookie($name, $content, $exptime) +{ + if (!headers_sent()) { + return setcookie($name, $content, time() + $exptime, '/', '.php.net'); + } else { + return FALSE; + } } // Use this function to write out proper headers on

« previous php.mirrors (#17758) next »