]> git.mxchange.org Git - friendica.git/blob - mod/statistics_json.php
The central item fetch does work now and the API now uses these functions
[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\System;
11
12 function statistics_json_init(App $a) {
13
14         if (!Config::get("system", "nodeinfo")) {
15                 System::httpExit(404);
16                 killme();
17         }
18
19         $statistics = [
20                 "name" => $a->config["sitename"],
21                 "network" => FRIENDICA_PLATFORM,
22                 "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION,
23                 "registrations_open" => ($a->config['register_policy'] != 0),
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"]["facebook"] = Addon::isEnabled("fbpost");
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["facebook"] = $statistics["services"]["facebook"];
50         $statistics["gnusocial"] = $statistics["services"]["gnusocial"];
51         $statistics["googleplus"] = $statistics["services"]["googleplus"];
52         $statistics["libertree"] = $statistics["services"]["libertree"];
53         $statistics["livejournal"] = $statistics["services"]["livejournal"];
54         $statistics["pumpio"] = $statistics["services"]["pumpio"];
55         $statistics["twitter"] = $statistics["services"]["twitter"];
56         $statistics["tumblr"] = $statistics["services"]["tumblr"];
57         $statistics["wordpress"] = $statistics["services"]["wordpress"];
58
59         header("Content-Type: application/json");
60         echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
61         logger("statistics_init: printed " . print_r($statistics, true), LOGGER_DATA);
62         killme();
63 }