PHP BB Code Smiles

BB Code Smiles

<?
function bbcode ($entry) {
global $query,$result2,$connect,$replace,$table_smilies;
    /*
    $query="SELECT * FROM $table_smilies";
    $result2 = mysql_query($query, $connect);
    while($replace=mysql_fetch_array($result2)){
    $entry = preg_replace("/".preg_quote($replace[code])."/","<img src=\"$replace[htmlreplace]\">",$entry);}
    */
$entry = eregi_replace("","<br>",$entry);
$entry = eregi_replace("\[b\]([^\[]+)\[/b\]","<b>\\1</b>",$entry);
$entry = eregi_replace("\[i\]([^\[]+)\[/i\]","<i>\\1</i>",$entry);
$entry = eregi_replace("\[u\]([^\[]+)\[/u\]","<u>\\1</u>",$entry);
$entry = eregi_replace("\[img\]([^\[]+)\[/img\]","<img src=\"\\1\" border=\"0\">",$entry);
$entry = eregi_replace("\[mail\]([^\[]+)\[/mail\]","<a href=\"mailto:\\1\">\\1</a>",$entry);
$entry = eregi_replace("\[url\]([^\[]+)\[/url\]","<a href=\"\\1\" target=\"_blank\">\\1</a>",$entry);
$entry = eregi_replace("\[url=\"([^\"]+)\"]([^\[]+)\[/url\]","<a href=\"\\1\" target=\"_blank\">\\2</a>",$entry);
return $entry; } 
?>