列印

超酷播放器 UBB 標籤 FOR Discuz! 6.0

超酷播放器 UBB 標籤 FOR Discuz! 6.0

from: http://www.discuz.net/thread-732576-1-3.html

超酷播放器 UBB 標籤 FOR Discuz! 6.0 正式版本發佈
標題: 超酷播放器 UBB 標籤 FOR Discuz! 6.0 正式版
=========================
插件名稱:超酷播放器 UBB 標籤
適合版本:Discuz! 6.0 正式版
發佈日期:2007-9-5
發  布 人: 2046
演     示:http://club.cimgoo.com/thread-230779-1-1.html
技術支援:Discuz! 官方論壇
=========================
ps. 如果出現 js 錯誤請下載 UBB_ALL_BIG5.rar 來對照相關程式碼
因為 D6 現在 CODE & QUOTE 有問題


前段時間伺服器頻繁無故關閉(原因大家該都知道),造成我的社區長時間無法訪問,也使得插件的開發滯後。讓 DZ 的朋友們久等了,這裡先想大家說對不起!

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! 代碼模式下進行。




一、下載附件, 依結構上傳附件


二、需要修改的代碼:

1、修改 ./include/discuzcode.func.php

查找
複製內容到剪貼簿
代碼:
for($i = 0; $i <= $discuzcodes['pcodecount']; $i++) {
上面添加:
複製內容到剪貼簿
代碼:
// 超酷播放器 UBB 標籤 - START
$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);
}
// 超酷播放器 UBB 標籤 - END
在檔案尾端("?>" 之前) 添加:
複製內容到剪貼簿
代碼:
// 超酷播放器 UBB 標籤 - START
$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');">顯示 URL</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;
}
// 超酷播放器 UBB 標籤 - END
2、修改 ./include/javascript/common.js

在尾端添加:
引用:
// 超酷播放器 UBB 標籤 - START
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><br />';
  }
  u.innerHTML = temp;
  u.style.display = 'block';
  $('download_' + pid).innerHTML = '隱藏 URL';
} else {
  u.innerHTML = '';
  u.style.display = 'none';
  $('download_' + pid).innerHTML = '顯示 URL'
}
}
// 超酷播放器 UBB 標籤 - END
3、修改 ./include/javascript/editor.js

在尾端添加:
複製內容到剪貼簿
代碼:
// 超酷播放器 UBB 標籤 - START
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;
}
// 超酷播放器 UBB 標籤 - END
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}-->
下面添加
複製內容到剪貼簿
代碼:
<!--// 超酷播放器 UBB 標籤 - START -->
<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>
<!--// 超酷播放器 UBB 標籤 - END -->
到此你的播放器就完成了,如果你想修改播放器樣式,讓他變的更酷更個性化,可以修改 ./include/discuzcode.func.php 下的對應代碼實現(在上面加入的代碼裡面找)。

關於播放器樣式代碼可以參考: http://club.cimgoo.com/thread-8389-1-1.html ,文章有詳細解釋。
附件: 您所在的用戶組無法下載或查看附件
Hack 安裝錯誤, 80% 來自粗心, 請專心安裝
Linux0911 打造您的個性論壇

本人現在忙於研究所, 沒多的時間管論壇, 有問題別發 pm 給我, 謝謝~
Linux0911 Forum © 2004-2009 All Rights Reserved.

TOP

這個好
總有一天會給他安裝



Linux0911 Forum © 2004-2009 All Rights Reserved.

TOP

6.0 的 CODE 真的有問題...

裝的時候注意一下 common.js 那個部分
Hack 安裝錯誤, 80% 來自粗心, 請專心安裝
Linux0911 打造您的個性論壇

本人現在忙於研究所, 沒多的時間管論壇, 有問題別發 pm 給我, 謝謝~
Linux0911 Forum © 2004-2009 All Rights Reserved.

TOP

痾~我已經給他安裝下去= =
是啥咪問題
我還沒測試勒



Linux0911 Forum © 2004-2009 All Rights Reserved.

TOP

請問這是 Admin 做的嘛?
感覺好像 "很厲害" 的插件...

先來去測試安裝囉
謝謝^^
Linux0911 Forum © 2004-2009 All Rights Reserved.

TOP



論壇聲明
  • 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
    如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
    請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!
最佳瀏覽解析度:不低於 1024 (最佳 1280 以上).(支援 IE 7, Mozilla Firefox, Safari, Chrome)
The Best Surfing Resolution: No Lower than 1024 (Best: above 1280).(IE 7, Mozilla Firefox, Safari, Chrome Supported)