3 require_once('include/Scrape.php');
4 require_once('include/follow.php');
5 require_once('include/contact_selectors.php');
7 function follow_content(&$a) {
10 notice( t('Permission denied.') . EOL);
11 goaway($_SESSION['return_url']);
16 $url = notags(trim($_REQUEST['url']));
18 // There is a current issue. It seems as if you can't start following a Friendica that is following you
19 // With Diaspora this works - but Friendica is special, it seems ...
20 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
21 (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
22 `network` != '%s' LIMIT 1",
23 intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)),
24 dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
27 notice(t('You already added this contact.').EOL);
28 goaway($_SESSION['return_url']);
32 $ret = probe_url($url);
34 if ($ret["network"] == NETWORK_PHANTOM) {
35 notice( t("The network type couldn't be detected. Contact can't be added.") . EOL);
36 goaway($_SESSION['return_url']);
40 if ($ret["network"] == NETWORK_MAIL)
41 $ret["url"] = $ret["addr"];
43 if($ret['network'] === NETWORK_DFRN) {
44 $request = $ret["request"];
45 $tpl = get_markup_template('dfrn_request.tpl');
47 $request = $a->get_baseurl()."/follow";
48 $tpl = get_markup_template('auto_request.tpl');
51 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
54 notice( t('Permission denied.') . EOL);
55 goaway($_SESSION['return_url']);
59 $myaddr = $r[0]["url"];
61 // Makes the connection request for friendica contacts easier
62 $_SESSION["fastlane"] = $ret["url"];
64 $r = q("SELECT `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
65 normalise_link($ret["url"]));
68 $r = array(array("location" => "", "about" => "", "keywords" => ""));
70 $header = $ret["name"];
72 if ($ret["addr"] != "")
73 $header .= " <".$ret["addr"].">";
75 $header .= " (".network_to_name($ret['network'], $ret['url']).")";
77 $o = replace_macros($tpl,array(
78 '$header' => htmlentities($header),
79 '$photo' => proxy_url($ret["photo"]),
81 '$pls_answer' => t('Please answer the following:'),
82 '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'),t('Yes'))),
83 '$add_note' => t('Add a personal note:'),
89 '$your_address' => t('Your Identity Address:'),
92 '$submit' => t('Submit Request'),
93 '$cancel' => t('Cancel'),
95 '$name' => $ret["name"],
96 '$url' => $ret["url"],
97 '$zrl' => zrl($ret["url"]),
98 '$url_label' => t("Profile URL"),
100 '$request' => $request,
101 '$location' => bbcode($r[0]["location"]),
102 '$location_label' => t("Location:"),
103 '$about' => bbcode($r[0]["about"], false, false),
104 '$about_label' => t("About:"),
105 '$keywords' => $r[0]["keywords"],
106 '$keywords_label' => t("Tags:")
111 function follow_post(&$a) {
114 notice( t('Permission denied.') . EOL);
115 goaway($_SESSION['return_url']);
119 if ($_REQUEST['cancel'])
120 goaway($_SESSION['return_url']);
123 $url = notags(trim($_REQUEST['url']));
124 $return_url = $_SESSION['return_url'];
126 // Makes the connection request for friendica contacts easier
127 // This is just a precaution if maybe this page is called somewhere directly via POST
128 $_SESSION["fastlane"] = $url;
130 $result = new_contact($uid,$url,true);
132 if($result['success'] == false) {
133 if($result['message'])
134 notice($result['message']);
136 } elseif ($result['cid'])
137 goaway($a->get_baseurl().'/contacts/'.$result['cid']);
139 info( t('Contact added').EOL);
141 if(strstr($return_url,'contacts'))
142 goaway($a->get_baseurl().'/contacts/'.$contact_id);