X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fparse_url.php;h=a1ca5a3db5e2e1c831d35bada4b52a3502b54183;hb=1f7f964bb7200d4f658742a999c07f1dd6cbe97c;hp=71d767675f8c51a1b3cba44b3edae4e2bd0c7bf8;hpb=dea1b067bddd2e946816dce9c9ab948bdb11f011;p=friendica.git diff --git a/mod/parse_url.php b/mod/parse_url.php index 71d767675f..a1ca5a3db5 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -1,16 +1,20 @@ - - - - -

Shiny Trinket

- -

Shiny trinkets are shiny.

- +/** + * @file mod/parse_url.php + * + * @todo https://developers.google.com/+/plugins/snippet/ + * + * @verbatim + * + * + * + * + * + *

Shiny Trinket

+ * + *

Shiny trinkets are shiny.

+ * + * @endverbatim */ if(!function_exists('deletenode')) { @@ -50,8 +54,33 @@ function completeurl($url, $scheme) { return($complete); } +function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true) { + + if ($url == "") + 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)); + + if ($r) + $data = $r[0]["content"]; + + if (!is_null($data)) { + $data = unserialize($data); + return $data; + } + + $data = parseurl_getsiteinfo($url, $no_guessing, $do_oembed); + + q("INSERT INTO `parsed_url` (`url`, `guessing`, `oembed`, `content`, `created`) VALUES ('%s', %d, %d, '%s', '%s')", + dbesc(normalise_link($url)), intval(!$no_guessing), intval($do_oembed), dbesc(serialize($data)), dbesc(datetime_convert())); + + return $data; +} + function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1) { require_once("include/network.php"); + require_once("include/Photo.php"); $a = get_app(); @@ -265,7 +294,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co if (isset($keywords)) { $siteinfo["keywords"] = array(); foreach ($keywords as $keyword) - $siteinfo["keywords"][] = trim($keyword); + if (!in_array(trim($keyword), $siteinfo["keywords"])) + $siteinfo["keywords"][] = trim($keyword); } //$list = $xpath->query("head/meta[@property]"); @@ -301,7 +331,7 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co $attr[$attribute->name] = $attribute->value; $src = completeurl($attr["src"], $url); - $photodata = @getimagesize($src); + $photodata = get_photo_info($src); if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) { if ($photodata[0] > 300) { @@ -318,12 +348,12 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co } } - } else { + } elseif ($siteinfo["image"] != "") { $src = completeurl($siteinfo["image"], $url); unset($siteinfo["image"]); - $photodata = @getimagesize($src); + $photodata = get_photo_info($src); if (($photodata) && ($photodata[0] > 10) and ($photodata[1] > 10)) $siteinfo["images"][] = array("src"=>$src,