X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fsocgraph.php;h=69d33089869dbc7b8acd574904d81b39fd1651e0;hb=83cb32d637b6a34d6ab654d6b202a1b18ad2a5ab;hp=17f2fcf01e8d78ce1ba96d4cb11b8cbee690341a;hpb=f196389580ba39a21430ee316399aaec27ce9236;p=friendica.git diff --git a/include/socgraph.php b/include/socgraph.php index 17f2fcf01e..69d3308986 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -225,15 +225,17 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca $created = $x[0]["created"]; $server_url = $x[0]["server_url"]; $nick = $x[0]["nick"]; + $addr = $x[0]["addr"]; } else { $created = "0000-00-00 00:00:00"; $server_url = ""; $urlparts = parse_url($profile_url); $nick = end(explode("/", $urlparts["path"])); + $addr = ""; } - if ((($network == "") OR ($name == "") OR ($profile_photo == "") OR ($server_url == "") OR $alternate) + if ((($network == "") OR ($name == "") OR ($addr == "") OR ($profile_photo == "") OR ($server_url == "") OR $alternate) AND poco_reachable($profile_url, $server_url, $network, false)) { $data = probe_url($profile_url); @@ -242,6 +244,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca $network = $data["network"]; $name = $data["name"]; $nick = $data["nick"]; + $addr = $data["addr"]; $profile_url = $data["url"]; $profile_photo = $data["photo"]; $server_url = $data["baseurl"]; @@ -294,14 +297,18 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca if (($keywords == "") AND ($x[0]['keywords'] != "")) $keywords = $x[0]['keywords']; + if (($addr == "") AND ($x[0]['addr'] != "")) + $addr = $x[0]['addr']; + if (($generation == 0) AND ($x[0]['generation'] > 0)) $generation = $x[0]['generation']; if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo || $x[0]['updated'] < $updated) { - q("UPDATE `gcontact` SET `name` = '%s', `network` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `server_url` = '%s', + q("UPDATE `gcontact` SET `name` = '%s', `addr` = '%s', `network` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `server_url` = '%s', `updated` = '%s', `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s', `generation` = %d WHERE (`generation` >= %d OR `generation` = 0) AND `nurl` = '%s'", dbesc($name), + dbesc($addr), dbesc($network), dbesc($profile_photo), dbesc($connect_url), @@ -318,10 +325,11 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca ); } } else { - q("INSERT INTO `gcontact` (`name`, `nick`, `network`, `url`, `nurl`, `photo`, `connect`, `server_url`, `created`, `updated`, `location`, `about`, `keywords`, `gender`, `generation`) - VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", + q("INSERT INTO `gcontact` (`name`, `nick`, `addr`, `network`, `url`, `nurl`, `photo`, `connect`, `server_url`, `created`, `updated`, `location`, `about`, `keywords`, `gender`, `generation`) + VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", dbesc($name), dbesc($nick), + dbesc($addr), dbesc($network), dbesc($profile_url), dbesc(normalise_link($profile_url)), @@ -1039,8 +1047,9 @@ function count_common_friends($uid,$cid) { $r = q("SELECT count(*) as `total` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` - where `glink`.`cid` = %d and `glink`.`uid` = %d - and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ", + WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND + ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) + AND `gcontact`.`nurl` IN (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ", intval($cid), intval($uid), intval($uid), @@ -1069,6 +1078,7 @@ function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) { WHERE `glink`.`cid` = %d and `glink`.`uid` = %d AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`hidden` = 0 AND `contact`.`id` != %d + AND ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) $sql_extra LIMIT %d, %d", intval($cid), intval($uid), @@ -1126,7 +1136,8 @@ function count_all_friends($uid,$cid) { $r = q("SELECT count(*) as `total` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` - where `glink`.`cid` = %d and `glink`.`uid` = %d ", + where `glink`.`cid` = %d and `glink`.`uid` = %d AND + ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`))", intval($cid), intval($uid) ); @@ -1144,7 +1155,8 @@ function all_friends($uid,$cid,$start = 0, $limit = 80) { FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = %d - WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d + WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND + ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) ORDER BY `gcontact`.`name` ASC LIMIT %d, %d ", intval($uid), intval($cid),