Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

170 lines
4.7 KiB

  1. <?php
  2. require_once('include/Scrape.php');
  3. require_once('include/follow.php');
  4. require_once('include/contact_selectors.php');
  5. function follow_content(&$a) {
  6. if(! local_user()) {
  7. notice( t('Permission denied.') . EOL);
  8. goaway($_SESSION['return_url']);
  9. // NOTREACHED
  10. }
  11. $uid = local_user();
  12. $url = notags(trim($_REQUEST['url']));
  13. $submit = t('Submit Request');
  14. // There is a current issue. It seems as if you can't start following a Friendica that is following you
  15. // With Diaspora this works - but Friendica is special, it seems ...
  16. $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
  17. (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
  18. `network` != '%s' LIMIT 1",
  19. intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)),
  20. dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
  21. if ($r) {
  22. notice(t('You already added this contact.').EOL);
  23. $submit = "";
  24. //goaway($_SESSION['return_url']);
  25. // NOTREACHED
  26. }
  27. $ret = probe_url($url);
  28. if (($ret["network"] == NETWORK_DIASPORA) AND !get_config('system','diaspora_enabled')) {
  29. notice( t("Diaspora support isn't enabled. Contact can't be added.") . EOL);
  30. $submit = "";
  31. //goaway($_SESSION['return_url']);
  32. // NOTREACHED
  33. }
  34. if (($ret["network"] == NETWORK_OSTATUS) AND get_config('system','ostatus_disabled')) {
  35. notice( t("OStatus support is disabled. Contact can't be added.") . EOL);
  36. $submit = "";
  37. //goaway($_SESSION['return_url']);
  38. // NOTREACHED
  39. }
  40. if ($ret["network"] == NETWORK_PHANTOM) {
  41. notice( t("The network type couldn't be detected. Contact can't be added.") . EOL);
  42. $submit = "";
  43. //goaway($_SESSION['return_url']);
  44. // NOTREACHED
  45. }
  46. if ($ret["network"] == NETWORK_MAIL)
  47. $ret["url"] = $ret["addr"];
  48. if($ret['network'] === NETWORK_DFRN) {
  49. $request = $ret["request"];
  50. $tpl = get_markup_template('dfrn_request.tpl');
  51. } else {
  52. $request = $a->get_baseurl()."/follow";
  53. $tpl = get_markup_template('auto_request.tpl');
  54. }
  55. $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
  56. if (!$r) {
  57. notice( t('Permission denied.') . EOL);
  58. goaway($_SESSION['return_url']);
  59. // NOTREACHED
  60. }
  61. $myaddr = $r[0]["url"];
  62. // Makes the connection request for friendica contacts easier
  63. $_SESSION["fastlane"] = $ret["url"];
  64. $r = q("SELECT `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
  65. normalise_link($ret["url"]));
  66. if (!$r)
  67. $r = array(array("location" => "", "about" => "", "keywords" => ""));
  68. if($ret['network'] === NETWORK_DIASPORA) {
  69. $r[0]["location"] = "";
  70. $r[0]["about"] = "";
  71. }
  72. $header = $ret["name"];
  73. if ($ret["addr"] != "")
  74. $header .= " <".$ret["addr"].">";
  75. $header .= " (".network_to_name($ret['network'], $ret['url']).")";
  76. $o = replace_macros($tpl,array(
  77. '$header' => htmlentities($header),
  78. '$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
  79. '$desc' => "",
  80. '$pls_answer' => t('Please answer the following:'),
  81. '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'),t('Yes'))),
  82. '$add_note' => t('Add a personal note:'),
  83. '$page_desc' => "",
  84. '$friendica' => "",
  85. '$statusnet' => "",
  86. '$diaspora' => "",
  87. '$diasnote' => "",
  88. '$your_address' => t('Your Identity Address:'),
  89. '$invite_desc' => "",
  90. '$emailnet' => "",
  91. '$submit' => $submit,
  92. '$cancel' => t('Cancel'),
  93. '$nickname' => "",
  94. '$name' => $ret["name"],
  95. '$url' => $ret["url"],
  96. '$zrl' => zrl($ret["url"]),
  97. '$url_label' => t("Profile URL"),
  98. '$myaddr' => $myaddr,
  99. '$request' => $request,
  100. '$location' => bbcode($r[0]["location"]),
  101. '$location_label' => t("Location:"),
  102. '$about' => bbcode($r[0]["about"], false, false),
  103. '$about_label' => t("About:"),
  104. '$keywords' => $r[0]["keywords"],
  105. '$keywords_label' => t("Tags:")
  106. ));
  107. return $o;
  108. }
  109. function follow_post(&$a) {
  110. if(! local_user()) {
  111. notice( t('Permission denied.') . EOL);
  112. goaway($_SESSION['return_url']);
  113. // NOTREACHED
  114. }
  115. if ($_REQUEST['cancel'])
  116. goaway($_SESSION['return_url']);
  117. $uid = local_user();
  118. $url = notags(trim($_REQUEST['url']));
  119. $return_url = $_SESSION['return_url'];
  120. // Makes the connection request for friendica contacts easier
  121. // This is just a precaution if maybe this page is called somewhere directly via POST
  122. $_SESSION["fastlane"] = $url;
  123. $result = new_contact($uid,$url,true);
  124. if($result['success'] == false) {
  125. if($result['message'])
  126. notice($result['message']);
  127. goaway($return_url);
  128. } elseif ($result['cid'])
  129. goaway($a->get_baseurl().'/contacts/'.$result['cid']);
  130. info( t('Contact added').EOL);
  131. if(strstr($return_url,'contacts'))
  132. goaway($a->get_baseurl().'/contacts/'.$contact_id);
  133. goaway($return_url);
  134. // NOTREACHED
  135. }