恋雾迷尘论坛's Archiver

爱雨冷雪 发表于 2005-9-8 14:58

Player's UBB Tags for Discuz! 论坛用播放器UBB标签

[color=red]作品: Player's UBB Tags for Discuz!
作者: Kinpoo (www.CNGUY.com)
日期: 2005.07.23[/color]


[quote]
功能简介:


        1.增加下列播放器标签(注:自动=1,手动=0)
                [mp]http://www.xxx.com/1.mp3[/mp]
                //用于播放mp3等无图像的media player可播放的文件

                [mp=1]http://www.xxx.com/1.mp3[/mp]
                //用于播放mp3等无图像的media player可播放的文件 带可控的[自动或手动]参数

                [wmv]http://www.xxx.com/1.wmv[/wmv]
                //用于播放media player可播放的文件

                [wmv=450,350,1]http://www.xxx.com/1.wmv[/wmv]
                //用于播放media player可播放的文件 带可控的[宽度,高度,自动或手动]参数

                [rm]http://www.xxx.com/1.rm[/rm]
                //用于播放real player可播放的文件

                [rm=450,350,1]http://www.xxx.com/1.rm[/rm]
                //用于播放real player可播放的文件 带可控的[宽度,高度,自动或手动]参数

        2.有图像的可以全屏观看
        3.支持一页内插入多个播放器(至多有一个播放器设置为自动播放,其他设置为手动)
        4.支持带有空格的url
        5.带有可控开关
        6.提供媒体文件url使播放器更加人性化
[/quote]

