continue;
}
- if (($attributes["rel"] == "lrdd") AND
- ($attributes["type"] == "application/xrd+xml")) {
+ if (($attributes["rel"] == "lrdd")
+ AND ($attributes["type"] == "application/xrd+xml")
+ ) {
$xrd_data["lrdd-xml"] = $attributes["template"];
- } elseif (($attributes["rel"] == "lrdd") AND
- ($attributes["type"] == "application/json")) {
+ } elseif (($attributes["rel"] == "lrdd")
+ AND ($attributes["type"] == "application/json")
+ ) {
$xrd_data["lrdd-json"] = $attributes["template"];
} elseif ($attributes["rel"] == "lrdd") {
$xrd_data["lrdd"] = $attributes["template"];
* a lengthy content page to scrape dfrn attributes
*
* @param string $webbie Address that should be probed
- * @param string $hcard Link to the hcard - is returned by reference
+ * @param string $hcard_url Link to the hcard - is returned by reference
*
* @return string profile link
*/
- public static function webfingerDfrn($webbie, &$hcard) {
+ public static function webfingerDfrn($webbie, &$hcard_url) {
$profile_link = '';
$profile_link = 'stat:'.$link['@attributes']['template'];
}
if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') {
- $hcard = $link['@attributes']['href'];
+ $hcard_url = $link['@attributes']['href'];
}
}
}
/// @todo temporary fix - we need a real contact update function that updates only changing fields
/// The biggest problem is the avatar picture that could have a reduced image size.
/// It should only be updated if the existing picture isn't existing anymore.
- if (($data['network'] != NETWORK_FEED) AND ($mode == PROBE_NORMAL) AND
- $data["name"] AND $data["nick"] AND $data["url"] AND $data["addr"] AND $data["poll"]) {
+ if (($data['network'] != NETWORK_FEED)
+ AND ($mode == PROBE_NORMAL)
+ AND $data["name"]
+ AND $data["nick"]
+ AND $data["url"]
+ AND $data["addr"]
+ AND $data["poll"]
+ ) {
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `addr` = '%s',
`notify` = '%s', `poll` = '%s', `alias` = '%s', `success_update` = '%s'
WHERE `nurl` = '%s' AND NOT `self` AND `uid` = 0",
* "noscrape" is a faster alternative to fetch the data from the hcard.
* This functionality was originally created for the directory.
*
- * @param string $noscrape Link to the noscrape page
+ * @param string $noscrape_url Link to the noscrape page
* @param array $data The already fetched data
*
* @return array noscrape data
*/
- private function pollNoscrape($noscrape, $data) {
- $ret = z_fetch_url($noscrape);
+ private function pollNoscrape($noscrape_url, $data) {
+ $ret = z_fetch_url($noscrape_url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false;
}
/**
* @brief Fetch data from a DFRN profile page and via "noscrape"
*
- * @param string $profile Link to the profile page
+ * @param string $profile_link Link to the profile page
*
* @return array profile data
*/
- public static function profile($profile) {
+ public static function profile($profile_link) {
$data = array();
- logger("Check profile ".$profile, LOGGER_DEBUG);
+ logger("Check profile ".$profile_link, LOGGER_DEBUG);
// Fetch data via noscrape - this is faster
- $noscrape = str_replace(array("/hcard/", "/profile/"), "/noscrape/", $profile);
- $data = self::pollNoscrape($noscrape, $data);
+ $noscrape_url = str_replace(array("/hcard/", "/profile/"), "/noscrape/", $profile_link);
+ $data = self::pollNoscrape($noscrape_url, $data);
- if (!isset($data["notify"]) OR !isset($data["confirm"]) OR
- !isset($data["request"]) OR !isset($data["poll"]) OR
- !isset($data["poco"]) OR !isset($data["name"]) OR
- !isset($data["photo"])) {
- $data = self::pollHcard($profile, $data, true);
+ if (!isset($data["notify"])
+ OR !isset($data["confirm"])
+ OR !isset($data["request"])
+ OR !isset($data["poll"])
+ OR !isset($data["poco"])
+ OR !isset($data["name"])
+ OR !isset($data["photo"])
+ ) {
+ $data = self::pollHcard($profile_link, $data, true);
}
$prof_data = array();
- $prof_data["addr"] = $data["addr"];
- $prof_data["nick"] = $data["nick"];
+ $prof_data["addr"] = $data["addr"];
+ $prof_data["nick"] = $data["nick"];
$prof_data["dfrn-request"] = $data["request"];
$prof_data["dfrn-confirm"] = $data["confirm"];
- $prof_data["dfrn-notify"] = $data["notify"];
- $prof_data["dfrn-poll"] = $data["poll"];
- $prof_data["dfrn-poco"] = $data["poco"];
- $prof_data["photo"] = $data["photo"];
- $prof_data["fn"] = $data["name"];
- $prof_data["key"] = $data["pubkey"];
+ $prof_data["dfrn-notify"] = $data["notify"];
+ $prof_data["dfrn-poll"] = $data["poll"];
+ $prof_data["dfrn-poco"] = $data["poco"];
+ $prof_data["photo"] = $data["photo"];
+ $prof_data["fn"] = $data["name"];
+ $prof_data["key"] = $data["pubkey"];
- logger("Result for profile ".$profile.": ".print_r($prof_data, true), LOGGER_DEBUG);
+ logger("Result for profile ".$profile_link.": ".print_r($prof_data, true), LOGGER_DEBUG);
return $prof_data;
}
*/
private function dfrn($webfinger) {
- $hcard = "";
+ $hcard_url = "";
$data = array();
foreach ($webfinger["links"] as $link) {
if (($link["rel"] == NAMESPACE_DFRN) AND ($link["href"] != "")) {
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") AND ($link["type"] == "text/html") AND ($link["href"] != "")) {
$data["url"] = $link["href"];
} elseif (($link["rel"] == "http://microformats.org/profile/hcard") AND ($link["href"] != "")) {
- $hcard = $link["href"];
+ $hcard_url = $link["href"];
} elseif (($link["rel"] == NAMESPACE_POCO) AND ($link["href"] != "")) {
$data["poco"] = $link["href"];
} elseif (($link["rel"] == "http://webfinger.net/rel/avatar") AND ($link["href"] != "")) {
}
}
- if (!isset($data["network"]) OR ($hcard == "")) {
+ if (!isset($data["network"]) OR ($hcard_url == "")) {
return false;
}
// Fetch data via noscrape - this is faster
- $noscrape = str_replace("/hcard/", "/noscrape/", $hcard);
- $data = self::pollNoscrape($noscrape, $data);
-
- if (isset($data["notify"]) AND isset($data["confirm"]) AND isset($data["request"]) AND
- isset($data["poll"]) AND isset($data["name"]) AND isset($data["photo"])) {
+ $noscrape_url = str_replace("/hcard/", "/noscrape/", $hcard_url);
+ $data = self::pollNoscrape($noscrape_url, $data);
+
+ if (isset($data["notify"])
+ AND isset($data["confirm"])
+ AND isset($data["request"])
+ AND isset($data["poll"])
+ AND isset($data["name"])
+ AND isset($data["photo"])
+ ) {
return $data;
}
- $data = self::pollHcard($hcard, $data, true);
+ $data = self::pollHcard($hcard_url, $data, true);
return $data;
}
/**
* @brief Poll the hcard page (Diaspora and Friendica specific)
*
- * @param string $hcard Link to the hcard page
+ * @param string $hcard_url Link to the hcard page
* @param array $data The already fetched data
* @param boolean $dfrn Poll DFRN specific data
*
* @return array hcard data
*/
- private function pollHcard($hcard, $data, $dfrn = false) {
- $ret = z_fetch_url($hcard);
+ private function pollHcard($hcard_url, $data, $dfrn = false) {
+ $ret = z_fetch_url($hcard_url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false;
}
*/
private function diaspora($webfinger) {
- $hcard = "";
+ $hcard_url = "";
$data = array();
foreach ($webfinger["links"] as $link) {
if (($link["rel"] == "http://microformats.org/profile/hcard") AND ($link["href"] != "")) {
- $hcard = $link["href"];
+ $hcard_url = $link["href"];
} elseif (($link["rel"] == "http://joindiaspora.com/seed_location") AND ($link["href"] != "")) {
$data["baseurl"] = trim($link["href"], '/');
} elseif (($link["rel"] == "http://joindiaspora.com/guid") AND ($link["href"] != "")) {
}
}
- if (!isset($data["url"]) OR ($hcard == "")) {
+ if (!isset($data["url"]) OR ($hcard_url == "")) {
return false;
}
}
// Fetch further information from the hcard
- $data = self::pollHcard($hcard, $data);
+ $data = self::pollHcard($hcard_url, $data);
if (!$data) {
return false;
}
- if (isset($data["url"]) AND isset($data["guid"]) AND isset($data["baseurl"]) AND
- isset($data["pubkey"]) AND ($hcard != "")) {
+ if (isset($data["url"])
+ AND isset($data["guid"])
+ AND isset($data["baseurl"])
+ AND isset($data["pubkey"])
+ AND ($hcard_url != "")
+ ) {
$data["network"] = NETWORK_DIASPORA;
// The Diaspora handle must always be lowercase
// We have to overwrite the detected value for "notify" since Hubzilla doesn't send it
$data["notify"] = $data["baseurl"] . "/receive/users/" . $data["guid"];
- $data["batch"] = $data["baseurl"] . "/receive/public";
+ $data["batch"] = $data["baseurl"] . "/receive/public";
} else {
return false;
}
}
$pubkey = "";
foreach ($webfinger["links"] as $link) {
- if (($link["rel"] == "http://webfinger.net/rel/profile-page") AND
- ($link["type"] == "text/html") AND ($link["href"] != "")) {
+ if (($link["rel"] == "http://webfinger.net/rel/profile-page")
+ AND ($link["type"] == "text/html")
+ AND ($link["href"] != "")
+ ) {
$data["url"] = $link["href"];
} elseif (($link["rel"] == "salmon") AND ($link["href"] != "")) {
$data["notify"] = $link["href"];
}
}
- if (isset($data["notify"]) AND isset($data["pubkey"]) AND
- isset($data["poll"]) AND isset($data["url"])) {
+ if (isset($data["notify"]) AND isset($data["pubkey"])
+ AND isset($data["poll"])
+ AND isset($data["url"])
+ ) {
$data["network"] = NETWORK_OSTATUS;
} else {
return false;
/**
* @brief Fetch data from a pump.io profile page
*
- * @param string $profile Link to the profile page
+ * @param string $profile_link Link to the profile page
*
* @return array profile data
*/
- private function pumpioProfileData($profile) {
+ private function pumpioProfileData($profile_link) {
$doc = new \DOMDocument();
- if (!@$doc->loadHTMLFile($profile)) {
+ if (!@$doc->loadHTMLFile($profile_link)) {
return false;
}
$data = array();
foreach ($webfinger["links"] as $link) {
- if (($link["rel"] == "http://webfinger.net/rel/profile-page") AND
- ($link["type"] == "text/html") AND ($link["href"] != "")) {
+ if (($link["rel"] == "http://webfinger.net/rel/profile-page")
+ AND ($link["type"] == "text/html")
+ AND ($link["href"] != "")
+ ) {
$data["url"] = $link["href"];
} elseif (($link["rel"] == "activity-inbox") AND ($link["href"] != "")) {
$data["notify"] = $link["href"];
$data["dialback"] = $link["href"];
}
}
- if (isset($data["poll"]) AND isset($data["notify"]) AND
- isset($data["dialback"]) AND isset($data["url"])) {
+ if (isset($data["poll"]) AND isset($data["notify"])
+ AND isset($data["dialback"])
+ AND isset($data["url"])
+ ) {
// by now we use these fields only for the network type detection
// So we unset all data that isn't used at the moment
unset($data["dialback"]);
return false;
}
- $data = array();
+ $phost = substr($uri, strpos($uri, '@') + 1);
- $data["addr"] = $uri;
+ $data = array();
+ $data["addr"] = $uri;
$data["network"] = NETWORK_MAIL;
- $data["name"] = substr($uri, 0, strpos($uri, '@'));
- $data["nick"] = $data["name"];
- $data["photo"] = avatar_img($uri);
-
- $phost = substr($uri, strpos($uri, '@') + 1);
- $data["url"] = 'http://'.$phost."/".$data["nick"];
- $data["notify"] = 'smtp '.random_string();
- $data["poll"] = 'email '.random_string();
+ $data["name"] = substr($uri, 0, strpos($uri, '@'));
+ $data["nick"] = $data["name"];
+ $data["photo"] = avatar_img($uri);
+ $data["url"] = 'http://'.$phost."/".$data["nick"];
+ $data["notify"] = 'smtp '.random_string();
+ $data["poll"] = 'email '.random_string();
$x = email_msg_meta($mbox, $msgs[0]);
if (stristr($x[0]->from, $uri)) {
foreach ($adr as $feadr) {
if ((strcasecmp($feadr->mailbox, $data["name"]) == 0)
&&(strcasecmp($feadr->host, $phost) == 0)
- && (strlen($feadr->personal))) {
-
+ && (strlen($feadr->personal))
+ ) {
$personal = imap_mime_header_decode($feadr->personal);
$data["name"] = "";
foreach ($personal as $perspart) {
$parts = array_merge($base_parts, $avatar_parts);
// And put them together again
- $scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '';
- $host = isset($parts['host']) ? $parts['host'] : '';
- $port = isset($parts['port']) ? ':' . $parts['port'] : '';
- $path = isset($parts['path']) ? $parts['path'] : '';
- $query = isset($parts['query']) ? '?' . $parts['query'] : '';
+ $scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '';
+ $host = isset($parts['host']) ? $parts['host'] : '';
+ $port = isset($parts['port']) ? ':' . $parts['port'] : '';
+ $path = isset($parts['path']) ? $parts['path'] : '';
+ $query = isset($parts['query']) ? '?' . $parts['query'] : '';
$fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
$fixed = $scheme.$host.$port.$path.$query.$fragment;