use Exception;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config;
+use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\GContact;
$friendica = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$1$2", $profile);
if ($friendica != $profile) {
$server_url = $friendica;
- $network = NETWORK_DFRN;
+ $network = Protocol::DFRN;
}
}
$diaspora = preg_replace("=(https?://)(.*)/u/(.*)=ism", "$1$2", $profile);
if ($diaspora != $profile) {
$server_url = $diaspora;
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
}
}
$red = preg_replace("=(https?://)(.*)/channel/(.*)=ism", "$1$2", $profile);
if ($red != $profile) {
$server_url = $red;
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
}
}
$mastodon = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
if ($mastodon != $profile) {
$server_url = $mastodon;
- $network = NETWORK_OSTATUS;
+ $network = Protocol::OSTATUS;
}
}
$ostatus = preg_replace("=(https?://)(.*)/user/(.*)=ism", "$1$2", $profile);
if ($ostatus != $profile) {
$server_url = $ostatus;
- $network = NETWORK_OSTATUS;
+ $network = Protocol::OSTATUS;
}
}
$base = preg_replace("=(https?://)(.*?)/(.*)=ism", "$1$2", $profile);
if ($base != $profile) {
$server_url = $base;
- $network = NETWORK_PHANTOM;
+ $network = Protocol::PHANTOM;
}
}
$server_url = normalise_link(self::detectServer($profile));
}
- if (!in_array($gcontacts[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_FEED, NETWORK_OSTATUS, ""])) {
+ if (!in_array($gcontacts[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
return false;
}
$contact['server_url'] = $server_url;
}
- if (in_array($gcontacts[0]["network"], ["", NETWORK_FEED])) {
+ if (in_array($gcontacts[0]["network"], ["", Protocol::FEED])) {
$server = q(
"SELECT `network` FROM `gserver` WHERE `nurl` = '%s' AND `network` != ''",
DBA::escape(normalise_link($server_url))
// Is the profile link the alternate OStatus link notation? (http://domain.tld/user/4711)
// Then check the other link and delete this one
- if (($data["network"] == NETWORK_OSTATUS) && self::alternateOStatusUrl($profile)
+ if (($data["network"] == Protocol::OSTATUS) && self::alternateOStatusUrl($profile)
&& (normalise_link($profile) == normalise_link($data["alias"]))
&& (normalise_link($profile) != normalise_link($data["url"]))
) {
return false;
}
- if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
+ if (($data["poll"] == "") || (in_array($data["network"], [Protocol::FEED, Protocol::PHANTOM]))) {
$fields = ['last_failure' => DateTimeFormat::utcNow()];
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
if ($url['type'] == 'zot') {
$server = [];
$server["platform"] = 'Hubzilla';
- $server["network"] = NETWORK_DIASPORA;
+ $server["network"] = Protocol::DIASPORA;
return $server;
}
}
}
if ($gnusocial) {
- $server['network'] = NETWORK_OSTATUS;
+ $server['network'] = Protocol::OSTATUS;
}
if ($diaspora) {
- $server['network'] = NETWORK_DIASPORA;
+ $server['network'] = Protocol::DIASPORA;
}
if ($friendica) {
- $server['network'] = NETWORK_DFRN;
+ $server['network'] = Protocol::DFRN;
}
if (!$server) {
}
if ($gnusocial) {
- $server['network'] = NETWORK_OSTATUS;
+ $server['network'] = Protocol::OSTATUS;
} elseif ($diaspora) {
- $server['network'] = NETWORK_DIASPORA;
+ $server['network'] = Protocol::DIASPORA;
} elseif ($friendica) {
- $server['network'] = NETWORK_DFRN;
+ $server['network'] = Protocol::DFRN;
}
if (empty($server)) {
$server = [];
$server["platform"] = $version_part[0];
$server["version"] = $version_part[1];
- $server["network"] = NETWORK_DFRN;
+ $server["network"] = Protocol::DFRN;
}
}
}
$server = [];
$server["platform"] = $attr['content'];
$server["version"] = "";
- $server["network"] = NETWORK_DIASPORA;
+ $server["network"] = Protocol::DIASPORA;
}
}
}
$platform = "Diaspora";
$version = trim(str_replace("X-Diaspora-Version:", "", $line));
$version = trim(str_replace("x-diaspora-version:", "", $version));
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
$versionparts = explode("-", $version);
$version = $versionparts[0];
}
if (stristr($line, 'Server: Mastodon')) {
$platform = "Mastodon";
- $network = NETWORK_OSTATUS;
+ $network = Protocol::OSTATUS;
}
}
}
// Remove junk that some GNU Social servers return
$version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
$version = trim($version, '"');
- $network = NETWORK_OSTATUS;
+ $network = Protocol::OSTATUS;
}
// Test for GNU Social
// Remove junk that some GNU Social servers return
$version = str_replace(chr(239) . chr(187) . chr(191), "", $serverret["body"]);
$version = trim($version, '"');
- $network = NETWORK_OSTATUS;
+ $network = Protocol::OSTATUS;
}
// Test for Mastodon
$version = $data['version'];
$site_name = $data['title'];
$info = $data['description'];
- $network = NETWORK_OSTATUS;
+ $network = Protocol::OSTATUS;
}
if (!empty($data['stats']['user_count'])) {
if (isset($data['url'])) {
$platform = $data['platform'];
$version = $data['version'];
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
}
if (!empty($data['site_name'])) {
if (isset($data['site']['platform'])) {
$platform = $data['site']['platform']['PLATFORM_NAME'];
$version = $data['site']['platform']['STD_VERSION'];
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
}
if (isset($data['site']['BlaBlaNet'])) {
$platform = $data['site']['BlaBlaNet']['PLATFORM_NAME'];
$version = $data['site']['BlaBlaNet']['STD_VERSION'];
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
}
if (isset($data['site']['hubzilla'])) {
$platform = $data['site']['hubzilla']['PLATFORM_NAME'];
$version = $data['site']['hubzilla']['RED_VERSION'];
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
}
if (isset($data['site']['redmatrix'])) {
}
$version = $data['site']['redmatrix']['RED_VERSION'];
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
}
if (isset($data['site']['friendica'])) {
$platform = $data['site']['friendica']['FRIENDICA_PLATFORM'];
$version = $data['site']['friendica']['FRIENDICA_VERSION'];
- $network = NETWORK_DFRN;
+ $network = Protocol::DFRN;
}
$site_name = $data['site']['name'];
}
if ($platform == "Diaspora") {
- $network = NETWORK_DIASPORA;
+ $network = Protocol::DIASPORA;
}
if (!empty($data['registrations_open']) && $data['registrations_open']) {
// Check for noscrape
// Friendica servers could be detected as OStatus servers
- if (!$failure && in_array($network, [NETWORK_DFRN, NETWORK_OSTATUS])) {
+ if (!$failure && in_array($network, [Protocol::DFRN, Protocol::OSTATUS])) {
$serverret = Network::curl($server_url . "/friendica/json");
if (!$serverret["success"]) {
$data = json_decode($serverret["body"], true);
if (isset($data['version'])) {
- $network = NETWORK_DFRN;
+ $network = Protocol::DFRN;
if (!empty($data['no_scrape_url'])) {
$noscrape = $data['no_scrape_url'];
DBA::insert('gserver', $fields);
}
- if (!$failure && in_array($fields['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
+ if (!$failure && in_array($fields['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
self::discoverRelay($server_url);
}
$fields = [];
if (isset($data['protocols'])) {
if (isset($data['protocols']['diaspora'])) {
- $fields['network'] = NETWORK_DIASPORA;
+ $fields['network'] = Protocol::DIASPORA;
if (isset($data['protocols']['diaspora']['receive'])) {
$fields['batch'] = $data['protocols']['diaspora']['receive'];
}
if (isset($data['protocols']['dfrn'])) {
- $fields['network'] = NETWORK_DFRN;
+ $fields['network'] = Protocol::DFRN;
if (isset($data['protocols']['dfrn']['receive'])) {
$fields['batch'] = $data['protocols']['dfrn']['receive'];
WHERE `network` IN ('%s', '%s', '%s') AND `last_contact` > `last_failure`
ORDER BY `last_contact`
LIMIT 1000",
- DBA::escape(NETWORK_DFRN),
- DBA::escape(NETWORK_DIASPORA),
- DBA::escape(NETWORK_OSTATUS)
+ DBA::escape(Protocol::DFRN),
+ DBA::escape(Protocol::DIASPORA),
+ DBA::escape(Protocol::OSTATUS)
);
if (!DBA::isResult($r)) {