]> git.mxchange.org Git - friendica.git/blobdiff - mod/nodeinfo.php
Catch HTTPExceptions in App::runFrontend()
[friendica.git] / mod / nodeinfo.php
index 134c690ce1dc949d58a91f971473e5eafcf96d9d..71aaae8d4eb8948e3e01f8fe19399c011ce725ae 100644 (file)
@@ -7,11 +7,11 @@
 
 use Friendica\App;
 use Friendica\Core\Addon;
-use Friendica\Core\System;
 use Friendica\Core\Config;
+use Friendica\Core\Logger;
+use Friendica\Core\System;
+use Friendica\Database\DBA;
 use Friendica\Util\Network;
-require_once 'include/dba.php';
-
 function nodeinfo_wellknown(App $a) {
        $nodeinfo = ['links' => [['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
                                        'href' => System::baseUrl().'/nodeinfo/1.0']]];
@@ -61,9 +61,9 @@ function nodeinfo_init(App $a) {
 
        $nodeinfo['usage'] = [];
 
-       $nodeinfo['openRegistrations'] = ($a->config['register_policy'] != 0);
+       $nodeinfo['openRegistrations'] = intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED;
 
-       $nodeinfo['metadata'] = ['nodeName' => $a->config['sitename']];
+       $nodeinfo['metadata'] = ['nodeName' => Config::get('config', 'sitename')];
 
        if (Config::get('system', 'nodeinfo')) {
 
@@ -73,29 +73,16 @@ function nodeinfo_init(App $a) {
                $nodeinfo['usage']['localPosts'] = (int)Config::get('nodeinfo', 'local_posts');
                $nodeinfo['usage']['localComments'] = (int)Config::get('nodeinfo', 'local_comments');
 
-               if (Addon::isEnabled('appnet')) {
-                       $nodeinfo['services']['inbound'][] = 'appnet';
-               }
-               if (Addon::isEnabled('appnet') || Addon::isEnabled('buffer')) {
-                       $nodeinfo['services']['outbound'][] = 'appnet';
-               }
                if (Addon::isEnabled('blogger')) {
                        $nodeinfo['services']['outbound'][] = 'blogger';
                }
                if (Addon::isEnabled('dwpost')) {
                        $nodeinfo['services']['outbound'][] = 'dreamwidth';
                }
-               if (Addon::isEnabled('fbpost') || Addon::isEnabled('buffer')) {
-                       $nodeinfo['services']['outbound'][] = 'facebook';
-               }
                if (Addon::isEnabled('statusnet')) {
                        $nodeinfo['services']['inbound'][] = 'gnusocial';
                        $nodeinfo['services']['outbound'][] = 'gnusocial';
                }
-
-               if (Addon::isEnabled('gpluspost') || Addon::isEnabled('buffer')) {
-                       $nodeinfo['services']['outbound'][] = 'google';
-               }
                if (Addon::isEnabled('ijpost')) {
                        $nodeinfo['services']['outbound'][] = 'insanejournal';
                }
@@ -141,6 +128,8 @@ function nodeinfo_init(App $a) {
                if (Addon::isEnabled('twitter')) {
                        $nodeinfo['metadata']['services']['inbound'][] = 'twitter';
                }
+
+               $nodeinfo['metadata']['explicitContent'] = Config::get('system', 'explicit_content', false) == true;
        }
 
        header('Content-type: application/json; charset=utf-8');
@@ -152,7 +141,7 @@ function nodeinfo_init(App $a) {
 
 function nodeinfo_cron() {
 
-       $a = get_app();
+       $a = \get_app();
 
        // If the addon 'statistics_json' is enabled then disable it and activate nodeinfo.
        if (Addon::isEnabled('statistics_json')) {
@@ -178,7 +167,7 @@ function nodeinfo_cron() {
                return;
        }
 
-       logger('cron_start');
+       Logger::log('cron_start');
 
        $users = q("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
                        FROM `user`
@@ -209,22 +198,22 @@ function nodeinfo_cron() {
                Config::set('nodeinfo', 'active_users_halfyear', $active_users_halfyear);
                Config::set('nodeinfo', 'active_users_monthly', $active_users_monthly);
 
-               logger('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, LOGGER_DEBUG);
+               Logger::log('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, Logger::DEBUG);
        }
 
-       $local_posts = dba::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]);
+       $local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]);
        Config::set('nodeinfo', 'local_posts', $local_posts);
-       logger('local_posts: ' . $local_posts, LOGGER_DEBUG);
+       Logger::log('local_posts: ' . $local_posts, Logger::DEBUG);
 
-       $local_comments = dba::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]);
+       $local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]);
        Config::set('nodeinfo', 'local_comments', $local_comments);
-       logger('local_comments: ' . $local_comments, LOGGER_DEBUG);
+       Logger::log('local_comments: ' . $local_comments, Logger::DEBUG);
 
        // Now trying to register
-       $url = 'http://the-federation.info/register/'.$a->get_hostname();
-       logger('registering url: '.$url, LOGGER_DEBUG);
+       $url = 'http://the-federation.info/register/'.$a->getHostName();
+       Logger::log('registering url: '.$url, Logger::DEBUG);
        $ret = Network::fetchUrl($url);
-       logger('registering answer: '.$ret, LOGGER_DEBUG);
+       Logger::log('registering answer: '.$ret, Logger::DEBUG);
 
-       logger('cron_end');
+       Logger::log('cron_end');
 }