use DOMDocument;\r
use DOMXPath;\r
use DOMNode;\r
+use Exception;\r
\r
require_once 'include/dba.php';\r
require_once 'mod/proxy.php';\r
}\r
\r
$domain = parse_url($url, PHP_URL_HOST);\r
+ if (!x($domain)) {\r
+ return false;\r
+ }\r
\r
$str_allowed = Config::get('system', 'allowed_oembed', '');\r
+ if (!x($str_allowed)) {\r
+ return false;\r
+ }\r
+ \r
$allowed = explode(',', $str_allowed);\r
\r
- return allowed_domain($domain, $allowed, true);\r
+ return allowed_domain($domain, $allowed);\r
+ }\r
+\r
+ public static function getHTML($url, $title = null)\r
+ {\r
+ // Always embed the SSL version\r
+ $url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"),\r
+ array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);\r
+\r
+ $o = OEmbed::fetchURL($url);\r
+\r
+ if (!is_object($o) || $o->type == 'error') {\r
+ throw new Exception('OEmbed failed for URL: ' . $url);\r
+ }\r
+\r
+ if (x($title)) {\r
+ $o->title = $title;\r
+ }\r
+\r
+ $html = OEmbed::formatObject($o);\r
+\r
+ return $html;\r
}\r
\r
/**\r