From 0ffe81c3abbc0605cf010a4872a01363a26f408f Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sun, 9 May 2021 20:01:39 +0200 Subject: [PATCH 01/11] remove a lot of error suppression in favor of ?? in various utility classes --- classes/email.php-class | 8 ++++---- classes/rrdstat.php-class | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/classes/email.php-class b/classes/email.php-class index 3bbb5e9..7c20b5a 100644 --- a/classes/email.php-class +++ b/classes/email.php-class @@ -169,7 +169,7 @@ class email { if (in_array('to', $addrtype)) { foreach ($this->recipients as $address) { - if (strlen(@$address['mail'])) { + if (strlen($address['mail'] ?? '')) { $mailaddresses[] = array('mail'=>$address['mail'], 'name'=>strlen($address['name'])?$address['name']:'', 'addrtype'=>'to'); @@ -178,7 +178,7 @@ class email { } if (in_array('cc', $addrtype)) { foreach ($this->cc as $address) { - if (strlen(@$address['mail'])) { + if (strlen($address['mail'] ?? '')) { $mailaddresses[] = array('mail'=>$address['mail'], 'name'=>strlen($address['name'])?$address['name']:'', 'addrtype'=>'cc'); @@ -187,7 +187,7 @@ class email { } if (in_array('bcc', $addrtype)) { foreach ($this->bcc as $address) { - if (strlen(@$address['mail'])) { + if (strlen($address['mail'] ?? '')) { $mailaddresses[] = array('mail'=>$address['mail'], 'name'=>strlen($address['name'])?$address['name']:'', 'addrtype'=>'bcc'); @@ -216,7 +216,7 @@ class email { if (count($this->recipients)) { $recpt = ''; foreach ($this->recipients as $address) { - if (strlen(@$address['mail'])) { + if (strlen($address['mail'] ?? '')) { if (strlen($address['name'])) { $recpt .= $this->mimeencode($address['name'], true).' <'.$address['mail'].'>,'; } else { $recpt .= $address['mail'].','; } } diff --git a/classes/rrdstat.php-class b/classes/rrdstat.php-class index 2770af7..1ed4504 100644 --- a/classes/rrdstat.php-class +++ b/classes/rrdstat.php-class @@ -576,7 +576,7 @@ class rrdstat { } foreach (array('scale_time_src','scale_time_tgt') as $st) { if (!isset($erow[$st]) || !is_numeric($erow[$st])) { - switch (@$erow[$st]) { + switch ($erow[$st] ?? null) { case 'dyn': case 'auto': $erow[$st] = $slice; @@ -785,7 +785,7 @@ class rrdstat { $legendlines = ''; foreach ($graphrows as $grow) { $legendline = isset($grow['desc'])?$grow['desc']:(isset($grow['legend'])?$grow['legend']:$grow['name']); - $legendline .= '|'.@$grow['color']; + $legendline .= '|'.($grow['color'] ?? ''); $legendline .= '|'.(isset($grow['color_bg'])?$grow['color_bg']:''); $legendline .= '|'.(isset($grow['legend_long'])?$grow['legend_long']:''); $legendlines .= 'legend:'.$legendline."\n"; @@ -845,7 +845,7 @@ class rrdstat { $pconf = $pconf + (array)$this->config_page; $return = null; - switch (@$pconf['type']) { + switch ($pconf['type'] ?? null) { case 'index': $return = $this->page_index($pconf); break; @@ -971,9 +971,9 @@ class rrdstat { if (isset($pconf['stats_url_add'])) { $sURL_add = $pconf['stats_url_add']; } else { $sURL_add = '&sub=%s'; } - $default_num_cols = $GLOBALS['ua']->isMobile()?1:2; - $num_cols = is_numeric(@$pconf['num_rows'])?$pconf['num_rows']:$default_num_cols; - $num_rows = ceil(count($stats)/$num_cols); + $default_num_cols = $GLOBALS['ua']->isMobile() ? 1 : 2; + $num_cols = is_numeric($pconf['num_rows'] ?? null) ? $pconf['num_rows'] : $default_num_cols; + $num_rows = ceil(count($stats) / $num_cols); $out .= ''."\n"; for ($row = 0; $row < $num_rows; $row++) { @@ -984,7 +984,7 @@ class rrdstat { if ($idx < count($stats)) { @list($sname, $s_psub) = explode('|', $stats[$idx]['name'], 2); $s_psname = 'page'.(isset($s_psub)?'.'.$s_psub:''); - $g_sub = @$this->config_all[$sname][$s_psname]['graph_sub']; + $g_sub = $this->config_all[$sname][$s_psname]['graph_sub'] ?? ''; if (isset($this->config_all[$sname][$s_psname]['title_page'])) { $s_ptitle = $this->config_all[$sname][$s_psname]['title_page']; @@ -1204,7 +1204,7 @@ class rrdstat { foreach ($snames as $iname) { $newstat = array('name'=>$iname); $sfiles[] = isset($this->config_all[$iname]['file'])?$this->config_all[$iname]['file']:$iname.'.rrd'; - if (is_array(@$this->config_all[$iname])) { + if (is_array($this->config_all[$iname] ?? null)) { foreach ($this->config_all[$iname] as $key=>$val) { if (substr($key, 0, 5) == 'page.') { $newstat['sub'][] = substr($key, 5); } } -- 2.35.3 From e67037744edbb115b88b23f3ab6926f77244ca9f Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Wed, 29 Dec 2021 23:26:17 +0100 Subject: [PATCH 02/11] make sure the array key exists --- classes/rrdstat.php-class | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/rrdstat.php-class b/classes/rrdstat.php-class index 1ed4504..9743e7a 100644 --- a/classes/rrdstat.php-class +++ b/classes/rrdstat.php-class @@ -496,7 +496,7 @@ class rrdstat { // assemble configuration $gconf = (array)$extra; - if (!is_null($sub) && is_array($this->config_raw['graph.'.$sub])) { + if (!is_null($sub) && array_key_exists('graph.'.$sub, $this->config_raw) && is_array($this->config_raw['graph.'.$sub])) { $gconf = $gconf + $this->config_raw['graph.'.$sub]; } $gconf = $gconf + (array)$this->config_graph; -- 2.35.3 From 5ae00086e5e4a5ffe979d5462b388d8277417e9f Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Fri, 18 Feb 2022 23:43:09 +0100 Subject: [PATCH 03/11] 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.35.3 From e78a75387d67c9293ba7dbd7dbd846b729f1ff19 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sat, 7 Jan 2023 18:16:27 +0100 Subject: [PATCH 04/11] short array syntax, standard return indentation, fix warnings --- classes/useragent.php-class | 133 ++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 60 deletions(-) diff --git a/classes/useragent.php-class b/classes/useragent.php-class index bebf553..9c95c6d 100755 --- a/classes/useragent.php-class +++ b/classes/useragent.php-class @@ -97,7 +97,7 @@ class userAgent { private $version; private $bot = false; private $mobile = false; - private $uadata = array(); + private $uadata = []; function __construct($ua_string = '') { // *** constructor *** @@ -980,12 +980,14 @@ class userAgent { $this->bot = false; } - $botArray = array('Scooter','Spinne','Vagabondo','Firefly','Scrubby','NG','Pompos','Szukacz','Schmozilla','42_HAL', - 'NetResearchServer','LinkWalker','Zeus','W3C_Validator','ZyBorg','Ask Jeeves','ia_archiver', - 'PingALink Monitoring Services','IlTrovatore-Setaccio','Nutch','Mercator','search.ch', - 'appie','larbin','NutchCVS','Webchat','Mediapartners-Google','sitecheck.internetseer.com', - 'FavOrg','findlinks','DataCha0s','ichiro','Francis','CoralWebPrx','DoCoMo','Ocelli','Sogou Video', - 'Yandex','Yeti','Austronaut-URL-Checker'); + $botArray = [ + 'Scooter', 'Spinne', 'Vagabondo', 'Firefly', 'Scrubby', 'NG', 'Pompos', 'Szukacz', 'Schmozilla', '42_HAL', + 'NetResearchServer', 'LinkWalker', 'Zeus', 'W3C_Validator', 'ZyBorg', 'Ask Jeeves', 'ia_archiver', + 'PingALink Monitoring Services', 'IlTrovatore-Setaccio', 'Nutch', 'Mercator', 'search.ch', + 'appie', 'larbin', 'NutchCVS', 'Webchat', 'Mediapartners-Google', 'sitecheck.internetseer.com', + 'FavOrg', 'findlinks', 'DataCha0s', 'ichiro', 'Francis', 'CoralWebPrx', 'DoCoMo', 'Ocelli', 'Sogou Video', + 'Yandex', 'Yeti', 'Austronaut-URL-Checker' + ]; if (in_array($this->brand, $botArray)) { $this->bot = true; @@ -997,14 +999,19 @@ class userAgent { } } - public function getBrand() { return $this->brand; } - public function getVersion() { return $this->version; } + public function getBrand() { + return $this->brand; + } + + public function getVersion() { + return $this->version; + } public function getAcceptLanguages() { if (!isset($this->uadata['accept-languages'])) { $headers = getAllHeaders(); $accLcomp = explode(',', ($headers['Accept-Language'] ?? '')); - $accLang = array(); + $accLang = []; foreach ($accLcomp as $lcomp) { if (strlen($lcomp)) { $ldef = explode(';', $lcomp); @@ -1018,10 +1025,12 @@ class userAgent { } $this->uadata['accept-languages'] = $accLang; } - return $this->uadata['accept-languages']; + return $this->uadata['accept-languages']; } - public function getUAString() { return $this->uastring; } + public function getUAString() { + return $this->uastring; + } public function getEngine() { // return gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|icestorm|netfront|unknown @@ -1106,10 +1115,12 @@ class userAgent { } } } - return $this->uadata['engine']; + return $this->uadata['engine']; } - public function hasEngine($rnd_engine) { return ($this->getEngine() == $rnd_engine); } + public function hasEngine($rnd_engine) { + return ($this->getEngine() == $rnd_engine); + } public function getEngineVersion() { if (!isset($this->uadata['eng_version'])) { @@ -1117,7 +1128,7 @@ class userAgent { // getOS() should get the date for us $this->getOS(); } - return $this->uadata['eng_version']; + return $this->uadata['eng_version']; } public function getOS() { @@ -1507,57 +1518,57 @@ class userAgent { elseif (preg_match('/iPhone OS ([\d_]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'iOS '.str_replace('_', '.', $regs[1]); } elseif (preg_match('/Mac ?OS ?X/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; } elseif (preg_match('/Mac_P(ower|)PC/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; } - elseif (strpos($this->uadata['os'], 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } - elseif (strpos($this->uadata['os'], 'Darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } - elseif (strpos($this->uadata['os'], 'apple') !== false) { $this->uadata['os'] = 'MacOS'; } - elseif (strpos($this->uadata['os'], 'Macintosh') !== false) { $this->uadata['os'] = 'MacOS'; } + elseif (strpos($this->uadata['os'] ?? '', 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } + elseif (strpos($this->uadata['os'] ?? '', 'Darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } + elseif (strpos($this->uadata['os'] ?? '', 'apple') !== false) { $this->uadata['os'] = 'MacOS'; } + elseif (strpos($this->uadata['os'] ?? '', 'Macintosh') !== false) { $this->uadata['os'] = 'MacOS'; } elseif (preg_match('/(?:web|hpw)OS\/([0-9a-zA-Z\._+]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'webOS '.$regs[1]; } elseif (preg_match('/Android \(Linux (.+)\)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'Android '.$regs[1]; } - elseif (strpos($this->uadata['os'], 'linux') !== false) { $this->uadata['os'] = 'Linux'; } + elseif (strpos($this->uadata['os'] ?? '', 'linux') !== false) { $this->uadata['os'] = 'Linux'; } elseif (preg_match('/SymbianOS[\/ ]([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) { $this->uadata['os'] = 'SymbianOS '.$regs[1]; } elseif (preg_match('/Symbian ?OS/i', $this->uadata['os'])) { $this->uadata['os'] = 'SymbianOS'; } - if (strpos($this->uadata['os'], 'Win') !== false) { $this->uadata['platform'] = 'Windows'; } - elseif (strpos($this->uadata['os'], 'Mac') !== false) { $this->uadata['platform'] = 'Macintosh'; } - elseif (strpos($this->uadata['os'], 'iOS') !== false) { $this->uadata['platform'] = 'Macintosh'; } - elseif (strpos($this->uadata['os'], 'Linux') !== false) { $this->uadata['platform'] = 'Linux'; } - elseif (strpos($this->uadata['os'], 'MeeGo') !== false) { $this->uadata['platform'] = 'Linux'; } - elseif (strpos($this->uadata['os'], 'webOS') !== false) { $this->uadata['platform'] = 'Linux'; } - elseif (strpos($this->uadata['os'], 'Android') !== false) { $this->uadata['platform'] = 'Android'; } - elseif (strpos($this->uadata['os'], 'Firefox OS') !== false) { $this->uadata['platform'] = 'Firefox OS'; } - elseif (strpos($this->uadata['os'], 'Solaris') !== false) { $this->uadata['platform'] = 'Solaris'; } - elseif (strpos($this->uadata['os'], 'SunOS') !== false) { $this->uadata['platform'] = 'Solaris'; } - elseif (strpos($this->uadata['os'], 'BeOS') !== false) { $this->uadata['platform'] = 'BeOS'; } - elseif (strpos($this->uadata['os'], 'BePC') !== false) { $this->uadata['platform'] = 'BeOS'; } - elseif (strpos($this->uadata['os'], 'FreeBSD') !== false) { $this->uadata['platform'] = 'FreeBSD'; } - elseif (strpos($this->uadata['os'], 'OpenBSD') !== false) { $this->uadata['platform'] = 'OpenBSD'; } - elseif (strpos($this->uadata['os'], 'NetBSD') !== false) { $this->uadata['platform'] = 'NetBSD'; } - elseif (strpos($this->uadata['os'], 'AIX') !== false) { $this->uadata['platform'] = 'AIX'; } - elseif (strpos($this->uadata['os'], 'IRIX') !== false) { $this->uadata['platform'] = 'IRIX'; } - elseif (strpos($this->uadata['os'], 'HP-UX') !== false) { $this->uadata['platform'] = 'HP-UX'; } - elseif (strpos($this->uadata['os'], 'AmigaOS') !== false) { $this->uadata['platform'] = 'Amiga'; } - elseif (strpos($this->uadata['os'], 'webOS') !== false) { $this->uadata['platform'] = 'webOS'; } - elseif (strpos($this->uadata['os'], 'Commodore 64') !== false) { $this->uadata['platform'] = 'C64'; } - elseif (strpos($this->uadata['os'], 'OpenVMS') !== false) { $this->uadata['platform'] = 'OpenVMS'; } - elseif (strpos($this->uadata['os'], 'Warp') !== false) { $this->uadata['platform'] = 'OS/2'; } - elseif (strpos($this->uadata['os'], 'OS/2') !== false) { $this->uadata['platform'] = 'OS/2'; } - elseif (strpos($this->uadata['os'], 'SymbianOS') !== false) { $this->uadata['platform'] = 'SymbianOS'; } - elseif (strpos($this->uadata['os'], 'BlackBerry') !== false) { $this->uadata['platform'] = 'BlackBerry'; } - elseif (strpos($this->uadata['os'], 'Gameboy') !== false) { $this->uadata['platform'] = 'Nintendo'; } - elseif (strpos($this->uadata['os'], 'Wii') !== false) { $this->uadata['platform'] = 'Nintendo'; } - elseif (strpos($this->uadata['os'], 'Nintendo') !== false) { $this->uadata['platform'] = 'Nintendo'; } - elseif (strpos($this->uadata['os'], 'J2ME') !== false) { $this->uadata['platform'] = 'Java'; } - elseif (strpos($this->uadata['os'], 'CYGWIN') !== false) { $this->uadata['platform'] = 'Windows'; } - elseif (strpos($this->uadata['os'], 'mingw') !== false) { $this->uadata['platform'] = 'Windows'; } + if (strpos($this->uadata['os'] ?? '', 'Win') !== false) { $this->uadata['platform'] = 'Windows'; } + elseif (strpos($this->uadata['os'] ?? '', 'Mac') !== false) { $this->uadata['platform'] = 'Macintosh'; } + elseif (strpos($this->uadata['os'] ?? '', 'iOS') !== false) { $this->uadata['platform'] = 'Macintosh'; } + elseif (strpos($this->uadata['os'] ?? '', 'Linux') !== false) { $this->uadata['platform'] = 'Linux'; } + elseif (strpos($this->uadata['os'] ?? '', 'MeeGo') !== false) { $this->uadata['platform'] = 'Linux'; } + elseif (strpos($this->uadata['os'] ?? '', 'webOS') !== false) { $this->uadata['platform'] = 'Linux'; } + elseif (strpos($this->uadata['os'] ?? '', 'Android') !== false) { $this->uadata['platform'] = 'Android'; } + elseif (strpos($this->uadata['os'] ?? '', 'Firefox OS') !== false) { $this->uadata['platform'] = 'Firefox OS'; } + elseif (strpos($this->uadata['os'] ?? '', 'Solaris') !== false) { $this->uadata['platform'] = 'Solaris'; } + elseif (strpos($this->uadata['os'] ?? '', 'SunOS') !== false) { $this->uadata['platform'] = 'Solaris'; } + elseif (strpos($this->uadata['os'] ?? '', 'BeOS') !== false) { $this->uadata['platform'] = 'BeOS'; } + elseif (strpos($this->uadata['os'] ?? '', 'BePC') !== false) { $this->uadata['platform'] = 'BeOS'; } + elseif (strpos($this->uadata['os'] ?? '', 'FreeBSD') !== false) { $this->uadata['platform'] = 'FreeBSD'; } + elseif (strpos($this->uadata['os'] ?? '', 'OpenBSD') !== false) { $this->uadata['platform'] = 'OpenBSD'; } + elseif (strpos($this->uadata['os'] ?? '', 'NetBSD') !== false) { $this->uadata['platform'] = 'NetBSD'; } + elseif (strpos($this->uadata['os'] ?? '', 'AIX') !== false) { $this->uadata['platform'] = 'AIX'; } + elseif (strpos($this->uadata['os'] ?? '', 'IRIX') !== false) { $this->uadata['platform'] = 'IRIX'; } + elseif (strpos($this->uadata['os'] ?? '', 'HP-UX') !== false) { $this->uadata['platform'] = 'HP-UX'; } + elseif (strpos($this->uadata['os'] ?? '', 'AmigaOS') !== false) { $this->uadata['platform'] = 'Amiga'; } + elseif (strpos($this->uadata['os'] ?? '', 'webOS') !== false) { $this->uadata['platform'] = 'webOS'; } + elseif (strpos($this->uadata['os'] ?? '', 'Commodore 64') !== false) { $this->uadata['platform'] = 'C64'; } + elseif (strpos($this->uadata['os'] ?? '', 'OpenVMS') !== false) { $this->uadata['platform'] = 'OpenVMS'; } + elseif (strpos($this->uadata['os'] ?? '', 'Warp') !== false) { $this->uadata['platform'] = 'OS/2'; } + elseif (strpos($this->uadata['os'] ?? '', 'OS/2') !== false) { $this->uadata['platform'] = 'OS/2'; } + elseif (strpos($this->uadata['os'] ?? '', 'SymbianOS') !== false) { $this->uadata['platform'] = 'SymbianOS'; } + elseif (strpos($this->uadata['os'] ?? '', 'BlackBerry') !== false) { $this->uadata['platform'] = 'BlackBerry'; } + elseif (strpos($this->uadata['os'] ?? '', 'Gameboy') !== false) { $this->uadata['platform'] = 'Nintendo'; } + elseif (strpos($this->uadata['os'] ?? '', 'Wii') !== false) { $this->uadata['platform'] = 'Nintendo'; } + elseif (strpos($this->uadata['os'] ?? '', 'Nintendo') !== false) { $this->uadata['platform'] = 'Nintendo'; } + elseif (strpos($this->uadata['os'] ?? '', 'J2ME') !== false) { $this->uadata['platform'] = 'Java'; } + elseif (strpos($this->uadata['os'] ?? '', 'CYGWIN') !== false) { $this->uadata['platform'] = 'Windows'; } + elseif (strpos($this->uadata['os'] ?? '', 'mingw') !== false) { $this->uadata['platform'] = 'Windows'; } else { $this->uadata['platform'] = $this->uadata['os']; } - if (strpos($this->uadata['os'], 'Windows Phone OS') !== false) { $this->mobile = true; } - elseif (strpos($this->uadata['os'], 'Gameboy') !== false) { $this->mobile = true; } + 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'] ?? '')); } } - return $this->uadata['os']; + return $this->uadata['os']; } public function getPlatform() { @@ -1566,7 +1577,7 @@ class userAgent { // getOS() should get the date for us $this->getOS(); } - return $this->uadata['platform']; + return $this->uadata['platform']; } public function getLanguage() { @@ -1575,7 +1586,7 @@ class userAgent { // getOS() should get the date for us $this->getOS(); } - return $this->uadata['lang']; + return $this->uadata['lang']; } public function getGeckoDate() { @@ -1584,7 +1595,7 @@ class userAgent { // getEngine() should get the date for us $this->getEngine(); } - return $this->uadata['geckodate']; + return $this->uadata['geckodate']; } public function getGeckoTime() { @@ -1602,10 +1613,12 @@ class userAgent { if ($use_time) { date_default_timezone_set($old_tz); } } } - return $this->uadata['geckotime']; + return $this->uadata['geckotime']; } - public function isBot() { return $this->bot; } + public function isBot() { + return $this->bot; + } public function isMobile() { if (!isset($this->uadata['os'])) { -- 2.35.3 From fb10d8f6bc2f713233929e8d6923155597941a84 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sat, 7 Jan 2023 18:20:01 +0100 Subject: [PATCH 05/11] fix Gecko version for Firefox 110 and later --- classes/useragent.php-class | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/useragent.php-class b/classes/useragent.php-class index 9c95c6d..cf38a17 100755 --- a/classes/useragent.php-class +++ b/classes/useragent.php-class @@ -1229,6 +1229,9 @@ class userAgent { $this->uadata['lang'] = null; $this->uadata['eng_version'] = null; } + if (($this->brand == 'Firefox') && (intval($this->version) >= 110)) { + $this->uadata['eng_version'] = $this->version; + } } elseif ($this->hasEngine('edgehtml')) { if (preg_match('#Mozilla/5.0 \(([^;]+); (WOW64|Win64); ([^\);]+)\)#', $this->uastring, $regs)) { -- 2.35.3 From a6d14fe0a88283bd7e6a227421c4e66ba710d824 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sun, 8 Jan 2023 16:48:18 +0100 Subject: [PATCH 06/11] update bot detection with a few more UA names --- classes/useragent.php-class | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/classes/useragent.php-class b/classes/useragent.php-class index cf38a17..6aea289 100755 --- a/classes/useragent.php-class +++ b/classes/useragent.php-class @@ -983,10 +983,11 @@ class userAgent { $botArray = [ 'Scooter', 'Spinne', 'Vagabondo', 'Firefly', 'Scrubby', 'NG', 'Pompos', 'Szukacz', 'Schmozilla', '42_HAL', 'NetResearchServer', 'LinkWalker', 'Zeus', 'W3C_Validator', 'ZyBorg', 'Ask Jeeves', 'ia_archiver', - 'PingALink Monitoring Services', 'IlTrovatore-Setaccio', 'Nutch', 'Mercator', 'search.ch', - 'appie', 'larbin', 'NutchCVS', 'Webchat', 'Mediapartners-Google', 'sitecheck.internetseer.com', - 'FavOrg', 'findlinks', 'DataCha0s', 'ichiro', 'Francis', 'CoralWebPrx', 'DoCoMo', 'Ocelli', 'Sogou Video', - 'Yandex', 'Yeti', 'Austronaut-URL-Checker' + 'PingALink Monitoring Services', 'IlTrovatore-Setaccio', 'Nutch', 'Mercator', 'search.ch', 'appie', 'larbin', + 'NutchCVS', 'Webchat', 'Mediapartners-Google', 'sitecheck.internetseer.com', 'FavOrg', 'findlinks', 'DataCha0s', + 'ichiro', 'Francis', 'CoralWebPrx', 'DoCoMo', 'Ocelli', 'Sogou Video', 'Yandex', 'Yeti', + 'Austronaut-URL-Checker', 'check_ssl_cert', 'check_http', 'vdirsyncer', 'Feedbin feed-id', + 'Cloudflare Custom Hostname Verification', 'FreshRSS', 'UniversalFeedParser', ]; if (in_array($this->brand, $botArray)) { -- 2.35.3 From 19aad8afcc770848fd356bd5f8c2d8286c6e97a3 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sun, 8 Jan 2023 16:51:01 +0100 Subject: [PATCH 07/11] update bot detection with a few more UA names --- classes/useragent.php-class | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/useragent.php-class b/classes/useragent.php-class index 6aea289..00ceb3a 100755 --- a/classes/useragent.php-class +++ b/classes/useragent.php-class @@ -982,12 +982,12 @@ class userAgent { $botArray = [ 'Scooter', 'Spinne', 'Vagabondo', 'Firefly', 'Scrubby', 'NG', 'Pompos', 'Szukacz', 'Schmozilla', '42_HAL', - 'NetResearchServer', 'LinkWalker', 'Zeus', 'W3C_Validator', 'ZyBorg', 'Ask Jeeves', 'ia_archiver', + 'NetResearchServer', 'LinkWalker', 'Zeus', 'W3C_Validator', 'ZyBorg', 'Ask Jeeves', 'ia_archiver', 'ichiro', 'PingALink Monitoring Services', 'IlTrovatore-Setaccio', 'Nutch', 'Mercator', 'search.ch', 'appie', 'larbin', 'NutchCVS', 'Webchat', 'Mediapartners-Google', 'sitecheck.internetseer.com', 'FavOrg', 'findlinks', 'DataCha0s', - 'ichiro', 'Francis', 'CoralWebPrx', 'DoCoMo', 'Ocelli', 'Sogou Video', 'Yandex', 'Yeti', - 'Austronaut-URL-Checker', 'check_ssl_cert', 'check_http', 'vdirsyncer', 'Feedbin feed-id', - 'Cloudflare Custom Hostname Verification', 'FreshRSS', 'UniversalFeedParser', + 'Francis', 'CoralWebPrx', 'DoCoMo', 'Ocelli', 'Sogou Video', 'Yandex', 'Yeti', 'SEO Scanner', 'Feedbin feed-id', + 'Austronaut-URL-Checker', 'check_ssl_cert', 'check_http', 'vdirsyncer', 'FreshRSS', 'UniversalFeedParser', + 'Cloudflare Custom Hostname Verification', 'Scoop.it', ]; if (in_array($this->brand, $botArray)) { -- 2.35.3 From c79be4c2c1230110175194a8aee78a5eb20d6af0 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sun, 26 Feb 2023 02:41:20 +0100 Subject: [PATCH 08/11] add support for datalist element --- classes/document.php-class | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/classes/document.php-class b/classes/document.php-class index ed688b6..4490589 100755 --- a/classes/document.php-class +++ b/classes/document.php-class @@ -125,6 +125,10 @@ class ExtendedDocument extends DOMDocument { // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params) // returns the new child // + // public function appendElementDatalist([$id], [$options]) + // appends an ExtendedDocument::createElementDatalist() as a child of this document (see there for params) + // returns the new child + // // public function appendText($text) // appends a DOMDocument::createTextNode() as a child of this document (see there for params) // returns the new child @@ -250,6 +254,9 @@ class ExtendedDocument extends DOMDocument { // public function createElementLabel($for_id, $value) // returns an ExtendedElement that is an HTML