X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FOEmbed.php;h=360a0dc4899439949d7addf0de0b99bcf088d469;hb=0360f7197aac062eb2fecf95969658ca56068deb;hp=bcfb2346745ae25f07a4ddcd40b7c1c9b64accf7;hpb=a5952e5425ee623253b2c91daa873ff6cc63bd39;p=friendica.git diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index bcfb234674..360a0dc489 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -3,19 +3,22 @@ /** * @file src/Content/OEmbed.php */ - namespace Friendica\Content; use Friendica\Core\Addon; use Friendica\Core\Cache; -use Friendica\Core\System; use Friendica\Core\Config; +use Friendica\Core\L10n; +use Friendica\Core\System; use Friendica\Database\DBM; +use Friendica\Util\DateTimeFormat; +use Friendica\Util\Network; use Friendica\Util\ParseUrl; use dba; use DOMDocument; -use DOMXPath; use DOMNode; +use DOMText; +use DOMXPath; use Exception; require_once 'include/dba.php'; @@ -78,7 +81,7 @@ class OEmbed if (!in_array($ext, $noexts)) { // try oembed autodiscovery $redirects = 0; - $html_text = fetch_url($embedurl, false, $redirects, 15, "text/*"); + $html_text = Network::fetchUrl($embedurl, false, $redirects, 15, "text/*"); if ($html_text) { $dom = @DOMDocument::loadHTML($html_text); if ($dom) { @@ -86,13 +89,13 @@ class OEmbed $entries = $xpath->query("//link[@type='application/json+oembed']"); foreach ($entries as $e) { $href = $e->getAttributeNode("href")->nodeValue; - $txt = fetch_url($href . '&maxwidth=' . $a->videowidth); + $txt = Network::fetchUrl($href . '&maxwidth=' . $a->videowidth); break; } $entries = $xpath->query("//link[@type='text/json+oembed']"); foreach ($entries as $e) { $href = $e->getAttributeNode("href")->nodeValue; - $txt = fetch_url($href . '&maxwidth=' . $a->videowidth); + $txt = Network::fetchUrl($href . '&maxwidth=' . $a->videowidth); break; } } @@ -105,12 +108,12 @@ class OEmbed $txt = '{"type":"error"}'; } else { //save in cache $j = json_decode($txt); - if ($j->type != "error") { + if (!empty($j->type) && $j->type != "error") { dba::insert('oembed', [ 'url' => normalise_link($embedurl), 'maxwidth' => $a->videowidth, 'content' => $txt, - 'created' => datetime_convert() + 'created' => DateTimeFormat::utcNow() ], true); } @@ -247,7 +250,7 @@ class OEmbed { $stopoembed = Config::get("system", "no_oembed"); if ($stopoembed == true) { - return preg_replace("/\[embed\](.+?)\[\/embed\]/is", "" . t('Embedding disabled') . " : $1", $text); + return preg_replace("/\[embed\](.+?)\[\/embed\]/is", "" . L10n::t('Embedding disabled') . " : $1", $text); } return preg_replace_callback("/\[embed\](.+?)\[\/embed\]/is", ['self', 'replaceCallback'], $text); } @@ -312,7 +315,7 @@ class OEmbed $allowed = explode(',', $str_allowed); - return allowed_domain($domain, $allowed); + return Network::isDomainAllowed($domain, $allowed); } public static function getHTML($url, $title = null) @@ -367,7 +370,7 @@ class OEmbed $width = '100%'; $src = System::baseUrl() . '/oembed/' . base64url_encode($src); - return ''; + return ''; } /**