mirror of
https://github.com/php/web-php.git
synced 2026-03-23 23:02:13 +01:00
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)
This commit is contained in:
@@ -95,8 +95,9 @@ function i2c_go()
|
||||
// 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
|
||||
|
||||
@@ -55,8 +55,8 @@ function language_choose_code()
|
||||
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 @@ function language_choose_code()
|
||||
$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)
|
||||
|
||||
@@ -147,6 +147,18 @@ function mirror_redirect($absoluteURI, $remote = FALSE)
|
||||
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
|
||||
// pages where the content should not be publicly cached
|
||||
function header_nocache()
|
||||
|
||||
@@ -92,6 +92,9 @@ if (isset($base)) {
|
||||
// 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/";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user