3 require_once('include/Scrape.php');
4 require_once('include/follow.php');
6 function follow_content(&$a) {
9 notice( t('Permission denied.') . EOL);
10 goaway($_SESSION['return_url']);
15 $url = notags(trim($_REQUEST['url']));
17 // There is a current issue. It seems as if you can't start following a Friendica that is following you
18 // With Diaspora this works - but Friendica is special, it seems ...
19 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
20 (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
21 `network` != '%s' LIMIT 1",
22 intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)),
23 dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
26 notice(t('You already added this contact.').EOL);
27 goaway($_SESSION['return_url']);
31 $ret = probe_url($url);
33 if($ret['network'] === NETWORK_DFRN) {
34 $request = $ret["request"];
35 $tpl = get_markup_template('dfrn_request.tpl');
37 $request = $a->get_baseurl()."/follow";
38 $tpl = get_markup_template('auto_request.tpl');
41 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
44 notice( t('Permission denied.') . EOL);
45 goaway($_SESSION['return_url']);
49 $myaddr = $r[0]["url"];
51 // Makes the connection request for friendica contacts easier
52 $_SESSION["fastlane"] = $ret["url"];
54 $o = replace_macros($tpl,array(
55 '$header' => $ret["name"]." (".$ret["addr"].")",
56 '$photo' => $ret["photo"],
58 '$pls_answer' => t('Please answer the following:'),
59 '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'),t('Yes'))),
60 '$add_note' => t('Add a personal note:'),
66 '$your_address' => t('Your Identity Address:'),
69 '$submit' => t('Submit Request'),
70 '$cancel' => t('Cancel'),
72 '$name' => $ret["name"],
73 '$url' => $ret["url"],
75 '$request' => $request
80 function follow_post(&$a) {
83 notice( t('Permission denied.') . EOL);
84 goaway($_SESSION['return_url']);
88 if ($_REQUEST['cancel'])
89 goaway($_SESSION['return_url']);
92 $url = notags(trim($_REQUEST['url']));
93 $return_url = $_SESSION['return_url'];
95 // Makes the connection request for friendica contacts easier
96 // This is just a precaution if maybe this page is called somewhere directly via POST
97 $_SESSION["fastlane"] = $url;
99 $result = new_contact($uid,$url,true);
101 if($result['success'] == false) {
102 if($result['message'])
103 notice($result['message']);
105 } elseif ($result['cid'])
106 goaway($a->get_baseurl().'/contacts/'.$result['cid']);
108 info( t('Contact added').EOL);
110 if(strstr($return_url,'contacts'))
111 goaway($a->get_baseurl().'/contacts/'.$contact_id);