|
  
- 主题
- 43
- 精华
- 2
- 积分
- 17508
- 荔枝
- 1424 颗
- 龙眼
- 390 个
- 香蕉
- 375 条
- 在线时间
- 65 小时
|
5楼
发表于 2026-5-18 11:38
| 只看该作者
修改discuzcode.func.php里面的多媒体相关代码为HTML5控件方案
禁用原BBcode [flash]
! j2 t! z% i) V) E8 E% W& y- 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);}
复制代码
* i% y& w$ d0 r改成直接显示链接地址:& y7 b6 F ]. ?, e; L; f
- 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
- );
- }
复制代码 # I% n! _0 X! {+ x2 b$ a/ O
, s2 b0 a& f. H) L/ K# E, j. Q7 h
顺便禁用 [swf]:1 \0 H: t% g& ^: s: b: c$ J
- 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 I9 k. N, P$ |; A4 J. {- s
替换为链接:
( E0 l4 `0 H; i7 A F, l) L) R8 S- 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
- );
- }
复制代码
% t! U! U& a7 ^" Z- z4 B+ f, Y5 T1 e
" f- N8 U& k' o( L原代码 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>';
- }
复制代码 |
|