6 use Friendica\Core\Config;
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
9 use Friendica\Model\Contact;
10 use Friendica\Model\Profile;
11 use Friendica\Network\Probe;
13 function follow_post(App $a) {
16 notice(L10n::t('Permission denied.') . EOL);
17 goaway($_SESSION['return_url']);
21 if ($_REQUEST['cancel']) {
22 goaway($_SESSION['return_url']);
26 $url = notags(trim($_REQUEST['url']));
27 $return_url = $_SESSION['return_url'];
29 // Makes the connection request for friendica contacts easier
30 // This is just a precaution if maybe this page is called somewhere directly via POST
31 $_SESSION["fastlane"] = $url;
33 $result = Contact::createFromProbe($uid, $url, true);
35 if ($result['success'] == false) {
36 if ($result['message']) {
37 notice($result['message']);
40 } elseif ($result['cid']) {
41 goaway(System::baseUrl().'/contacts/'.$result['cid']);
44 info(L10n::t('The contact could not be added.').EOL);
50 function follow_content(App $a) {
53 notice(L10n::t('Permission denied.') . EOL);
54 goaway($_SESSION['return_url']);
59 $url = notags(trim($_REQUEST['url']));
61 $submit = L10n::t('Submit Request');
63 // There is a current issue. It seems as if you can't start following a Friendica that is following you
64 // With Diaspora this works - but Friendica is special, it seems ...
65 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
66 (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
67 `network` != '%s' LIMIT 1",
68 intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)),
69 dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
72 notice(L10n::t('You already added this contact.').EOL);
74 //goaway($_SESSION['return_url']);
78 $ret = Probe::uri($url);
80 if (($ret["network"] == NETWORK_DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
81 notice(L10n::t("Diaspora support isn't enabled. Contact can't be added.") . EOL);
83 //goaway($_SESSION['return_url']);
87 if (($ret["network"] == NETWORK_OSTATUS) && Config::get('system', 'ostatus_disabled')) {
88 notice(L10n::t("OStatus support is disabled. Contact can't be added.") . EOL);
90 //goaway($_SESSION['return_url']);
94 if ($ret["network"] == NETWORK_PHANTOM) {
95 notice(L10n::t("The network type couldn't be detected. Contact can't be added.") . EOL);
97 //goaway($_SESSION['return_url']);
101 if ($ret["network"] == NETWORK_MAIL) {
102 $ret["url"] = $ret["addr"];
105 if ($ret['network'] === NETWORK_DFRN) {
106 $request = $ret["request"];
107 $tpl = get_markup_template('dfrn_request.tpl');
109 $request = System::baseUrl()."/follow";
110 $tpl = get_markup_template('auto_request.tpl');
113 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
116 notice(L10n::t('Permission denied.') . EOL);
117 goaway($_SESSION['return_url']);
121 $myaddr = $r[0]["url"];
124 // Makes the connection request for friendica contacts easier
125 $_SESSION["fastlane"] = $ret["url"];
127 $r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
128 normalise_link($ret["url"]));
131 $r = [["location" => "", "about" => "", "keywords" => ""]];
133 $gcontact_id = $r[0]["id"];
136 if ($ret['network'] === NETWORK_DIASPORA) {
137 $r[0]["location"] = "";
141 $header = L10n::t("Connect/Follow");
143 $o = replace_macros($tpl, [
144 '$header' => htmlentities($header),
145 //'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
147 '$pls_answer' => L10n::t('Please answer the following:'),
148 '$does_know_you' => ['knowyou', L10n::t('Does %s know you?', $ret["name"]), false, '', [L10n::t('No'), L10n::t('Yes')]],
149 '$add_note' => L10n::t('Add a personal note:'),
155 '$your_address' => L10n::t('Your Identity Address:'),
156 '$invite_desc' => "",
158 '$submit' => $submit,
159 '$cancel' => L10n::t('Cancel'),
161 '$name' => $ret["name"],
162 '$url' => $ret["url"],
163 '$zrl' => Profile::zrl($ret["url"]),
164 '$url_label' => L10n::t("Profile URL"),
165 '$myaddr' => $myaddr,
166 '$request' => $request,
167 /*'$location' => Friendica\Content\Text\BBCode::::convert($r[0]["location"]),
168 '$location_label' => L10n::t("Location:"),
169 '$about' => Friendica\Content\Text\BBCode::::convert($r[0]["about"], false, false),
170 '$about_label' => L10n::t("About:"), */
171 '$keywords' => $r[0]["keywords"],
172 '$keywords_label' => L10n::t("Tags:")
175 $a->page['aside'] = "";
177 Profile::load($a, "", 0, Contact::getDetailsByURL($ret["url"]), false);
179 if ($gcontact_id <> 0) {
180 $o .= replace_macros(get_markup_template('section_title.tpl'),
181 ['$title' => L10n::t('Status Messages and Posts')]
184 // Show last public posts
185 $o .= Contact::getPostsFromUrl($ret["url"]);