|
  
- 主题
- 44
- 精华
- 2
- 积分
- 17681
- 荔枝
- 1436 颗
- 龙眼
- 395 个
- 香蕉
- 385 条
- 在线时间
- 67 小时
|
修改discuzcode.func.php里面的多媒体相关代码为HTML5控件方案
禁用原BBcode [flash]5 v7 A6 Q1 o( z( V
- if($allowmediacode && strpos($msglower, '[/flash]') !== FALSE) { $message = preg_replace("/\[flash\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", "<script type=\"text/javascript\" reload=\"1\">document.write(AC_FL_RunContent(...));</script>", $message);}
复制代码 2 b5 T! t- I8 w1 g# |8 `: s
改成直接显示链接地址:
" T3 _& {! Y+ _0 S( b3 t- if($allowmediacode && strpos($msglower, '[/flash]') !== FALSE) {
- $message = preg_replace(
- "/\[flash\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is",
- '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>',
- $message
- );
- }
复制代码
3 s( p$ P) N2 }# o0 K! u! p ^" M" E# w& M4 @5 j0 J& ]7 p0 u
顺便禁用 [swf]:
3 ]" S' S5 |. L' b8 H0 H5 Z! ~- if($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) {
- $message = preg_replace("/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/ies",
- "bbcodeurl('\\1', ' <img src=\"images/attachicons/flash.gif\" ... Flash: %s</a> ')",
- $message);
- }
复制代码
~6 s+ f% b0 I1 _ \替换为链接:
2 A6 [+ a( S1 P- if($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) {
- $message = preg_replace(
- "/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/ies",
- "'<a href=\"$1\" target=\"_blank\" rel=\"noopener noreferrer\">$1</a>'",
- $message
- );
- }
复制代码
6 O+ n6 ~' v, o4 ?9 k+ K( b7 k( K, J0 i
原代码 parseaudio()(MP3音频等):- function parseaudio($url, $width = 400, $autostart = 0) {
- ...
- <object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6">
- ...
- }
复制代码 ✅ 换成 HTML5- function parseaudio($url, $width = 400, $autostart = 0) {
- $url = str_replace('\\"', '"', $url);
- return '<audio controls style="width:100%;max-width:'.$width.'px;border-radius:6px;" src="'.$url.'"></audio>';
- }
复制代码 原FALSH多媒体代码:- function parsemedia($params, $url) {
- ...
- AC_FL_RunContent(...)
- }
复制代码 ✅ 改成 HTML5 优先:- function parsemedia($params, $url) {
- $params = explode(',', $params);
- $width = isset($params[1]) ? min(intval($params[1]), 800) : 400;
- $height = isset($params[2]) ? min(intval($params[2]), 600) : 300;
- $url = str_replace(array('<', '>'), '', str_replace('\\"', '"', $url));
- $ext = strtolower(substr(strrchr($url, '.'), 1, 5));
- if(in_array($ext, array('mp3','wav','ogg'))) {
- return '<audio controls style="width:100%;max-width:'.$width.'px;">'.
- '<source src="'.$url.'" type="audio/mpeg"></audio>';
- }
- if(in_array($ext, array('mp4','webm'))) {
- return '<video controls style="width:100%;max-width:'.$width.'px;">'.
- '<source src="'.$url.'" type="video/mp4"></video>';
- }
- // 其他一律当链接
- return '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url.'</a>';
- }
复制代码 |
|