|
  
- 主题
- 44
- 精华
- 2
- 积分
- 17681
- 荔枝
- 1436 颗
- 龙眼
- 395 个
- 香蕉
- 385 条
- 在线时间
- 67 小时
|
5楼
发表于 2026-5-18 11:38
| 只看该作者
修改discuzcode.func.php里面的多媒体相关代码为HTML5控件方案
禁用原BBcode [flash]
% ~1 s4 _( w8 l! Z% g: z- 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);}
复制代码 - x ? V/ G) y
改成直接显示链接地址:
& \: Y1 ^, K0 u* [- 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
- );
- }
复制代码 6 G2 W& {6 H3 Y( L" m1 u- R) ~
& ^# p) q+ Q2 S+ v+ E6 U+ {
顺便禁用 [swf]: Y- @) G# ]+ X7 x9 Q0 j- t
- 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);
- }
复制代码 % @4 U4 y/ h! _4 K& v- y
替换为链接:8 Q) _5 ?; V: t! 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
- );
- }
复制代码 ; m* Z* T& l5 G% ~8 E. L
1 g* l2 b: f& g9 N
原代码 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>';
- }
复制代码 |
|