|
  
- 主题
- 44
- 精华
- 2
- 积分
- 17681
- 荔枝
- 1436 颗
- 龙眼
- 395 个
- 香蕉
- 385 条
- 在线时间
- 67 小时
|
5楼
发表于 2026-5-18 11:38
| 只看该作者
修改discuzcode.func.php里面的多媒体相关代码为HTML5控件方案
禁用原BBcode [flash]
@+ |& D; f& \2 s4 d7 h r# x% ?- 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);}
复制代码 9 j! G/ c/ N1 [
改成直接显示链接地址:2 M, B8 u3 E% 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
- );
- }
复制代码
6 n' O! e" V# L: f# H4 B. v- c3 G+ c
n+ O" Z! R& e. b顺便禁用 [swf]:
% V) d5 t3 Q" i4 k( {- 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);
- }
复制代码
/ ^9 L7 X* R+ ]( f7 b替换为链接:
7 w1 K0 p- I9 u: F* E. t- 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
- );
- }
复制代码
5 t5 N. R( `4 \
0 P; Z) F4 r, w2 V4 L; S原代码 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>';
- }
复制代码 |
|