The addon "statistics_json" becomes the system setting "nodeinfo"
This commit is contained in:
parent
7ed5632f9c
commit
c2a1cf958d
4 changed files with 82 additions and 0 deletions
|
@ -390,6 +390,7 @@ function admin_page_site_post(&$a){
|
||||||
$poco_discovery = ((x($_POST,'poco_discovery')) ? intval(trim($_POST['poco_discovery'])) : 0);
|
$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_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);
|
$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);
|
$dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
|
||||||
$ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? 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);
|
$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',$poco_discovery);
|
||||||
set_config('system','poco_discovery_since',$poco_discovery_since);
|
set_config('system','poco_discovery_since',$poco_discovery_since);
|
||||||
set_config('system','poco_local_search',$poco_local_search);
|
set_config('system','poco_local_search',$poco_local_search);
|
||||||
|
set_config('system','nodeinfo',$nodeinfo);
|
||||||
set_config('config','sitename',$sitename);
|
set_config('config','sitename',$sitename);
|
||||||
set_config('config','hostname',$hostname);
|
set_config('config','hostname',$hostname);
|
||||||
set_config('config','sender_email', $sender_email);
|
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_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.")),
|
'$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 information and usage data will be published. Th data contains the number of users, number of posts and the activated connectors. See <a href='http://the-federation.info/'>the-federation.info</a> 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.")),
|
'$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_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.")),
|
'$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.")),
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
Documentation: http://nodeinfo.diaspora.software/schema.html
|
Documentation: http://nodeinfo.diaspora.software/schema.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once("include/plugin.php");
|
||||||
|
|
||||||
function nodeinfo_wellknown(&$a) {
|
function nodeinfo_wellknown(&$a) {
|
||||||
if (!get_config("system", "nodeinfo")) {
|
if (!get_config("system", "nodeinfo")) {
|
||||||
http_status_exit(404);
|
http_status_exit(404);
|
||||||
|
@ -143,6 +145,26 @@ function nodeinfo_cron() {
|
||||||
|
|
||||||
$a = get_app();
|
$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"))
|
if (!get_config("system", "nodeinfo"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
55
mod/statistics_json.php
Normal file
55
mod/statistics_json.php
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
require_once("mod/nodeinfo.php");
|
||||||
|
|
||||||
|
function statistics_json_init(&$a) {
|
||||||
|
|
||||||
|
if (!get_config("system", "nodeinfo")) {
|
||||||
|
http_status_exit(404);
|
||||||
|
killme();
|
||||||
|
}
|
||||||
|
|
||||||
|
$statistics = array(
|
||||||
|
"name" => $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();
|
||||||
|
}
|
|
@ -113,6 +113,7 @@
|
||||||
{{include file="field_input.tpl" field=$basepath}}
|
{{include file="field_input.tpl" field=$basepath}}
|
||||||
{{include file="field_checkbox.tpl" field=$suppress_language}}
|
{{include file="field_checkbox.tpl" field=$suppress_language}}
|
||||||
{{include file="field_checkbox.tpl" field=$suppress_tags}}
|
{{include file="field_checkbox.tpl" field=$suppress_tags}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$nodeinfo}}
|
||||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
||||||
|
|
||||||
<h3>{{$portable_contacts}}</h3>
|
<h3>{{$portable_contacts}}</h3>
|
||||||
|
|
Loading…
Reference in a new issue