Location: PHPKode > projects > BBCode Advanced > bbcode-advanced/lib/class.bbCode.php
<?
#########################################################
#	More Interactive Projects							#
#	Engine by []==ThoRĀ®									#
#														#
#	Contact:											#
#	hide@address.com							#
#	hide@address.com										#
#	More Interactive - www.more.it						#
#########################################################

/*
	$Id: class.bbCode.php,v 1.2 2006/02/03 09:54:49 thor Exp $
*/

/*********************************************************/
/* 					B B C O D E                        	 */
/*********************************************************/

class bbCode	{

	//	THIS FUNCTION WILL WRITE THE FORM 
	Function writeBBCode($NameOfForm,$NameOfField,$notShown="")	{
		//	The BBCode	//
		##	var MyForm 	= document.forms[theForm];
		##	var txtarea	= MyForm[theField];

		/*	List of all elements
			1. Bold
			2. Italic
			3. Underline
			4. Strikes
			5. Quote
			6. List
			7. Bullet Points
			8. Images
			9. Flash Animations
			10. Documents
			11. Url
			12. Email
			13. Font Size
			14. Font Family
			15. Paragraph
			16. Font color
		*/
		//	Elements not shown in BBCode (in_array())
		$notShown		= ($notShown == "")	? Array() : $notShown;
		$i				= 0;

		$putTheBBCode	= "";
		$putTheBBCode .= "<script language=\"Javascript\" type=\"text/javascript\" src=\"js/BBCode.js\"></script>\n";
		$putTheBBCode .= "\n\n\n<br>";
		$putTheBBCode .= "<!--	BBCODE	-->\n";
		$putTheBBCode .= "<table width=\"100%\" border=0 cellpadding=1 cellspacing=1 bgcolor=\"#CCCCCC\">\n";
		$putTheBBCode .= "<tr>\n";
		$putTheBBCode .= "<td bgcolor=\"#EAEAEA\">";
		$putTheBBCode .= "<table border=0 cellpadding=0 cellspacing=0>\n";
		$putTheBBCode .= "<tr>\n";
		/*******************************\
		|	BOLD						|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode0\" value=\"B\" style=\"font-weight:bold; width:20px; width:25px;\" onClick=\"bbstyle(0,'".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>\n";
		}
		/*******************************\
		|	ITALIC						|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode2\" value=\"i\" style=\"font-style:italic; width:20px; width:25px;\" onClick=\"bbstyle(2,'".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>\n";
		}
		/*******************************\
		|	UNDERLINE					|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode4\" value=\"u\" style=\"text-decoration: underline; width:25px;\" onClick=\"bbstyle(4,'".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>\n";
		}
		/*******************************\
		|	STRIKES						|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode6\" value=\"strike\" style=\"text-decoration: line-through; width:35px;\" onClick=\"bbstyle(6,'".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>\n";
		}
		/*******************************\
		|	QUOTE						|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode8\" value=\"Quote\" onClick=\"PromptQuote('".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>";
		}
		/*******************************\
		|	LIST						|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode10\" value=\"List\" style=\"width:35px;\" onClick=\"bbstyle(10,'".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>\n";
		}
		/*******************************\
		|	POINTS LIST					|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode12\" value=\"*\" style=\"width:25px;\" onClick=\"bbstyle(12,'".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>\n";
		}
		/*******************************\
		|	IMAGES						|
		\*******************************/
		//	This will open a popUp, where user can upload files.
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode14\" value=\"Img\"  onClick=\"TheOpener('images.php','fileList','780','400','yes','no','Close all PopUp Blocker','')\" />";
			$putTheBBCode .= "</td>";
		}
		/*******************************\
		|	FLASH ANIMATION (SWF)		|
		\*******************************/
		//	This will open a popUp, where user can upload files.
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode16\" value=\"Flash (SWF)\"  onClick=\"TheOpener('flash.php','flashList','780','400','yes','no','Close all PopUp Blocker','')\" />";
			$putTheBBCode .= "</td>";
		}
		/*******************************\
		|	DOCUMENTS					|
		\*******************************/
		//	This will open a popUp, where user can upload files.
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode18\" value=\"DOC\"  onClick=\"TheOpener('doc.php','flashList','780','400','yes','no','Close all PopUp Blocker','')\" />";
			$putTheBBCode .= "</td>";
		}
		/*******************************\
		|	URL							|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode20\" value=\"URL\" style=\"text-decoration: underline;width:35px;\" onClick=\"PromptUrl('".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>\n";
		}
		/*******************************\
		|	EMAIL						|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "	<input type=\"button\" name=\"addbbcode22\" value=\"Email\" style=\"text-decoration: underline;width:45px;\" onClick=\"PromptMail('".$NameOfForm."',theField)\" />";
			$putTheBBCode .= "</td>\n";
		}
		$putTheBBCode .= "</tr></table>\n";

		/*******************************\
		|	FONT SIZE					|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<br><table border=0 cellpadding=0 cellspacing=0>\n";
			$putTheBBCode .= "<tr>\n";
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "&nbsp;Dimensione font: ";
			$putTheBBCode .= "<select name=\"addbbcodeSize\" onChange=\"bbfontstyle('[size=' + this.form.addbbcodeSize.options[this.form.addbbcodeSize.selectedIndex].value + ']', '[/size]','".$NameOfForm."',theField);this.selectedIndex=0\">";
			$putTheBBCode .= "<option value=\"0\">-- scegli --</option>";
			$fontSize	= Array(10,11,12,14,15,16,18,20,22,24);
			foreach ($fontSize as $valFont)	{
				$putTheBBCode .= "<option value=\"".$valFont."\">".$valFont."px</option>";
			}
			$putTheBBCode .= "</select>";
			$putTheBBCode .= "</td>\n";
		}

		/*******************************\
		|	SPACER						|
		\*******************************/
		$putTheBBCode .= "<td width=\"15\">&nbsp;</td>\n";

		/*******************************\
		|	FONT FAMILY					|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<td>";
			$putTheBBCode .= "&nbsp;Stile font: ";
			$putTheBBCode .= "<select name=\"addbbcodeFamily\" onChange=\"bbfontstyle('[font=' + this.form.addbbcodeFamily.options[this.form.addbbcodeFamily.selectedIndex].value + ']', '[/font]','".$NameOfForm."',theField);this.selectedIndex=0\">";
			$putTheBBCode .= "<option value=\"0\">-- scegli --</option>";
			$fontSize	= Array("Verdana","Times New Roman","Trebuchet MS","Arial","Courier New","Geneva");
			foreach ($fontSize as $valFont)	{
				$putTheBBCode .= "<option value=\"".$valFont."\">".$valFont."</option>";
			}
			$putTheBBCode .= "</select>";
			$putTheBBCode .= "</td>\n";
		}
		$putTheBBCode .= "</tr>\n";
		$putTheBBCode .= "</table><br>\n";

		/*******************************\
		|	PARAGRAPH					|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<table border=0 cellpadding=0 cellspacing=0>\n";
			$putTheBBCode .= "<tr>\n";
			$putTheBBCode .= "	<td>";
			$putTheBBCode .= "	<a href=\"#\"><img src=\"img/common/bbCode_left.png\" name=\"addbbcode24\" onClick=\"bbstyle(22,'".$NameOfForm."',theField)\" border=0 /></a>";
			$putTheBBCode .= "	&nbsp;</td>";
			$putTheBBCode .= "	<td>";
			$putTheBBCode .= "	<a href=\"#\"><img src=\"img/common/bbCode_center.png\" name=\"addbbcode26\" onClick=\"bbstyle(24,'".$NameOfForm."',theField)\" border=0 /></a>";
			$putTheBBCode .= "	&nbsp;</td>";
			$putTheBBCode .= "	<td>";
			$putTheBBCode .= "	<a href=\"#\"><img src=\"img/common/bbCode_right.png\" name=\"addbbcode28\" onClick=\"bbstyle(26,'".$NameOfForm."',theField)\" border=0 /></a>";
			$putTheBBCode .= "	&nbsp;</td>";
			$putTheBBCode .= "	<td>";
			$putTheBBCode .= "	<a href=\"#\"><img src=\"img/common/bbCode_justify.png\" name=\"addbbcode30\" onClick=\"bbstyle(28,'".$NameOfForm."',theField)\" border=0 /></a>";
			$putTheBBCode .= "	&nbsp;</td>";

			/* EVIDENZIA: not fully working	*/
			/*
			$putTheBBCode .= "	<td>";
			$putTheBBCode .= "	<a href=\"#\"><img src=\"img/common/bbCode_txtBgColor.png\" name=\"addbbcode32\" onClick=\"bbstyle(30,'".$NameOfForm."',theField)\" border=0 /></a>";
			$putTheBBCode .= "	&nbsp;</td>";
			*/

			$putTheBBCode .= "</tr>\n";
			$putTheBBCode .= "</table>\n";
		}

		/*******************************\
		|	FONT-COLOR					|
		\*******************************/
		$i++;
		if (!in_array($i,$notShown))	{
			$putTheBBCode .= "<table border=0 cellpadding=1 cellspacing=1>\n";
			$putTheBBCode .= "<tr><td valign=\"top\">\n";

			$putTheBBCode .= "<table border=0 cellpadding=1 cellspacing=1>\n";
			$putTheBBCode .= "<tr>\n";

			$color	= new colorConverter();

			$maxPerRow		= 36;
			$maxWidthTD		= 7;		//	Pixels
			$maxHeightTD	= 7;		//	Pixels

			$colorStep		= 51;		//	Color Style (by step 51 is WebBased)

			//	Fast Colors
			$fastColors	= Array();
			$listFastColors	= "";
			$multiWidthTD	= 3;
			$multiHeightTD	= 1;

			$cc	= 0;
			$fc	= 0;	//	Counter for fast colors;
			for($a=0;$a<=255;$a=$a+$colorStep)	{
				$num1	= $a;
				for($b=0;$b<=255;$b=$b+$colorStep)	{
					$num2	= $b;
					for($c=0;$c<=255;$c=$c+$colorStep)	{
						$num3	= $c;
						$RGB	= $color->RGBToHex($num1,$num2,$num3);
						$RGB2	= $color->RGBToHex(0,0,0);

						$putTheBBCode	.= ($cc == 0)	? "<tr>" : "";

						if (in_array($RGB,$fastColors))	{
							$listFastColors	.= ($fc == 0)	? "<tr>" : "";
							$listFastColors	.= "<td bgcolor=\"#".$RGB."\" width=\"".($maxWidthTD * $multiWidthTD)."\" height=\"".($maxHeightTD * $multiHeightTD)."\">
												<a href=\"javascript:;\" onClick=\"\"onMouseOver=\"cellover(cellToColor,'#EAEAEA','#".$RGB."');writeTXTonLayer('textToChange','#".$RGB."','#".$RGB2."')\" onMouseOut=\"cellout(cellToColor,'#EAEAEA')\"><img src=\"img/common/pix.gif\" width=\"".($maxWidthTD * $multiWidthTD)."\" height=\"".($maxHeightTD * $multiHeightTD)."\" border=0 alt=\"#".$RGB."\" onClick=\"bbfontstyle('[color=#".$RGB."]', '[/color]','".$NameOfForm."',theField);\"></a>
												</td>";
							$fc++;
							$listFastColors	.= ($fc == $maxPerRow)	? "</tr>\n" : "";
							$fc	= ($fc >= $maxPerRow) ?  0 : $fc;
						}
						//fwrite($fp,$RGB."\n");
						$putTheBBCode .= "<td bgcolor=\"#".$RGB."\" width=\"".$maxWidthTD."\" height=\"".$maxHeightTD."\">
						<a href=\"javascript:;\" onClick=\"\" onMouseOver=\"cellover(cellToColor,'#EAEAEA','#".$RGB."');writeTXTonLayer('textToChange','#".$RGB."','#".$RGB2."')\" onMouseOut=\"cellout(cellToColor,'#EAEAEA')\"><img src=\"img/common/pix.gif\" width=\"".$maxWidthTD."\" height=\"".$maxHeightTD."\" border=0 alt=\"#".$RGB."\" onClick=\"bbfontstyle('[color=#".$RGB."]', '[/color]','".$NameOfForm."',theField);\"></a></td>\n";
						$cc++;
						$putTheBBCode	.= ($cc >= $maxPerRow)	? "</tr>\n" : "";
						$cc	= ($cc >= $maxPerRow) ?  0 : $cc;

					}
				}
			}
			$putTheBBCode .= "</tr>\n";
			$putTheBBCode .= "</table>\n";
			$putTheBBCode .= "</td>\n";
			$putTheBBCode .= "<td valign=\"top\">\n";
			$putTheBBCode .= "<table border=0 cellpadding=1 cellspacing=1>\n";
			$putTheBBCode .= "<tr>\n";
			$putTheBBCode .= "<td id=\"cellToColor\"><div id=\"textToChange\">&nbsp;</div></td>\n";
			$putTheBBCode .= "</tr>\n";
			$putTheBBCode .= "</table>\n";
			$putTheBBCode .= "</td></tr></table>\n";
			//	LIST FAST COLORS
			if (count($fastColors) > 0)	{
				$putTheBBCode .= "<!--	###	FAST COLORS ###		-->";
				$putTheBBCode .= "<table border=0 cellpadding=1 cellspacing=1>\n";
				$putTheBBCode .= "<tr><td><strong>Colori veloci</strong></td>\n";
				$putTheBBCode .= "</table><br>\n";
				$putTheBBCode .= "<table border=0 cellpadding=1 cellspacing=1>\n";
				$putTheBBCode .= "<tr>\n";
				$putTheBBCode .= $listFastColors;
				$putTheBBCode .= "</tr>\n";
				$putTheBBCode .= "</table><br>\n";
				$putTheBBCode .= "<!--	###	FAST COLORS ###		-->";
			}
		}
		/*******************************\
		|	HELP						|
		\*******************************/
		//	NO MORE USED
		/*
		$putTheBBCode .= "<table border=0 cellpadding=0 cellspacing=0>\n";
		$putTheBBCode .= "<tr>\n";
		$putTheBBCode .= "	<td><input type=\"text\" name=\"helpbox\" size=\"35\" maxlength=\"100\" style=\"width:500px; font-size:10px\" value=\"Suggerimento: gli Stili possono essere applicati velocemente al testo selezionato\" /></td>\n";
		$putTheBBCode .= "</tr>\n";
		$putTheBBCode .= "</table>\n";
		*/
		$putTheBBCode .= "<input type=\"hidden\" name=\"helpbox\">\n";
		$putTheBBCode .= "<!--	END BBCODE	-->";
		$putTheBBCode .= "</tr></table>\n";
		$putTheBBCode .= "<br>\n\n\n";
		return $putTheBBCode;
			// End BBCode	//
	}

	//	FIRST PASS TO PARSE THE BBOCDE
	Function _doTheFirstBBCode($text)	{
		//	pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
		//	This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.

		$text = preg_replace("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "[color=\\1]\\2[/color]", $text);
		$text = preg_replace("#\[bgcolor=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/bgcolor\]#si", "[bgcolor=\\1]\\2[/bgcolor]", $text);
		$text = preg_replace("#\[font=(.*?)\](.*?)\[/font\]#si", "[font=\\1]\\1[/font]", $text);
		$text = preg_replace("#\[size=([\-\+]?[1-2]?[0-9])\](.*?)\[/size\]#si", "[size=\\1:$uid]\\2[/size]", $text);
		$text = preg_replace("#\[b\](.*?)\[/b\]#si", "[b]\\1[/b]", $text);
		$text = preg_replace("#\[u\](.*?)\[/u\]#si", "[u]\\1[/u]", $text);
		$text = preg_replace("#\[i\](.*?)\[/i\]#si", "[i]\\1[/i]", $text);
		$text = substr($text, 1);
		return $text;
	}

	//	REAL PARSE OF BBCODE
	Function parseBBCode($text)	{
		//	_doTheFirstBBCode($text)

		//	list
		$text	= str_replace("[list]", "<ul>", $text);
		$text	= str_replace("[/list]", "</ul>", $text);
		// *
		$text	= str_replace("[*]", "<li>", $text);

		// colours
		$text	= preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\]/si", "<font color=\"\\1\">", $text);
		$text	= str_replace("[/color]", "</font>", $text);

		// test background-color
		//	<font style=\"background-color:#FFFF33\">$1</font>
		$text	= preg_replace("/\[bgcolor=(\#[0-9A-F]{6}|[a-z]+)\]/si", "<font style=\"background-color:\\1\">", $text);
		$text	= str_replace("[/bgcolor]", "</font>", $text);

		// size
		$text	= preg_replace("/\[size=([\-\+]?[1-2]?[0-9])\]/si", "<span class=\"bbCode$1\">", $text);
		$text	= str_replace("[/size]", "</span>", $text);

		// family
		$text	= preg_replace("/\[font=(.*?)\]/si", "<font face=\"$1\">", $text);
		$text	= str_replace("[/font]", "</font>", $text);

		// [b] and [/b] for bolding text.
		$text	= str_replace("[b]", "<b>", $text);
		$text	= str_replace("[/b]", "</b>", $text);

		// [u] and [/u] for underlining text.
		$text	= str_replace("[u]", "<u>", $text);
		$text	= str_replace("[/u]", "</u>", $text);

		// [i] and [/i] for italicizing text.
		$text	= str_replace("[i]", "<em>", $text);
		$text	= str_replace("[/i]", "</em>", $text);

		$text	= str_replace("[strike]", "<span class=\"lineThrough\">", $text);
		$text	= str_replace("[/strike]", "</span>", $text);

		//	Image
		//	default (align left is default)
		$i	= 0;		//	COUNTER FOR ARRAY REPLACEMENT
		$patterns[$i]		= "#\[img\](.*?)\[/img\]#si";
		$replacements[$i]	= "<img src=\"$1\" alt=\"\" align=\"left\">";
		//	with alignment (left or right)
		$addDivO	= "";
		$addDivC	= "";
		$i++;			//	COUNTER FOR ARRAY REPLACEMENT
		$patterns[$i]		= "#\[img=(.*?)\](.*?)\[/img\]#si";
		$replacements[$i]	= "<img src=\"$2\" align=\"$1\" border=\"0\" alt=\"\">";

		$i++;			//	COUNTER FOR ARRAY REPLACEMENT
		$patterns[$i]		= "#\[flash=(.*?)x(.*?)\](.*?)\[/flash\]#si";
		$replacements[$i]	= "<script>FlashWrite('$3','$1','$2')</script>";

		// documents
		$i++;			//	COUNTER FOR ARRAY REPLACEMENT
		$patterns[$i]		= "#\[doc=(.*?)~(.*?)\](.*?)\[/doc\]#si";
		$replacements[$i]	= "<img src=\"img/common/repository/icons/$1\" alt=\"\" border=0 align=\"absmiddle\"> <a href=\"$2\" target=\"_blank\">$3</a>";

		//	quote
		$i++;
		$patterns[$i]		= "#\[quote=(.*)](.*)\[/quote]#si";
		$replacements[$i]	= "<div class=\"openQuote\"></div><div class=\"quoteWords\">$2</span></div><div class=\"closeQuote\"></div><div class=\"quoteFrom\">$1</div>";

		//	url
		$i++;
		$patterns[$i] = "#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
		$replacements[$i] = "<a href=\"\\1\\2\">\\1\\2</a>";
		// [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
		$i++;
		$patterns[$i] = "#\[url\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
		$replacements[$i] = "<a href=\"\\1\">\\1</a>";
		// [url=xxxx://www.phpbb.com]phpBB[/url] code..
		$i++;
		$patterns[$i] = "#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
		$replacements[$i] = "<a href=\"\\1\\2\">\\3</a>";
		// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
		$i++;
		$patterns[$i] = "#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
		$replacements[$i] = "<a href=\"\\1\">\\2</a>";

		//	email
		// [email]hide@address.com[/email] code..
		$i++;
		$patterns[$i] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
		$replacements[$i] = "<a href=\"mailto:\\1\">\\1</a>";
		// [email=hide@address.com]testo[/email] code..
		$i++;
		$patterns[$i] = "#\[email=(.*?)\](.*?)\[/email\]#si";
		$replacements[$i] = "<a href=\"mailto:\\1\">\\2</a>";

		//	Paragraph
		$text = str_replace("[t_left]", "<div align=\"left\">", $text);
		$text = str_replace("[/t_left]", "</div>", $text);
		$text = str_replace("[t_center]", "<div align=\"center\">", $text);
		$text = str_replace("[/t_center]", "</div>", $text);
		$text = str_replace("[t_right]", "<div align=\"right\">", $text);
		$text = str_replace("[/t_right]", "</div>", $text);
		$text = str_replace("[t_justify]", "<div align=\"justify\">", $text);
		$text = str_replace("[/t_justify]", "</div>", $text);

		$text = @preg_replace($patterns, $replacements, $text);

		return $text;
	}


}
?>
Return current item: BBCode Advanced