3 namespace Friendica\Model;
5 use Friendica\Core\Addon;
6 use Friendica\Database\DBA;
10 * Model interaction for the nodeinfo
15 * Updates the info about the current node
17 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
19 public static function update()
22 $config = $app->getConfig();
23 $logger = $app->getLogger();
25 // If the addon 'statistics_json' is enabled then disable it and activate nodeinfo.
26 if (Addon::isEnabled('statistics_json')) {
27 $config->set('system', 'nodeinfo', true);
29 $addon = 'statistics_json';
30 $addons = $config->get('system', 'addon');
33 $addons_arr = explode(',', str_replace(' ', '', $addons));
35 $idx = array_search($addon, $addons_arr);
37 unset($addons_arr[$idx]);
38 Addon::uninstall($addon);
39 $config->set('system', 'addon', implode(', ', $addons_arr));
44 if (empty($config->get('system', 'nodeinfo'))) {
48 $userStats = User::getStatistics();
50 $config->set('nodeinfo', 'total_users', $userStats['total_users']);
51 $config->set('nodeinfo', 'active_users_halfyear', $userStats['active_users_halfyear']);
52 $config->set('nodeinfo', 'active_users_monthly', $userStats['active_users_monthly']);
54 $logger->debug('user statistics', $userStats);
56 $local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]);
57 $config->set('nodeinfo', 'local_posts', $local_posts);
58 $logger->debug('thread statistics', ['local_posts' => $local_posts]);
60 $local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]);
61 $config->set('nodeinfo', 'local_comments', $local_comments);
62 $logger->debug('item statistics', ['local_comments' => $local_comments]);