X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fnetwork.php;h=25db62d1611a0d4b78c8970981b03c5e1663abe5;hb=f5c5da742da1154c26277df7ff86eebea6ffe049;hp=c6f5fd909fa2004157a64ba08f4add5579145d7d;hpb=01164c8c2f802f0b4c2f0f7c4a83ed826768ae1a;p=friendica.git diff --git a/include/network.php b/include/network.php old mode 100644 new mode 100755 index c6f5fd909f..25db62d161 --- a/include/network.php +++ b/include/network.php @@ -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); @@ -527,6 +535,9 @@ function fetch_xrd_links($url) { if ((! $xml) || (! stristr($xml,''),array('href="','"/>'),$xml); + $h = parse_xml_string($xml); if(! $h) return array(); @@ -568,6 +579,9 @@ function fetch_xrd_links($url) { if(! function_exists('validate_url')) { function validate_url(&$url) { + // no naked subdomains + if(strpos($url,'.') === false) + return false; if(substr($url,0,4) != 'http') $url = 'http://' . $url; $h = @parse_url($url); @@ -732,7 +746,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()), @@ -760,5 +773,6 @@ function add_fcontact($arr,$update = false) { dbesc(datetime_convert()) ); } + return $r; }