]> git.mxchange.org Git - friendica.git/blobdiff - include/Scrape.php
The feed function has now a simulation mode
[friendica.git] / include / Scrape.php
index b7df8e04feebdac46e9493eb5cfc1b5e0f3a78c4..ca6489b16ad37255311c4b327442824552413ac4 100644 (file)
@@ -235,7 +235,9 @@ function scrape_feed($url) {
        $a = get_app();
 
        $ret = array();
-       $s = fetch_url($url);
+       $cookiejar = tempnam(get_temppath(), 'cookiejar-scrape-feed-');
+       $s = fetch_url($url, false, $redirects, 0, Null, $cookiejar);
+       unlink($cookiejar);
 
        $headers = $a->get_curl_headers();
        $code = $a->get_curl_code();
@@ -547,9 +549,23 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
                }
        }
 
+       // Scrape the public key from the hcard.
+       // Diaspora will remove it from the webfinger somewhere in the future.
+       if (($hcard != "") AND ($pubkey == "")) {
+               $ret = scrape_dfrn(($hcard) ? $hcard : $dfrn, true);
+               if (isset($ret["key"])) {
+                       $hcard_key = $ret["key"];
+                       if(strstr($hcard_key,'RSA '))
+                               $pubkey = rsatopem($hcard_key);
+                       else
+                               $pubkey = $hcard_key;
+               }
+       }
        if($diaspora && $diaspora_base && $diaspora_guid) {
-               if($mode == PROBE_DIASPORA || ! $notify) {
-                       $notify = $diaspora_base . 'receive/users/' . $diaspora_guid;
+               $diaspora_notify = $diaspora_base.'receive/users/'.$diaspora_guid;
+
+               if($mode == PROBE_DIASPORA || ! $notify || ($notify == $diaspora_notify)) {
+                       $notify = $diaspora_notify;
                        $batch  = $diaspora_base . 'receive/public' ;
                }
                if(strpos($url,'@'))
@@ -632,7 +648,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
 
                if ($connectornetworks)
                        $check_feed = false;
+
                if($check_feed) {
+
                        $feedret = scrape_feed(($poll) ? $poll : $url);
 
                        logger('probe_url: scrape_feed ' . (($poll)? $poll : $url) . ' returns: ' . print_r($feedret,true), LOGGER_DATA);
@@ -646,7 +664,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
                                $vcard['photo'] = $feedret['photo'];
                        require_once('library/simplepie/simplepie.inc');
                        $feed = new SimplePie();
-                       $xml = fetch_url($poll);
+                       $cookiejar = tempnam(get_temppath(), 'cookiejar-scrape-feed-');
+                       $xml = fetch_url($poll, false, $redirects, 0, Null, $cookiejar);
+                       unlink($cookiejar);
 
                        logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA);
                        $a = get_app();
@@ -760,7 +780,6 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
                                        if (isset($noscrapedata["dfrn-poll"]))
                                                $poll = $noscrapedata["dfrn-poll"];
 
-//                                     print_r($noscrapedata);
                                }
                        }