]> git.mxchange.org Git - friendica.git/blobdiff - include/network.php
Merge remote-tracking branch 'friendica/master'
[friendica.git] / include / network.php
index ec99d1e0dc12a0c0ec1f206187ae958782d60f91..551d5e1d0f7ee87ef39b0f817bec9659b90de91c 100644 (file)
@@ -5,7 +5,7 @@
 // results. 
 
 if(! function_exists('fetch_url')) {
-function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) {
+function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_content=Null) {
 
        $a = get_app();
 
@@ -14,8 +14,16 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) {
                return false;
 
        @curl_setopt($ch, CURLOPT_HEADER, true);
+       
+       if (!is_null($accept_content)){
+               curl_setopt($ch,CURLOPT_HTTPHEADER, array (
+                       "Accept: "+$accept_content
+               ));
+       }
+       
        @curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
-       @curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
+       @curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
+
 
        if(intval($timeout)) {
                @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
@@ -97,7 +105,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
        curl_setopt($ch, CURLOPT_POST,1);
        curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
-       curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
+       curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
 
        if(intval($timeout)) {
                curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
@@ -429,7 +437,12 @@ function lrdd($uri) {
        // don't try and parse raw xml as html
        if(! strstr($html,'<?xml')) {
                require_once('library/HTML5/Parser.php');
-               $dom = @HTML5_Parser::parse($html);
+
+               try {
+                       $dom = HTML5_Parser::parse($html);
+               } catch (DOMException $e) {
+                       logger('lrdd: parse error: ' . $e);
+               }
 
                if($dom) {
                        $items = $dom->getElementsByTagName('link');
@@ -522,6 +535,9 @@ function fetch_xrd_links($url) {
        if ((! $xml) || (! stristr($xml,'<xrd')))
                return array();
 
+       // fix diaspora's bad xml
+       $xml = str_replace(array('href=&quot;','&quot;/>'),array('href="','"/>'),$xml);
+
        $h = parse_xml_string($xml);
        if(! $h)
                return array();
@@ -727,7 +743,6 @@ function add_fcontact($arr,$update = false) {
                        dbesc($arr['notify']),
                        dbesc($arr['poll']),
                        dbesc($arr['confirm']),
-                       dbesc($arr['network']),
                        dbesc($arr['alias']),
                        dbesc($arr['pubkey']),
                        dbesc(datetime_convert()),
@@ -755,5 +770,6 @@ function add_fcontact($arr,$update = false) {
                        dbesc(datetime_convert())
                );
        }
+
        return $r;
 }