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
18 (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
19 `network` != '%s' LIMIT 1",
20 intval(local_user()), dbesc(normalise_link($url)),
21 dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
24 notice(t('You already added this contact.').EOL);
25 goaway($_SESSION['return_url']);
29 $ret = probe_url($url);
31 if($ret['network'] === NETWORK_DFRN) {
32 $request = $ret["request"];
33 $tpl = get_markup_template('dfrn_request.tpl');
35 $request = $a->get_baseurl()."/follow";
36 $tpl = get_markup_template('auto_request.tpl');
39 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
42 notice( t('Permission denied.') . EOL);
43 goaway($_SESSION['return_url']);
47 $myaddr = $r[0]["url"];
49 // Makes the connection request for friendica contacts easier
50 $_SESSION["fastlane"] = $ret["url"];
52 $o = replace_macros($tpl,array(
53 '$header' => $ret["name"]." (".$ret["addr"].")",
54 '$photo' => $ret["photo"],
56 '$pls_answer' => t('Please answer the following:'),
57 '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'),t('Yes'))),
58 '$add_note' => t('Add a personal note:'),
64 '$your_address' => t('Your Identity Address:'),
67 '$submit' => t('Submit Request'),
68 '$cancel' => t('Cancel'),
70 '$name' => $ret["name"],
71 '$url' => $ret["url"],
73 '$request' => $request
78 function follow_post(&$a) {
81 notice( t('Permission denied.') . EOL);
82 goaway($_SESSION['return_url']);
86 if ($_REQUEST['cancel'])
87 goaway($_SESSION['return_url']);
90 $url = notags(trim($_REQUEST['url']));
91 $return_url = $_SESSION['return_url'];
93 // Makes the connection request for friendica contacts easier
94 // This is just a precaution if maybe this page is called somewhere directly via POST
95 $_SESSION["fastlane"] = $url;
97 $result = new_contact($uid,$url,true);
99 if($result['success'] == false) {
100 if($result['message'])
101 notice($result['message']);
103 } elseif ($result['cid'])
104 goaway($a->get_baseurl().'/contacts/'.$result['cid']);
106 info( t('Contact added').EOL);
108 if(strstr($return_url,'contacts'))
109 goaway($a->get_baseurl().'/contacts/'.$contact_id);