Improved server platform detection

This commit is contained in:
Michael 2020-01-13 05:57:05 +00:00
parent 7e1cbf8f67
commit bc83eb5c4e

View file

@ -931,6 +931,11 @@ class GServer
$serverdata['site_name'] = $data['title'];
}
if (!empty($data['title']) && empty($serverdata['platform']) && empty($serverdata['network'])) {
$serverdata['platform'] = 'mastodon';
$serverdata['network'] = Protocol::ACTIVITYPUB;
}
if (!empty($data['description'])) {
$serverdata['info'] = trim($data['description']);
}
@ -944,9 +949,14 @@ class GServer
$serverdata['version'] = $matches[2];
}
if (!empty($serverdata['version']) && strstr($serverdata['version'], 'Pleroma')) {
if (!empty($serverdata['version']) && strstr(strtolower($serverdata['version']), 'pleroma')) {
$serverdata['platform'] = 'pleroma';
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
}
if (!empty($serverdata['platform']) && strstr($serverdata['platform'], 'pleroma')) {
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform']));
$serverdata['platform'] = 'pleroma';
$serverdata['version'] = trim(str_replace('Pleroma', '', $serverdata['version']));
}
return $serverdata;
@ -1203,10 +1213,8 @@ class GServer
$serverdata['network'] = Protocol::ACTIVITYPUB;
}
}
if ($attr['name'] == 'generator') {
if (($attr['name'] == 'generator') && (empty($serverdata['platform']) || (substr(strtolower($attr['content']), 0, 9) == 'wordpress'))) {
$serverdata['platform'] = strtolower($attr['content']);
$version_part = explode(' ', $attr['content']);
if (count($version_part) == 2) {