[color=#008000]适用版本:
        Discuz! 2.5F
        其他版本未验证
修改程序列表:
        ./include/discuzcode.php
        ./viewpro.php
        ./viewthread.php
        ./include/bbcode.js
修改模版列表:
        ./templates/相应的模版目录/post_bbinsert.htm
        ./templates/相应的模版目录/templates.lang.php[/color]


[quote]
功能演示地址:
                 一:http://haohao036.meibu.com/bbs/p ... ;fid=51&typeid=
                 (感谢haohao036提供演示)
                 test id: test
                 test password: test

                 二:http://bbs.cnguy.com/post.php?fid=180
                 (这是pw版的 功能是一样)
                 http://bbs.cnguy.com/read.php?tid=6934
                 test id: test
                 test password: 123456
[/quote]


[quote]
作品内容:
/*
BEGIN||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||BEGIN
*/

建议按照附件中的文本进行修改

====================================================================================
上传图片文件

------------------------------------------------------------------------------------

0.将bb_rm.gif,bb_wmv.gif,bb_mp.gif放到 "./images/相应的风格目录/" 里
bb_rm.gif
bb_wmv.gif
bb_mp.gif
没有找到好的图标 自己又不会做 见谅~

====================================================================================

====================================================================================
修改程序文件 共六步
------------------------------------------------------------------------------------
./include/discuzcode.php(三步)
./viewpro.php(一步)
./viewthread.php(一步)
./include/bbcode.js(一步)
====================================================================================
[/quote]

1.修改./include/discuzcode.php
1.1找到

[code]for($i = 0; $i <= $post_codecount; $i++) {[/code]

在上面加上

[code]/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com---BEGIN*/
        if(!$bbcodeoff && $allowplayercode && $GLOBALS['player_ubb_on']) {
                if(empty($searcharray['playercode']) || empty($replacearray['playercode'])) {
                        $searcharray['playercode'] = array(
                                "/\[mp\](.+?)\[\/mp\]/eis",
                                "/(\[mp=)([0-1]{1,1})(\])(.+?)(\[\/mp\])/eis",
                                "/\[wmv\](.+?)\[\/wmv\]/eis",
                                "/(\[wmv=)([0-9]{1,3})(\,)([0-9]{1,3})(\,)([0-1]{1,1})(\])(.+?)(\[\/wmv\])/eis",
                                "/\[rm\](.+?)\[\/rm\]/eis",
                                "/(\[rm=)([0-9]{1,3})(\,)([0-9]{1,3})(\,)([0-1]{1,1})(\])(.+?)(\[\/rm\])/eis"               
                        );
                        $replacearray['playercode'] = array(
                                "mediaplayer('\\1','-01')",
                                "mediaplayer('\\4','\\2','-01')",
                                "mediaplayer('\\1','-00')",
                                "mediaplayer('\\8','\\6','\\2','\\4')",
                                "realplayer('\\1')",
                                "realplayer('\\8','\\2','\\4','\\6')"
                        );
                }
                $message = preg_replace($searcharray['playercode'], $replacearray['playercode'], $message);
        }
/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com-----END*/[/code]

1.2找到

[code]?>[/code]

在上面加上

[code]/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com---BEGIN*/
################################################config begin############################
//"true" or "1" is on,"false" or "0" is off
$download_media=true;        //show media file url or not
$player_ubb_on=true;        //use player ubb or not
#################################################config end#############################
function realplayer($realmediaurl,$realwidth=450,$realheight=350,$realautostart=1){
        global $discuz_uid,$download_media,$realplayernum;
        !$realplayernum && $realplayernum = 0;
        if($download_media){
                if($discuz_uid){
                        $realpalyerifuser="<a href='$realmediaurl' style='color=orangered'>Download Media File</a>";
                }else{
                        $realpalyerifuser="<a href='./logging.php?action=login' style='color=orangered'>Download Media File-Please Login</a>";
                }
        }else{
                $realpalyerifuser='';
        }
        $realplayerhtml="<br><OBJECT classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' id='RAOCX$realplayernum' width='$realwidth' height='$realheight'><PARAM NAME='SRC' VALUE='$realmediaurl'><PARAM NAME='CONSOLE' VALUE='realplayer$realplayernum'><PARAM NAME='CONTROLS' VALUE='Imagewindow'><PARAM NAME='AUTOSTART' VALUE='$realautostart'></OBJECT><br><OBJECT classid='CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA' height='32' id='video$realplayernum' width='$realwidth'><PARAM NAME='SRC' VALUE='$realmediaurl'><PARAM NAME='AUTOSTART' VALUE='$realautostart'><PARAM NAME='CONTROLS' VALUE='controlpanel'><PARAM NAME='CONSOLE' VALUE='realplayer$realplayernum'></OBJECT><br><script language=javascript>function real_full$realplayernum(){if(!document.RAOCX$realplayernum.CanStop()){alert('影片未开始,无法全屏!');}else{alert('将进入全屏模式,按Esc键退出全屏!');document.RAOCX$realplayernum.SetFullScreen();}}</script><input type='button' name='rmplayer$realplayernum' onclick='javascript:real_full$realplayernum()' value='全屏播放'>&nbsp;$realpalyerifuser<br>";
        $realplayernum++;
        return $realplayerhtml;
}
function mediaplayer($wmmediaurl,$mediaauto,$mediawidth=450,$mediaheight=350){
        global $discuz_uid,$download_media,$mediaplayernum;
        !$mediaplayernum && $mediaplayernum = 0;
        $mediaallscreen="<script language=javascript>function media_full$mediaplayernum(){alert('将进入全屏模式,按Esc键退出全屏!\\n若影片未加载成功将无法进入全屏!');document.MediaPlayer$mediaplayernum.DisplaySize=3;}</script><input type='button' name='mplayer$mediaplayernum' onclick='javascript:media_full$mediaplayernum()' value='全屏播放'>&nbsp;";
        if($download_media){
                if($discuz_uid){
                        $mediapalyerifuser="<a href='$wmmediaurl' style='color:orangered;'>Download Media File</a>";
                }else{
                        $mediapalyerifuser="<a href='./logging.php?action=login' style='color:orangered;'>Download Media File-Please Login</a>";
                }
        }else{
                $mediapalyerifuser='';
        }
        if($mediaauto==="-00"){
                $mediaauto=1;
        }elseif($mediaauto=="-01"){
                $mediaauto=1;
                $mediaallscreen="";
                $mediawidth=280;
                $mediaheight=69;
        }
        if($mediawidth=="-01"){
                $mediaallscreen="";
                $mediawidth=280;
                $mediaheight=69;
        }
        $mediaplayerhtml="<br><OBJECT align='middle' classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' id='MediaPlayer$mediaplayernum' width='$mediawidth' height='$mediaheight'><param name='autostart' value='$mediaauto'><param name='ShowStatusBar' value='-1'><param name='Filename' value='$wmmediaurl'></OBJECT><br>$mediaallscreen$mediapalyerifuser<br>";
        $mediaplayernum++;
        return $mediaplayerhtml;
}
/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com-----END*/[/code]

1.3找到

[code]function postify($message, $smileyoff, $bbcodeoff, $allowsmilies = 1, $allowhtml = 0, $allowbbcode = 1, $allowimgcode = 1) {[/code]

修改为
[code]function postify($message, $smileyoff, $bbcodeoff, $allowsmilies = 1, $allowhtml = 0, $allowbbcode = 1, $allowimgcode = 1, $allowplayercode=1) {        //", $allowplayercode=1" added for player ubb,by kinpoo[/code]

2.修改./viewpro.php
找到
[code]$member['signature'] = postify($member['signature'], 1, 0, 0, 0, $member['allowsigbbcode'], $member['allowsigimgcode']);[/code]

修改为
[code]$member['signature'] = postify($member['signature'], 1, 0, 0, 0, $member['allowsigbbcode'], $member['allowsigimgcode'], 0);        //the last ", 0" added for player ubb,by kinpoo[/code]

3.修改./viewthread.php
找到

[code]$post['signature'] = $post['usesig'] && $post['signature'] ? postify($post['signature'], 1, 0, 0, 0, $_DCACHE['usergroups'][$post['groupid']]['allowsigbbcode'], $_DCACHE['usergroups'][$post['groupid']]['allowsigimgcode']) : NULL;[/code]

修改为

[code]$post['signature'] = $post['usesig'] && $post['signature'] ? postify($post['signature'], 1, 0, 0, 0, $_DCACHE['usergroups'][$post['groupid']]['allowsigbbcode'], $_DCACHE['usergroups'][$post['groupid']]['allowsigimgcode'], 0) : NULL;        //the last ", 0" added for player ubb,by kinpoo[/code]

4.修改./include/bbcode.js
在文件的末尾加上

[code]/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com---BEGIN*/
function realplayer() {
        if (helpmode) {
                alert(realplayer_help);
        } else if (getSelectedText()) {
                var        range =        document.selection.createRange();
                range.text = "[rm]" + range.text +        "[/rm]";
        } else if (advmode)        {
                AddTxt="[rm] [/rm]";
                AddText(AddTxt);
        } else {
                txt2=prompt(realplayer_normal,"450,350,1");
                if (txt2!=null)        {
                        txt=prompt(realplayer_normal_input,"");         
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[rm]"+txt;
                                        AddText(AddTxt);
                                        AddText("[/rm]");
                                } else {
                                        AddTxt="[rm="+txt2+"]"+txt;
                                        AddText(AddTxt);
                                        AddText("[/rm]");
                                }                  
                        }
                }
        }
}
function wmvplayer() {
        if (helpmode) {
                alert(wmvplayer_help);
        } else if (getSelectedText()) {
                var        range =        document.selection.createRange();
                range.text = "[wmv]" + range.text +        "[/wmv]";
        } else if (advmode)        {
                AddTxt="[wmv] [/wmv]";
                AddText(AddTxt);
        } else {
                txt2=prompt(wmvplayer_normal,"450,350,1");
                if (txt2!=null)        {
                        txt=prompt(wmvplayer_normal_input,"");         
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[wmv]"+txt;
                                        AddText(AddTxt);
                                        AddText("[/wmv]");
                                } else {
                                        AddTxt="[wmv="+txt2+"]"+txt;
                                        AddText(AddTxt);
                                        AddText("[/wmv]");
                                }                  
                        }
                }
        }
}
function mp3player() {
        if (helpmode) {
                alert(mp3player_help);
        } else if (getSelectedText()) {
                var        range =        document.selection.createRange();
                range.text = "[mp]" + range.text +        "[/mp]";
        } else if (advmode)        {
                AddTxt="[mp] [/mp]";
                AddText(AddTxt);
        } else {
                txt2=prompt(mp3player_normal,"1");
                if (txt2!=null)        {
                        txt=prompt(mp3player_normal_input,"");         
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[mp]"+txt;
                                        AddText(AddTxt);
                                        AddText("[/mp]");
                                } else {
                                        AddTxt="[mp="+txt2+"]"+txt;
                                        AddText(AddTxt);
                                        AddText("[/mp]");
                                }                  
                        }
                }
        }
}
/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com-----END*/[/code]

