cvs: php4 /pear HTTP.php

From: Date: Tue, 18 Dec 2001 14:13:44 +0000
Subject: cvs: php4 /pear HTTP.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1606@lists.php.net to get a copy of this message
mj Tue Dec 18 09:13:44 2001 EDT Modified files: /php4/pear HTTP.php Log: * Convert tabs to spaces. Index: php4/pear/HTTP.php diff -u php4/pear/HTTP.php:1.8 php4/pear/HTTP.php:1.9 --- php4/pear/HTTP.php:1.8 Fri Dec 14 06:43:20 2001 +++ php4/pear/HTTP.php Tue Dec 18 09:13:43 2001 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: HTTP.php,v 1.8 2001/12/14 11:43:20 sterling Exp $ +// $Id: HTTP.php,v 1.9 2001/12/18 14:13:43 mj Exp $ // // HTTP utility functions. // @@ -74,46 +74,47 @@ * @author Stig Bakken <ssb@fast.no> */ function negotiateLanguage(&$supported, $default = 'en_US') { - global $HTTP_SERVER_VARS; + global $HTTP_SERVER_VARS; - /* If the client has sent an Accept-Language: header, see if - * it contains a language we support. - */ - if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'])) { - $accepted = split(',[[:space:]]*', $HTTP_ACCEPT_LANGUAGE); - for ($i = 0; $i < count($accepted); $i++) { - if (eregi('^([a-z]+);[[:space:]]*q=([0-9\.]+)', $accepted[$i], &$arr)) { - $q = (double)$arr[2]; - $l = $arr[1]; - } else { - $q = 42; - $l = $accepted[$i]; - } - if (!empty($supported[$l]) && ($q > 0.0)) { - if ($q == 42) { - return $l; - } - $candidates[$l] = $q; - } + /* If the client has sent an Accept-Language: header, see if + * it contains a language we support. + */ + if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'])) { + $accepted = split(',[[:space:]]*', $HTTP_ACCEPT_LANGUAGE); + for ($i = 0; $i < count($accepted); $i++) { + if (eregi('^([a-z]+);[[:space:]]*q=([0-9\.]+)', $accepted[$i], &$arr)) { + $q = (double)$arr[2]; + $l = $arr[1]; + } else { + $q = 42; + $l = $accepted[$i]; + } + + if (!empty($supported[$l]) && ($q > 0.0)) { + if ($q == 42) { + return $l; + } + $candidates[$l] = $q; + } + } + if (isset($candidates)) { + arsort($candidates); + reset($candidates); + return key($candidates); + } } - if (isset($candidates)) { - arsort($candidates); - reset($candidates); - return key($candidates); - } - } - /* Check for a valid language code in the top-level domain of - * the client's host address. - */ - if (ereg("\.[^\.]+$", $HTTP_SERVER_VARS['REMOTE_HOST'], &$arr)) { - $lang = strtolower($arr[1]); - if (!empty($supported[$lang])) { - return $lang; + /* Check for a valid language code in the top-level domain of + * the client's host address. + */ + if (ereg("\.[^\.]+$", $HTTP_SERVER_VARS['REMOTE_HOST'], &$arr)) { + $lang = strtolower($arr[1]); + if (!empty($supported[$lang])) { + return $lang; + } } - } - return $default; + return $default; } } ?>

« previous php.pear.cvs (#1606) next »