cvs: phpweb / my.php /include langchooser.inc
| From: | Jacques Marneweck | Date: | Wed, 14 May 2003 00:50:53 +0000 |
| Subject: | cvs: phpweb / my.php /include langchooser.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-17597@lists.php.net to get a copy of this message | ||
jacques Tue May 13 20:50:53 2003 EDT
Modified files:
/phpweb my.php
/phpweb/include langchooser.inc
Log:
* Busy fixing all the errors that appears when E_NOTICE is set on php.net
as reported by James Cox in his e-mail with message id
<MMEPJPGPACDMPGEEKFMKIECLLCAA.james@imajes.info>
--jm
Index: phpweb/my.php
diff -u phpweb/my.php:1.13 phpweb/my.php:1.14
--- phpweb/my.php:1.13 Mon May 5 15:56:44 2003
+++ phpweb/my.php Tue May 13 20:50:53 2003
@@ -1,5 +1,5 @@
<?php
-/* $Id: my.php,v 1.13 2003/05/05 19:56:44 goba Exp $ */
+/* $Id: my.php,v 1.14 2003/05/14 00:50:53 jacques Exp $ */
include_once "prepend.inc";
@@ -20,7 +20,7 @@
$langs[$_POST['my_lang']] . "</option>\n";
// Remove, so it is not listed two times
- unset($langs[$_POST['lang']]);
+ unset($langs[$_POST['my_lang']]);
}
// We have recevied a cookie and it is an available language
@@ -90,7 +90,7 @@
(isset($_COOKIE['LAST_LANG']) ? $_COOKIE['LAST_LANG'] : "None"),
"Your Accept-Language browser setting" =>
- $_SERVER['HTTP_ACCEPT_LANGUAGE'],
+ (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE']
: "None"),
"The mirror's default language" =>
default_language(),
Index: phpweb/include/langchooser.inc
diff -u phpweb/include/langchooser.inc:1.19 phpweb/include/langchooser.inc:1.20
--- phpweb/include/langchooser.inc:1.19 Sat Mar 15 07:56:28 2003
+++ phpweb/include/langchooser.inc Tue May 13 20:50:53 2003
@@ -1,6 +1,6 @@
<?php // -*- C++ -*-
-// $Id: langchooser.inc,v 1.19 2003/03/15 12:56:28 goba Exp $
+// $Id: langchooser.inc,v 1.20 2003/05/14 00:50:53 jacques Exp $
/*
@@ -99,21 +99,25 @@
// Specified by the user via the browser's Accept Language setting
// Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5"
- $browser_accept = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$browser_langs = array(); $parsed_langs = array();
-
- // Go through all language preference specs
- foreach ($browser_accept as $langpref) {
-
- // The language part is either a code or a code with a quality
- // We cannot do anything with a * code, so it is skipped
- // If the quality is missing, it is assumed to be 1 according to the RFC
- if (preg_match("!([a-z-]+)(;q=([0-9\\.]+))?!", trim($langpref), $found)) {
- $quality = (isset($found[3]) ? (float) $found[3] : 1.0);
- $browser_langs[] = array($found[1], $quality);
- }
- unset($found);
- }
+
+ // Check if we have $_SERVER['HTTP_ACCEPT_LANGUAGE'] set and
+ // it no longer breaks if you only have one language set :)
+ if (isset ($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+ $browser_accept = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
+
+ // Go through all language preference specs
+ for ($i = 0; $i < count($browser_accept); $i++) {
+ // The language part is either a code or a code with a quality
+ // We cannot do anything with a * code, so it is skipped
+ // If the quality is missing, it is assumed to be 1 according to the RFC
+ if (preg_match("!([a-z-]+)(;q=([0-9\\.]+))?!", trim($browser_accept[$i]), $found)) {
+ $quality = (isset($found[3]) ? (float) $found[3] : 1.0);
+ $browser_langs[] = array($found[1], $quality);
+ }
+ unset($found);
+ }
+ }
// Order the codes by quality
usort($browser_langs, "language_accept_order");
@@ -191,3 +195,5 @@
if ($a[1] == $b[1]) { return 0; }
return ($a[1] > $b[1]) ? -1 : 1;
}
+
+/* vim: set noet ts=4 sw=4 ft=php: : */