X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FParseUrl.php;h=8fff3bcd87de9bab198bffcd4ce836480545191c;hb=0448ca38973fed14840d33079989fd71af93708b;hp=3074e74dd6659cd41ef0a5e417607db56c80db36;hpb=8aff8a76eb9efc4acaab0af3c8c0ca7a011f4349;p=friendica.git diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 3074e74dd6..8fff3bcd87 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -50,19 +50,11 @@ class ParseUrl return false; } - $r = q( - "SELECT * FROM `parsed_url` WHERE `url` = '%s' AND `guessing` = %d AND `oembed` = %d", - dbesc(normalise_link($url)), - intval(!$no_guessing), - intval($do_oembed) + $parsed_url = dba::selectFirst('parsed_url', ['content'], + ['url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed] ); - - if ($r) { - $data = $r[0]["content"]; - } - - if (!is_null($data)) { - $data = unserialize($data); + if (!empty($parsed_url['content'])) { + $data = unserialize($parsed_url['content']); return $data; } @@ -73,7 +65,7 @@ class ParseUrl [ 'url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed, 'content' => serialize($data), - 'created' => Temporal::utcNow() + 'created' => DateTimeFormat::utcNow() ], true ); @@ -167,19 +159,21 @@ class ParseUrl if ($do_oembed) { $oembed_data = OEmbed::fetchURL($url); - if (!in_array($oembed_data->type, ["error", "rich", ""])) { - $siteinfo["type"] = $oembed_data->type; - } - - if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) { - if (isset($oembed_data->title)) { - $siteinfo["title"] = trim($oembed_data->title); + if (!empty($oembed_data->type)) { + if (!in_array($oembed_data->type, ["error", "rich", ""])) { + $siteinfo["type"] = $oembed_data->type; } - if (isset($oembed_data->description)) { - $siteinfo["text"] = trim($oembed_data->description); - } - if (isset($oembed_data->thumbnail_url)) { - $siteinfo["image"] = $oembed_data->thumbnail_url; + + if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) { + if (isset($oembed_data->title)) { + $siteinfo["title"] = trim($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; + } } } } @@ -259,9 +253,9 @@ class ParseUrl } } - $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8")); + if (!empty($attr["content"])) { + $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8")); - if ($attr["content"] != "") { switch (strtolower($attr["name"])) { case "fulltitle": $siteinfo["title"] = trim($attr["content"]); @@ -327,9 +321,9 @@ class ParseUrl } } - $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8")); + if (!empty($attr["content"])) { + $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8")); - if ($attr["content"] != "") { switch (strtolower($attr["property"])) { case "og:image": $siteinfo["image"] = $attr["content"]; @@ -371,7 +365,7 @@ class ParseUrl "height" => $photodata[1]]; } } - } elseif ($siteinfo["image"] != "") { + } elseif (!empty($siteinfo["image"])) { $src = self::completeUrl($siteinfo["image"], $url); unset($siteinfo["image"]);