From f1cac5170b3e9fb7d07a25a7ba3e7f06325079e7 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 6 Feb 2022 08:02:19 +0000 Subject: [PATCH] mark sites as "phantom" that are up but couldn't be detected --- src/Model/GServer.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Model/GServer.php b/src/Model/GServer.php index 4db851571b..6a4b14a7b6 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -1562,7 +1562,7 @@ class GServer // Using only body information we cannot safely detect a lot of systems. // So we define a list of platforms that we can detect safely. - $valid_platforms = ['friendica', 'friendika', 'hubzilla', 'misskey', 'peertube', 'wordpress', 'write.as']; + $valid_platforms = ['friendica', 'friendika', 'diaspora', 'mastodon', 'hubzilla', 'misskey', 'peertube', 'wordpress', 'write.as']; $doc = new DOMDocument(); @$doc->loadHTML($curlResult->getBody()); @@ -1592,11 +1592,6 @@ class GServer } } - $platform = explode(' ', strtolower($attr['content'])); - if (!in_array($platform[0], $valid_platforms)) { - continue; - } - if ($attr['name'] == 'description') { $serverdata['info'] = $attr['content']; } @@ -1656,11 +1651,6 @@ class GServer } } - $platform = explode(' ', strtolower($attr['content'])); - if (!in_array($platform[0], $valid_platforms)) { - continue; - } - if ($attr['property'] == 'og:site_name') { $serverdata['site_name'] = $attr['content']; } @@ -1687,7 +1677,11 @@ class GServer } } - if (!empty($serverdata['network']) && ($serverdata['detection-method'] == self::DETECT_MANUAL)) { + if (!empty($serverdata['platform']) && in_array($serverdata['detection-method'], [self::DETECT_MANUAL, self::DETECT_BODY]) && !in_array($serverdata['platform'], $valid_platforms)) { + $serverdata['network'] = Protocol::PHANTOM; + $serverdata['version'] = ''; + $serverdata['detection-method'] = self::DETECT_MANUAL; + } elseif (!empty($serverdata['network']) && ($serverdata['detection-method'] == self::DETECT_MANUAL)) { $serverdata['detection-method'] = self::DETECT_BODY; } -- 2.39.5