From 5ae00086e5e4a5ffe979d5462b388d8277417e9f Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Fri, 18 Feb 2022 23:43:09 +0100 Subject: [PATCH] fix some warnings from modern PHP versions --- classes/document.php-class | 2 +- classes/useragent.php-class | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/classes/document.php-class b/classes/document.php-class index 198296f..ed688b6 100755 --- a/classes/document.php-class +++ b/classes/document.php-class @@ -439,7 +439,7 @@ class ExtendedDocument extends DOMDocument { public function createElement($name, $value = '') { // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that. $aelem = parent::createElement($name); - if (strlen($value)) { $aelem->appendText($value); } + if (strlen($value ?? '')) { $aelem->appendText($value); } return $aelem; } diff --git a/classes/useragent.php-class b/classes/useragent.php-class index efda352..bebf553 100755 --- a/classes/useragent.php-class +++ b/classes/useragent.php-class @@ -1003,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; @@ -1549,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']; -- 2.43.0