|
  
- 主题
- 44
- 精华
- 2
- 积分
- 17681
- 荔枝
- 1436 颗
- 龙眼
- 395 个
- 香蕉
- 385 条
- 在线时间
- 67 小时
|
5楼
发表于 2026-5-18 11:38
| 只看该作者
修改discuzcode.func.php里面的多媒体相关代码为HTML5控件方案
禁用原BBcode [flash]8 Q3 Q1 D+ R) R& s N: c3 t( ^
- 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);}
复制代码 1 }# y2 p: ~/ n7 w- @
改成直接显示链接地址:+ T3 {) j+ q. v
- 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
- );
- }
复制代码 ! E* O0 Q1 m6 w. e" l! \
0 ^: [) a# h, z; z( s顺便禁用 [swf]:! y8 Z& {" w; o8 C' ?7 ]7 M l& [6 `
- 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);
- }
复制代码
: \2 [. M% v9 Y替换为链接:/ |& e( d r8 o" |. |" G
- 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
- );
- }
复制代码 & a" N( V5 g+ T, O
9 a8 I8 U. Q0 y ?- v( d原代码 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>';
- }
复制代码 |
|