From aea83f0bec6338cab8427d5fadeda4e32122feb3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 5 Apr 2015 20:40:31 +0200 Subject: [PATCH 1/2] The order for the page parsing is changed. --- mod/parse_url.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/mod/parse_url.php b/mod/parse_url.php index 7f4bd29a08..951c070110 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -97,15 +97,6 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co return($siteinfo); } - if ($do_oembed) { - require_once("include/oembed.php"); - - $oembed_data = oembed_fetch_url($url); - - 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); @@ -116,6 +107,24 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co $stamp1 = microtime(true); + if ($do_oembed) { + require_once("include/oembed.php"); + + $oembed_data = oembed_fetch_url($url); + + if ($oembed_data->type != "error") + $siteinfo["type"] = $oembed_data->type; + + 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; + } + } + // Now fetch the body as well $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); @@ -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) { From 539a93b3f1aa2b373cf73a76762c615d9cca31bc Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 6 Apr 2015 13:49:57 +0200 Subject: [PATCH 2/2] The timestamp was at the wrong place --- mod/parse_url.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/parse_url.php b/mod/parse_url.php index 951c070110..71d767675f 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -105,8 +105,6 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co if (($curl_info["content_type"] != "") AND !strstr(strtolower($curl_info["content_type"]),"html")) return($siteinfo); - $stamp1 = microtime(true); - if ($do_oembed) { require_once("include/oembed.php"); @@ -125,6 +123,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co } } + $stamp1 = microtime(true); + // Now fetch the body as well $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);