]> git.mxchange.org Git - friendica.git/commitdiff
User lowercase for platform data
authorMichael <heluecht@pirati.ca>
Sun, 12 Jan 2020 21:07:40 +0000 (21:07 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 12 Jan 2020 21:07:40 +0000 (21:07 +0000)
src/Model/GServer.php
src/Module/Admin/Federation.php
src/Module/NodeInfo.php

index 9c75da3472740c724b8cff9c1c36cf0b52169d91..a85ab2408d230d325c96140613c92cc5ddfbd275 100644 (file)
@@ -424,11 +424,11 @@ class GServer
                }
 
                if (!empty($data['network'])) {
-                       $serverdata['platform'] = $data['network'];
+                       $serverdata['platform'] = strtolower($data['network']);
 
-                       if ($serverdata['platform'] == 'Diaspora') {
+                       if ($serverdata['platform'] == 'diaspora') {
                                $serverdata['network'] = Protocol::DIASPORA;
-                       } elseif ($serverdata['platform'] == 'Friendica') {
+                       } elseif ($serverdata['platform'] == 'friendica') {
                                $serverdata['network'] = Protocol::DFRN;
                        } elseif ($serverdata['platform'] == 'hubzilla') {
                                $serverdata['network'] = Protocol::ZOT;
@@ -528,7 +528,7 @@ class GServer
 
                if (is_array($nodeinfo['software'])) {
                        if (!empty($nodeinfo['software']['name'])) {
-                               $server['platform'] = $nodeinfo['software']['name'];
+                               $server['platform'] = strtolower($nodeinfo['software']['name']);
                        }
 
                        if (!empty($nodeinfo['software']['version'])) {
@@ -605,7 +605,7 @@ class GServer
 
                if (is_array($nodeinfo['software'])) {
                        if (!empty($nodeinfo['software']['name'])) {
-                               $server['platform'] = $nodeinfo['software']['name'];
+                               $server['platform'] = strtolower($nodeinfo['software']['name']);
                        }
 
                        if (!empty($nodeinfo['software']['version'])) {
@@ -673,7 +673,7 @@ class GServer
                }
 
                if (!empty($data['url'])) {
-                       $serverdata['platform'] = $data['platform'];
+                       $serverdata['platform'] = strtolower($data['platform']);
                        $serverdata['version'] = $data['version'];
                }
 
@@ -940,7 +940,7 @@ class GServer
                }
 
                if (!empty($serverdata['version']) && preg_match('/.*?\(compatible;\s(.*)\s(.*)\)/ism', $serverdata['version'], $matches)) {
-                       $serverdata['platform'] = $matches[1];
+                       $serverdata['platform'] = strtolower($matches[1]);
                        $serverdata['version'] = $matches[2];
                }
 
@@ -977,22 +977,22 @@ class GServer
                }
 
                if (!empty($data['site']['platform'])) {
-                       $serverdata['platform'] = $data['site']['platform']['PLATFORM_NAME'];
+                       $serverdata['platform'] = strtolower($data['site']['platform']['PLATFORM_NAME']);
                        $serverdata['version'] = $data['site']['platform']['STD_VERSION'];
                        $serverdata['network'] = Protocol::ZOT;
                }
 
                if (!empty($data['site']['hubzilla'])) {
-                       $serverdata['platform'] = $data['site']['hubzilla']['PLATFORM_NAME'];
+                       $serverdata['platform'] = strtolower($data['site']['hubzilla']['PLATFORM_NAME']);
                        $serverdata['version'] = $data['site']['hubzilla']['RED_VERSION'];
                        $serverdata['network'] = Protocol::ZOT;
                }
 
                if (!empty($data['site']['redmatrix'])) {
                        if (!empty($data['site']['redmatrix']['PLATFORM_NAME'])) {
-                               $serverdata['platform'] = $data['site']['redmatrix']['PLATFORM_NAME'];
+                               $serverdata['platform'] = strtolower($data['site']['redmatrix']['PLATFORM_NAME']);
                        } elseif (!empty($data['site']['redmatrix']['RED_PLATFORM'])) {
-                               $serverdata['platform'] = $data['site']['redmatrix']['RED_PLATFORM'];
+                               $serverdata['platform'] = strtolower($data['site']['redmatrix']['RED_PLATFORM']);
                        }
 
                        $serverdata['version'] = $data['site']['redmatrix']['RED_VERSION'];
@@ -1149,7 +1149,7 @@ class GServer
                                break;
                }
 
-               $serverdata['platform'] = $data['platform'] ?? '';
+               $serverdata['platform'] = strtolower($data['platform'] ?? '');
 
                return $serverdata;
        }
@@ -1198,20 +1198,20 @@ class GServer
                        }
 
                        if ($attr['name'] == 'application-name') {
-                               $serverdata['platform'] = $attr['content'];
+                               $serverdata['platform'] = strtolower($attr['content']);
                                if (in_array($attr['content'], ['Misskey', 'Write.as'])) {
                                        $serverdata['network'] = Protocol::ACTIVITYPUB;
                                }
                        }
 
                        if ($attr['name'] == 'generator') {
-                               $serverdata['platform'] = $attr['content'];
+                               $serverdata['platform'] = strtolower($attr['content']);
 
                                $version_part = explode(' ', $attr['content']);
 
                                if (count($version_part) == 2) {
                                        if (in_array($version_part[0], ['WordPress'])) {
-                                               $serverdata['platform'] = $version_part[0];
+                                               $serverdata['platform'] = strtolower($version_part[0]);
                                                $serverdata['version'] = $version_part[1];
 
                                                // We still do need a reliable test if some AP plugin is activated
@@ -1222,7 +1222,7 @@ class GServer
                                                }
                                        }
                                        if (in_array($version_part[0], ['Friendika', 'Friendica'])) {
-                                               $serverdata['platform'] = $version_part[0];
+                                               $serverdata['platform'] = strtolower($version_part[0]);
                                                $serverdata['version'] = $version_part[1];
                                                $serverdata['network'] = Protocol::DFRN;
                                        }
@@ -1258,7 +1258,7 @@ class GServer
                        }
 
                        if ($attr['property'] == 'og:platform') {
-                               $serverdata['platform'] = $attr['content'];
+                               $serverdata['platform'] = strtolower($attr['content']);
 
                                if (in_array($attr['content'], ['PeerTube'])) {
                                        $serverdata['network'] = Protocol::ACTIVITYPUB;
@@ -1266,7 +1266,7 @@ class GServer
                        }
 
                        if ($attr['property'] == 'generator') {
-                               $serverdata['platform'] = $attr['content'];
+                               $serverdata['platform'] = strtolower($attr['content']);
 
                                if (in_array($attr['content'], ['hubzilla'])) {
                                        // We later check which compatible protocol modules are loaded.
index cc0067808fb22758c303dbe27d591c6c1c1d5c8d..db7781f0f66994f47432f6885cc08a054627d019 100644 (file)
@@ -17,7 +17,7 @@ class Federation extends BaseAdminModule
                // get counts on active federation systems this node is knowing
                // We list the more common systems by name. The rest is counted as "other"
                $systems = [
-                       'Friendica'   => ['name' => 'Friendica', 'color' => '#ffc018'], // orange from the logo
+                       'friendica'   => ['name' => 'Friendica', 'color' => '#ffc018'], // orange from the logo
                        'diaspora'    => ['name' => 'Diaspora', 'color' => '#a1a1a1'], // logo is black and white, makes a gray
                        'funkwhale'   => ['name' => 'Funkwhale', 'color' => '#4082B4'], // From the homepage
                        'gnusocial'   => ['name' => 'GNU Social/Statusnet', 'color' => '#a22430'], // dark red from the logo
@@ -66,11 +66,11 @@ class Federation extends BaseAdminModule
                        }
                        DBA::close($versions);
 
-                       $platform = $gserver['platform'];
+                       $platform = $gserver['platform'] = strtolower($gserver['platform']);
 
-                       if ($platform == 'Friendika') {
-                               $platform = 'Friendica';
-                       } elseif (in_array($platform, ['Red Matrix', 'redmatrix', 'red'])) {
+                       if ($platform == 'friendika') {
+                               $platform = 'friendica';
+                       } elseif (in_array($platform, ['red matrix', 'redmatrix', 'red'])) {
                                $platform = 'hubzilla';
                        } elseif(stristr($platform, 'pleroma')) {
                                $platform = 'pleroma';
@@ -96,7 +96,7 @@ class Federation extends BaseAdminModule
                                $gserver['users'] += $counts[$platform][0]['users'] ?? 0;
                        }
 
-                       if ($platform == 'Friendica') {
+                       if ($platform == 'friendica') {
                                $versionCounts = self::reformaFriendicaVersions($versionCounts);
                        } elseif ($platform == 'pleroma') {
                                $versionCounts = self::reformaPleromaVersions($versionCounts);
index 2f83a78b478408849d36b4507c639b7a62d983f6..99ae26b381536f1fd8960a0c1bd200365dc33814 100644 (file)
@@ -118,15 +118,15 @@ class NodeInfo extends BaseModule
                $nodeinfo = [
                        'version'           => '1.0',
                        'software'          => [
-                               'name'    => 'Friendica',
+                               'name'    => 'friendica',
                                'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
                        ],
                        'protocols'         => [
                                'inbound'  => [
-                                       'friendica', 'activitypub'
+                                       'friendica'
                                ],
                                'outbound' => [
-                                       'friendica', 'activitypub'
+                                       'friendica'
                                ],
                        ],
                        'services'          => [],
@@ -181,7 +181,7 @@ class NodeInfo extends BaseModule
                $nodeinfo = [
                        'version'           => '2.0',
                        'software'          => [
-                               'name'    => 'Friendica',
+                               'name'    => 'friendica',
                                'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
                        ],
                        'protocols'         => ['dfrn', 'activitypub'],