====================================================================================
修改模版文件 共三步
------------------------------------------------------------------------------------
./templates/相应的模版目录/post_bbinsert.htm(两步)
./templates/相应的模版目录/templates.lang.php(一步)
====================================================================================
5.修改post_bbinsert.htm
5.1找到

[code]var center_normal = "{lang post_discuzcode_center_normal}";[/code]

在下面加上

[code]/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com---BEGIN*/
        var realplayer_help = "{lang post_discuzcode_realplayer}\n\n{lang post_discuzcode_realplayer_comment}";
        var realplayer_normal = "{lang post_discuzcode_realplayer_normal}";
        var realplayer_normal_input = "{lang post_discuzcode_realplayer_normal_input}";
        var realplayer_help = "{lang post_discuzcode_wmvplayer}\n\n{lang post_discuzcode_wmvplayer_comment}";
        var wmvplayer_normal = "{lang post_discuzcode_wmvplayer_normal}";
        var wmvplayer_normal_input = "{lang post_discuzcode_wmvplayer_normal_input}";
        var mp3player_help = "{lang post_discuzcode_mp3player}\n\n{lang post_discuzcode_mp3player_comment}";
        var mp3player_normal = "{lang post_discuzcode_mp3player_normal}";
        var mp3player_normal_input = "{lang post_discuzcode_mp3player_normal_input}";
