X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fparse_url.php;h=71d767675f8c51a1b3cba44b3edae4e2bd0c7bf8;hb=c7566d49179afcbc6b844043084e8d6235c21160;hp=cd2263dbe2622d8ae532ab87dcce935ac037b916;hpb=08696acb189bc17c4118de558269149e367b1c8f;p=friendica.git diff --git a/mod/parse_url.php b/mod/parse_url.php index cd2263dbe2..71d767675f 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -97,6 +97,14 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co return($siteinfo); } + // if the file is too large then exit + if ($curl_info["download_content_length"] > 1000000) + return($siteinfo); + + // if it isn't a HTML file then exit + if (($curl_info["content_type"] != "") AND !strstr(strtolower($curl_info["content_type"]),"html")) + return($siteinfo); + if ($do_oembed) { require_once("include/oembed.php"); @@ -104,15 +112,16 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co if ($oembed_data->type != "error") $siteinfo["type"] = $oembed_data->type; - } - - // if the file is too large then exit - if ($curl_info["download_content_length"] > 1000000) - return($siteinfo); - // if it isn't a HTML file then exit - if (($curl_info["content_type"] != "") AND !strstr(strtolower($curl_info["content_type"]),"html")) - return($siteinfo); + if (($oembed_data->type == "link") AND ($siteinfo["type"] != "photo")) { + if (isset($oembed_data->title)) + $siteinfo["title"] = $oembed_data->title; + if (isset($oembed_data->description)) + $siteinfo["text"] = trim($oembed_data->description); + if (isset($oembed_data->thumbnail_url)) + $siteinfo["image"] = $oembed_data->thumbnail_url; + } + } $stamp1 = microtime(true); @@ -283,15 +292,6 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co } } - if (isset($oembed_data) AND ($oembed_data->type == "link") AND ($siteinfo["type"] != "photo")) { - if (isset($oembed_data->title) AND (trim($oembed_data->title) != "")) - $siteinfo["title"] = $oembed_data->title; - if (isset($oembed_data->description) AND (trim($oembed_data->description) != "")) - $siteinfo["text"] = trim($oembed_data->description); - if (isset($oembed_data->thumbnail_url) AND (trim($oembed_data->thumbnail_url) != "")) - $siteinfo["image"] = $oembed_data->thumbnail_url; - } - if ((@$siteinfo["image"] == "") AND !$no_guessing) { $list = $xpath->query("//img[@src]"); foreach ($list as $node) { @@ -407,6 +407,15 @@ function parse_url_content(&$a) { } } + // add url scheme if missing + $arrurl = parse_url($url); + if (!x($arrurl, 'scheme')) { + if (x($arrurl, 'host')) + $url = "http:".$url; + else + $url = "http://".$url; + } + logger('parse_url: ' . $url); if($textmode) @@ -462,10 +471,7 @@ function parse_url_content(&$a) { $sitedata = ""; - if($siteinfo["title"] == "") { - $sitedata .= sprintf($template,$url,$url,'') . $str_tags; - killme(); - } else { + if($siteinfo["title"] != "") { $text = $siteinfo["text"]; $title = $siteinfo["title"]; }