4 use Friendica\Core\System;
6 require_once 'include/probe.php';
7 require_once 'include/follow.php';
8 require_once 'include/Contact.php';
9 require_once 'include/contact_selectors.php';
11 function follow_post(App $a) {
14 notice( t('Permission denied.') . EOL);
15 goaway($_SESSION['return_url']);
19 if ($_REQUEST['cancel']) {
20 goaway($_SESSION['return_url']);
24 $url = notags(trim($_REQUEST['url']));
25 $return_url = $_SESSION['return_url'];
27 // Makes the connection request for friendica contacts easier
28 // This is just a precaution if maybe this page is called somewhere directly via POST
29 $_SESSION["fastlane"] = $url;
31 $result = new_contact($uid,$url,true);
33 if ($result['success'] == false) {
34 if ($result['message']) {
35 notice($result['message']);
38 } elseif ($result['cid']) {
39 goaway(System::baseUrl().'/contacts/'.$result['cid']);
42 info( t('Contact added').EOL);
44 if (strstr($return_url,'contacts')) {
45 goaway(System::baseUrl().'/contacts/'.$contact_id);
52 function follow_content(App $a) {
55 notice( t('Permission denied.') . EOL);
56 goaway($_SESSION['return_url']);
61 $url = notags(trim($_REQUEST['url']));
63 $submit = t('Submit Request');
65 // There is a current issue. It seems as if you can't start following a Friendica that is following you
66 // With Diaspora this works - but Friendica is special, it seems ...
67 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
68 (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
69 `network` != '%s' LIMIT 1",
70 intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)),
71 dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
74 notice(t('You already added this contact.').EOL);
76 //goaway($_SESSION['return_url']);
80 $ret = probe_url($url);
82 if (($ret["network"] == NETWORK_DIASPORA) && !get_config('system','diaspora_enabled')) {
83 notice( t("Diaspora support isn't enabled. Contact can't be added.") . EOL);
85 //goaway($_SESSION['return_url']);
89 if (($ret["network"] == NETWORK_OSTATUS) && get_config('system','ostatus_disabled')) {
90 notice( t("OStatus support is disabled. Contact can't be added.") . EOL);
92 //goaway($_SESSION['return_url']);
96 if ($ret["network"] == NETWORK_PHANTOM) {
97 notice( t("The network type couldn't be detected. Contact can't be added.") . EOL);
99 //goaway($_SESSION['return_url']);
103 if ($ret["network"] == NETWORK_MAIL) {
104 $ret["url"] = $ret["addr"];
107 if ($ret['network'] === NETWORK_DFRN) {
108 $request = $ret["request"];
109 $tpl = get_markup_template('dfrn_request.tpl');
111 $request = System::baseUrl()."/follow";
112 $tpl = get_markup_template('auto_request.tpl');
115 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
118 notice( t('Permission denied.') . EOL);
119 goaway($_SESSION['return_url']);
123 $myaddr = $r[0]["url"];
126 // Makes the connection request for friendica contacts easier
127 $_SESSION["fastlane"] = $ret["url"];
129 $r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
130 normalise_link($ret["url"]));
133 $r = array(array("location" => "", "about" => "", "keywords" => ""));
135 $gcontact_id = $r[0]["id"];
138 if ($ret['network'] === NETWORK_DIASPORA) {
139 $r[0]["location"] = "";
143 $header = t("Connect/Follow");
145 $o = replace_macros($tpl,array(
146 '$header' => htmlentities($header),
147 //'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
149 '$pls_answer' => t('Please answer the following:'),
150 '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'), t('Yes'))),
151 '$add_note' => t('Add a personal note:'),
157 '$your_address' => t('Your Identity Address:'),
158 '$invite_desc' => "",
160 '$submit' => $submit,
161 '$cancel' => t('Cancel'),
163 '$name' => $ret["name"],
164 '$url' => $ret["url"],
165 '$zrl' => zrl($ret["url"]),
166 '$url_label' => t("Profile URL"),
167 '$myaddr' => $myaddr,
168 '$request' => $request,
169 /*'$location' => bbcode($r[0]["location"]),
170 '$location_label' => t("Location:"),
171 '$about' => bbcode($r[0]["about"], false, false),
172 '$about_label' => t("About:"), */
173 '$keywords' => $r[0]["keywords"],
174 '$keywords_label' => t("Tags:")
177 $a->page['aside'] = "";
178 profile_load($a, "", 0, get_contact_details_by_url($ret["url"]));
180 if ($gcontact_id <> 0) {
181 $o .= replace_macros(get_markup_template('section_title.tpl'),
182 array('$title' => t('Status Messages and Posts')
185 // Show last public posts
186 $o .= posts_from_contact_url($a, $ret["url"]);