3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module;
24 use Friendica\BaseModule;
25 use Friendica\Core\Addon;
27 use Friendica\Network\HTTPException\NotFoundException;
29 class Statistics extends BaseModule
31 public static function init(array $parameters = [])
33 if (!DI::config()->get("system", "nodeinfo")) {
34 throw new NotFoundException();
38 public static function rawContent(array $parameters = [])
40 $config = DI::config();
41 $logger = DI::logger();
44 intval($config->get('config', 'register_policy')) !== Register::CLOSED
45 && !$config->get('config', 'invitation_only');
47 /// @todo mark the "service" addons and load them dynamically here
49 'appnet' => Addon::isEnabled('appnet'),
50 'buffer' => Addon::isEnabled('buffer'),
51 'dreamwidth' => Addon::isEnabled('dreamwidth'),
52 'gnusocial' => Addon::isEnabled('gnusocial'),
53 'libertree' => Addon::isEnabled('libertree'),
54 'livejournal' => Addon::isEnabled('livejournal'),
55 'pumpio' => Addon::isEnabled('pumpio'),
56 'twitter' => Addon::isEnabled('twitter'),
57 'tumblr' => Addon::isEnabled('tumblr'),
58 'wordpress' => Addon::isEnabled('wordpress'),
61 $statistics = array_merge([
62 'name' => $config->get('config', 'sitename'),
63 'network' => FRIENDICA_PLATFORM,
64 'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
65 'registrations_open' => $registration_open,
66 'total_users' => $config->get('nodeinfo', 'total_users'),
67 'active_users_halfyear' => $config->get('nodeinfo', 'active_users_halfyear'),
68 'active_users_monthly' => $config->get('nodeinfo', 'active_users_monthly'),
69 'local_posts' => $config->get('nodeinfo', 'local_posts'),
70 'services' => $services,
73 header("Content-Type: application/json");
74 echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
75 $logger->debug("statistics.", ['statistics' => $statistics]);