aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--index.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/index.php b/index.php
index 9ab70f6c..7795a597 100644
--- a/index.php
+++ b/index.php
@@ -302,12 +302,17 @@ function keepMultipleSpaces($text)
302// (Note that is may not work on your server if the corresponding local is not installed.) 302// (Note that is may not work on your server if the corresponding local is not installed.)
303function autoLocale() 303function autoLocale()
304{ 304{
305 $loc='en_US'; // Default if browser does not send HTTP_ACCEPT_LANGUAGE 305 $attempts = array('en_US'); // Default if browser does not send HTTP_ACCEPT_LANGUAGE
306 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) // e.g. "fr,fr-fr;q=0.8,en;q=0.5,en-us;q=0.3" 306 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) // e.g. "fr,fr-fr;q=0.8,en;q=0.5,en-us;q=0.3"
307 { // (It's a bit crude, but it works very well. Preferred language is always presented first.) 307 { // (It's a bit crude, but it works very well. Preferred language is always presented first.)
308 if (preg_match('/([a-z]{2}(-[a-z]{2})?)/i',$_SERVER['HTTP_ACCEPT_LANGUAGE'],$matches)) $loc=$matches[1]; 308 if (preg_match('/([a-z]{2})-?([a-z]{2})?/i',$_SERVER['HTTP_ACCEPT_LANGUAGE'],$matches)) {
309 $loc = $matches[1] . (!empty($matches[2]) ? '_' . strtoupper($matches[2]) : '');
310 $attempts = array($loc, str_replace('_', '-', $loc),
311 $loc . '_' . strtoupper($loc), $loc . '_' . $loc,
312 $loc . '-' . strtoupper($loc), $loc . '-' . $loc);
313 }
309 } 314 }
310 setlocale(LC_TIME,$loc); // LC_TIME = Set local for date/time format only. 315 setlocale(LC_TIME, $attempts); // LC_TIME = Set local for date/time format only.
311} 316}
312 317
313// ------------------------------------------------------------------------------------------ 318// ------------------------------------------------------------------------------------------
@@ -549,7 +554,7 @@ function endsWith($haystack,$needle,$case=true)
549function linkdate2timestamp($linkdate) 554function linkdate2timestamp($linkdate)
550{ 555{
551 $Y=$M=$D=$h=$m=$s=0; 556 $Y=$M=$D=$h=$m=$s=0;
552 $r = sscanf($linkdate,'%4d%2d%2d_%2d%2d%2d',$Y,$M,$D,$h,$m,$s); 557 sscanf($linkdate,'%4d%2d%2d_%2d%2d%2d',$Y,$M,$D,$h,$m,$s);
553 return mktime($h,$m,$s,$M,$D,$Y); 558 return mktime($h,$m,$s,$M,$D,$Y);
554} 559}
555 560