]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #4375 from MrPetovan/task/3878-move-friendica_smarty-to-src
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Sat, 3 Feb 2018 09:32:32 +0000 (10:32 +0100)
committerGitHub <noreply@github.com>
Sat, 3 Feb 2018 09:32:32 +0000 (10:32 +0100)
 Move include/friendica_smarty to src/

doc/Developers-Intro.md
library/OAuth1.php
mod/admin.php
mod/phpinfo.php [new file with mode: 0644]
src/Network/Probe.php
src/Protocol/PortableContact.php

index b1a4d3e4bf4337ec65cf6b17bb36322d5ae4a47b..f0591cddcb2543f2bd011b8d72cea85c6ed3d642 100644 (file)
@@ -63,7 +63,7 @@ If you want to have git automatically update the dependencies with composer, you
     # to update all the php dependencies
     check_run composer.lock "util/composer.phar install --no-dev"
 
-just place it into `.git/hooks/post-merge` and make it executeable.
+just place it into `.git/hooks/post-merge` and make it executable.
 
 * [Class autoloading](help/autoloader)
 * [Using Composer](help/Composer)
index a2097be064b2c78cf698d733e9ce0cbcb3daa175..c537f2b252f7db0c8f69967859702bbbb4f30093 100644 (file)
@@ -3,10 +3,8 @@
 
 /* Generic exception class
  */
-if (!class_exists('OAuthException')) {
-       class OAuthException extends Exception {
-               // pass
-       }
+class OAuthException extends Exception {
+  // pass
 }
 
 class OAuthConsumer {
index 55a8a78f1c637253440d0336e9c961e29fd97013..d7495340b4c961932c84e7ec81732ff3263ee5a6 100644 (file)
@@ -180,10 +180,10 @@ function admin_content(App $a)
                        'addons'       => ["admin/addons/"      , L10n::t("Addons")               , "addons"],
                        'themes'       => ["admin/themes/"      , L10n::t("Themes")               , "themes"],
                        'features'     => ["admin/features/"    , L10n::t("Additional features")  , "features"] ]],
