Platforms: only use and show trusted detections
This commit is contained in:
parent
121e40357c
commit
650f90df25
|
@ -1566,6 +1566,10 @@ class GServer
|
||||||
return $serverdata;
|
return $serverdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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'];
|
||||||
|
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
@$doc->loadHTML($curlResult->getBody());
|
@$doc->loadHTML($curlResult->getBody());
|
||||||
$xpath = new DOMXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
|
@ -1594,6 +1598,10 @@ class GServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!in_array(strtolower($attr['content']), $valid_platforms)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($attr['name'] == 'description') {
|
if ($attr['name'] == 'description') {
|
||||||
$serverdata['info'] = $attr['content'];
|
$serverdata['info'] = $attr['content'];
|
||||||
}
|
}
|
||||||
|
@ -1653,6 +1661,10 @@ class GServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!in_array(strtolower($attr['content']), $valid_platforms)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($attr['property'] == 'og:site_name') {
|
if ($attr['property'] == 'og:site_name') {
|
||||||
$serverdata['site_name'] = $attr['content'];
|
$serverdata['site_name'] = $attr['content'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Admin;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\GServer;
|
||||||
use Friendica\Module\BaseAdmin;
|
use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class Federation extends BaseAdmin
|
class Federation extends BaseAdmin
|
||||||
|
@ -71,15 +72,15 @@ class Federation extends BaseAdmin
|
||||||
|
|
||||||
$gservers = DBA::p("SELECT COUNT(*) AS `total`, SUM(`registered-users`) AS `users`, `platform`,
|
$gservers = DBA::p("SELECT COUNT(*) AS `total`, SUM(`registered-users`) AS `users`, `platform`,
|
||||||
ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version`
|
ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version`
|
||||||
FROM `gserver` WHERE NOT `failed` GROUP BY `platform`");
|
FROM `gserver` WHERE NOT `failed` AND `detection-method` != ? GROUP BY `platform`", GServer::DETECT_MANUAL);
|
||||||
while ($gserver = DBA::fetch($gservers)) {
|
while ($gserver = DBA::fetch($gservers)) {
|
||||||
$total += $gserver['total'];
|
$total += $gserver['total'];
|
||||||
$users += $gserver['users'];
|
$users += $gserver['users'];
|
||||||
|
|
||||||
$versionCounts = [];
|
$versionCounts = [];
|
||||||
$versions = DBA::p("SELECT COUNT(*) AS `total`, `version` FROM `gserver`
|
$versions = DBA::p("SELECT COUNT(*) AS `total`, `version` FROM `gserver`
|
||||||
WHERE NOT `failed` AND `platform` = ?
|
WHERE NOT `failed` AND `platform` = ? AND `detection-method` != ?
|
||||||
GROUP BY `version` ORDER BY `version`", $gserver['platform']);
|
GROUP BY `version` ORDER BY `version`", $gserver['platform'], GServer::DETECT_MANUAL);
|
||||||
while ($version = DBA::fetch($versions)) {
|
while ($version = DBA::fetch($versions)) {
|
||||||
$version['version'] = str_replace(["\n", "\r", "\t"], " ", $version['version']);
|
$version['version'] = str_replace(["\n", "\r", "\t"], " ", $version['version']);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue