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 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') LIMIT 1",
18 intval(local_user()), dbesc(normalise_link($url)), dbesc(normalise_link($url)), dbesc($url));
21 notice(t('You already added this contact.').EOL);
22 goaway($_SESSION['return_url']);
26 $ret = probe_url($url);
28 if($ret['network'] === NETWORK_DFRN) {
29 $request = $ret["request"];
30 $tpl = get_markup_template('dfrn_request.tpl');
32 $request = $a->get_baseurl()."/follow";
33 $tpl = get_markup_template('auto_request.tpl');
36 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
39 notice( t('Permission denied.') . EOL);
40 goaway($_SESSION['return_url']);
44 $myaddr = $r[0]["url"];
46 // Makes the connection request for friendica contacts easier
47 $_SESSION["fastlane"] = $ret["url"];
49 $o = replace_macros($tpl,array(
50 '$header' => $ret["name"]." (".$ret["addr"].")",
51 '$photo' => $ret["photo"],
53 '$pls_answer' => t('Please answer the following:'),
54 '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'),t('Yes'))),
55 '$add_note' => t('Add a personal note:'),
61 '$your_address' => t('Your Identity Address:'),
64 '$submit' => t('Submit Request'),
65 '$cancel' => t('Cancel'),
67 '$name' => $ret["name"],
68 '$url' => $ret["url"],
70 '$request' => $request
75 function follow_post(&$a) {
78 notice( t('Permission denied.') . EOL);
79 goaway($_SESSION['return_url']);
83 if ($_REQUEST['cancel'])
84 goaway($_SESSION['return_url']);
87 $url = notags(trim($_REQUEST['url']));
88 $return_url = $_SESSION['return_url'];
90 // Makes the connection request for friendica contacts easier
91 // This is just a precaution if maybe this page is called somewhere directly via POST
92 $_SESSION["fastlane"] = $url;
94 $result = new_contact($uid,$url,true);
96 if($result['success'] == false) {
97 if($result['message'])
98 notice($result['message']);
100 } elseif ($result['cid'])
101 goaway($a->get_baseurl().'/contacts/'.$result['cid']);
103 info( t('Contact added').EOL);
105 if(strstr($return_url,'contacts'))
106 goaway($a->get_baseurl().'/contacts/'.$contact_id);