3 require_once('include/Scrape.php');
4 require_once('include/follow.php');
5 require_once('include/Contact.php');
6 require_once('include/contact_selectors.php');
8 function follow_content(&$a) {
11 notice( t('Permission denied.') . EOL);
12 goaway($_SESSION['return_url']);
17 $url = notags(trim($_REQUEST['url']));
19 $submit = t('Submit Request');
21 // There is a current issue. It seems as if you can't start following a Friendica that is following you
22 // With Diaspora this works - but Friendica is special, it seems ...
23 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
24 (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
25 `network` != '%s' LIMIT 1",
26 intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)),
27 dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
30 notice(t('You already added this contact.').EOL);
32 //goaway($_SESSION['return_url']);
36 $ret = probe_url($url);
38 if (($ret["network"] == NETWORK_DIASPORA) AND !get_config('system','diaspora_enabled')) {
39 notice( t("Diaspora support isn't enabled. Contact can't be added.") . EOL);
41 //goaway($_SESSION['return_url']);
45 if (($ret["network"] == NETWORK_OSTATUS) AND get_config('system','ostatus_disabled')) {
46 notice( t("OStatus support is disabled. Contact can't be added.") . EOL);
48 //goaway($_SESSION['return_url']);
52 if ($ret["network"] == NETWORK_PHANTOM) {
53 notice( t("The network type couldn't be detected. Contact can't be added.") . EOL);
55 //goaway($_SESSION['return_url']);
59 if ($ret["network"] == NETWORK_MAIL)
60 $ret["url"] = $ret["addr"];
62 if($ret['network'] === NETWORK_DFRN) {
63 $request = $ret["request"];
64 $tpl = get_markup_template('dfrn_request.tpl');
66 $request = $a->get_baseurl()."/follow";
67 $tpl = get_markup_template('auto_request.tpl');
70 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
73 notice( t('Permission denied.') . EOL);
74 goaway($_SESSION['return_url']);
78 $myaddr = $r[0]["url"];
81 // Makes the connection request for friendica contacts easier
82 $_SESSION["fastlane"] = $ret["url"];
84 $r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
85 normalise_link($ret["url"]));
88 $r = array(array("location" => "", "about" => "", "keywords" => ""));
90 $gcontact_id = $r[0]["id"];
92 if($ret['network'] === NETWORK_DIASPORA) {
93 $r[0]["location"] = "";
97 $header = $ret["name"];
99 if ($ret["addr"] != "")
100 $header .= " <".$ret["addr"].">";
102 //$header .= " (".network_to_name($ret['network'], $ret['url']).")";
103 $header = t("Connect/Follow");
105 $o = replace_macros($tpl,array(
106 '$header' => htmlentities($header),
107 //'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
109 '$pls_answer' => t('Please answer the following:'),
110 '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'),t('Yes'))),
111 '$add_note' => t('Add a personal note:'),
117 '$your_address' => t('Your Identity Address:'),
118 '$invite_desc' => "",
120 '$submit' => $submit,
121 '$cancel' => t('Cancel'),
123 '$name' => $ret["name"],
124 '$url' => $ret["url"],
125 '$zrl' => zrl($ret["url"]),
126 '$url_label' => t("Profile URL"),
127 '$myaddr' => $myaddr,
128 '$request' => $request,
129 /*'$location' => bbcode($r[0]["location"]),
130 '$location_label' => t("Location:"),
131 '$about' => bbcode($r[0]["about"], false, false),
132 '$about_label' => t("About:"), */
133 '$keywords' => $r[0]["keywords"],
134 '$keywords_label' => t("Tags:")
137 $a->page['aside'] = "";
138 profile_load($a, "", 0, get_contact_details_by_url($ret["url"]));
140 // Show last public posts
141 if ($gcontact_id <> 0) {
142 $o .= replace_macros(get_markup_template('section_title.tpl'),
143 array('$title' => t('Status Messages and Posts')
146 $o .= posts_from_gcontact($a, $gcontact_id);
152 function follow_post(&$a) {
155 notice( t('Permission denied.') . EOL);
156 goaway($_SESSION['return_url']);
160 if ($_REQUEST['cancel'])
161 goaway($_SESSION['return_url']);
164 $url = notags(trim($_REQUEST['url']));
165 $return_url = $_SESSION['return_url'];
167 // Makes the connection request for friendica contacts easier
168 // This is just a precaution if maybe this page is called somewhere directly via POST
169 $_SESSION["fastlane"] = $url;
171 $result = new_contact($uid,$url,true);
173 if($result['success'] == false) {
174 if($result['message'])
175 notice($result['message']);
177 } elseif ($result['cid'])
178 goaway($a->get_baseurl().'/contacts/'.$result['cid']);
180 info( t('Contact added').EOL);
182 if(strstr($return_url,'contacts'))
183 goaway($a->get_baseurl().'/contacts/'.$contact_id);