- 最后登录
- 2010-9-1
- 威望
- 3282 点
- 金币
- 8512 元
- 注册时间
- 2006-9-25
- 阅读权限
- 255
- 精华
- 98
- 积分
- 11794
- 帖子
- 4199
    
|
标题:超酷播放器UBB标签 FOR Discuz! 6.0正式版
=========================
插件名称:超酷播放器UBB标签
适合版本:Discuz! 6.0正式版
发布日期:2007-9-5
发 布 人: 2046
演 示:http://club.cimgoo.com/thread-230779-1-1.html
技术支持:Discuz!官方论坛
=========================
A、手动修改方法见下面的详细步骤,强烈推荐;你也可以直接下载我们做好的相应版本完整插件包直接上传覆盖你的原来文件,但记得一定要备份原始文件以防意外;如果你装过其他播放器插件,建议先删除(与DZ系统内置的所有播放标签都没有冲突,而且可以同时使用!)。
B、大家在安装过程中有什么问题直接到我站发贴提问 http://club.cimgoo.com/forum-60-1.html ,我会第一时间答疑帮助,有什么建议和BUG希望大家提出,我会努力改进。
C、插件在“西谷IT社区”正式应用,而且永久和官方版本同步更新,关注本插件最新版本直接到
http://club.cimgoo.com/thread-230778-1-1.html免费下载。
D、此次版本较以前版本在安全机制上改动较大,对JavaScript嵌入攻击、钓鱼做过很好的防御,强烈建议更新。
E、插入要在Discuz!代码模式下进行。
一、需要添加的文件:
复制下面附件的 ubb_dialog.php 文件到根目录
ubb_dialog.php
复制下面附件的 bb_player.gif 图片到 ./images/common/目录下
二、需要修改的代码:
1、打开./include/discuzcode.func.php文件,查找:
-
- for($i = 0; $i <= $discuzcodes['pcodecount']; $i++) {
复制代码 在他前面加如以下代码:-
- /*--------------------------------------------- CIMGOO --------------------------------------->>>---*/
- $allowplayercode = $allowsmilies;
- if(!$bbcodeoff && $allowplayercode && $GLOBALS['player_ubb_on']) {
- if(empty($discuzcodes['searcharray']['playercode'])) {
- $discuzcodes['searcharray']['playercode'] = array(
- "/\[mp\](.+?)\[\/mp\]/eis",
- "/\[mp=(\d)\](.+?)\[\/mp\]/eis",
- "/\[wmv\](.+?)\[\/wmv\]/eis",
- "/\[wmv=(\d{1,3})\,(\d{1,3})\,(\d)\](.+?)\[\/wmv\]/eis",
- "/\[rm\](.+?)\[\/rm\]/eis",
- "/\[rm=(\d{1,3})\,(\d{1,3})\,(\d)\](.+?)\[\/rm\]/eis"
- );
- $discuzcodes['replacearray']['playercode'] = array(
- "media_player('mp', '\\1')",
- "media_player('mp', '\\2', '\\1')",
- "media_player('wmv', '\\1')",
- "media_player('wmv', '\\4', '\\3', '\\1', '\\2')",
- "media_player('rm' , '\\1')",
- "media_player('rm' , '\\4', '\\3', '\\1', '\\2')"
- );
- }
- $message = preg_replace($discuzcodes['searcharray']['playercode'], $discuzcodes['replacearray']['playercode'], $message);
- }
- /*--------------------------------------------- CIMGOO ---------------------------------------<<<---*/
复制代码 在文件尾("?>"之前) 添加以下代码:-
- /*--------------------------------------------- CIMGOO --------------------------------------->>>---*/
- $player_ubb_on = true; //是否开启
- $player_num = 0;
- $player_pre = mt_rand();
- function media_player($type, $url, $auto = 0, $width = 450, $height = 340) {//需默认自动开始播放,请将$auto = 0改为$auto = 1
- global $player_pre, $player_num;
- $pid = $player_pre.'_'.$player_num;
- if($type == 'rm') {
- $player = <<<html
- <object classid="CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="$width" height="$height" id="player_{$pid}">
- <param name="Console" value="Console_{$pid}">
- <param name="Controls" value="ImageWindow">
- <param name="AutoStart" value="0">
- <param name="Src" value="http://cnguy.com/">
- </object>
- <object classid="CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="$width" height="32">
- <param name="Console" value="Console_{$pid}">
- <param name="Controls" value="ControlPanel">
- </object>
- html;
- } else {
- if ($type == 'mp') {
- $width = 280; $height = 69;
- }else {
- $height += 69;
- }
- $player = <<<html
- <object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="$width" height="$height" id="player_{$pid}">
- <param name="AutoStart" value="0">
- <param name="ShowStatusBar" value="1">
- <!--param name="EnableContextMenu" value="0"-->
- <param name="FileName" value="http://cnguy.com/">
- </object>
- html;
- }
- $url = explode("\r\n", trim($url));
- $select = "播放> <select id=\"select_{$pid}\" onchange=\"player_change('$pid', '$type')\">";
- foreach ($url as $key => $value) {
- $value = preg_replace("/<a href=\"(.[^\"']+)\"(.+?)<\/a>/i","\\1", str_replace('\"','"',$value));
- $one = explode('|', $value);
- $one[0] = str_replace('"', '"', trim($one[0]));
- if(!$one[0]) continue;
- ++$count;
- $select .= "<option value=\"{$one[0]}\"> $count ".cutstr(trim($one[1]), 20)." </option>";
- }
- $select .= '</select>';
- if($type != 'mp') {
- $full = "<a href=\"###\" onclick=\"javascript:player_fullscreen('$pid', '$type')\">全屏播放</a> ";
- } else { $full = ''; }
- $prev_next = "<a href=\"###\" onclick=\"player_prev('$pid', '$type');\">上一集</a> ";
- $prev_next .= "<a href=\"###\" onclick=\"player_next('$pid', '$type');\">下一集</a> ";
- $cp = '© CIMGOO.COM';
- if($count == 1) {
- $select = "<div style=\"display:none\">$select</div>";
- $select .= $cp;
- $prev_next = '';
- }
- $player = <<<html
- <table class="msgborder" style="width:auto;">
- <tr class="msgheader"><td style="padding:5px;">
- Web Media Player ( x$count )
- </td><td align="right">
- <a href="###" id="expand_{$pid}" onclick="player_expand('$pid', '$type')">展开</a>
- </td></tr>
- <tbody id="tbody_$pid" style="display:none;">
- <tr><td colspan="2">
- $player
- </td></tr>
- </tbody>
- <tr><td colspan="2">
- <span id="cp_$pid" style="float:right">$cp</span>
- <span id="buttons_$pid" style="display:none;">
- <div style="float:right;">$select</div>{$full}{$prev_next}
- </span>
- <a href="###" id="download_$pid" onclick="player_showurl('$pid');">显示地址</a>
- </td></tr>
- <tr><td colspan="2" id="url_$pid" style="display:none;">
- </td></tr>
- </table>
- html;
- if ($auto) {
- $player .= "<script type=\"text/javascript\">player_change('$pid', '$type');</script>";
- }
- $player_num ++;
- //$player = str_replace(array("\t","\r","\n"), '', $player);
- $player = preg_replace("/\s+/s", ' ', $player);
- return $player;
- }
- /*--------------------------------------------- CIMGOO ---------------------------------------<<<---*/
复制代码 2、打开./include/javascript/common.js文件。在末尾添加以下代码:-
- /*--------------------------------------------- CIMGOO --------------------------------------->>>---*/
- function player_fullscreen(pid, t)
- {
- var p = $('player_' + pid);
- if(t == 'rm') {
- if(!p.CanStop()) {
- alert('影片未开始,无法全屏!');
- } else {
- alert('将进入全屏模式,按Esc键退出全屏!');
- p.SetFullScreen();
- }
- } else if(t == 'wmv' || t == 'mp') {
- if(p.playstate != 2) {
- alert('影片未开始,无法全屏!');
- } else {
- alert('将进入全屏模式,双击可退出全屏!');
- p.DisplaySize = 3;
- }
- }
- }
- function player_expand(pid, t)
- {
- var pl = $('player_' + pid);
- var tb = $('tbody_' + pid);
- var bt = $('buttons_' + pid);
- var ep = $('expand_' + pid);
- var cp = $('cp_' + pid);
- if(tb.style.display == 'none') {
- tb.style.display = 'block';
- bt.style.display = 'inline';
- cp.style.display = 'none';
- ep.innerHTML = '关闭';
- if(t == 'rm') {
- if(pl.GetSource() == 'http://cnguy.com/') {
- player_change(pid, t);
- }
- pl.DoPlay();
- } else if(t == 'wmv' || t == 'mp') {
- pl.autostart = true;
- if(pl.filename == 'http://cnguy.com/') {
- player_change(pid, t);
- }
- pl.play();
- }
- } else {
- tb.style.display = 'none';
- bt.style.display = 'none';
- ep.innerHTML = '展开';
- cp.style.display = 'inline';
- if(t == 'rm') {
- pl.DoPause();
- } else if(t == 'wmv' || t == 'mp') {
- pl.pause();
- }
- }
- }
- function player_change(pid, t)
- {
- var p = $('player_'+pid);
- var s = $('select_'+pid);
- if($('tbody_'+pid).style.display == 'none') {
- player_expand(pid, t);
- }
- if(t == 'rm') {
- p.DoStop();
- p.SetSource(s.options[s.selectedIndex].value);
- p.DoPlay();
- } else if(t == 'wmv' || t == 'mp') {
- p.stop();
- p.filename = s.options[s.selectedIndex].value;
- p.play();
- }
- self.focus();
- }
- function player_prev(pid, t)
- {
- var s = $('select_' + pid);
- if(s.selectedIndex == 0) {
- alert('这已经是第一集了!'); return;
- }
- s.selectedIndex = s.selectedIndex - 1;
- player_change(pid, t);
- }
- function player_next(pid, t)
- {
- var s = $('select_' + pid);
- if(s.selectedIndex == s.options.length - 1) {
- alert('这已经是最后一集了!'); return;
- }
- s.selectedIndex = s.selectedIndex + 1;
- player_change(pid, t);
- }
- function player_showurl(pid)
- {
- var u = $('url_' + pid);
- if(u.style.display == 'none')
- {
- var s = $('select_' + pid);
- var temp = '';
- for(i=0; i<s.options.length ;i++)
- {
- temp += s.options.text + ' <a href="' + s.options.value + '" target="_blank">' + s.options.value + '</a>
- ';
- }
- u.innerHTML = temp;
- u.style.display = 'block';
- $('download_' + pid).innerHTML = '隐藏地址';
- } else {
- u.innerHTML = '';
- u.style.display = 'none';
- $('download_' + pid).innerHTML = '显示地址'
- }
- }
- /*---------------------------------------------CIMGOO---------------------------------------<<<---*/
复制代码
3、打开./include/javascript/editor.js文件。在文件尾添加以下代码:-
- /*--------------------------------------------- CIMGOO --------------------------------------->>>---*/
- function CNGUY_UBB(mod) {
- if(wysiwyg) {
- alert('请在代码模式下使用');
- return false;
- }
- var selection = getSel();
- if(selection === false) {
- selection = '';
- } else {
- selection += '';
- }
- var text = showModalDialog("./ubb_dialog.php?mod="+mod, selection, "dialogWidth:28em; dialogHeight:21em; status:yes; help:no; scroll:no");
- if (text === undefined) {
- return false;
- }
- addSnapshot(getEditorContents());
- checkFocus();
- insertText(text, mb_strlen(text), 0);
- addSnapshot(getEditorContents());
- checkFocus();
- return false;
- }
- /*---------------------------------------------CIMGOO---------------------------------------<<<---*/
复制代码
4、打开./template/default/post_editor.htm文件(如果你改模板也改过该文件,就到相应位置改这个文件),查找以下:-
- <!--{if $allowhidecode}--><td><a id="{$editorid}_cmd_hide"><img
- src="images/common/bb_hide.gif" title="{lang post_discuzcode_hide}" alt="Hide" /></a></td><!--{/if}-->
复制代码 在下面添加:-
- <td><div class="editor_buttonnormal" id="{$editorid}_cmd_insertplayer" onclick="CNGUY_UBB('player')" onMouseOver="buttonContext(this, 'mouseover')" onMouseOut="buttonContext(this, 'mouseout')"><img src="images/common/bb_player.gif" width="21" height="20" alt="插入UBB播放器" /></div></td>
复制代码 到此你的播放器就完成了,如果你想修改播放器样式,让他变的更酷更个性化,可以修改include\discuzcode.func.php下的相应代码实现(在上面加入的代码里面找)。关于播放器样式代码可以参考: http://club.cimgoo.com/thread-8389-1-1.html ,文章有详细解释。
下面是完整插件包(直接覆盖),做插件不容易啊(又是两个通宵,专门做个压力和攻击测试),希望大家支持下!>> |
|