]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_request.php
Also use is_filled_array() here, too. if $contacts is FALSE count() issues are E_WARNING
[friendica.git] / mod / dfrn_request.php
index 1b1bf4e05689e0c7f6b974930a82e2023d840786..82886a6efaab2206bee069bfd0d7155395b62160 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 require_once('include/enotify.php');
+require_once('include/Scrape.php');
 
 if(! function_exists('dfrn_request_init')) {
 function dfrn_request_init(&$a) {
@@ -41,8 +42,10 @@ function dfrn_request_init(&$a) {
 if(! function_exists('dfrn_request_post')) {
 function dfrn_request_post(&$a) {
 
-       if(($a->argc != 2) || (! count($a->profile)))
+       if(($a->argc != 2) || (! count($a->profile))) {
+               logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile));
                return;
+       }
 
 
        if(x($_POST, 'cancel')) {
@@ -112,8 +115,6 @@ function dfrn_request_post(&$a) {
                                         * Scrape the other site's profile page to pick up the dfrn links, key, fn, and photo
                                         */
 
-                                       require_once('include/Scrape.php');
-
                                        $parms = scrape_dfrn($dfrn_url);
 
                                        if(! count($parms)) {
@@ -441,28 +442,28 @@ function dfrn_request_post(&$a) {
 
                        // Next send an email verify form to the requestor.
 
-               }
-
-               else {
+               } else {
                        // Detect the network
                        $data = probe_url($url);
                        $network = $data["network"];
 
-                       // Use the detected address - if present
-                       if ($data["addr"] != "")
-                               $url = $data["addr"];
-
                        // Canonicalise email-style profile locator
                        $url = webfinger_dfrn($url,$hcard);
 
-                       if (substr($url,0,5) === 'stat:')
-                               $url = substr($url,5);
+                       if (substr($url,0,5) === 'stat:') {
+
+                               // Every time we detect the remote subscription we define this as OStatus.
+                               // We do this even if it is not OStatus.
+                               // we only need to pass this through another section of the code.
+                               if ($network != NETWORK_DIASPORA)
+                                       $network = NETWORK_OSTATUS;
 
-                       if (($url == "") AND ($network === NETWORK_DIASPORA))
-                               $url = $data["baseurl"]."/people?q={uri}";
+                               $url = substr($url,5);
+                       } else
+                               $network = NETWORK_DFRN;
                }
 
-               logger('dfrn_request: url: ' . $url);
+               logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG);
 
                if($network === NETWORK_DFRN) {
                        $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
@@ -826,6 +827,7 @@ function dfrn_request_content(&$a) {
                else
                        $tpl = get_markup_template('auto_request.tpl');
 
+               // TODO This .= triggers an E_NOTICE, really needed?
                $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:");
 
                // see if we are allowed to have NETWORK_MAIL2 contacts
@@ -851,6 +853,7 @@ function dfrn_request_content(&$a) {
                        get_server()
                );
 
+               // TODO This .= triggers an E_NOTICE, really needed?
                $o .= replace_macros($tpl,array(
                        '$header' => t('Friend/Connection Request'),
                        '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'),