return ($val);
}
-function poco_detect_friendica_server($body) {
+/**
+ * @brief Detect server type (Hubzilla or Friendica) via the front page body
+ *
+ * @param string $body Front page of the server
+ * @return array Server data
+ */
+function poco_detect_server_type($body) {
$server = false;
$doc = new \DOMDocument();
}
}
+ if (!$server) {
+ $list = $xpath->query("//meta[@property]");
+
+ foreach ($list as $node) {
+ $attr = array();
+ if ($node->attributes->length) {
+ foreach ($node->attributes as $attribute) {
+ $attr[$attribute->name] = $attribute->value;
+ }
+ }
+ if ($attr['property'] == 'generator') {
+ if (in_array($attr['content'], array("hubzilla"))) {
+ $server = array();
+ $server["platform"] = $attr['content'];
+ $server["version"] = "";
+ $server["network"] = NETWORK_DIASPORA;
+ }
+ }
+ }
+ }
+
if (!$server) {
return false;
}
$last_contact = datetime_convert();
if (!$failure) {
- // Test for Diaspora
+ // Test for Diaspora, Hubzilla, Mastodon or older Friendica servers
$serverret = z_fetch_url($server_url);
if (!$serverret["success"] OR ($serverret["body"] == "")) {
$last_failure = datetime_convert();
$failure = true;
} else {
+ $server = poco_detect_server_type($serverret["body"]);
+ if ($server) {
+ $platform = $server['platform'];
+ $network = $server['network'];
+ $version = $server['version'];
+ $site_name = $server['site_name'];
+ $last_contact = datetime_convert();
+ }
+
$lines = explode("\n",$serverret["header"]);
if(count($lines)) {
foreach($lines as $line) {
}
}
}
-
- $friendica_server = poco_detect_friendica_server($serverret["body"]);
- if ($friendica_server) {
- $platform = $friendica_server['platform'];
- $network = $friendica_server['network'];
- $version = $friendica_server['version'];
- $site_name = $friendica_server['site_name'];
- $last_contact = datetime_convert();
- }
}
}
$last_contact = datetime_convert();
}
+ // Test for Hubzilla, Redmatrix or Friendica
$serverret = z_fetch_url($server_url."/api/statusnet/config.json");
if ($serverret["success"]) {
$data = json_decode($serverret["body"]);