Vì nhiều bạn hỏi về cách tạo nút post nhạc & flash trong diễn đàn nên mình post lên đây. Nếu bạn hack mod UBBC (như diễn đàn này) thì ko cần phải hack mod này nữa.
Mod này sẽ tạo cho bạn các tag để post rất nhiều thể loại nhạc khác nhau.
+ MEDIA: .wma .wmv .asf .mp3 .mpeg .avi
+ REAL: .ram .rm
+ FLASH: .swf
Mở sources\lib\post_parser.php
Tìm:
CODE
$txt = preg_replace( "#\[s\](.+?)\[/s\]#is", "<s>\\1</s>", $txt );
Thêm phía dưới:
CODE
$txt = preg_replace( "#\[media=(.+?)\](.+?)\[/media\]#is", "<object classid='clsid:6bf52a52-394a-11d3-b153-00c04f79faa6'><param name='url' value='\\2'><param name='volume' value='100'><param name='autostart' value='\\1'><embed type='application/x-mplayer2' src='\\2' showstatusbar='1' autostart='\\1'></object>", $txt );
$txt = preg_replace( "#\[real=(.+?)\](.+?)\[/real\]#is", "<embed type='audio/x-pn-realaudio-plugin' width='240' height='58' src='\\2' controls='all' autostart='\\1'></embed>", $txt );
$txt = preg_replace( "#\[flash=(.+?),(.+?)\](.+?)\[/flash\]#is", "<embed type='application/x-shockwave-flash' src='\\3' width='\\1' height='\\2'></embed>", $txt );
Tìm:
CODE
$txt = preg_replace( "#<u>(.+?)</u>#is" , "\[u\]\\1\[/u\]" , $txt );
Thêm phía dưới:
CODE
$txt = preg_replace( "#<object classid='clsid:6bf52a52-394a-11d3-b153-00c04f79faa6'><param name='url' value='(.+?)'><param name='volume' value='100'><param name='autostart' value='(.+?)'><embed type='application/x-mplayer2' src='(.+?)' showstatusbar='1' autostart='(.+?)'></object>#is" , "\[media=\\2\]\\1\[/media\]" , $txt );
$txt = preg_replace( "#<embed type='audio/x-pn-realaudio-plugin' width='240' height='58' src='(.+?)' controls='all' autostart='(.+?)'></embed>#is" , "\[real=\\2\]\\1\[/real\]" , $txt );
$txt = preg_replace( "#<embed type='application/x-shockwave-flash' src='(.+?)' width='(.+?)' height='(.+?)'></embed>#is" , "\[flash=\\2,\\3\]\\1\[/flash\]" , $txt );
Mở jscripts\ipb_bbcode.js
Tìm:
CODE
function tag_email()
{
var emailAddress = prompt(text_enter_email, "");
if (!emailAddress) {
alert(error_no_email);
return;
}
doInsert("[EMAIL]"+emailAddress+"[/EMAIL]", "", false);
}
Thêm phía dưới:
CODE
function tag_media()
{
var FoundErrors = '';
var enterINFO = prompt(text_enter_media, "http://");
var enterSTATE = prompt(text_enter_state, "1");
if (!enterINFO) {
FoundErrors += " " + error_no_url;
}
if (!enterSTATE) {
FoundErrors += " " + error_no_url;
}
if (FoundErrors) {
alert("Error! " + error_no_url);
return;
}
doInsert("[MEDIA="+enterSTATE+"]"+enterINFO+"[/MEDIA]", "", false);
}
function tag_real()
{
var FoundErrors = '';
var enterINFO = prompt(text_enter_real, "http://");
var enterSTATE = prompt(text_enter_state, "1");
if (!enterINFO) {
FoundErrors += " " + error_no_url;
}
if (!enterSTATE) {
FoundErrors += " " + error_no_url;
}
if (FoundErrors) {
alert("Error! " + error_no_url);
return;
}
doInsert("[REAL="+enterSTATE+"]"+enterINFO+"[/REAL]", "", false);
}
function tag_flash()
{
var FoundErrors = '';
var enterINFO = prompt(text_enter_flash, "http://");
var enterWIDTH = prompt(text_enter_width, "350");
var enterHEIGHT = prompt(text_enter_height, "300");
if (!enterINFO) {
FoundErrors += " " + error_no_url;
}
if (!enterWIDTH) {
FoundErrors += " " + error_no_url;
}
if (FoundErrors) {
alert("Error! " + error_no_url);
return;
}
doInsert("[FLASH="+enterWIDTH+","+enterHEIGHT+"]"+enterINFO+"[/FLASH]", "", false);
}
Mở lang/lang_post.php:
Thêm vào:
CODE
// Media Real Flash mod by TUOI THI THAM
'hb_media' => "Insert Media (alt + m)",
'hb_real' => "Insert Real (alt + r)",
'hb_flash' => "Insert Flash (alt + f)",
'jscode_text_enter_media' => "Enter the URL to the media file",
'jscode_text_enter_real' => "Enter the URL to the real file",
'jscode_text_enter_state' => "Auto play? ( yes = '' 1 '' || no = '' 0 '' )",
'jscode_text_enter_width' => "Enter the width for the flash file",
'jscode_text_enter_height' => "Enter the height for the flash file",
Mở skin_cache/cacheid_2/skin_post.php
Tìm: (dấu "..." là cả một đoạn code to)
CODE
// IBC Code stuff
var text_enter_url = "{$ibforums->lang['jscode_text_enter_url']}";
.......
.......
.......
.......
//-->
Thay tất cả bằng:
CODE
// IBC Code stuff
var text_enter_url = "{$ibforums->lang['jscode_text_enter_url']}";
var text_enter_url_name = "{$ibforums->lang['jscode_text_enter_url_name']}";
var text_enter_image = "{$ibforums->lang['jscode_text_enter_image']}";
var text_enter_email = "{$ibforums->lang['jscode_text_enter_email']}";
var text_enter_flash = "{$ibforums->lang['jscode_text_enter_flash']}";
var text_code = "{$ibforums->lang['jscode_text_code']}";
var text_quote = "{$ibforums->lang['jscode_text_quote']}";
var error_no_url = "{$ibforums->lang['jscode_error_no_url']}";
var error_no_title = "{$ibforums->lang['jscode_error_no_title']}";
var error_no_email = "{$ibforums->lang['jscode_error_no_email']}";
var error_no_width = "{$ibforums->lang['jscode_error_no_width']}";
var error_no_height = "{$ibforums->lang['jscode_error_no_height']}";
var prompt_start = "{$ibforums->lang['js_text_to_format']}";
var text_enter_media = "{$ibforums->lang['jscode_text_enter_media']}";
var text_enter_real = "{$ibforums->lang['jscode_text_enter_real']}";
var text_enter_state = "{$ibforums->lang['jscode_text_enter_state']}";
var text_enter_width = "{$ibforums->lang['jscode_text_enter_width']}";
var text_enter_height = "{$ibforums->lang['jscode_text_enter_height']}";
var help_bold = "{$ibforums->lang['hb_bold']}";
var help_italic = "{$ibforums->lang['hb_italic']}";
var help_under = "{$ibforums->lang['hb_under']}";
var help_font = "{$ibforums->lang['hb_font']}";
var help_size = "{$ibforums->lang['hb_size']}";
var help_color = "{$ibforums->lang['hb_color']}";
var help_close = "{$ibforums->lang['hb_close']}";
var help_url = "{$ibforums->lang['hb_url']}";
var help_img = "{$ibforums->lang['hb_img']}";
var help_email = "{$ibforums->lang['hb_email']}";
var help_quote = "{$ibforums->lang['hb_quote']}";
var help_list = "{$ibforums->lang['hb_list']}";
var help_code = "{$ibforums->lang['hb_code']}";
var help_click_close = "{$ibforums->lang['hb_click_close']}";
var list_prompt = "{$ibforums->lang['js_tag_list']}";
var help_fly = "{$ibforums->lang['hb_fly']}";
var help_media = "{$ibforums->lang['hb_media']}";
var help_real = "{$ibforums->lang['hb_real']}";
var help_flash = "{$ibforums->lang['hb_flash']}";
var help_highlight = "{$ibforums->lang['hb_highlight']}";
var help_align = "{$ibforums->lang['hb_align']}";
Tìm: (trong function postbox_buttons)
CODE
<input type="button" accesskey="l" value=" LIST " onclick="tag_list()" class="codebuttons" name="LIST" onmouseover="hstat('list')" />
Thêm phía dưới:
CODE
<input type='button' accesskey="m" value=" MEDIA " onClick="tag_media()" class='codebuttons' name="media" onmouseover="hstat('media')" />
<input type='button' accesskey="r" value=" REAL " onClick="tag_real()" class='codebuttons' name="real" onmouseover="hstat('real')" />
<input type='button' accesskey="f" value=" FLASH " onClick="tag_flash()" class='codebuttons' name="flash" onmouseover="hstat('flash')" />
##################################################
### Mở ./sources/lib/post_parser.php và XÓA ĐI ###
##################################################
CODE
$txt = preg_replace( "#<!--Flash (.+?)-->.+?<!--End Flash-->#e" , "\$this->unconvert_flash('\\1')", $txt );
CODE
function unconvert_flash($flash="")
{
$f_arr = explode( "+", $flash );
return '[flash='.$f_arr[0].','.$f_arr[1].']'.$f_arr[2].'[/flash]';
}
CODE
/*-------------------------------------------------------------------------*/
// regex_check_flash: Checks, and builds the <object>
// html.
/*-------------------------------------------------------------------------*/
function regex_check_flash($width="", $height="", $url="")
{
global $ibforums;
$default = "\[flash=$width,$height\]$url\[/flash\]";
if (!$ibforums->vars['allow_flash']) {
return $default;
}
if ($width > $ibforums->vars['max_w_flash']) {
$this->error = 'flash_too_big';
return $default;
}
if ($height > $ibforums->vars['max_h_flash']) {
$this->error = 'flash_too_big';
return $default;
}
if (!preg_match( "/^http:\/\/(\S+)\.swf$/i", $url) ) {
$this->error = 'flash_url';
return $default;
}
return "<!--Flash $width+$height+$url--><OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH=$width HEIGHT=$height><PARAM NAME=MOVIE VALUE=$url><PARAM NAME=PLAY VALUE=TRUE><PARAM NAME=LOOP VALUE=TRUE><PARAM NAME=QUALITY VALUE=HIGH><EMBED SRC=$url WIDTH=$width HEIGHT=$height PLAY=TRUE LOOP=TRUE QUALITY=HIGH></EMBED></OBJECT><!--End Flash-->";
}
CODE
$txt = preg_replace( "#(\[flash=)(\S+?)(\,)(\S+?)(\])(\S+?)(\[\/flash\])#ie", "\$this->regex_check_flash('\\2','\\4','\\6')", $txt );
Done!