MyBB Community Forums

Full Version: Use badword filter to shorten music code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Coolanyone know how to use badword filter to shorten music code..So members can use this code by typing shorter code
Example i want [nhac]link[/nhac] replaces this code

<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="piemagolon" width="345" height="43">
<param name="URL" value="http://thaodfsfsabvinh.net/forum/uploads/asdf.wma">
<param name="rate" value="1">
<param name="balance" value="0">
<param name="currentPosition" value="0">
<param name="defaultFrame" value>
<param name="playCount" value="1">
<param name="autoStart" value="0">
<param name="currentMarker" value="0">
<param name="invokeURLs" value="-1">
<param name="baseURL" value>
<param name="volume" value="50">
<param name="mute" value="0">
<param name="uiMode" value="full">
<param name="stretchToFit" value="-1">
<param name="windowlessVideo" value="0">
<param name="enabled" value="-1">
<param name="enableContextMenu" value="-1">
<param name="fullScreen" value="0">
<param name="SAMIStyle" value>
<param name="SAMILang" value>
<param name="SAMIFilename" value>
<param name="captioningID" value>
<param name="enableErrorDialogs" value="0">
</object>

so members just have to type [nhac]link[/nhac],it will replaces that code and the link is put in value... immediately
i just want members to use media code quickly
thanks for any help!!!!thanks againCool
Make a new file called nhac_tag.php and copy the code below into it. Save the file and upload it to your forum/inc/plugins directory.
After that, activate the plugin.
<?php
$plugins->add_hook("parse_message", "nhac_tag");

function nhac_tag_info()
{
	return array(
		"name"				=> "Musiccode",
		"description"		=> "",
		"website"			=> "http://www.smethead.tk/",
		"author"			=> "orjan",
		"authorsite"		=> "mailto:[email protected]",
		"version"			=> "1.0",
	);
}

function nhac_tag_activate()
{
}

function nhac_tag_deactivate()
{
}

function nhac_tag($message)
{
$message = preg_replace('#\[nhac\](.*?)\[\/nhac\]#ies', "nhac_musiccode($1)", $message);
return $message;

}

function nhac_musiccode($url)
{
$musiccode = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="piemagolon" width="345" height="43">
<param name="URL" value="'.$url.'">
<param name="rate" value="1">
<param name="balance" value="0">
<param name="currentPosition" value="0">
<param name="defaultFrame" value>
<param name="playCount" value="1">
<param name="autoStart" value="0">
<param name="currentMarker" value="0">
<param name="invokeURLs" value="-1">
<param name="baseURL" value>
<param name="volume" value="50">
<param name="mute" value="0">
<param name="uiMode" value="full">
<param name="stretchToFit" value="-1">
<param name="windowlessVideo" value="0">
<param name="enabled" value="-1">
<param name="enableContextMenu" value="-1">
<param name="fullScreen" value="0">
<param name="SAMIStyle" value>
<param name="SAMILang" value>
<param name="SAMIFilename" value>
<param name="captioningID" value>
<param name="enableErrorDialogs" value="0">
</object>';
return $musiccode;
}
?>
hello Smethead,thanks for your helping but i got a small problem
i use your code [nhac]my music file's link[/nhac],it appears window
play music file but if [nhac]another website's link[/nhac] the path now is http://mysite.com/another website's link,it doesn't work and cause error to my post
how to solve?
thanks again
i want to remove my web link in this code and when use [nhac]link[/nhac],i can use my link or another website link
does it code set my website link as default?maybe put the file nhac_tag.php in my plugin dic,it uses my link?
so how to use,i can see the wma window player but the link it change
Firstly, you can edit your post by clicking the edit button below. so you don't have to triple post. (moderators, please merge)
Secondly, I couldn't reply right away since I have to work.

And thirdly. I think the best way to solve this problem is to add the message replacement code in inc/functions_post.php right after
$message = docode($message);
where do i add $message = docode($message); in functions_post.php??
can you instruct more?

i see these lines in nhac_tag.php

function nhac_musiccode($url)
{
$musiccode = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="piemagolon" width="345" height="43">
<param name="URL" value="'.$url.'">
<param name="rate" value="1">
<param name="balance" value="0">

in .$url. the code add my website link automatically,how to remove this
so members just type [nhac]the link they want[/nhac]