-               'database' => [ L10n::t('Database'), [ 
+               'database' => [ L10n::t('Database'), [
                        'dbsync'       => ["admin/dbsync/"      , L10n::t('DB updates')           , "dbsync"],
                        'queue'        => ["admin/queue/"       , L10n::t('Inspect Queue')        , "queue"], ]],
-               'tools' => [ L10n::t('Tools'), [ 
+               'tools' => [ L10n::t('Tools'), [
                        'contactblock' => ["admin/contactblock/", L10n::t('Contact Blocklist')    , "contactblock"],
                        'blocklist'    => ["admin/blocklist/"   , L10n::t('Server Blocklist')     , "blocklist"],
                        'deleteitem'   => ["admin/deleteitem/"  , L10n::t('Delete Item')          , 'deleteitem'], ]],
@@ -192,6 +192,7 @@ function admin_content(App $a)
                        "logsview" => ["admin/viewlogs/", L10n::t("View Logs"), 'viewlogs']
                ]],
                "diagnostics" => [ L10n::t("Diagnostics"), [
+                       "phpinfo" => ['phpinfo/', L10n::t('PHP Info'), 'phpinfo'],
                        "probe" => ['probe/', L10n::t('probe address'), 'probe'],
                        "webfinger" =>['webfinger/', L10n::t('check webfinger'), 'webfinger']
                ]]
diff --git a/mod/phpinfo.php b/mod/phpinfo.php
new file mode 100644 (file)
index 0000000..ec2897d
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/**
+ * @file mod/phpinfo.php
+ */
+
+require_once 'boot.php';
+
+function phpinfo_content()
+{
+       if (!is_site_admin()) {
+               return false;
+       }
+
+       phpinfo();
+       killme();
+}
index f7c3b84fdd46803c35eb334a505366189595004f..dc533d18de7f464480083f7baed14271bfb28f27 100644 (file)
@@ -90,6 +90,9 @@ class Probe
        /**
         * @brief Probes for webfinger path via "host-meta"
         *
+        * We have to check if the servers in the future still will offer this.
+        * It seems as if it was dropped from the standard.
+        *
         * @param string $host The host part of an url
         *
         * @return array with template and type of the webfinger template for JSON or XML
index fb9a725f082b7008de6565b06acf5d317dcbe66d..e70e67366cf8333beae39f09a6efe522dcb50351 100644 (file)
@@ -646,30 +646,51 @@ class PortableContact
                        return false;
                }
 
-               $nodeinfo_url = '';
+               $nodeinfo1_url = '';
+               $nodeinfo2_url = '';
 
                foreach ($nodeinfo->links as $link) {
                        if ($link->rel == 'http://nodeinfo.diaspora.software/ns/schema/1.0') {
-                               $nodeinfo_url = $link->href;
+                               $nodeinfo1_url = $link->href;
+                       }
+                       if ($link->rel == 'http://nodeinfo.diaspora.software/ns/schema/2.0') {
+                               $nodeinfo2_url = $link->href;
                        }
                }
 
-               if ($nodeinfo_url == '') {
+               if ($nodeinfo1_url . $nodeinfo2_url == '') {
                        return false;
                }
 
+               $server = [];
+
                // When the nodeinfo url isn't on the same host, then there is obviously something wrong
-               if (parse_url($server_url, PHP_URL_HOST) != parse_url($nodeinfo_url, PHP_URL_HOST)) {
-                       return false;
+               if (!empty($nodeinfo2_url) && (parse_url($server_url, PHP_URL_HOST) == parse_url($nodeinfo2_url, PHP_URL_HOST))) {
+                       $server = self::parseNodeinfo2($nodeinfo2_url);
+               }
+
+               // When the nodeinfo url isn't on the same host, then there is obviously something wrong
+               if (empty($server) && !empty($nodeinfo1_url) && (parse_url($server_url, PHP_URL_HOST) == parse_url($nodeinfo1_url, PHP_URL_HOST))) {
+                       $server = self::parseNodeinfo1($nodeinfo1_url);
                }
 
+               return $server;
+       }
+
+       /**
+        * @brief Parses Nodeinfo 1
+        *
+        * @param string $nodeinfo_url address of the nodeinfo path
+        * @return array Server data
+        */
+       private static function parseNodeinfo1($nodeinfo_url)
+       {
                $serverret = Network::curl($nodeinfo_url);
                if (!$serverret["success"]) {
                        return false;
                }
 
                $nodeinfo = json_decode($serverret['body']);
-
                if (!is_object($nodeinfo)) {
                        return false;
                }
@@ -740,6 +761,90 @@ class PortableContact
                return $server;
        }
 
+       /**
+        * @brief Parses Nodeinfo 2
+        *
+        * @param string $nodeinfo_url address of the nodeinfo path
+        * @return array Server data
+        */
+       private static function parseNodeinfo2($nodeinfo_url)
+       {
+               $serverret = Network::curl($nodeinfo_url);
+               if (!$serverret["success"]) {
+                       return false;
+               }
+
+               $nodeinfo = json_decode($serverret['body']);
+               if (!is_object($nodeinfo)) {
+                       return false;
+               }
+
+               $server = [];
+
+               $server['register_policy'] = REGISTER_CLOSED;
+
+               if (is_bool($nodeinfo->openRegistrations) && $nodeinfo->openRegistrations) {
+                       $server['register_policy'] = REGISTER_OPEN;
+               }
+
+               if (is_object($nodeinfo->software)) {
+                       if (isset($nodeinfo->software->name)) {
+                               $server['platform'] = $nodeinfo->software->name;
+                       }
+
+                       if (isset($nodeinfo->software->version)) {
+                               $server['version'] = $nodeinfo->software->version;
+                               // Version numbers on Nodeinfo are presented with additional info, e.g.:
+                               // 0.6.3.0-p1702cc1c, 0.6.99.0-p1b9ab160 or 3.4.3-2-1191.
+                               $server['version'] = preg_replace("=(.+)-(.{4,})=ism", "$1", $server['version']);
+                       }
+               }
+
+               if (is_object($nodeinfo->metadata)) {
+                       if (isset($nodeinfo->metadata->nodeName)) {
+                               $server['site_name'] = $nodeinfo->metadata->nodeName;
+                       }
+               }
+
+               if (!empty($nodeinfo->usage->users->total)) {
+                       $server['registered-users'] = $nodeinfo->usage->users->total;
+               }
+
+               $diaspora = false;
+               $friendica = false;
+               $gnusocial = false;
+
+               if (is_array($nodeinfo->protocols)) {
+                       foreach ($nodeinfo->protocols as $protocol) {
+                               if ($protocol == 'diaspora') {
+                                       $diaspora = true;
+                               }
+                               if ($protocol == 'friendica') {
+                                       $friendica = true;
+                               }
+                               if ($protocol == 'gnusocial') {
+                                       $gnusocial = true;
+                               }
+                       }
+               }
+
+               if ($gnusocial) {
+                       $server['network'] = NETWORK_OSTATUS;
+               }
+               if ($diaspora) {
+                       $server['network'] = NETWORK_DIASPORA;
+               }
+               if ($friendica) {
+                       $server['network'] = NETWORK_DFRN;
+               }
+
+               if (!$server) {
+                       return false;
+               }
+
+               return $server;
+       }
+
        /**
         * @brief Detect server type (Hubzilla or Friendica) via the front page body
         *