aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php31
1 files changed, 6 insertions, 25 deletions
diff --git a/index.php b/index.php
index c2bec1db..6712f90e 100644
--- a/index.php
+++ b/index.php
@@ -268,7 +268,7 @@ $GLOBALS['redirector'] = !empty($GLOBALS['redirector']) ? escape($GLOBALS['redir
268// a token depending of deployment salt, user password, and the current ip 268// a token depending of deployment salt, user password, and the current ip
269define('STAY_SIGNED_IN_TOKEN', sha1($GLOBALS['hash'].$_SERVER["REMOTE_ADDR"].$GLOBALS['salt'])); 269define('STAY_SIGNED_IN_TOKEN', sha1($GLOBALS['hash'].$_SERVER["REMOTE_ADDR"].$GLOBALS['salt']));
270 270
271autoLocale(); // Sniff browser language and set date format accordingly. 271autoLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']); // Sniff browser language and set date format accordingly.
272header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling. 272header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling.
273 273
274//================================================================================================== 274//==================================================================================================
@@ -315,26 +315,6 @@ function setup_login_state() {
315} 315}
316$userIsLoggedIn = setup_login_state(); 316$userIsLoggedIn = setup_login_state();
317 317
318
319// ------------------------------------------------------------------------------------------
320// Sniff browser language to display dates in the right format automatically.
321// (Note that is may not work on your server if the corresponding local is not installed.)
322function autoLocale()
323{
324 $attempts = array('en_US'); // Default if browser does not send HTTP_ACCEPT_LANGUAGE
325 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) // e.g. "fr,fr-fr;q=0.8,en;q=0.5,en-us;q=0.3"
326 { // (It's a bit crude, but it works very well. Preferred language is always presented first.)
327 if (preg_match('/([a-z]{2})-?([a-z]{2})?/i',$_SERVER['HTTP_ACCEPT_LANGUAGE'],$matches)) {
328 $loc = $matches[1] . (!empty($matches[2]) ? '_' . strtoupper($matches[2]) : '');
329 $attempts = array($loc.'.UTF-8', $loc, str_replace('_', '-', $loc).'.UTF-8', str_replace('_', '-', $loc),
330 $loc . '_' . strtoupper($loc).'.UTF-8', $loc . '_' . strtoupper($loc),
331 $loc . '_' . $loc.'.UTF-8', $loc . '_' . $loc, $loc . '-' . strtoupper($loc).'.UTF-8',
332 $loc . '-' . strtoupper($loc), $loc . '-' . $loc.'.UTF-8', $loc . '-' . $loc);
333 }
334 }
335 setlocale(LC_TIME, $attempts); // LC_TIME = Set local for date/time format only.
336}
337
338// ------------------------------------------------------------------------------------------ 318// ------------------------------------------------------------------------------------------
339// PubSubHubbub protocol support (if enabled) [UNTESTED] 319// PubSubHubbub protocol support (if enabled) [UNTESTED]
340// (Source: http://aldarone.fr/les-flux-rss-shaarli-et-pubsubhubbub/ ) 320// (Source: http://aldarone.fr/les-flux-rss-shaarli-et-pubsubhubbub/ )
@@ -1243,11 +1223,12 @@ function renderPage()
1243 uksort($tags, function($a, $b) { 1223 uksort($tags, function($a, $b) {
1244 // Collator is part of PHP intl. 1224 // Collator is part of PHP intl.
1245 if (class_exists('Collator')) { 1225 if (class_exists('Collator')) {
1246 $c = new Collator(setlocale(LC_ALL, 0)); 1226 $c = new Collator(setlocale(LC_COLLATE, 0));
1247 return $c->compare($a, $b); 1227 if (!intl_is_failure(intl_get_error_code())) {
1248 } else { 1228 return $c->compare($a, $b);
1249 return strcasecmp($a, $b); 1229 }
1250 } 1230 }
1231 return strcasecmp($a, $b);
1251 }); 1232 });
1252 1233
1253 $tagList=array(); 1234 $tagList=array();