3 * @file src/Network/Probe.php
5 namespace Friendica\Network;
8 * @file src/Network/Probe.php
9 * @brief Functions for probing URL
14 use Friendica\Core\Cache;
15 use Friendica\Core\Config;
16 use Friendica\Core\Logger;
17 use Friendica\Core\Protocol;
18 use Friendica\Core\System;
19 use Friendica\Database\DBA;
20 use Friendica\Model\Profile;
21 use Friendica\Protocol\ActivityPub;
22 use Friendica\Protocol\Email;
23 use Friendica\Protocol\Feed;
24 use Friendica\Util\Crypto;
25 use Friendica\Util\DateTimeFormat;
26 use Friendica\Util\Network;
27 use Friendica\Util\Strings;
28 use Friendica\Util\XML;
31 * @brief This class contain functions for probing URL
36 private static $baseurl;
37 private static $istimeout;
40 * @brief Rearrange the array so that it always has the same order
42 * @param array $data Unordered data
44 * @return array Ordered data
46 private static function rearrangeData($data)
48 $fields = ["name", "nick", "guid", "url", "addr", "alias", "photo", "account-type",
49 "community", "keywords", "location", "about", "gender", "hide",
50 "batch", "notify", "poll", "request", "confirm", "poco",
51 "following", "followers", "inbox", "outbox", "sharedinbox",
52 "priority", "network", "pubkey", "baseurl"];
55 foreach ($fields as $field) {
56 if (isset($data[$field])) {
57 $newdata[$field] = $data[$field];
59 $newdata[$field] = "";
63 // We don't use the "priority" field anymore and replace it with a dummy.
64 $newdata["priority"] = 0;
70 * @brief Check if the hostname belongs to the own server
72 * @param string $host The hostname that is to be checked
74 * @return bool Does the testes hostname belongs to the own server?
76 private static function ownHost($host)
78 $own_host = \get_app()->getHostName();
80 $parts = parse_url($host);
82 if (!isset($parts['scheme'])) {
83 $parts = parse_url('http://'.$host);
86 if (!isset($parts['host'])) {
89 return $parts['host'] == $own_host;
93 * @brief Probes for webfinger path via "host-meta"
95 * We have to check if the servers in the future still will offer this.
96 * It seems as if it was dropped from the standard.
98 * @param string $host The host part of an url
100 * @return array with template and type of the webfinger template for JSON or XML
101 * @throws HTTPException\InternalServerErrorException
103 private static function hostMeta($host)
105 // Reset the static variable
108 $ssl_url = "https://".$host."/.well-known/host-meta";
109 $url = "http://".$host."/.well-known/host-meta";
111 $xrd_timeout = Config::get('system', 'xrd_timeout', 20);
113 Logger::log("Probing for ".$host, Logger::DEBUG);
116 $curlResult = Network::curl($ssl_url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
117 if ($curlResult->isSuccess()) {
118 $xml = $curlResult->getBody();
119 $xrd = XML::parseString($xml, false);
120 $host_url = 'https://'.$host;
123 if (!is_object($xrd)) {
124 $curlResult = Network::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
125 if ($curlResult->isTimeout()) {
126 Logger::log("Probing timeout for " . $url, Logger::DEBUG);
127 self::$istimeout = true;
130 $xml = $curlResult->getBody();
131 $xrd = XML::parseString($xml, false);
132 $host_url = 'http://'.$host;
134 if (!is_object($xrd)) {
135 Logger::log("No xrd object found for ".$host, Logger::DEBUG);
139 $links = XML::elementToArray($xrd);
140 if (!isset($links["xrd"]["link"])) {
141 Logger::log("No xrd data found for ".$host, Logger::DEBUG);
146 // The following webfinger path is defined in RFC 7033 https://tools.ietf.org/html/rfc7033
147 // Problem is that Hubzilla currently doesn't provide all data in the JSON webfinger
148 // compared to the XML webfinger. So this is commented out by now.
149 // $lrdd = array("application/jrd+json" => $host_url.'/.well-known/webfinger?resource={uri}');
151 foreach ($links["xrd"]["link"] as $value => $link) {
152 if (!empty($link["@attributes"])) {
153 $attributes = $link["@attributes"];
154 } elseif ($value == "@attributes") {
160 if (!empty($attributes["rel"]) && $attributes["rel"] == "lrdd" && !empty($attributes["template"])) {
161 $type = (empty($attributes["type"]) ? '' : $attributes["type"]);
163 $lrdd[$type] = $attributes["template"];
167 self::$baseurl = $host_url;
169 Logger::log("Probing successful for ".$host, Logger::DEBUG);
175 * @brief Perform Webfinger lookup and return DFRN data
177 * Given an email style address, perform webfinger lookup and
178 * return the resulting DFRN profile URL, or if no DFRN profile URL
179 * is located, returns an OStatus subscription template (prefixed
180 * with the string 'stat:' to identify it as on OStatus template).
181 * If this isn't an email style address just return $webbie.
182 * Return an empty string if email-style addresses but webfinger fails,
183 * or if the resultant personal XRD doesn't contain a supported
184 * subscription/friend-request attribute.
186 * amended 7/9/2011 to return an hcard which could save potentially loading
187 * a lengthy content page to scrape dfrn attributes
189 * @param string $webbie Address that should be probed
190 * @param string $hcard_url Link to the hcard - is returned by reference
192 * @return string profile link
193 * @throws HTTPException\InternalServerErrorException
195 public static function webfingerDfrn($webbie, &$hcard_url)
199 $links = self::lrdd($webbie);
200 Logger::log('webfingerDfrn: '.$webbie.':'.print_r($links, true), Logger::DATA);
201 if (!empty($links) && is_array($links)) {
202 foreach ($links as $link) {
203 if ($link['@attributes']['rel'] === NAMESPACE_DFRN) {
204 $profile_link = $link['@attributes']['href'];
206 if (($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB) && ($profile_link == "")) {
207 $profile_link = 'stat:'.$link['@attributes']['template'];
209 if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') {
210 $hcard_url = $link['@attributes']['href'];
214 return $profile_link;
218 * @brief Check an URI for LRDD data
220 * this is a replacement for the "lrdd" function.
221 * It isn't used in this class and has some redundancies in the code.
222 * When time comes we can check the existing calls for "lrdd" if we can rework them.
224 * @param string $uri Address that should be probed
226 * @return array uri data
227 * @throws HTTPException\InternalServerErrorException
229 public static function lrdd($uri)
231 $lrdd = self::hostMeta($uri);
234 if (is_bool($lrdd)) {
239 $parts = @parse_url($uri);
240 if (!$parts || empty($parts["host"]) || empty($parts["path"])) {
244 $host = $parts["host"];
245 if (!empty($parts["port"])) {
246 $host .= ':'.$parts["port"];
249 $path_parts = explode("/", trim($parts["path"], "/"));
251 $nick = array_pop($path_parts);
254 $lrdd = self::hostMeta($host);
255 $host .= "/".array_shift($path_parts);
256 } while (!$lrdd && (sizeof($path_parts) > 0));
260 Logger::log("No lrdd data found for ".$uri, Logger::DEBUG);
264 foreach ($lrdd as $type => $template) {
269 $path = str_replace('{uri}', urlencode($uri), $template);
270 $webfinger = self::webfinger($path, $type);
272 if (!$webfinger && (strstr($uri, "@"))) {
273 $path = str_replace('{uri}', urlencode("acct:".$uri), $template);
274 $webfinger = self::webfinger($path, $type);
277 // Special treatment for Mastodon
278 // Problem is that Mastodon uses an URL format like http://domain.tld/@nick
279 // But the webfinger for this format fails.
280 if (!$webfinger && !empty($nick)) {
281 // Mastodon uses a "@" as prefix for usernames in their url format
282 $nick = ltrim($nick, '@');
284 $addr = $nick."@".$host;
286 $path = str_replace('{uri}', urlencode("acct:".$addr), $template);
287 $webfinger = self::webfinger($path, $type);
291 if (!is_array($webfinger["links"])) {
292 Logger::log("No webfinger links found for ".$uri, Logger::DEBUG);
298 foreach ($webfinger["links"] as $link) {
299 $data[] = ["@attributes" => $link];
302 if (is_array($webfinger["aliases"])) {
303 foreach ($webfinger["aliases"] as $alias) {
304 $data[] = ["@attributes" =>
314 * @brief Fetch information (protocol endpoints and user information) about a given uri
316 * @param string $uri Address that should be probed
317 * @param string $network Test for this specific network
318 * @param integer $uid User ID for the probe (only used for mails)
319 * @param boolean $cache Use cached values?
321 * @return array uri data
322 * @throws HTTPException\InternalServerErrorException
323 * @throws \ImagickException
325 public static function uri($uri, $network = '', $uid = -1, $cache = true)
328 $result = Cache::get('Probe::uri:' . $network . ':' . $uri);
329 if (!is_null($result)) {
338 self::$istimeout = false;
340 if ($network != Protocol::ACTIVITYPUB) {
341 $data = self::detect($uri, $network, $uid);
346 // When the previous detection process had got a time out
347 // we could falsely detect a Friendica profile as AP profile.
348 if (!self::$istimeout) {
349 $ap_profile = ActivityPub::probeProfile($uri);
351 if (empty($data) || (!empty($ap_profile) && empty($network) && (defaults($data, 'network', '') != Protocol::DFRN))) {
353 } elseif (!empty($ap_profile)) {
354 $ap_profile['batch'] = '';
355 $data = array_merge($ap_profile, $data);
358 Logger::notice('Time out detected. AP will not be probed.', ['uri' => $uri]);
361 if (!isset($data['url'])) {
365 if (!empty($data['photo'])) {
366 $data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink(defaults($data, 'baseurl', '')), Strings::normaliseLink($data['photo']));
368 $data['photo'] = System::baseUrl() . '/images/person-300.jpg';
371 if (empty($data['name'])) {
372 if (!empty($data['nick'])) {
373 $data['name'] = $data['nick'];
376 if (empty($data['name'])) {
377 $data['name'] = $data['url'];
381 if (empty($data['nick'])) {
382 $data['nick'] = strtolower($data['name']);
384 if (strpos($data['nick'], ' ')) {
385 $data['nick'] = trim(substr($data['nick'], 0, strpos($data['nick'], ' ')));
389 if (!empty(self::$baseurl)) {
390 $data['baseurl'] = self::$baseurl;
393 if (empty($data['network'])) {
394 $data['network'] = Protocol::PHANTOM;
397 if (empty($data['hide']) && ($data['network'] != Protocol::DFRN)) {
398 $data['hide'] = self::getHideStatus($data['url']);
401 $data = self::rearrangeData($data);
403 // Only store into the cache if the value seems to be valid
404 if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
405 Cache::set('Probe::uri:' . $network . ':' . $uri, $data, Cache::DAY);
413 * Fetches the "hide" status from the profile
415 * @param string $url URL of the profile
417 * @return boolean "hide" status
419 private static function getHideStatus($url)
421 $curlResult = Network::curl($url);
422 if (!$curlResult->isSuccess()) {
426 // If the file is too large then exit
427 if (defaults($curlResult->getInfo(), 'download_content_length', 0) > 1000000) {
431 // If it isn't a HTML file then exit
432 if (($curlResult->getContentType() != '') && !strstr(strtolower($curlResult->getContentType()), 'html')) {
436 $body = $curlResult->getBody();
438 $doc = new DOMDocument();
439 @$doc->loadHTML($body);
441 $xpath = new DOMXPath($doc);
443 $list = $xpath->query('//meta[@name]');
444 foreach ($list as $node) {
446 if ($node->attributes->length) {
447 foreach ($node->attributes as $attribute) {
448 $meta_tag[$attribute->name] = $attribute->value;
452 if (empty($meta_tag['content'])) {
456 $content = strtolower(trim($meta_tag['content']));
458 switch (strtolower(trim($meta_tag['name']))) {
459 case 'dfrn-global-visibility':
460 if ($content == 'false') {
465 if (strpos($content, 'noindex') !== false) {
476 * @brief Checks if a profile url should be OStatus but only provides partial information
478 * @param array $webfinger Webfinger data
479 * @param string $lrdd Path template for webfinger request
480 * @param string $type type
482 * @return array fixed webfinger data
483 * @throws HTTPException\InternalServerErrorException
485 private static function fixOStatus($webfinger, $lrdd, $type)
487 if (empty($webfinger['links']) || empty($webfinger['subject'])) {
494 foreach ($webfinger['links'] as $link) {
495 if ($link['rel'] == NAMESPACE_OSTATUSSUB) {
498 if ($link['rel'] == 'magic-public-key') {
503 if (!$is_ostatus || $has_key) {
507 $url = Network::switchScheme($webfinger['subject']);
508 $path = str_replace('{uri}', urlencode($url), $lrdd);
509 $webfinger2 = self::webfinger($path, $type);
511 // Is the new webfinger detectable as OStatus?
512 if (self::ostatus($webfinger2, true)) {
513 $webfinger = $webfinger2;
520 * @brief Fetch information (protocol endpoints and user information) about a given uri
522 * This function is only called by the "uri" function that adds caching and rearranging of data.
524 * @param string $uri Address that should be probed
525 * @param string $network Test for this specific network
526 * @param integer $uid User ID for the probe (only used for mails)
528 * @return array uri data
529 * @throws HTTPException\InternalServerErrorException
531 private static function detect($uri, $network, $uid)
533 $parts = parse_url($uri);
535 if (!empty($parts["scheme"]) && !empty($parts["host"])) {
536 $host = $parts["host"];
537 if (!empty($parts["port"])) {
538 $host .= ':'.$parts["port"];
541 if ($host == 'twitter.com') {
542 return self::twitter($uri);
544 $lrdd = self::hostMeta($host);
546 if (is_bool($lrdd)) {
550 $path_parts = explode("/", trim(defaults($parts, 'path', ''), "/"));
552 while (!$lrdd && (sizeof($path_parts) > 1)) {
553 $host .= "/".array_shift($path_parts);
554 $lrdd = self::hostMeta($host);
557 Logger::log('No XRD data was found for '.$uri, Logger::DEBUG);
558 return self::feed($uri);
560 $nick = array_pop($path_parts);
562 // Mastodon uses a "@" as prefix for usernames in their url format
563 $nick = ltrim($nick, '@');
565 $addr = $nick."@".$host;
566 } elseif (strstr($uri, '@')) {
567 // If the URI starts with "mailto:" then jump directly to the mail detection
568 if (strpos($uri, 'mailto:') !== false) {
569 $uri = str_replace('mailto:', '', $uri);
570 return self::mail($uri, $uid);
573 if ($network == Protocol::MAIL) {
574 return self::mail($uri, $uid);
576 // Remove "acct:" from the URI
577 $uri = str_replace('acct:', '', $uri);
579 $host = substr($uri, strpos($uri, '@') + 1);
580 $nick = substr($uri, 0, strpos($uri, '@'));
582 if (strpos($uri, '@twitter.com')) {
583 return self::twitter($uri);
585 $lrdd = self::hostMeta($host);
587 if (is_bool($lrdd)) {
592 Logger::log('No XRD data was found for '.$uri, Logger::DEBUG);
593 return self::mail($uri, $uid);
597 Logger::log("Uri ".$uri." was not detectable", Logger::DEBUG);
603 /// @todo Do we need the prefix "acct:" or "acct://"?
605 foreach ($lrdd as $type => $template) {
610 // At first try it with the given uri
611 $path = str_replace('{uri}', urlencode($uri), $template);
612 $webfinger = self::webfinger($path, $type);
614 // Fix possible problems with GNU Social probing to wrong scheme
615 $webfinger = self::fixOStatus($webfinger, $template, $type);
617 // We cannot be sure that the detected address was correct, so we don't use the values
618 if ($webfinger && ($uri != $addr)) {
623 // Try webfinger with the address (user@domain.tld)
625 $path = str_replace('{uri}', urlencode($addr), $template);
626 $webfinger = self::webfinger($path, $type);
629 // Mastodon needs to have it with "acct:"
631 $path = str_replace('{uri}', urlencode("acct:".$addr), $template);
632 $webfinger = self::webfinger($path, $type);
637 return self::feed($uri);
642 Logger::log("Probing ".$uri, Logger::DEBUG);
644 if (in_array($network, ["", Protocol::DFRN])) {
645 $result = self::dfrn($webfinger);
647 if ((!$result && ($network == "")) || ($network == Protocol::DIASPORA)) {
648 $result = self::diaspora($webfinger);
650 if ((!$result && ($network == "")) || ($network == Protocol::OSTATUS)) {
651 $result = self::ostatus($webfinger);
653 if ((!$result && ($network == "")) || ($network == Protocol::PUMPIO)) {
654 $result = self::pumpio($webfinger, $addr);
656 if ((!$result && ($network == "")) || ($network == Protocol::FEED)) {
657 $result = self::feed($uri);
659 // We overwrite the detected nick with our try if the previois routines hadn't detected it.
660 // Additionally it is overwritten when the nickname doesn't make sense (contains spaces).
661 if ((empty($result["nick"]) || (strstr($result["nick"], " "))) && ($nick != "")) {
662 $result["nick"] = $nick;
665 if (empty($result["addr"]) && ($addr != "")) {
666 $result["addr"] = $addr;
670 if (empty($result["network"])) {
671 $result["network"] = Protocol::PHANTOM;
674 if (empty($result["url"])) {
675 $result["url"] = $uri;
678 Logger::log($uri." is ".$result["network"], Logger::DEBUG);
680 if (empty($result["baseurl"])) {
681 $pos = strpos($result["url"], $host);
683 $result["baseurl"] = substr($result["url"], 0, $pos).$host;
690 * @brief Perform a webfinger request.
692 * For details see RFC 7033: <https://tools.ietf.org/html/rfc7033>
694 * @param string $url Address that should be probed
695 * @param string $type type
697 * @return array webfinger data
698 * @throws HTTPException\InternalServerErrorException
700 private static function webfinger($url, $type)
702 $xrd_timeout = Config::get('system', 'xrd_timeout', 20);
704 $curlResult = Network::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
705 if ($curlResult->isTimeout()) {
706 self::$istimeout = true;
709 $data = $curlResult->getBody();
711 $webfinger = json_decode($data, true);
712 if (is_array($webfinger)) {
713 if (!isset($webfinger["links"])) {
714 Logger::log("No json webfinger links for ".$url, Logger::DEBUG);
720 // If it is not JSON, maybe it is XML
721 $xrd = XML::parseString($data, false);
722 if (!is_object($xrd)) {
723 Logger::log("No webfinger data retrievable for ".$url, Logger::DEBUG);
727 $xrd_arr = XML::elementToArray($xrd);
728 if (!isset($xrd_arr["xrd"]["link"])) {
729 Logger::log("No XML webfinger links for ".$url, Logger::DEBUG);
735 if (!empty($xrd_arr["xrd"]["subject"])) {
736 $webfinger["subject"] = $xrd_arr["xrd"]["subject"];
739 if (!empty($xrd_arr["xrd"]["alias"])) {
740 $webfinger["aliases"] = $xrd_arr["xrd"]["alias"];
743 $webfinger["links"] = [];
745 foreach ($xrd_arr["xrd"]["link"] as $value => $data) {
746 if (!empty($data["@attributes"])) {
747 $attributes = $data["@attributes"];
748 } elseif ($value == "@attributes") {
754 $webfinger["links"][] = $attributes;
760 * @brief Poll the Friendica specific noscrape page.
762 * "noscrape" is a faster alternative to fetch the data from the hcard.
763 * This functionality was originally created for the directory.
765 * @param string $noscrape_url Link to the noscrape page
766 * @param array $data The already fetched data
768 * @return array noscrape data
769 * @throws HTTPException\InternalServerErrorException
771 private static function pollNoscrape($noscrape_url, $data)
773 $curlResult = Network::curl($noscrape_url);
774 if ($curlResult->isTimeout()) {
775 self::$istimeout = true;
778 $content = $curlResult->getBody();
780 Logger::log("Empty body for ".$noscrape_url, Logger::DEBUG);
784 $json = json_decode($content, true);
785 if (!is_array($json)) {
786 Logger::log("No json data for ".$noscrape_url, Logger::DEBUG);
790 if (!empty($json["fn"])) {
791 $data["name"] = $json["fn"];
794 if (!empty($json["addr"])) {
795 $data["addr"] = $json["addr"];
798 if (!empty($json["nick"])) {
799 $data["nick"] = $json["nick"];
802 if (!empty($json["guid"])) {
803 $data["guid"] = $json["guid"];
806 if (!empty($json["comm"])) {
807 $data["community"] = $json["comm"];
810 if (!empty($json["tags"])) {
811 $keywords = implode(", ", $json["tags"]);
812 if ($keywords != "") {
813 $data["keywords"] = $keywords;
817 $location = Profile::formatLocation($json);
819 $data["location"] = $location;
822 if (!empty($json["about"])) {
823 $data["about"] = $json["about"];
826 if (!empty($json["gender"])) {
827 $data["gender"] = $json["gender"];
830 if (!empty($json["key"])) {
831 $data["pubkey"] = $json["key"];
834 if (!empty($json["photo"])) {
835 $data["photo"] = $json["photo"];
838 if (!empty($json["dfrn-request"])) {
839 $data["request"] = $json["dfrn-request"];
842 if (!empty($json["dfrn-confirm"])) {
843 $data["confirm"] = $json["dfrn-confirm"];
846 if (!empty($json["dfrn-notify"])) {
847 $data["notify"] = $json["dfrn-notify"];
850 if (!empty($json["dfrn-poll"])) {
851 $data["poll"] = $json["dfrn-poll"];
854 if (isset($json["hide"])) {
855 $data["hide"] = (bool)$json["hide"];
857 $data["hide"] = false;
864 * @brief Check for valid DFRN data
866 * @param array $data DFRN data
868 * @return int Number of errors
870 public static function validDfrn($data)
873 if (!isset($data['key'])) {
876 if (!isset($data['dfrn-request'])) {
879 if (!isset($data['dfrn-confirm'])) {
882 if (!isset($data['dfrn-notify'])) {
885 if (!isset($data['dfrn-poll'])) {
892 * @brief Fetch data from a DFRN profile page and via "noscrape"
894 * @param string $profile_link Link to the profile page
896 * @return array profile data
897 * @throws HTTPException\InternalServerErrorException
898 * @throws \ImagickException
900 public static function profile($profile_link)
904 Logger::log("Check profile ".$profile_link, Logger::DEBUG);
906 // Fetch data via noscrape - this is faster
907 $noscrape_url = str_replace(["/hcard/", "/profile/"], "/noscrape/", $profile_link);
908 $data = self::pollNoscrape($noscrape_url, $data);
910 if (!isset($data["notify"])
911 || !isset($data["confirm"])
912 || !isset($data["request"])
913 || !isset($data["poll"])
914 || !isset($data["name"])
915 || !isset($data["photo"])
917 $data = self::pollHcard($profile_link, $data, true);
922 if (empty($data["addr"]) || empty($data["nick"])) {
923 $probe_data = self::uri($profile_link);
924 $data["addr"] = defaults($data, "addr", $probe_data["addr"]);
925 $data["nick"] = defaults($data, "nick", $probe_data["nick"]);
928 $prof_data["addr"] = $data["addr"];
929 $prof_data["nick"] = $data["nick"];
930 $prof_data["dfrn-request"] = defaults($data, 'request', null);
931 $prof_data["dfrn-confirm"] = defaults($data, 'confirm', null);
932 $prof_data["dfrn-notify"] = defaults($data, 'notify' , null);
933 $prof_data["dfrn-poll"] = defaults($data, 'poll' , null);
934 $prof_data["photo"] = defaults($data, 'photo' , null);
935 $prof_data["fn"] = defaults($data, 'name' , null);
936 $prof_data["key"] = defaults($data, 'pubkey' , null);
938 Logger::log("Result for profile ".$profile_link.": ".print_r($prof_data, true), Logger::DEBUG);
944 * @brief Check for DFRN contact
946 * @param array $webfinger Webfinger data
948 * @return array DFRN data
949 * @throws HTTPException\InternalServerErrorException
951 private static function dfrn($webfinger)
955 // The array is reversed to take into account the order of preference for same-rel links
956 // See: https://tools.ietf.org/html/rfc7033#section-4.4.4
957 foreach (array_reverse($webfinger["links"]) as $link) {
958 if (($link["rel"] == NAMESPACE_DFRN) && !empty($link["href"])) {
959 $data["network"] = Protocol::DFRN;
960 } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
961 $data["poll"] = $link["href"];
962 } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
963 $data["url"] = $link["href"];
964 } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
965 $hcard_url = $link["href"];
966 } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) {
967 $data["poco"] = $link["href"];
968 } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) {
969 $data["photo"] = $link["href"];
970 } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) {
971 $data["baseurl"] = trim($link["href"], '/');
972 } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
973 $data["guid"] = $link["href"];
974 } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) {
975 $data["pubkey"] = base64_decode($link["href"]);
977 //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA"))
978 if (strstr($data["pubkey"], 'RSA ')) {
979 $data["pubkey"] = Crypto::rsaToPem($data["pubkey"]);
984 if (!empty($webfinger["aliases"]) && is_array($webfinger["aliases"])) {
985 foreach ($webfinger["aliases"] as $alias) {
986 if (empty($data["url"]) && !strstr($alias, "@")) {
987 $data["url"] = $alias;
988 } elseif (!strstr($alias, "@") && Strings::normaliseLink($alias) != Strings::normaliseLink($data["url"])) {
989 $data["alias"] = $alias;
990 } elseif (substr($alias, 0, 5) == 'acct:') {
991 $data["addr"] = substr($alias, 5);
996 if (!empty($webfinger["subject"]) && (substr($webfinger["subject"], 0, 5) == "acct:")) {
997 $data["addr"] = substr($webfinger["subject"], 5);
1000 if (!isset($data["network"]) || ($hcard_url == "")) {
1004 // Fetch data via noscrape - this is faster
1005 $noscrape_url = str_replace("/hcard/", "/noscrape/", $hcard_url);
1006 $data = self::pollNoscrape($noscrape_url, $data);
1008 if (isset($data["notify"])
1009 && isset($data["confirm"])
1010 && isset($data["request"])
1011 && isset($data["poll"])
1012 && isset($data["name"])
1013 && isset($data["photo"])
1018 $data = self::pollHcard($hcard_url, $data, true);
1024 * @brief Poll the hcard page (Diaspora and Friendica specific)
1026 * @param string $hcard_url Link to the hcard page
1027 * @param array $data The already fetched data
1028 * @param boolean $dfrn Poll DFRN specific data
1030 * @return array hcard data
1031 * @throws HTTPException\InternalServerErrorException
1033 private static function pollHcard($hcard_url, $data, $dfrn = false)
1035 $curlResult = Network::curl($hcard_url);
1036 if ($curlResult->isTimeout()) {
1037 self::$istimeout = true;
1040 $content = $curlResult->getBody();
1045 $doc = new DOMDocument();
1046 if (!@$doc->loadHTML($content)) {
1050 $xpath = new DomXPath($doc);
1052 $vcards = $xpath->query("//div[contains(concat(' ', @class, ' '), ' vcard ')]");
1053 if (!is_object($vcards)) {
1057 if (!isset($data["baseurl"])) {
1058 $data["baseurl"] = "";
1061 if ($vcards->length > 0) {
1062 $vcard = $vcards->item(0);
1064 // We have to discard the guid from the hcard in favour of the guid from lrdd
1065 // Reason: Hubzilla doesn't use the value "uid" in the hcard like Diaspora does.
1066 $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' uid ')]", $vcard); // */
1067 if (($search->length > 0) && empty($data["guid"])) {
1068 $data["guid"] = $search->item(0)->nodeValue;
1071 $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' nickname ')]", $vcard); // */
1072 if ($search->length > 0) {
1073 $data["nick"] = $search->item(0)->nodeValue;
1076 $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' fn ')]", $vcard); // */
1077 if ($search->length > 0) {
1078 $data["name"] = $search->item(0)->nodeValue;
1081 $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' searchable ')]", $vcard); // */
1082 if ($search->length > 0) {
1083 $data["searchable"] = $search->item(0)->nodeValue;
1086 $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' key ')]", $vcard); // */
1087 if ($search->length > 0) {
1088 $data["pubkey"] = $search->item(0)->nodeValue;
1089 if (strstr($data["pubkey"], 'RSA ')) {
1090 $data["pubkey"] = Crypto::rsaToPem($data["pubkey"]);
1094 $search = $xpath->query("//*[@id='pod_location']", $vcard); // */
1095 if ($search->length > 0) {
1096 $data["baseurl"] = trim($search->item(0)->nodeValue, "/");
1101 if (!empty($vcard)) {
1102 $photos = $xpath->query("//*[contains(concat(' ', @class, ' '), ' photo ') or contains(concat(' ', @class, ' '), ' avatar ')]", $vcard); // */
1103 foreach ($photos as $photo) {
1105 foreach ($photo->attributes as $attribute) {
1106 $attr[$attribute->name] = trim($attribute->value);
1109 if (isset($attr["src"]) && isset($attr["width"])) {
1110 $avatar[$attr["width"]] = $attr["src"];
1113 // We don't have a width. So we just take everything that we got.
1114 // This is a Hubzilla workaround which doesn't send a width.
1115 if ((sizeof($avatar) == 0) && !empty($attr["src"])) {
1116 $avatar[] = $attr["src"];
1121 if (sizeof($avatar)) {
1123 $data["photo"] = self::fixAvatar(array_pop($avatar), $data["baseurl"]);
1127 // Poll DFRN specific data
1128 $search = $xpath->query("//link[contains(concat(' ', @rel), ' dfrn-')]");
1129 if ($search->length > 0) {
1130 foreach ($search as $link) {
1131 //$data["request"] = $search->item(0)->nodeValue;
1133 foreach ($link->attributes as $attribute) {
1134 $attr[$attribute->name] = trim($attribute->value);
1137 $data[substr($attr["rel"], 5)] = $attr["href"];
1141 // Older Friendica versions had used the "uid" field differently than newer versions
1142 if (!empty($data["nick"]) && !empty($data["guid"]) && ($data["nick"] == $data["guid"])) {
1143 unset($data["guid"]);
1152 * @brief Check for Diaspora contact
1154 * @param array $webfinger Webfinger data
1156 * @return array Diaspora data
1157 * @throws HTTPException\InternalServerErrorException
1159 private static function diaspora($webfinger)
1163 // The array is reversed to take into account the order of preference for same-rel links
1164 // See: https://tools.ietf.org/html/rfc7033#section-4.4.4
1165 foreach (array_reverse($webfinger["links"]) as $link) {
1166 if (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
1167 $hcard_url = $link["href"];
1168 } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) {
1169 $data["baseurl"] = trim($link["href"], '/');
1170 } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
1171 $data["guid"] = $link["href"];
1172 } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
1173 $data["url"] = $link["href"];
1174 } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
1175 $data["poll"] = $link["href"];
1176 } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) {
1177 $data["poco"] = $link["href"];
1178 } elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
1179 $data["notify"] = $link["href"];
1180 } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) {
1181 $data["pubkey"] = base64_decode($link["href"]);
1183 //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA"))
1184 if (strstr($data["pubkey"], 'RSA ')) {
1185 $data["pubkey"] = Crypto::rsaToPem($data["pubkey"]);
1190 if (!isset($data["url"]) || ($hcard_url == "")) {
1194 if (!empty($webfinger["aliases"]) && is_array($webfinger["aliases"])) {
1195 foreach ($webfinger["aliases"] as $alias) {
1196 if (Strings::normaliseLink($alias) != Strings::normaliseLink($data["url"]) && ! strstr($alias, "@")) {
1197 $data["alias"] = $alias;
1198 } elseif (substr($alias, 0, 5) == 'acct:') {
1199 $data["addr"] = substr($alias, 5);
1204 if (!empty($webfinger["subject"]) && (substr($webfinger["subject"], 0, 5) == 'acct:')) {
1205 $data["addr"] = substr($webfinger["subject"], 5);
1208 // Fetch further information from the hcard
1209 $data = self::pollHcard($hcard_url, $data);
1215 if (isset($data["url"])
1216 && isset($data["guid"])
1217 && isset($data["baseurl"])
1218 && isset($data["pubkey"])
1219 && ($hcard_url != "")
1221 $data["network"] = Protocol::DIASPORA;
1223 // The Diaspora handle must always be lowercase
1224 if (!empty($data["addr"])) {
1225 $data["addr"] = strtolower($data["addr"]);
1228 // We have to overwrite the detected value for "notify" since Hubzilla doesn't send it
1229 $data["notify"] = $data["baseurl"] . "/receive/users/" . $data["guid"];
1230 $data["batch"] = $data["baseurl"] . "/receive/public";
1239 * @brief Check for OStatus contact
1241 * @param array $webfinger Webfinger data
1242 * @param bool $short Short detection mode
1244 * @return array|bool OStatus data or "false" on error or "true" on short mode
1245 * @throws HTTPException\InternalServerErrorException
1247 private static function ostatus($webfinger, $short = false)
1251 if (!empty($webfinger["aliases"]) && is_array($webfinger["aliases"])) {
1252 foreach ($webfinger["aliases"] as $alias) {
1253 if (strstr($alias, "@") && !strstr(Strings::normaliseLink($alias), "http://")) {
1254 $data["addr"] = str_replace('acct:', '', $alias);
1259 if (!empty($webfinger["subject"]) && strstr($webfinger["subject"], "@")
1260 && !strstr(Strings::normaliseLink($webfinger["subject"]), "http://")
1262 $data["addr"] = str_replace('acct:', '', $webfinger["subject"]);
1265 if (is_array($webfinger["links"])) {
1266 // The array is reversed to take into account the order of preference for same-rel links
1267 // See: https://tools.ietf.org/html/rfc7033#section-4.4.4
1268 foreach (array_reverse($webfinger["links"]) as $link) {
1269 if (($link["rel"] == "http://webfinger.net/rel/profile-page")
1270 && (defaults($link, "type", "") == "text/html")
1271 && ($link["href"] != "")
1273 $data["url"] = $link["href"];
1274 } elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
1275 $data["notify"] = $link["href"];
1276 } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
1277 $data["poll"] = $link["href"];
1278 } elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) {
1279 $pubkey = $link["href"];
1281 if (substr($pubkey, 0, 5) === 'data:') {
1282 if (strstr($pubkey, ',')) {
1283 $pubkey = substr($pubkey, strpos($pubkey, ',') + 1);
1285 $pubkey = substr($pubkey, 5);
1287 } elseif (Strings::normaliseLink($pubkey) == 'http://') {
1288 $curlResult = Network::curl($pubkey);
1289 if ($curlResult->isTimeout()) {
1290 self::$istimeout = true;
1293 $pubkey = $curlResult->getBody();
1296 $key = explode(".", $pubkey);
1298 if (sizeof($key) >= 3) {
1299 $m = Strings::base64UrlDecode($key[1]);
1300 $e = Strings::base64UrlDecode($key[2]);
1301 $data["pubkey"] = Crypto::meToPem($m, $e);
1307 if (isset($data["notify"]) && isset($data["pubkey"])
1308 && isset($data["poll"])
1309 && isset($data["url"])
1311 $data["network"] = Protocol::OSTATUS;
1320 // Fetch all additional data from the feed
1321 $curlResult = Network::curl($data["poll"]);
1322 if ($curlResult->isTimeout()) {
1323 self::$istimeout = true;
1326 $feed = $curlResult->getBody();
1330 $feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true);
1335 if (!empty($feed_data["header"]["author-name"])) {
1336 $data["name"] = $feed_data["header"]["author-name"];
1338 if (!empty($feed_data["header"]["author-nick"])) {
1339 $data["nick"] = $feed_data["header"]["author-nick"];
1341 if (!empty($feed_data["header"]["author-avatar"])) {
1342 $data["photo"] = self::fixAvatar($feed_data["header"]["author-avatar"], $data["url"]);
1344 if (!empty($feed_data["header"]["author-id"])) {
1345 $data["alias"] = $feed_data["header"]["author-id"];
1347 if (!empty($feed_data["header"]["author-location"])) {
1348 $data["location"] = $feed_data["header"]["author-location"];
1350 if (!empty($feed_data["header"]["author-about"])) {
1351 $data["about"] = $feed_data["header"]["author-about"];
1353 // OStatus has serious issues when the the url doesn't fit (ssl vs. non ssl)
1354 // So we take the value that we just fetched, although the other one worked as well
1355 if (!empty($feed_data["header"]["author-link"])) {
1356 $data["url"] = $feed_data["header"]["author-link"];
1359 if (($data['poll'] == $data['url']) && ($data["alias"] != '')) {
1360 $data['url'] = $data["alias"];
1361 $data["alias"] = '';
1364 /// @todo Fetch location and "about" from the feed as well
1369 * @brief Fetch data from a pump.io profile page
1371 * @param string $profile_link Link to the profile page
1373 * @return array profile data
1375 private static function pumpioProfileData($profile_link)
1377 $doc = new DOMDocument();
1378 if (!@$doc->loadHTMLFile($profile_link)) {
1382 $xpath = new DomXPath($doc);
1386 $data["name"] = $xpath->query("//span[contains(@class, 'p-name')]")->item(0)->nodeValue;
1388 if ($data["name"] == '') {
1389 // This is ugly - but pump.io doesn't seem to know a better way for it
1390 $data["name"] = trim($xpath->query("//h1[@class='media-header']")->item(0)->nodeValue);
1391 $pos = strpos($data["name"], chr(10));
1393 $data["name"] = trim(substr($data["name"], 0, $pos));
1397 $data["location"] = XML::getFirstNodeValue($xpath, "//p[contains(@class, 'p-locality')]");
1399 if ($data["location"] == '') {
1400 $data["location"] = XML::getFirstNodeValue($xpath, "//p[contains(@class, 'location')]");
1403 $data["about"] = XML::getFirstNodeValue($xpath, "//p[contains(@class, 'p-note')]");
1405 if ($data["about"] == '') {
1406 $data["about"] = XML::getFirstNodeValue($xpath, "//p[contains(@class, 'summary')]");
1409 $avatar = $xpath->query("//img[contains(@class, 'u-photo')]")->item(0);
1411 $avatar = $xpath->query("//img[@class='img-rounded media-object']")->item(0);
1414 foreach ($avatar->attributes as $attribute) {
1415 if ($attribute->name == "src") {
1416 $data["photo"] = trim($attribute->value);
1425 * @brief Check for pump.io contact
1427 * @param array $webfinger Webfinger data
1430 * @return array pump.io data
1432 private static function pumpio($webfinger, $addr)
1435 // The array is reversed to take into account the order of preference for same-rel links
1436 // See: https://tools.ietf.org/html/rfc7033#section-4.4.4
1437 foreach (array_reverse($webfinger["links"]) as $link) {
1438 if (($link["rel"] == "http://webfinger.net/rel/profile-page")
1439 && (defaults($link, "type", "") == "text/html")
1440 && ($link["href"] != "")
1442 $data["url"] = $link["href"];
1443 } elseif (($link["rel"] == "activity-inbox") && ($link["href"] != "")) {
1444 $data["notify"] = $link["href"];
1445 } elseif (($link["rel"] == "activity-outbox") && ($link["href"] != "")) {
1446 $data["poll"] = $link["href"];
1447 } elseif (($link["rel"] == "dialback") && ($link["href"] != "")) {
1448 $data["dialback"] = $link["href"];
1451 if (isset($data["poll"]) && isset($data["notify"])
1452 && isset($data["dialback"])
1453 && isset($data["url"])
1455 // by now we use these fields only for the network type detection
1456 // So we unset all data that isn't used at the moment
1457 unset($data["dialback"]);
1459 $data["network"] = Protocol::PUMPIO;
1464 $profile_data = self::pumpioProfileData($data["url"]);
1466 if (!$profile_data) {
1470 $data = array_merge($data, $profile_data);
1472 if (($addr != '') && ($data['name'] != '')) {
1473 $name = trim(str_replace($addr, '', $data['name']));
1475 $data['name'] = $name;
1483 * @brief Check for twitter contact
1485 * @param string $uri
1487 * @return array twitter data
1489 private static function twitter($uri)
1491 if (preg_match('=(.*)@twitter.com=i', $uri, $matches)) {
1492 $nick = $matches[1];
1493 } elseif (preg_match('=https?://twitter.com/(.*)=i', $uri, $matches)) {
1494 $nick = $matches[1];
1500 $data['url'] = 'https://twitter.com/' . $nick;
1501 $data['addr'] = $nick . '@twitter.com';
1502 $data['nick'] = $data['name'] = $nick;
1503 $data['network'] = Protocol::TWITTER;
1504 $data['baseurl'] = 'https://twitter.com';
1506 $curlResult = Network::curl($data['url'], false);
1507 if ($curlResult->isSuccess()) {
1514 * @brief Check page for feed link
1516 * @param string $url Page link
1518 * @return string feed link
1520 private static function getFeedLink($url)
1522 $doc = new DOMDocument();
1524 if (!@$doc->loadHTMLFile($url)) {
1528 $xpath = new DomXPath($doc);
1530 //$feeds = $xpath->query("/html/head/link[@type='application/rss+xml']");
1531 $feeds = $xpath->query("/html/head/link[@type='application/rss+xml' and @rel='alternate']");
1532 if (!is_object($feeds)) {
1536 if ($feeds->length == 0) {
1542 foreach ($feeds as $feed) {
1544 foreach ($feed->attributes as $attribute) {
1545 $attr[$attribute->name] = trim($attribute->value);
1548 if ($feed_url == "") {
1549 $feed_url = $attr["href"];
1557 * @brief Check for feed contact
1559 * @param string $url Profile link
1560 * @param boolean $probe Do a probe if the page contains a feed link
1562 * @return array feed data
1563 * @throws HTTPException\InternalServerErrorException
1565 private static function feed($url, $probe = true)
1567 $curlResult = Network::curl($url);
1568 if ($curlResult->isTimeout()) {
1569 self::$istimeout = true;
1572 $feed = $curlResult->getBody();
1573 $dummy1 = $dummy2 = $dummy3 = null;
1574 $feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true);
1581 $feed_url = self::getFeedLink($url);
1587 return self::feed($feed_url, false);
1590 if (!empty($feed_data["header"]["author-name"])) {
1591 $data["name"] = $feed_data["header"]["author-name"];
1594 if (!empty($feed_data["header"]["author-nick"])) {
1595 $data["nick"] = $feed_data["header"]["author-nick"];
1598 if (!empty($feed_data["header"]["author-avatar"])) {
1599 $data["photo"] = $feed_data["header"]["author-avatar"];
1602 if (!empty($feed_data["header"]["author-id"])) {
1603 $data["alias"] = $feed_data["header"]["author-id"];
1606 $data["url"] = $url;
1607 $data["poll"] = $url;
1609 if (!empty($feed_data["header"]["author-link"])) {
1610 $data["baseurl"] = $feed_data["header"]["author-link"];
1612 $data["baseurl"] = $data["url"];
1615 $data["network"] = Protocol::FEED;
1621 * @brief Check for mail contact
1623 * @param string $uri Profile link
1624 * @param integer $uid User ID
1626 * @return array mail data
1627 * @throws \Exception
1629 private static function mail($uri, $uid)
1631 if (!Network::isEmailDomainValid($uri)) {
1639 $user = DBA::selectFirst('user', ['prvkey'], ['uid' => $uid]);
1641 $condition = ["`uid` = ? AND `server` != ''", $uid];
1642 $fields = ['pass', 'user', 'server', 'port', 'ssltype', 'mailbox'];
1643 $mailacct = DBA::selectFirst('mailacct', $fields, $condition);
1645 if (!DBA::isResult($user) || !DBA::isResult($mailacct)) {
1649 $mailbox = Email::constructMailboxName($mailacct);
1651 openssl_private_decrypt(hex2bin($mailacct['pass']), $password, $user['prvkey']);
1652 $mbox = Email::connect($mailbox, $mailacct['user'], $password);
1657 $msgs = Email::poll($mbox, $uri);
1658 Logger::log('searching '.$uri.', '.count($msgs).' messages found.', Logger::DEBUG);
1660 if (!count($msgs)) {
1664 $phost = substr($uri, strpos($uri, '@') + 1);
1667 $data["addr"] = $uri;
1668 $data["network"] = Protocol::MAIL;
1669 $data["name"] = substr($uri, 0, strpos($uri, '@'));
1670 $data["nick"] = $data["name"];
1671 $data["photo"] = Network::lookupAvatarByEmail($uri);
1672 $data["url"] = 'mailto:'.$uri;
1673 $data["notify"] = 'smtp ' . Strings::getRandomHex();
1674 $data["poll"] = 'email ' . Strings::getRandomHex();
1676 $x = Email::messageMeta($mbox, $msgs[0]);
1677 if (stristr($x[0]->from, $uri)) {
1678 $adr = imap_rfc822_parse_adrlist($x[0]->from, '');
1679 } elseif (stristr($x[0]->to, $uri)) {
1680 $adr = imap_rfc822_parse_adrlist($x[0]->to, '');
1683 foreach ($adr as $feadr) {
1684 if ((strcasecmp($feadr->mailbox, $data["name"]) == 0)
1685 &&(strcasecmp($feadr->host, $phost) == 0)
1686 && (strlen($feadr->personal))
1688 $personal = imap_mime_header_decode($feadr->personal);
1690 foreach ($personal as $perspart) {
1691 if ($perspart->charset != "default") {
1692 $data["name"] .= iconv($perspart->charset, 'UTF-8//IGNORE', $perspart->text);
1694 $data["name"] .= $perspart->text;
1698 $data["name"] = Strings::escapeTags($data["name"]);
1702 if (!empty($mbox)) {
1709 * @brief Mix two paths together to possibly fix missing parts
1711 * @param string $avatar Path to the avatar
1712 * @param string $base Another path that is hopefully complete
1714 * @return string fixed avatar path
1715 * @throws \Exception
1717 public static function fixAvatar($avatar, $base)
1719 $base_parts = parse_url($base);
1721 // Remove all parts that could create a problem
1722 unset($base_parts['path']);
1723 unset($base_parts['query']);
1724 unset($base_parts['fragment']);
1726 $avatar_parts = parse_url($avatar);
1729 $parts = array_merge($base_parts, $avatar_parts);
1731 // And put them together again
1732 $scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '';
1733 $host = isset($parts['host']) ? $parts['host'] : '';
1734 $port = isset($parts['port']) ? ':' . $parts['port'] : '';
1735 $path = isset($parts['path']) ? $parts['path'] : '';
1736 $query = isset($parts['query']) ? '?' . $parts['query'] : '';
1737 $fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
1739 $fixed = $scheme.$host.$port.$path.$query.$fragment;
1741 Logger::log('Base: '.$base.' - Avatar: '.$avatar.' - Fixed: '.$fixed, Logger::DATA);