]> git.mxchange.org Git - friendica.git/blobdiff - mod/nodeinfo.php
Merge pull request #3949 from annando/further-information
[friendica.git] / mod / nodeinfo.php
index 5415bac48143938454d0c0decb034a9238df7cc4..7a690c15e92bd5589d93ada3d8f57fa7fa62cf6b 100644 (file)
@@ -5,13 +5,15 @@
  * Documentation: http://nodeinfo.diaspora.software/schema.html
 */
 
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\System;
+use Friendica\Core\Config;
 
-require_once('include/plugin.php');
+require_once 'include/plugin.php';
 
 function nodeinfo_wellknown(App $a) {
        $nodeinfo = array('links' => array(array('rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
-                                       'href' => App::get_baseurl().'/nodeinfo/1.0')));
+                                       'href' => System::baseUrl().'/nodeinfo/1.0')));
 
        header('Content-type: application/json; charset=utf-8');
        echo json_encode($nodeinfo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
@@ -24,12 +26,12 @@ function nodeinfo_init(App $a) {
                killme();
        }
 
-       if (($a->argc != 2) OR ($a->argv[1] != '1.0')) {
+       if (($a->argc != 2) || ($a->argv[1] != '1.0')) {
                http_status_exit(404);
                killme();
        }
 
-       $smtp = (function_exists('imap_open') AND !Config::get('system', 'imap_disabled') AND !Config::get('system', 'dfrn_only'));
+       $smtp = (function_exists('imap_open') && !Config::get('system', 'imap_disabled') && !Config::get('system', 'dfrn_only'));
 
        $nodeinfo = array();
        $nodeinfo['version'] = '1.0';
@@ -73,7 +75,7 @@ function nodeinfo_init(App $a) {
                if (plugin_enabled('appnet')) {
                        $nodeinfo['services']['inbound'][] = 'appnet';
                }
-               if (plugin_enabled('appnet') OR plugin_enabled('buffer')) {
+               if (plugin_enabled('appnet') || plugin_enabled('buffer')) {
                        $nodeinfo['services']['outbound'][] = 'appnet';
                }
                if (plugin_enabled('blogger')) {
@@ -82,7 +84,7 @@ function nodeinfo_init(App $a) {
                if (plugin_enabled('dwpost')) {
                        $nodeinfo['services']['outbound'][] = 'dreamwidth';
                }
-               if (plugin_enabled('fbpost') OR plugin_enabled('buffer')) {
+               if (plugin_enabled('fbpost') || plugin_enabled('buffer')) {
                        $nodeinfo['services']['outbound'][] = 'facebook';
                }
                if (plugin_enabled('statusnet')) {
@@ -90,7 +92,7 @@ function nodeinfo_init(App $a) {
                        $nodeinfo['services']['outbound'][] = 'gnusocial';
                }
 
-               if (plugin_enabled('gpluspost') OR plugin_enabled('buffer')) {
+               if (plugin_enabled('gpluspost') || plugin_enabled('buffer')) {
                        $nodeinfo['services']['outbound'][] = 'google';
                }
                if (plugin_enabled('ijpost')) {
@@ -122,7 +124,7 @@ function nodeinfo_init(App $a) {
                if (plugin_enabled('tumblr')) {
                        $nodeinfo['services']['outbound'][] = 'tumblr';
                }
-               if (plugin_enabled('twitter') OR plugin_enabled('buffer')) {
+               if (plugin_enabled('twitter') || plugin_enabled('buffer')) {
                        $nodeinfo['services']['outbound'][] = 'twitter';
                }
                if (plugin_enabled('wppost')) {
@@ -186,7 +188,7 @@ function nodeinfo_cron() {
        }
         logger('cron_start');
 
-       $users = qu("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
+       $users = q("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
                        FROM `user`
                        INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid` AND `profile`.`is-default`
                        INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
@@ -202,11 +204,11 @@ function nodeinfo_cron() {
                        $month = time() - (30 * 24 * 60 * 60);
 
                        foreach ($users AS $user) {
-                               if ((strtotime($user['login_date']) > $halfyear) OR
+                               if ((strtotime($user['login_date']) > $halfyear) ||
                                        (strtotime($user['last-item']) > $halfyear)) {
                                        ++$active_users_halfyear;
                                }
-                               if ((strtotime($user['login_date']) > $month) OR
+                               if ((strtotime($user['login_date']) > $month) ||
                                        (strtotime($user['last-item']) > $month)) {
                                        ++$active_users_monthly;
                                }
@@ -218,7 +220,7 @@ function nodeinfo_cron() {
                        Config::set('nodeinfo', 'active_users_monthly', $active_users_monthly);
        }
 
-       $posts = qu("SELECT COUNT(*) AS local_posts FROM `thread` WHERE `thread`.`wall` AND `thread`.`uid` != 0");
+       $posts = q("SELECT COUNT(*) AS `local_posts` FROM `thread` WHERE `thread`.`wall` AND `thread`.`uid` != 0");
 
        if (!is_array($posts)) {
                $local_posts = -1;
@@ -229,7 +231,7 @@ function nodeinfo_cron() {
 
         logger('local_posts: '.$local_posts, LOGGER_DEBUG);
 
-       $posts = qu("SELECT COUNT(*) FROM `contact`
+       $posts = q("SELECT COUNT(*) AS `local_comments` FROM `contact`
                        INNER JOIN `item` ON `item`.`contact-id` = `contact`.`id` AND `item`.`uid` = `contact`.`uid` AND
                                `item`.`id` != `item`.`parent` AND `item`.`network` IN ('%s', '%s', '%s')
                        WHERE `contact`.`self`",
@@ -251,5 +253,3 @@ function nodeinfo_cron() {
         logger('cron_end');
        Config::set('nodeinfo', 'last_calucation', time());
 }
-
-?>