<?php
function  ubb($Text){    
        //$Text=htmlspecialchars($Text);    
        //$Text=stripslashes($Text);  
        //$Text=ereg_replace("\r\n","<br/>",$Text);    
        //$Text=ereg_replace("\r","<br/>",$Text);    
        //$Text=nl2br($Text);    
        //$Text=preg_replace("/\\t/is",\",$Text);    
        //$Text=ereg_replace(\","&nbsp;",$Text);    
                         
        $Text=preg_replace("/\[h1\](.+?)\[\/h1\]/is","<h1>\\1</h1>",$Text);    
        $Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","<h2>\\1</h2>",$Text);    
        $Text=preg_replace("/\[h3\](.+?)\[\/h3\]/is","<h3>\\1</h3>",$Text);    
        $Text=preg_replace("/\[h4\](.+?)\[\/h4\]/is","<h4>\\1</h4>",$Text);    
        $Text=preg_replace("/\[h5\](.+?)\[\/h5\]/is","<h5>\\1</h5>",$Text);    
        $Text=preg_replace("/\[h6\](.+?)\[\/h6\]/is","<h6>\\1</h6>",$Text);
	    $Text=preg_replace("/\[left\](.+?)\[\/left\]/is","<div align=left>\\1</div>",$Text);    
        $Text=preg_replace("/\[center\](.+?)\[\/center\]/is","<center>\\1</center>",$Text);
	    $Text=preg_replace("/\[right\](.+?)\[\/right\]/is","<div align=right>\\1</div>",$Text);    
        $Text=preg_replace("/\[big\](.+?)\[\/big\]/is","<big>\\1</big>",$Text);    
        $Text=preg_replace("/\[small\](.+?)\[\/small\]/is","<small>\\1</small>",$Text);                                                                            
                         
        $Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","<a href=\\1>\\1</a>",$Text);    
        $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=http://\\1>http://\\1</a>",$Text);    
        $Text=preg_replace("/\[url=(http:\/\/.+?)\](.*)\[\/url\]/is","<a href=\\1>\\2</a>",$Text);    
        $Text=preg_replace("/\[url=(.+?)\](.*)\[\/url\]/is","<a href=http://\\1>\\2</a>",$Text);    
        
	    $Text=preg_replace("/\[move\](.*)\[\/move\]/is","<marquee scrollamount=3>\\1</marquee>",$Text);
		                
        $Text=preg_replace("/\[img\](.+?)\[\/img\]/is","<img  src=\\1  border=0 resize=\"1\">",$Text);    
        $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","<font  color=\\1>\\2</font>",$Text);    
        $Text=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/is","<font  size=\\1>\\2</font>",$Text);
	    $Text=preg_replace("/\[face=(.+?)\](.+?)\[\/face\]/is","<font  face=\\1>\\2</font>",$Text);  
        $Text=preg_replace("/\[sup\](.+?)\[\/sup\]/is","<sup>\\1</sup>",$Text);    
        $Text=preg_replace("/\[sub\](.+?)\[\/sub\]/is","<sub>\\1</sub>",$Text);    
        $Text=preg_replace("/\[pre\](.+?)\[\/pre\]/is","<pre>\\1</pre>",$Text);    
        $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","<a href=mailto:\\1>\\1</a>",$Text);    
        $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","<i>\\1</i>",$Text);
		$Text=preg_replace("/\[u\](.+?)\[\/u\]/is","<u>\\1</u>",$Text);  
        $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","<b>\\1</b>",$Text);
        $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","<b>\\1</b>",$Text);
		$Text=preg_replace("/\[strike\](.+?)\[\/strike\]/is","<strike>\\1</strike>",$Text);
		$Text=preg_replace("/\[bgcolor=(.+?)\](.+?)\[\/bgcolor\]/is","<font style=\\1>\\2</font>",$Text); //08-8-13 add
	    $Text=preg_replace("/\[flash=(.+?),(.+?)\](.+?)\[\/flash\]/is","<embed src=\"\\3\" width=\"\\1\" height=\"\\2\"></embed>",$Text);
        $Text=preg_replace("/\[mp=(.+?),(.+?),(.+?)\](.+?)\[\/mp\]/is","<object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=\\1 height=\\2 ><param name=ShowStatusBar value=-1><param name=AUTOSTART value=\\3><param name=Filename value=\\4><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src=\\4 width=\\1 height=\\2></embed></object>",$Text);
		$Text=preg_replace("/\[rm=(.+?),(.+?),(.+?)\](.+?)\[\/rm\]/is","<object classid=clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=\\1 height=\\2><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><param name=AUTOSTART value=\\3><param name=SHUFFLE value=0><param name=PREFETCH value=0><param name=NOLABELS value=0><param name=LOOP value=0><param name=NUMLOOP value=0><param name=CENTER value=0><param name=MAINTAINASPECT value=0><param name=BACKGROUNDCOLOR value=#000000><ARAM NAME=SRC VALUE=\\4></object>",$Text);
        $Text=preg_replace("/\[flv=(.+?),(.+?),(.+?)\](.+?)\[\/flv\]/is","<object type=\"application/x-shockwave-flash\" data=\"flv/ftplayer.swf?xml=<vcastr><channel><item><source>\\4</source><duration></duration><title></title></item></channel></vcastr>\" width=\"\\1\" height=\"\\2\" id=ftbbs><param name=movie value=\"flv/ftplayer.swf?xml=<vcastr><channel><item><source>\\4</source><duration></duration><title></title></item></channel><config><bufferTime>4</bufferTime><contralPanelAlpha>0.75</contralPanelAlpha><controlPanelBgColor>0x000000</controlPanelBgColor><controlPanelBtnColor>0xffffff</controlPanelBtnColor><contralPanelBtnGlowColro>0xffff00</contralPanelBtnGlowColro><controlPanelMode>float</controlPanelMode><defautVolume>0.8</defautVolume><isAutoPlay>\\3</isAutoPlay><isLoadBegin>\\4</isLoadBegin><isShowAbout>true</isShowAbout><scaleMode>showAll</scaleMode></config><plugIns><logoPlugIn><url>flv/LogoPlugIn.swf</url><logoText>FTBBS.CN</logoText><logoTextAlpha>0.75</logoTextAlpha><logoTextFontSize>30</logoTextFontSize><logoTextColor>0xffffff</logoTextColor><textMargin>0 auto auto 10</textMargin></logoPlugIn></plugIns></vcastr>\" /><param name=\"allowFullScreen\" value=\"true\" /></object>",$Text);
		//$Text=preg_replace("/\[quote\](.+?)\[\/quote\]/is","<blockquote><font  size='1'  face='Courier  New'>quote:</font><hr>\\1<hr></blockquote>",  $Text);
  return $Text;
}
function jscode($code){
  return ( preg_match('/((\<script(?:.*?)\>)|(\<\/script(?:.*?)\>))|((javascript(.*?):))|((vbscript(.*?):))|((on(?:\w+?)=))/i',preg_quote($code)) === 0 ? false : true );
}
function codetohtml($nl){
      $nl=str_replace(chr(13),"<br>",$nl);
	  $nl=str_replace(chr(32),"&nbsp;",$nl);
	  $nl=str_replace(chr(9)," ",$nl);
	  $nl=str_replace(chr(34),"&quot;",$nl);
	  $nl=str_replace(chr(39),"&#39;",$nl);
	  //$nl=str_replace(">","&gt;",$nl);
	  //$nl=str_replace("<","&lt;",$nl);
	  //$nl=str_replace("&","&amp;",$nl);
      return $nl;
}
function htmltocode($nl){ //form
      $nl=str_replace("<br>",chr(13),$nl);
	  $nl=str_replace("&nbsp;",chr(32),$nl);
	  $nl=str_replace(" ",chr(9),$nl);
	  $nl=str_replace("&quot;",chr(34),$nl);
	  $nl=str_replace("&#39;",chr(39),$nl);
	  //$nl=str_replace("&gt;",">",$nl);
	  //$nl=str_replace("&lt;","<",$nl);
	  //$nl=str_replace("&amp;","&",$nl);
      return $nl;
}
function nohtml($str){
	$str=preg_replace( '/<(.[^>]*)>/i' ,'' ,$str );
	return $str;
}
function clearnulllen($str){
    $str=strtolower($str);
	$str=str_replace("<div>","",$str);
	$str=str_replace("</div>","",$str);
	$str=str_replace("<br>","",$str);
	$str=str_replace("<br />","",$str);
	$str=str_replace("&nbsp;","",$str);
	$str=str_replace(" ","",$str);
	$str=strlen($str);
	return $str;
}
function nojs($str){
	$str=preg_replace( '/\bscript\b/i' ,' script ' ,$str );
	$str=preg_replace( '/\biframe\b/i' ,' iframe ' ,$str );
	return $str;
}
?>