X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ffollow.php;h=c5214fe4612ae22bb24e16338e8726af035c5aa2;hb=96501bda816bb3db29ea19d89e6ffc0e83f350b3;hp=8d80538e0c924856c51c0547511d4e4769f750aa;hpb=f8a213e23be1c43a00dea6079f78100f6df99d77;p=friendica.git diff --git a/include/follow.php b/include/follow.php index 8d80538e0c..c5214fe461 100644 --- a/include/follow.php +++ b/include/follow.php @@ -1,11 +1,16 @@ $val) { - if (isset($r[0][$key]) AND ($r[0][$key] != "") AND ($val == "")) + if (isset($r[0][$key]) && ($r[0][$key] != "") && ($val == "")) $ret[$key] = $r[0][$key]; - if (isset($r[0][$key]) AND ($ret[$key] != $r[0][$key])) + if (isset($r[0][$key]) && ($ret[$key] != $r[0][$key])) $update = true; } @@ -67,7 +72,7 @@ function update_contact($id) { -function new_contact($uid,$url,$interactive = false) { +function new_contact($uid, $url, $interactive = false, $network = '') { $result = array('cid' => -1, 'success' => false,'message' => ''); @@ -82,6 +87,11 @@ function new_contact($uid,$url,$interactive = false) { return $result; } + if (blocked_url($url)) { + $result['message'] = t('Blocked domain'); + return $result; + } + if (! $url) { $result['message'] = t('Connect URL missing.'); return $result; @@ -93,15 +103,19 @@ function new_contact($uid,$url,$interactive = false) { if (x($arr['contact'],'name')) { $ret = $arr['contact']; + } else { + $ret = Probe::uri($url, $network, $uid, false); } - else { - $ret = probe_url($url); + + if (($network != '') && ($ret['network'] != $network)) { + logger('Expected network '.$network.' does not match actual network '.$ret['network']); + return result; } if ($ret['network'] === NETWORK_DFRN) { if ($interactive) { if (strlen($a->path)) { - $myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']); + $myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']); } else { $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname()); } @@ -110,12 +124,10 @@ function new_contact($uid,$url,$interactive = false) { // NOTREACHED } - } else { - if (get_config('system','dfrn_only')) { - $result['message'] = t('This site is not configured to allow communications with other networks.') . EOL; - $result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL; - return $result; - } + } elseif (get_config('system','dfrn_only')) { + $result['message'] = t('This site is not configured to allow communications with other networks.') . EOL; + $result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL; + return $result; } // This extra param just confuses things, remove it @@ -180,14 +192,10 @@ function new_contact($uid,$url,$interactive = false) { if (dbm::is_result($r)) { // update contact - if ($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) { - q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d", - intval(CONTACT_IS_FRIEND), - intval($subhub), - intval($r[0]['id']), - intval($uid) - ); - } + $new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING); + + $fields = array('rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false); + dba::update('contact', $fields, array('id' => $r[0]['id'])); } else { // check service class limits @@ -215,7 +223,7 @@ function new_contact($uid,$url,$interactive = false) { return $result; } - $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING); + $new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING); // create contact record $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network`, `pubkey`, `rel`, `priority`,