X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FOEmbed.php;h=07c36685c3516f3afeb969e124d704bd8df37d02;hb=fd1515eff40341dab917f486bf15e392040cd48d;hp=4aaae4d5dca37effc185eeee2c6cb5b0117e7d92;hpb=1cd80018330d7a608a47116e11682f1572164b22;p=friendica.git diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 4aaae4d5dc..07c36685c3 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -15,6 +15,7 @@ use dba; use DOMDocument; use DOMXPath; use DOMNode; +use Exception; require_once 'include/dba.php'; require_once 'mod/proxy.php'; @@ -298,11 +299,39 @@ class OEmbed } $domain = parse_url($url, PHP_URL_HOST); + if (!x($domain)) { + return false; + } $str_allowed = Config::get('system', 'allowed_oembed', ''); + if (!x($str_allowed)) { + return false; + } + $allowed = explode(',', $str_allowed); - return allowed_domain($domain, $allowed, true); + return allowed_domain($domain, $allowed); + } + + public static function getHTML($url, $title = null) + { + // Always embed the SSL version + $url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"), + array("https://www.youtube.com/", "https://player.vimeo.com/"), $url); + + $o = OEmbed::fetchURL($url); + + if (!is_object($o) || $o->type == 'error') { + throw new Exception('OEmbed failed for URL: ' . $url); + } + + if (x($title)) { + $o->title = $title; + } + + $html = OEmbed::formatObject($o); + + return $html; } /**