/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com-----END*/[/code]

5.2找到

[code]<a href="javascript:center()"><img src="{IMGDIR}/bb_center.gif" border="0" alt="{lang post_discuzcode_center}"></a>[/code]

在下面加上

[code]        <!--------------------------------------------------------------------------PLAYER--START-->
        <a href="javascript:realplayer()"><img src="{IMGDIR}/bb_rm.gif" border="0" alt="{lang post_discuzcode_realplayer}"></a>
        <a href="javascript:wmvplayer()"><img src="{IMGDIR}/bb_wmv.gif" border="0" alt="{lang post_discuzcode_wmvplayer}"></a>
        <a href="javascript:mp3player()"><img src="{IMGDIR}/bb_mp.gif" border="0" alt="{lang post_discuzcode_mp3player}"></a>
        <!--------------------------------------------------------------------------PLAYER--END-->[/code]

6.修改templates.lang.php
找到

[code]'post_discuzcode_center_normal' => '请输入要居中对齐的文字。',[/code]

在下面加上

[code]/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com---BEGIN*/
        'post_discuzcode_realplayer' => '插入一个Real播放器',
        'post_discuzcode_realplayer_comment' => '插入一个Real播放器。\n例如:\n[rm]http://www.cnguy.com/1.rm[/rm]\n[rm=450,350,1]http://www.cnguy.com/1.rm[/rm]',
        'post_discuzcode_realplayer_normal' => '播放器的[宽度,高度,自动播放与否(1代表自动播放 0为手动播放)]。\n如无特别需要,保留默认即可。',
        'post_discuzcode_realplayer_normal_input' => '请输入Real Player可以播放的媒体文件 URL。',
        'post_discuzcode_wmvplayer' => '插入一个Media播放器',
        'post_discuzcode_wmvplayer_comment' => '插入一个Media播放器。\n例如:\n[wmv]http://www.cnguy.com/1.wmv[/wmv]\n[wmv=450,350,1]http://www.cnguy.com/1.wmv[/wmv]',
        'post_discuzcode_wmvplayer_normal' => '播放器的[宽度,高度,自动播放与否(1代表自动播放 0为手动播放)]。\n如无特别需要,保留默认即可。',
        'post_discuzcode_wmvplayer_normal_input' => '请输入Media Player可以播放的媒体文件 URL。',
        'post_discuzcode_mp3player' => '插入一个MP3播放器',
        'post_discuzcode_mp3player_comment' => '插入一个无图像Media播放器。\n例如:\n[mp]http://www.cnguy.com/1.mp3[/mp]\n[mp=1]http://www.cnguy.com/1.mp3[/mp]',
        'post_discuzcode_mp3player_normal' => '播放器的[自动播放与否(1代表自动播放 0为手动播放)]。\n如无特别需要,保留默认即可。',
        'post_discuzcode_mp3player_normal_input' => '请输入Media Player可以播放的无图像媒体文件 URL。',
/*------------------------------------------------PLAYER UBB CODE--BY KINPOO--HTTP://www.CNGUY.com-----END*/[/code]

/*
END||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||END
*/

Aben 发表于 2005-10-28 15:58

sp1适用吗?

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.