diff --git a/mod/admin.php b/mod/admin.php index ad6460d9c..ff8cedc0c 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -390,6 +390,7 @@ function admin_page_site_post(&$a){ $poco_discovery = ((x($_POST,'poco_discovery')) ? intval(trim($_POST['poco_discovery'])) : 0); $poco_discovery_since = ((x($_POST,'poco_discovery_since')) ? intval(trim($_POST['poco_discovery_since'])) : 30); $poco_local_search = ((x($_POST,'poco_local_search')) ? intval(trim($_POST['poco_local_search'])) : false); + $nodeinfo = ((x($_POST,'nodeinfo')) ? intval(trim($_POST['nodeinfo'])) : false); $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False); $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False); $ostatus_poll_interval = ((x($_POST,'ostatus_poll_interval')) ? intval(trim($_POST['ostatus_poll_interval'])) : 0); @@ -463,6 +464,7 @@ function admin_page_site_post(&$a){ set_config('system','poco_discovery',$poco_discovery); set_config('system','poco_discovery_since',$poco_discovery_since); set_config('system','poco_local_search',$poco_local_search); + set_config('system','nodeinfo',$nodeinfo); set_config('config','sitename',$sitename); set_config('config','hostname',$hostname); set_config('config','sender_email', $sender_email); @@ -743,6 +745,8 @@ function admin_page_site(&$a) { '$poco_discovery_since' => array('poco_discovery_since', t("Timeframe for fetching global contacts"), (string) intval(get_config('system','poco_discovery_since')), t("When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers."), $poco_discovery_since_choices), '$poco_local_search' => array('poco_local_search', t("Search the local directory"), get_config('system','poco_local_search'), t("Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.")), + '$nodeinfo' => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See the-federation.info for details.")), + '$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")), '$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")), '$suppress_tags' => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")), diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index d19d0fc99..e68054208 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -3,6 +3,8 @@ Documentation: http://nodeinfo.diaspora.software/schema.html */ +require_once("include/plugin.php"); + function nodeinfo_wellknown(&$a) { if (!get_config("system", "nodeinfo")) { http_status_exit(404); @@ -143,6 +145,26 @@ function nodeinfo_cron() { $a = get_app(); + // If the plugin "statistics_json" is enabled then disable it and actrivate nodeinfo. + if (nodeinfo_plugin_enabled("statistics_json")) { + set_config("system", "nodeinfo", true); + + $plugin = "statistics_json"; + $plugins = get_config("system","addon"); + $plugins_arr = array(); + + if($plugins) { + $plugins_arr = explode(",",str_replace(" ", "",$plugins)); + + $idx = array_search($plugin, $plugins_arr); + if ($idx !== false){ + unset($plugins_arr[$idx]); + uninstall_plugin($plugin); + set_config("system","addon", implode(", ",$plugins_arr)); + } + } + } + if (!get_config("system", "nodeinfo")) return; diff --git a/mod/statistics_json.php b/mod/statistics_json.php new file mode 100644 index 000000000..9f97d6ac7 --- /dev/null +++ b/mod/statistics_json.php @@ -0,0 +1,55 @@ + $a->config["sitename"], + "network" => FRIENDICA_PLATFORM, + "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION, + "registrations_open" => ($a->config['register_policy'] != 0), + "total_users" => get_config('nodeinfo','total_users'), + "active_users_halfyear" => get_config('nodeinfo','active_users_halfyear'), + "active_users_monthly" => get_config('nodeinfo','active_users_monthly'), + "local_posts" => get_config('nodeinfo','local_posts') + ); + + $statistics["services"] = array(); + $statistics["services"]["appnet"] = nodeinfo_plugin_enabled("appnet"); + $statistics["services"]["blogger"] = nodeinfo_plugin_enabled("blogger"); + $statistics["services"]["buffer"] = nodeinfo_plugin_enabled("buffer"); + $statistics["services"]["dreamwidth"] = nodeinfo_plugin_enabled("dwpost"); + $statistics["services"]["facebook"] = nodeinfo_plugin_enabled("fbpost"); + $statistics["services"]["gnusocial"] = nodeinfo_plugin_enabled("statusnet"); + $statistics["services"]["googleplus"] = nodeinfo_plugin_enabled("gpluspost"); + $statistics["services"]["libertree"] = nodeinfo_plugin_enabled("libertree"); + $statistics["services"]["livejournal"] = nodeinfo_plugin_enabled("ljpost"); + $statistics["services"]["pumpio"] = nodeinfo_plugin_enabled("pumpio"); + $statistics["services"]["twitter"] = nodeinfo_plugin_enabled("twitter"); + $statistics["services"]["tumblr"] = nodeinfo_plugin_enabled("tumblr"); + $statistics["services"]["wordpress"] = nodeinfo_plugin_enabled("wppost"); + + $statistics["appnet"] = $statistics["services"]["appnet"]; + $statistics["blogger"] = $statistics["services"]["blogger"]; + $statistics["buffer"] = $statistics["services"]["buffer"]; + $statistics["dreamwidth"] = $statistics["services"]["dreamwidth"]; + $statistics["facebook"] = $statistics["services"]["facebook"]; + $statistics["gnusocial"] = $statistics["services"]["gnusocial"]; + $statistics["googleplus"] = $statistics["services"]["googleplus"]; + $statistics["libertree"] = $statistics["services"]["libertree"]; + $statistics["livejournal"] = $statistics["services"]["livejournal"]; + $statistics["pumpio"] = $statistics["services"]["pumpio"]; + $statistics["twitter"] = $statistics["services"]["twitter"]; + $statistics["tumblr"] = $statistics["services"]["tumblr"]; + $statistics["wordpress"] = $statistics["services"]["wordpress"]; + + header("Content-Type: application/json"); + echo json_encode($statistics, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); + logger("statistics_init: printed ".print_r($statistics, true), LOGGER_DATA); + killme(); +} diff --git a/view/templates/admin_site.tpl b/view/templates/admin_site.tpl index 9b3c75a0e..1517b9f01 100644 --- a/view/templates/admin_site.tpl +++ b/view/templates/admin_site.tpl @@ -113,6 +113,7 @@ {{include file="field_input.tpl" field=$basepath}} {{include file="field_checkbox.tpl" field=$suppress_language}} {{include file="field_checkbox.tpl" field=$suppress_tags}} + {{include file="field_checkbox.tpl" field=$nodeinfo}}

{{$portable_contacts}}