X-Git-Url: https://git-public.kairo.at/?a=blobdiff_plain;f=classes%2Fuseragent.php-class;h=bebf5535a55a78e42b2a492f8bfc23133e991898;hb=5ae00086e5e4a5ffe979d5462b388d8277417e9f;hp=9026179b8ed99bfe0855c769241ecb95020b207f;hpb=7b9ebce7d25e4eaa557e8a64f8b1ed15aad1a9bb;p=php-utility-classes.git diff --git a/classes/useragent.php-class b/classes/useragent.php-class index 9026179..bebf553 100755 --- a/classes/useragent.php-class +++ b/classes/useragent.php-class @@ -1,39 +1,7 @@ - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ class userAgent { // userAgent PHP class @@ -1035,12 +1003,17 @@ class userAgent { public function getAcceptLanguages() { if (!isset($this->uadata['accept-languages'])) { $headers = getAllHeaders(); - $accLcomp = explode(',', $headers['Accept-Language']); + $accLcomp = explode(',', ($headers['Accept-Language'] ?? '')); $accLang = array(); foreach ($accLcomp as $lcomp) { if (strlen($lcomp)) { $ldef = explode(';', $lcomp); - $accLang[$ldef[0]] = (float)((strpos(@$ldef[1],'q=')===0)?substr($ldef[1],2):1); + if (count($ldef) > 1 && strpos($ldef[1], 'q=') === 0) { + $accLang[$ldef[0]] = substr($ldef[1], 2); + } + else { + $accLang[$ldef[0]] = 1; + } } } $this->uadata['accept-languages'] = $accLang; @@ -1581,7 +1554,7 @@ class userAgent { if (strpos($this->uadata['os'], 'Windows Phone OS') !== false) { $this->mobile = true; } elseif (strpos($this->uadata['os'], 'Gameboy') !== false) { $this->mobile = true; } - $this->uadata['lang'] = str_replace('_', '-', @$this->uadata['lang']); + $this->uadata['lang'] = str_replace('_', '-', ($this->uadata['lang'] ?? '')); } } return $this->uadata['os'];