From 602821279a504752f15829afbe7eca848352d0c8 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 25 Nov 2015 18:46:02 +0100 Subject: [PATCH 1/2] scrape_dfrn now scrapes the address as well. --- include/Scrape.php | 9 +++++++-- mod/dfrn_request.php | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/Scrape.php b/include/Scrape.php index ae9331ff7..64a930bfd 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -4,7 +4,7 @@ require_once('library/HTML5/Parser.php'); require_once('include/crypto.php'); if(! function_exists('scrape_dfrn')) { -function scrape_dfrn($url) { +function scrape_dfrn($url, $dont_probe = false) { $a = get_app(); @@ -17,6 +17,11 @@ function scrape_dfrn($url) { if(! $s) return $ret; + $probe = probe_url($url); + + if (isset($probe["addr"])) + $ret["addr"] = $probe["addr"]; + $headers = $a->get_curl_headers(); logger('scrape_dfrn: headers=' . $headers, LOGGER_DEBUG); @@ -524,7 +529,7 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) { if(strlen($dfrn)) { - $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn); + $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn, true); if(is_array($ret) && x($ret,'dfrn-request')) { $network = NETWORK_DFRN; $request = $ret['dfrn-request']; diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 7e5b67b7c..b0ad2d4a0 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -136,7 +136,7 @@ function dfrn_request_post(&$a) { $dfrn_request = $parms['dfrn-request']; - /********* Escape the entire array ********/ + /********* Escape the entire array ********/ dbesc_array($parms); @@ -146,13 +146,14 @@ function dfrn_request_post(&$a) { * Create a contact record on our site for the other person */ - $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `name`, `nick`, `photo`, `site-pubkey`, + $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `addr`, `name`, `nick`, `photo`, `site-pubkey`, `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`) - VALUES ( %d, '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)", + VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)", intval(local_user()), datetime_convert(), dbesc($dfrn_url), dbesc(normalise_link($dfrn_url)), + $parms['addr'], $parms['fn'], $parms['nick'], $parms['photo'], @@ -539,13 +540,14 @@ function dfrn_request_post(&$a) { dbesc_array($parms); - $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`,`name`, `nick`, `issued-id`, `photo`, `site-pubkey`, + $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`, `request`, `confirm`, `notify`, `poll`, `poco`, `network` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($uid), dbesc(datetime_convert()), $parms['url'], dbesc(normalise_link($parms['url'])), + $parms['addr'], $parms['fn'], $parms['nick'], $parms['issued-id'], From 1203088c3eadb26b2105c99f3421d2f6852b6d52 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 26 Nov 2015 08:26:29 +0100 Subject: [PATCH 2/2] Only update contact data for OStatus contacts --- include/ostatus.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ostatus.php b/include/ostatus.php index 0dd462d3e..523ccfe51 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -137,9 +137,9 @@ function ostatus_fetchauthor($xpath, $context, $importer, &$contact, $onlyfetch) if ($value != "") $contact["location"] = $value; - q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', `name-date` = '%s' WHERE `id` = %d", + q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', `name-date` = '%s' WHERE `id` = %d AND `network` = '%s'", dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]), - dbesc(datetime_convert()), intval($contact["id"])); + dbesc(datetime_convert()), intval($contact["id"]), dbesc(NETWORK_OSTATUS)); poco_check($contact["url"], $contact["name"], $contact["network"], $author["author-avatar"], $contact["about"], $contact["location"], "", "", "", datetime_convert(), 2, $contact["id"], $contact["uid"]); @@ -152,9 +152,9 @@ function ostatus_fetchauthor($xpath, $context, $importer, &$contact, $onlyfetch) $photos = import_profile_photo($author["author-avatar"], $importer["uid"], $contact["id"]); - q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d", + q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d AND `network` = '%s'", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), - dbesc(datetime_convert()), intval($contact["id"])); + dbesc(datetime_convert()), intval($contact["id"]), dbesc(NETWORK_OSTATUS)); } }