From: zotlabs Date: Thu, 20 Jul 2017 00:56:40 +0000 (-0700) Subject: reduce the number of network fetches for server detection of hubzilla/red systems... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a583bda5fc2839d0f2e84aa0321471052be7342e;p=friendica.git reduce the number of network fetches for server detection of hubzilla/red systems from around 10 to maybe 5. Kind of wasteful to get hit on 10 non-existent endpoints every couple of minutes. --- diff --git a/include/socgraph.php b/include/socgraph.php index ce6cdcdef6..eccde26214 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1160,53 +1160,77 @@ function poco_check_server($server_url, $network = "", $force = false) { if (!$failure) { // Test for Hubzilla, Redmatrix or Friendica - $serverret = z_fetch_url($server_url."/api/statusnet/config.json"); + $serverret = z_fetch_url($server_url."/siteinfo.json"); if ($serverret["success"]) { $data = json_decode($serverret["body"]); - if (isset($data->site->server)) { - if (isset($data->site->platform)) { - $platform = $data->site->platform->PLATFORM_NAME; - $version = $data->site->platform->STD_VERSION; - $network = NETWORK_DIASPORA; - } - if (isset($data->site->BlaBlaNet)) { - $platform = $data->site->BlaBlaNet->PLATFORM_NAME; - $version = $data->site->BlaBlaNet->STD_VERSION; - $network = NETWORK_DIASPORA; - } - if (isset($data->site->hubzilla)) { - $platform = $data->site->hubzilla->PLATFORM_NAME; - $version = $data->site->hubzilla->RED_VERSION; - $network = NETWORK_DIASPORA; - } - if (isset($data->site->redmatrix)) { - if (isset($data->site->redmatrix->PLATFORM_NAME)) { - $platform = $data->site->redmatrix->PLATFORM_NAME; - } elseif (isset($data->site->redmatrix->RED_PLATFORM)) { - $platform = $data->site->redmatrix->RED_PLATFORM; + if(isset($data->url)) { + $platform = $data->platform; + $version = $data->version; + $network = NETWORK_DIASPORA; + } + $site_name = $data->site_name; + switch ($data->register_policy) { + case "REGISTER_OPEN": + $register_policy = REGISTER_OPEN; + break; + case "REGISTER_APPROVE": + $register_policy = REGISTER_APPROVE; + break; + case "REGISTER_CLOSED": + default: + $register_policy = REGISTER_CLOSED; + break; + } + } + else { + $serverret = z_fetch_url($server_url."/api/statusnet/config.json"); + if ($serverret["success"]) { + $data = json_decode($serverret["body"]); + if (isset($data->site->server)) { + if (isset($data->site->platform)) { + $platform = $data->site->platform->PLATFORM_NAME; + $version = $data->site->platform->STD_VERSION; + $network = NETWORK_DIASPORA; + } + if (isset($data->site->BlaBlaNet)) { + $platform = $data->site->BlaBlaNet->PLATFORM_NAME; + $version = $data->site->BlaBlaNet->STD_VERSION; + $network = NETWORK_DIASPORA; } + if (isset($data->site->hubzilla)) { + $platform = $data->site->hubzilla->PLATFORM_NAME; + $version = $data->site->hubzilla->RED_VERSION; + $network = NETWORK_DIASPORA; + } + if (isset($data->site->redmatrix)) { + if (isset($data->site->redmatrix->PLATFORM_NAME)) { + $platform = $data->site->redmatrix->PLATFORM_NAME; + } elseif (isset($data->site->redmatrix->RED_PLATFORM)) { + $platform = $data->site->redmatrix->RED_PLATFORM; + } - $version = $data->site->redmatrix->RED_VERSION; - $network = NETWORK_DIASPORA; - } - if (isset($data->site->friendica)) { - $platform = $data->site->friendica->FRIENDICA_PLATFORM; - $version = $data->site->friendica->FRIENDICA_VERSION; - $network = NETWORK_DFRN; - } + $version = $data->site->redmatrix->RED_VERSION; + $network = NETWORK_DIASPORA; + } + if (isset($data->site->friendica)) { + $platform = $data->site->friendica->FRIENDICA_PLATFORM; + $version = $data->site->friendica->FRIENDICA_VERSION; + $network = NETWORK_DFRN; + } - $site_name = $data->site->name; + $site_name = $data->site->name; - $data->site->closed = poco_to_boolean($data->site->closed); - $data->site->private = poco_to_boolean($data->site->private); - $data->site->inviteonly = poco_to_boolean($data->site->inviteonly); + $data->site->closed = poco_to_boolean($data->site->closed); + $data->site->private = poco_to_boolean($data->site->private); + $data->site->inviteonly = poco_to_boolean($data->site->inviteonly); - if (!$data->site->closed && !$data->site->private and $data->site->inviteonly) { - $register_policy = REGISTER_APPROVE; - } elseif (!$data->site->closed && !$data->site->private) { - $register_policy = REGISTER_OPEN; - } else { - $register_policy = REGISTER_CLOSED; + if (!$data->site->closed && !$data->site->private and $data->site->inviteonly) { + $register_policy = REGISTER_APPROVE; + } elseif (!$data->site->closed && !$data->site->private) { + $register_policy = REGISTER_OPEN; + } else { + $register_policy = REGISTER_CLOSED; + } } } }