879 Star 3.6K Fork 1.5K

Discuz / DiscuzX

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
media_youtube.php 715 Bytes
一键复制 编辑 原始数据 按行查看 历史
老周部落 提交于 2021-12-18 04:23 . !1349修复 防沦陷安全更新
<?php
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$checkurl = array('youtube.com/watch?');
function media_youtube($url, $width, $height) {
if(preg_match("/^https?:\/\/(|m.|www.)youtube.com\/watch\?v=([^\/&]+)&?/i", $url, $matches)) {
$flv = 'https://www.youtube.com/v/'.$matches[2].'&fs=1';
$iframe = 'https://www.youtube.com/embed/'.$matches[2];
if(!$width && !$height) {
$str = dfsockopen($url);
if(!empty($str) && preg_match("/'VIDEO_HQ_THUMB':\s'(.+?)'/i", $str, $image)) {
$url = substr($image[1], 0, strrpos($image[1], '/')+1);
$filename = substr($image[1], strrpos($image[1], '/')+3);
$imgurl = $url.$filename;
}
}
}
return array($flv, $iframe, $url, $imgurl);
}
PHP
1
https://gitee.com/Discuz/DiscuzX.git
git@gitee.com:Discuz/DiscuzX.git
Discuz
DiscuzX
DiscuzX
master

搜索帮助