]> git.mxchange.org Git - friendica.git/blob - mod/statistics_json.php
Move Composer autoload require out of boot.php
[friendica.git] / mod / statistics_json.php
1 <?php
2
3 /**
4  * @file mod/statistics_json.php
5  */
6
7 use Friendica\App;
8 use Friendica\Core\Addon;
9 use Friendica\Core\Config;
10 use Friendica\Core\Logger;
11 use Friendica\Core\System;
12
13 function statistics_json_init(App $a) {
14
15         if (!Config::get("system", "nodeinfo")) {
16                 System::httpExit(404);
17                 killme();
18         }
19
20         $statistics = [
21                 "name" => Config::get('config', 'sitename'),
22                 "network" => FRIENDICA_PLATFORM,
23                 "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION,
24                 "registrations_open" => intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED,
25                 "total_users" => Config::get('nodeinfo', 'total_users'),
26                 "active_users_halfyear" => Config::get('nodeinfo', 'active_users_halfyear'),
27                 "active_users_monthly" => Config::get('nodeinfo', 'active_users_monthly'),
28                 "local_posts" => Config::get('nodeinfo', 'local_posts')
29         ];
30
31         $statistics["services"] = [];
32         $statistics["services"]["appnet"] = Addon::isEnabled("appnet");
33         $statistics["services"]["blogger"] = Addon::isEnabled("blogger");
34         $statistics["services"]["buffer"] = Addon::isEnabled("buffer");
35         $statistics["services"]["dreamwidth"] = Addon::isEnabled("dwpost");
36         $statistics["services"]["gnusocial"] = Addon::isEnabled("statusnet");
37         $statistics["services"]["googleplus"] = Addon::isEnabled("gpluspost");
38         $statistics["services"]["libertree"] = Addon::isEnabled("libertree");
39         $statistics["services"]["livejournal"] = Addon::isEnabled("ljpost");
40         $statistics["services"]["pumpio"] = Addon::isEnabled("pumpio");
41         $statistics["services"]["twitter"] = Addon::isEnabled("twitter");
42         $statistics["services"]["tumblr"] = Addon::isEnabled("tumblr");
43         $statistics["services"]["wordpress"] = Addon::isEnabled("wppost");
44
45         $statistics["appnet"] = $statistics["services"]["appnet"];
46         $statistics["blogger"] = $statistics["services"]["blogger"];
47         $statistics["buffer"] = $statistics["services"]["buffer"];
48         $statistics["dreamwidth"] = $statistics["services"]["dreamwidth"];
49         $statistics["gnusocial"] = $statistics["services"]["gnusocial"];
50         $statistics["googleplus"] = $statistics["services"]["googleplus"];
51         $statistics["libertree"] = $statistics["services"]["libertree"];
52         $statistics["livejournal"] = $statistics["services"]["livejournal"];
53         $statistics["pumpio"] = $statistics["services"]["pumpio"];
54         $statistics["twitter"] = $statistics["services"]["twitter"];
55         $statistics["tumblr"] = $statistics["services"]["tumblr"];
56         $statistics["wordpress"] = $statistics["services"]["wordpress"];
57
58         header("Content-Type: application/json");
59         echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
60         Logger::log("statistics_init: printed " . print_r($statistics, true), Logger::DATA);
61         killme();
62 }