PHP Ubb converted into html,html to UBB code
function Htmltoubb ($STR)
{
$str = Preg_replace ("/]+src=" ([^ "]+)" [^>]*>/i "," [Img]$1[/img] ", $STR);
$str = Preg_replace ("/<embed[^>]+src=" ([^ "]+)" [^>]*></embed>/i "," [Video]$1[/video] ", $STR);
return $str;
}
function UBB ($STR)
{
$auto _arr = Array (
"/(? <=[^]a-z0-9-=" ' \/]) (https?| FTP|MMS|RTSP)://) ([a-z0-9/-_+=.~!%@?#%&;:$\│]+)/I ",
"/(? <=[^]a-z0-9/-_.~?=:.]) ([_a-z0-9-]+ (. [ _a-z0-9-]+) *@[a-z0-9-]+ (. [ a-z0-9-]+) * (. [ a-z]{2,4}))/I ",
"/[img" (. +?) [/img]/is ",
"/[video" (. +?) [/video]/is]
);
$auto _url = Array (
"<a href=" \1\3 "target=" _blank ">\1\3</a>",
' <a href= ' mailto:\0 ' >\0</a> ',
' <a href= ' \1 "rel=" Pic "class=" Thickbox "onfocus=" This.blur () "></a> ',
"<embed src=" \1 "quality=" High "width=" "" "height=", "" align= "Middle" wmode= "Opaque" "allowscriptaccess=" Samedomain "type=" Application/x-shockwave-flash "></embed>"
);
$str = Preg_replace ($auto _arr, $auto _url, "". $str);
$str = NL2BR ($STR);
return $str;
}