]> git.mxchange.org Git - friendica.git/blob - mod/statistics_json.php
Remove/replace killme() with *exit()
[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         }
18
19         $statistics = [
20                 "name" => Config::get('config', 'sitename'),
21                 "network" => FRIENDICA_PLATFORM,
22                 "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION,
23                 "registrations_open" => intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED,
24                 "total_users" => Config::get('nodeinfo', 'total_users'),
25                 "active_users_halfyear" => Config::get('nodeinfo', 'active_users_halfyear'),
26                 "active_users_monthly" => Config::get('nodeinfo', 'active_users_monthly'),
27                 "local_posts" => Config::get('nodeinfo', 'local_posts')
28         ];
29
30         $statistics["services"] = [];
31         $statistics["services"]["appnet"] = Addon::isEnabled("appnet");
32         $statistics["services"]["blogger"] = Addon::isEnabled("blogger");
33         $statistics["services"]["buffer"] = Addon::isEnabled("buffer");
34         $statistics["services"]["dreamwidth"] = Addon::isEnabled("dwpost");
35         $statistics["services"]["gnusocial"] = Addon::isEnabled("statusnet");
36         $statistics["services"]["libertree"] = Addon::isEnabled("libertree");
37         $statistics["services"]["livejournal"] = Addon::isEnabled("ljpost");
38         $statistics["services"]["pumpio"] = Addon::isEnabled("pumpio");
39         $statistics["services"]["twitter"] = Addon::isEnabled("twitter");
40         $statistics["services"]["tumblr"] = Addon::isEnabled("tumblr");
41         $statistics["services"]["wordpress"] = Addon::isEnabled("wppost");
42
43         $statistics["appnet"] = $statistics["services"]["appnet"];
44         $statistics["blogger"] = $statistics["services"]["blogger"];
45         $statistics["buffer"] = $statistics["services"]["buffer"];
46         $statistics["dreamwidth"] = $statistics["services"]["dreamwidth"];
47         $statistics["gnusocial"] = $statistics["services"]["gnusocial"];
48         $statistics["libertree"] = $statistics["services"]["libertree"];
49         $statistics["livejournal"] = $statistics["services"]["livejournal"];
50         $statistics["pumpio"] = $statistics["services"]["pumpio"];
51         $statistics["twitter"] = $statistics["services"]["twitter"];
52         $statistics["tumblr"] = $statistics["services"]["tumblr"];
53         $statistics["wordpress"] = $statistics["services"]["wordpress"];
54
55         header("Content-Type: application/json");
56         echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
57         Logger::log("statistics_init: printed " . print_r($statistics, true), Logger::DATA);
58         exit();
59 }