CJ - Twitch Posted February 28, 2010 Posted February 28, 2010 When I send a message I get this error... Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found in /******/bbcode.php on line 42 Any Ideas? Quote
Paddy Posted February 28, 2010 Posted February 28, 2010 When I send a message I get this error... Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found in /******/bbcode.php on line 42 Any Ideas? can you post 1 or 2 lines where the error is? like line 40,41,42,43 could help Quote
CJ - Twitch Posted February 28, 2010 Author Posted February 28, 2010 Here is the code. :) <?phpfunction bb2html($text){$pattern[] = "/\[url=([^<> \n]+?)\](.+?)\[\/url\]/i";$replacement[] = '[url="\\1"]\\2[/url]';$pattern[] = "/\[url\](.+?)\[\/url\]/i";$replacement[] = '[url="\\1"]\\1[/url]';$pattern[] = "/\[email=([^<> \n]+?)\](.+?)\[\/email\]/i";$replacement[] = '[email="\\1"]\\2[/email]';$pattern[] = "/\[img[=]?(left|right)?\](([^<> \n]+?)\.(gif|jpg|jpeg|png|bmp))\[\/img\]/i";$replacement[] = '[img=\\2]';$pattern[] = "/\[[bB]\](.+?)\[\/[bB]\]/s";$replacement[] = '[b]\\1[/b]';$pattern[] = "/\[[iI]\](.+?)\[\/[iI]\]/s";$replacement[] = '[i]\\1[/i]';$pattern[] = "/\[[uU]\](.+?)\[\/[uU]\]/s";$replacement[] = '<u>\\1</u>';$pattern[] = "/\[[pP]\](.+?)\[\/[pP]\]/s";$replacement[] = ' \\1</p>';$pattern[] = "/\[[sS]\](.+?)\[\/[sS]\]/s";$replacement[] = '<s>\\1</s>';$pattern[] = "/\/s";$replacement[] = '<hr />';$pattern[] = "/\(.+?)\[\/center\]/is";$replacement[] = '<center>\\1</center>';$pattern[] = "/\[align(=left|=right|=center|=justify)?\](.+?)\[\/align\]/is";$replacement[] = '<div align\\1>\\2</div>';$pattern[] = "/\[color=(#[A-F0-9]{6})\](.+?)\[\/color\]/is";$replacement[] = '<font color="\\1">\\2</font>';$pattern[] = "/\[link=([^<> \n]+?)\](.+?)\[\/link\]/i";$replacement[] = '[url="\\1"]\\2[/url]';$pattern[] = "/\[nbsp]/s";$replacement[] = ' ';$pattern[] = "/\[div]/s";$replacement[] = '<div class="hr"> </div>';$pattern[] = "/\[bp]/s";$replacement[] = '[img=icons/bullet.png] ';$pattern[] = "/\[arrow]/s";$replacement[] = '[img=icons/arrow.png] ';$pattern[] = "/\[ab=([^<> \n].+?)\](.+?)\[\/ab\]/i";$replacement[] = '<abbr title="\\1">\\2</abbr>';$text = preg_replace($pattern, $replacement, $text);return $text;}function strip_bbcode($text){$pattern[] = "/\[url=([^<> \n]+?)\](.+?)\[\/url\]/i";$pattern[] = "/\[email=([^<> \n]+?)\](.+?)\[\/email\]/i";$pattern[] = "/\[img(=left|=right)?\](([^<> \n]+?)\.(gif|jpg|jpeg|png))\[\/img\]/i";$pattern[] = "/\[[bB]\](.+?)\[\/[bB]\]/s";$pattern[] = "/\[[iI]\](.+?)\[\/[iI]\]/s";$pattern[] = "/\[[uU]\](.+?)\[\/[uU]\]/s";$pattern[] = "/\/s";$pattern[] = "/\(.+?)\[\/center\]/is";$pattern[] = "/\[align(=left|=right|=center|=justify)?\](.+?)\[\/align\]/is";$pattern[] = "/\[font(#[A-F0-9]{6})\](.+?)\[\/font\]/is";$pattern[] = "/\[link=([^<> \n]+?)\](.+?)\[\/link\]/i";$pattern[] = "/\[nbsp]/s";$pattern[] = "/\[div]/s";$pattern[] = "/\[bp]/s";$text = preg_replace($pattern, '', $text);return $text;}?> Quote
CJ - Twitch Posted February 28, 2010 Author Posted February 28, 2010 My Mail Box... <?php include "globals.php"; require "bbcodestyle.css"; require "bbcode.php"; if($ir['mailban']) { die("<center><font color=red><font size='4' face='Arial, Helvetica, sans-serif'>Error</font> You have been mail banned for {$ir['mailban']} days. [b]Reason: {$ir['mb_reason']}</font>[/b]"); } if($ir['pagetutorials'] == ON) { print " <table width=85% border=3 bordercolor=#BDBDBD cellspacing=0 bgcolor=#FBFBE0 frame=border rules=none> <tr><td width=85><img src=images/lightbulb.gif> <font color=#999999>[i][[url="preferences.php><font"][i]Turn Off[/i]</font>[/url]][/i]</font></center></td><td><center>[b]Mailbox Tutorial[/b]</center><font color=#000000 size=2> Here you can view your mail and send mail to other players. Making friends on Mini Mafia is imperative, they can protect you when you need it, and help you out with questions you have. Mailing them is one of the the best ways to do this. When you have a new mail, the Mailbox word on the sidebar will go bold. You can then click the subject of the mail to read it. </font></td></tr></table> "; } $_GET['ID'] = abs((float) $_GET['ID']); print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Mail Box</font><hr widTH=75%><table border='0' width=75%><tr bgcolor=#999999><tr> <TD widTH=20% align=center>> [url='mailbox.php?action=compose'] Compose[/url]</TD> <TD widTH=20% align=center>> [url='mailbox.php?action=outbox'] Outbox[/url]</TD> <TD widTH=20% align=center>> [url='mailbox.php?action=archive'] Save[/url]</TD> <TD widTH=20% align=center>> [url='ignorelist.php'] Ignore List[/url]</TD> <TD widTH=20% align=center>> [url='mailbox.php?action=mailhome'] Inbox[/url]</TD> </tr></table><hr widTH=75%>"; switch($_GET['action']) { case 'inbox': mail_inbox(); break; case 'outbox': mail_outbox(); break; case 'compose': mail_compose(); break; case 'delete': mail_delete(); break; case 'send': mail_send(); break; case 'delall': mail_delall(); break; case 'delall2': mail_delall2(); break; case 'archive': mail_archive(); break; case 'read': mail_view(); break; case 'mailhome': mail_home(); break; default: mail_home(); break; } function mail_home() { if($ir['pagetutorials'] == ON) { print " <table width=85% border=3 bordercolor=#BDBDBD cellspacing=0 bgcolor=#FBFBE0 frame=border rules=none> <tr><td width=85><img src=images/lightbulb.gif> <font color=#999999>[i][[url="preferences.php><font"][i]Turn Off[/i]</font>[/url]][/i]</font></center></td><td><center>[b]Mailbox Tutorial[/b]</center><font color=#000000 size=2> Here you can view your mail and send mail to other players. Making friends on Mini Mafia is imperative, they can protect you when you need it, and help you out with questions you have. Mailing them is one of the the best ways to do this. When you have a new mail, the Mailbox word on the sidebar will go bold. You can then click the subject of the mail to read it. </font></td></tr></table> "; } global $ir,$c,$userid,$h,$db; print "Below are the Last 20 Messages Sent to you<hr widTH=85%> <table width=75% border=0 cellspacing=0><tr bgcolor=#999999> <TH widTH=30%>From</TH> <TH widTH=40%>Subject</TH> <TH widTH=15%>Status</TH> <TH widTH=15%>Manage</TH> </tr> <tr bgcolor=$bgcolor>"; $q = $db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_to=$userid ORDER BY mail_time DESC LIMIT 20",$c); while($r = $db->fetch_row($q)) { $bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf"; $sent = date('F j, Y, g:i:s a',$r['mail_time']); print "<tr bgcolor=$bgcolor><TD>"; if($ir['userid'] == 0) { echo 'SYSTEM'; } else { echo '[url="viewuser.php?u='.$r['userid'].'"]'.$r['username'].'[/url] ['.$r['userid'].']'; } $fm = urlencode($r['mail_subject']); if($r['mail_read'] == 0) { $status = "<font color=red>Unread</font>"; } else { $status = "<font color=green>Read</font>"; } if($r['mail_subject'] == '') { $subj="No Subject"; } else { $subj="{$r['mail_subject']}"; } print " </TD> <TD> [b]Subject:[/b] [url='mailbox.php?action=read&ID={$r[']$subj[/url] [i]Sent at: $sent[/i] </TD> <TD> <center> $status </center> </TD> <TD> <center> [[url='mailbox.php?action=delete&ID={$r[']Delete[/url]] [[url='mailbox.php?action=read&ID={$r[']Read[/url]] </center> </TD> </tr>"; } echo '</table>'; } function mail_view() { global $ir,$c,$userid,$h,$db; print " <table width=75% border=0 cellspacing=0><tr bgcolor=#999999>"; mysql_query("UPDATE users SET new_mail=new_mail-1 WHERE userid='$userid' AND new_mail>0") or die(mysql_error()); $id= abs((int) $_GET['ID']); $q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_id=$id LIMIT 1"); while($r=$db->fetch_row($q)) { $bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf"; $sent=date('F j, Y, g:i:s a',$r['mail_time']); print "<tr bgcolor=$bgcolor><TD bgcolor=#AAAAAA>"; if($r['userid']) { print "[b]Mail From: [/b][url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]"; } else { print "SYSTEM"; } if($r['mail_subject'] == '') { $subj="No Subject"; } else { $subj="{$r['mail_subject']}"; } $fm=urlencode($r['mail_text']); print "<th bgcolor=#AAAAAA width=85%>[b]Subject:[/b] {$r['mail_subject']}</th></tr><tr bgcolor=$bgcolor><TD>Sent at: $sent [url='mailbox.php?action=compose&ID={$r[']Reply[/url] [url='mailbox.php?action=delete&ID={$r[']Delete[/url] [url='preport.php?ID={$r[']Report[/url]</TD><TD>{$r['mail_text']}</TD></tr></table> <form action='mailbox.php?action=send' method='post'> <table width=75% border=0 cellspacing=0><th colspan=2 bgcolor=#AAAAAA>[b]Reply To This Message[/b]</th> <tr bgcolor=$bgcolor> <TD>User's ID:</TD> <TD><input type='text' name='userid' value='{$r['userid']}' size='5' maxlength='10' /> [i]<font size=1.9>(E.g. 123456)</font>[/i]</TD></tr><tr bgcolor=$bgcolor> <TD>Subject:</TD> <TD><input type='text' name='subject' size='50' maxlength='50' value='Re: {$r['mail_subject']}' /> [i]<font size=1.9>(E.g. Hello there)</font>[/i]</TD></tr><tr bgcolor=$bgcolor> <TD>Message:</TD> <TD><textarea name='message' id='notepadText' rows='0' cols='0'></textarea></TD></tr><tr bgcolor=$bgcolor> <TD colspan=2><center><input type='submit' value='Send' /></TD></tr></form>"; } $db->query("UPDATE mail SET mail_read=1 WHERE mail_id=$id",$c); } function mail_outbox() { global $ir,$c,$userid,$h,$db; print "Below are the Last 20 Messages You have Sent<hr widTH=85%> <table width=75% border=0 cellspacing=0 bgcolor=#DEDEDE><tr bgcolor=#999999><TH widTH=35%>From</TH><TH widTH=50%>Subject</TH><TH widTH=15%>Manage</TH></tr>"; $q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_to=u.userid WHERE m.mail_from=$userid ORDER BY mail_time DESC LIMIT 20",$c); while($r=$db->fetch_row($q)) { $bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf"; $sent=date('F j, Y, g:i:s a',$r['mail_time']); print "<tr bgcolor=$bgcolor><TD>"; if($r['userid']) { print "[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]"; } else { print "SYSTEM"; print "SYSTEM"; } if($r['mail_subject'] == '') { $subj="No Subject"; } else { $subj="{$r['mail_subject']}"; } $fm=urlencode($r['mail_subject']); if($r['mail_read'] == 0) { $status="<font color=red>Unread</font>"; } else { $status="<font color=green>Read</font>"; } if($r['mail_subject'] == '') { $subj="No Subject"; } else { $subj="{$r['mail_subject']}"; } print "</TD>\n<TD>[b]Subject:[/b] [url='mailbox.php?action=read&ID={$r[']$subj[/url] [i]Sent at: $sent[/i]</TD><TD><center>[[url='mailbox.php?action=read&ID={$r[']Read[/url]]</TD></tr>"; } echo '</table>'; } function mail_compose() { global $ir,$c,$userid,$h,$db; echo <<< EOF <script type="text/javascript"> function insert(el,ins) { if (el.setSelectionRange){ el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) + el.value.substring(el.selectionEnd,el.value.length); } else if (document.selection && document.selection.createRange) { el.focus(); var range = document.selection.createRange(); range.text = ins + range.text; } } </script> $q = $db->query($select); $r=$db->fetch_row($q); $iduser = (int) $_GET['ID']; print "<form action='mailbox.php?action=send' method='post'> <table width=75% border=0 cellspacing=0><tr colspan=3 bgcolor=#999999> <tr bgcolor=$bgcolor><TD>[b] Send a Message[/b]</TD></tr><tr bgcolor=$bgcolor> <TD>User's ID:</TD> <TD><input type='text' name='userid' value='$iduser' size='5' maxlength='10' /> [i]<font size=1.9>(E.g. 64)</font>[/i]</TD></tr><tr bgcolor=$bgcolor> <TD>Subject:</TD> <TD><input type='text' name='subject' size='50' maxlength='50' value=' ' /> [i]<font size=1.9>(E.g. Good Morning)</font>[/i]</TD></tr><tr bgcolor=$bgcolor> <TD>Message:</TD> <TD> <center> <input type="button" class="bbcode_hover" onClick="insert(this.form.message,'[b][/b]'); return false;" value="" /> <input type="button" class="bbcode_hover1" onClick="insert(this.form.message,'[i][/i]'); return false;" value="" /> <input type="button" class="bbcode_hover2" onClick="insert(this.form.message,'[u][/u]'); return false;" value="" /> <input type="button" class="bbcode_hover3" onClick="insert(this.form.message,'[url][/url]'); return false;" value="" /> <input type="button" class="bbcode_hover4" onClick="insert(this.form.message,''); return false;" value="" /> <input type="button" class="bbcode_hover5" onClick="insert(this.form.message,'[img][/img]'); return false;" value="" /> <input type="button" class="bbcode_hover6" onClick="insert(this.form.message,''); return false;" value="" /> <input type="button" class="bbcode_hover7" onClick="insert(this.form.message,'[color=#xxxxxx][/color]'); return false;" value="" /> <textarea name='message' rows='10' cols='70'></textarea> <input type="image" src="smilies/smiley1.gif" alt="Smile" title="smile" onclick="insert(this.form.message,':)'); return false;" /> <input type="image" src="smilies/smiley2.gif" alt="Wink" title="Wink" onclick="insert(this.form.message,';)'); return false;" /> <input type="image" src="smilies/smiley3.gif" alt="Suprised" title="Suprised" onclick="insert(this.form.message,':o'); return false;" /> <input type="image" src="smilies/smiley4.gif" alt="Cheesy Grin" title="Cheesy Grin" onclick="insert(this.form.message,':D'); return false;" /> <input type="image" src="smilies/smiley5.gif" alt="Confused" title="Confused" onclick="insert(this.form.message,':s'); return false;" /> <input type="image" src="smilies/smiley6.gif" alt="Sad" title="Sad" onclick="insert(this.form.message,':('); return false;" /> <input type="image" src="smilies/smiley7.gif" alt="Angry" title="Angry" onclick="insert(this.form.message,':red'); return false;" /> <input type="image" src="smilies/smiley8.gif" alt="Clown" title="Clown" onclick="insert(this.form.message,':clown'); return false;" /> <input type="image" src="smilies/smiley9.gif" alt="Embarrassed" title="Embarrassed" onclick="insert(this.form.message,':bashful'); return false;" /> <input type="image" src="smilies/smiley10.gif" alt="Star" title="Star" onclick="insert(this.form.message,':x'); return false;" /> <input type="image" src="smilies/smiley11.gif" alt="Sick" title="Sick" onclick="insert(this.form.message,':green'); return false;" /> <input type="image" src="smilies/smiley12.gif" alt="Bored" title="Bored" onclick="insert(this.form.message,':|'); return false;" /> <input type="image" src="smilies/smiley13.gif" alt="Begging" title="Begging" onclick="insert(this.form.message,';('); return false;" /> <input type="image" src="smilies/smiley14.gif" alt="Smug" title="Smug" onclick="insert(this.form.message,':]'); return false;" /> <input type="image" src="smilies/smiley15.gif" alt="Horny" title="Horny" onclick="insert(this.form.message,':horny'); return false;" /> <input type="image" src="smilies/smiley16.gif" alt="Cool" title="Cool" onclick="insert(this.form.message,':cool'); return false;" /></center> </TD></tr><tr bgcolor=$bgcolor> <TD colspan=2><center><input type='submit' value='Send' /></TD></tr></table></form><hr width=85%>> [url='mailbox.php']Back to Messages[/url]<hr width=85%>"; if($_GET['ID']) { print " <table width=75% border=0 cellspacing=0 bgcolor=#DEDEDE><tr bgcolor=#999999><tr bgcolor=$bgcolor><TD bgcolor=#AAAAAA>[b]Your last 10 mails to/from this person:[/b]</TD></tr>"; $q=$db->query("SELECT m.*,u1.username as sender from mail m left join users u1 on m.mail_from=u1.userid WHERE (m.mail_from=$userid AND m.mail_to={$_GET['ID']}) OR (m.mail_to=$userid AND m.mail_from={$_GET['ID']}) ORDER BY m.mail_time DESC LIMIT 10",$c); while($r=$db->fetch_row($q)) { $bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf"; $sent=date('F j, Y, g:i:s a',$r['mail_time']); print "<tr bgcolor=$bgcolor><TD>$sent</TD> <TD>[b]{$r['sender']} wrote:[/b] {$r['mail_text']}</TD></tr>"; } print "</table>"; } } function mail_send() { global $ir,$c,$userid,$h,$db; $subj=str_replace(array("\n"),array(" "),strip_tags($_POST['subject'])); $msg=bb2html($_POST['message']); $codes = array(":)", ";)", ":o", ":D", ":s", ":(", ":red", ":clown", ":bashful", ":x", ":green", ":|", ";(", ":]", ":horny", ":cool"); $images = array("<img src=smilies/smiley1.gif>", "<img src=smilies/smiley2.gif>", "<img src=smilies/smiley3.gif>", "<img src=smilies/smiley4.gif>", "<img src=smilies/smiley5.gif>", "<img src=smilies/smiley6.gif>", "<img src=smilies/smiley7.gif>", "<img src=smilies/smiley8.gif>", "<img src=smilies/smiley9.gif>", "<img src=smilies/smiley10.gif>", "<img src=smilies/smiley11.gif>", "<img src=smilies/smiley12.gif>", "<img src=smilies/smiley13.gif>", "<img src=smilies/smiley14.gif>", "<img src=smilies/smiley15.gif>", "<img src=smilies/smiley16.gif>"); $newmsg = str_replace($codes, $images, $msg); $to= (int) $_POST['userid']; if($_POST['userid'] < 0) { die("<font color=red>[b]Coo Off Stop trying to exploit bugs.[/b]</font>"); } mysql_query("UPDATE users SET new_mail=new_mail+1 WHERE userid='{$to}'") or die(mysql_error()); $db->query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$newmsg','{$_POST['subject']}','{$_POST['message']}')",$c) or die(mysql_error()); print "Your message was sent to {$ir['username']}. [url='mailbox.php']> Back[/url]"; } function mail_delete() { global $ir,$c,$userid,$h,$db; $m=$db->query("SELECT * FROM mail WHERE mail_to=$userid"); $nm=$db->num_rows($m); $db->query("UPDATE users SET new_mail=new_mail-{$nm} WHERE userid=$userid AND new_mail>0",$c); $db->query("DELETE FROM mail WHERE mail_id={$_GET['ID']} AND mail_to='{$ir['userid']}'",$c); print "Message deleted. [url='mailbox.php']> Back[/url]"; } function mail_delall() { global $ir,$c,$userid,$h,$db; print "THis will delete all THe messages in your inbox. THere is [b]NO[/b] undo, so be sure. [url='mailbox.php?action=delall2']> Yes, delete all messages[/url] [url='mailbox.php']> No, go back[/url]"; } function mail_delall2() { global $ir,$c,$userid,$h,$db; $db->query("DELETE FROM mail WHERE mail_to=$userid",$c); $db->query("UPDATE users SET new_mail=new_mail-".mysql_affected_rows($c)." WHERE userid=$userid AND new_mail>0",$c); print "All ".mysql_affected_rows($c)." mails in your inbox were deleted. [url='mailbox.php']> Back[/url]"; } function mail_archive() { global $ir,$c,$userid,$h; print "THis tool will download an archive of all your messages. [url='dlarchive.php?a=inbox']> Download Inbox[/url] [url='dlarchive.php?a=outbox']> Download Outbox[/url]"; } $h->endpage(); ?> Quote
CJ - Twitch Posted February 28, 2010 Author Posted February 28, 2010 The BBCodea gain... (Last one fu*ked up) <?php function bb2html($text) { $pattern[] = "/\[url=([^<> \n]+?)\](.+?)\[\/url\]/i"; $replacement[] = '[url="\\1"]\\2[/url]'; $pattern[] = "/\[url\](.+?)\[\/url\]/i"; $replacement[] = '[url="\\1"]\\1[/url]'; $pattern[] = "/\[email=([^<> \n]+?)\](.+?)\[\/email\]/i"; $replacement[] = '[email="\\1"]\\2[/email]'; $pattern[] = "/\[img[=]?(left|right)?\](([^<> \n]+?)\.(gif|jpg|jpeg|png|bmp))\[\/img\]/i"; $replacement[] = '[img=\\2]'; $pattern[] = "/\[[bB]\](.+?)\[\/[bB]\]/s"; $replacement[] = '[b]\\1[/b]'; $pattern[] = "/\[[iI]\](.+?)\[\/[iI]\]/s"; $replacement[] = '[i]\\1[/i]'; $pattern[] = "/\[[uU]\](.+?)\[\/[uU]\]/s"; $replacement[] = '<u>\\1</u>'; $pattern[] = "/\[[pP]\](.+?)\[\/[pP]\]/s"; $replacement[] = ' \\1</p>'; $pattern[] = "/\[[sS]\](.+?)\[\/[sS]\]/s"; $replacement[] = '<s>\\1</s>'; $pattern[] = "/\/s"; $replacement[] = '<hr />'; $pattern[] = "/\(.+?)\[\/center\]/is"; $replacement[] = '<center>\\1</center>'; $pattern[] = "/\[align(=left|=right|=center|=justify)?\](.+?)\[\/align\]/is"; $replacement[] = '<div align\\1>\\2</div>'; $pattern[] = "/\[color=(#[A-F0-9]{6})\](.+?)\[\/color\]/is"; $replacement[] = '<font color="\\1">\\2</font>'; $pattern[] = "/\[link=([^<> \n]+?)\](.+?)\[\/link\]/i"; $replacement[] = '[url="\\1"]\\2[/url]'; $pattern[] = "/\[nbsp]/s"; $replacement[] = ' '; $pattern[] = "/\[div]/s"; $replacement[] = '<div class="hr"> </div>'; $pattern[] = "/\[bp]/s"; $replacement[] = '[img=icons/bullet.png] '; $pattern[] = "/\[arrow]/s"; $replacement[] = '[img=icons/arrow.png] '; $pattern[] = "/\[ab=([^<> \n].+?)\](.+?)\[\/ab\]/i"; $replacement[] = '<abbr title="\\1">\\2</abbr>'; $text = preg_replace($pattern, $replacement, $text); return $text; } function strip_bbcode($text) { $pattern[] = "/\[url=([^<> \n]+?)\](.+?)\[\/url\]/i"; $pattern[] = "/\[email=([^<> \n]+?)\](.+?)\[\/email\]/i"; $pattern[] = "/\[img(=left|=right)?\](([^<> \n]+?)\.(gif|jpg|jpeg|png))\[\/img\]/i"; $pattern[] = "/\[[bB]\](.+?)\[\/[bB]\]/s"; $pattern[] = "/\[[iI]\](.+?)\[\/[iI]\]/s"; $pattern[] = "/\[[uU]\](.+?)\[\/[uU]\]/s"; $pattern[] = "/\/s"; $pattern[] = "/\(.+?)\[\/center\]/is"; $pattern[] = "/\[align(=left|=right|=center|=justify)?\](.+?)\[\/align\]/is"; $pattern[] = "/\[font(#[A-F0-9]{6})\](.+?)\[\/font\]/is"; $pattern[] = "/\[link=([^<> \n]+?)\](.+?)\[\/link\]/i"; $pattern[] = "/\[nbsp]/s"; $pattern[] = "/\[div]/s"; $pattern[] = "/\[bp]/s"; $text = preg_replace($pattern, '', $text); return $text; } ?> Quote
Paddy Posted February 28, 2010 Posted February 28, 2010 Try This PHP Source code function bb2html($text){$pattern[] = "/\[url=([^<> \n]+?)\](.+?)\[\/url\]/i";$replacement[] = '[url="\\1"]\\2[/url]';$pattern[] = "/\[url\](.+?)\[\/url\]/i";$replacement[] = '[url="\\1"]\\1[/url]';$pattern[] = "/\[email=([^<> \n]+?)\](.+?)\[\/email\]/i";$replacement[] = '[email="\\1"]\\2[/email]';$pattern[] = "/\[img[=]?(left|right)?\](([^<> \n]+?)\.(gif|jpg|jpeg|png|bmp))\[\/img\]/i";$replacement[] = '[img=\\2]';$pattern[] = "/\[[bB]\](.+?)\[\/[bB]\]/s";$replacement[] = '[b]\\1[/b]';$pattern[] = "/\[[iI]\](.+?)\[\/[iI]\]/s";$replacement[] = '[i]\\1[/i]';$pattern[] = "/\[[uU]\](.+?)\[\/[uU]\]/s";$replacement[] = '<u>\\1</u>';$pattern[] = "/\[[pP]\](.+?)\[\/[pP]\]/s";$replacement[] = ' \\1</p>';$pattern[] = "/\[[sS]\](.+?)\[\/[sS]\]/s";$replacement[] = '<s>\\1</s>';$pattern[] = "/\/s";$replacement[] = '<hr />';$pattern[] = "/\(.+?)\[\/center\]/is";$replacement[] = '<center>\\1</center>';$pattern[] = "/\[align(=left|=right|=center|=justify)?\](.+?)\[\/align\]/is";$replacement[] = '<div align\\1>\\2</div>';$pattern[] = "/\[color=(#[A-F0-9]{6})\](.+?)\[\/color\]/is";$replacement[] = '<font color="\\1">\\2</font>';$pattern[] = "/\[link=([^<> \n]+?)\](.+?)\[\/link\]/i";$replacement[] = '[url="\\1"]\\2[/url]';$pattern[] = "/\[nbsp]/s";$replacement[] = ' ';$pattern[] = "/\[div]/s";$replacement[] = '<div class="hr"> </div>';$pattern[] = "/\[bp]/s";$replacement[] = '[img=icons/bullet.png] ';$pattern[] = "/\[arrow]/s";$replacement[] = '[img=icons/arrow.png] ';$pattern[] = "/\[ab=([^<> \n].+?)\](.+?)\[\/ab\]/i";$replacement[] = '<abbr title="\\1">\\2</abbr>';$text = preg_replace($pattern, $replacement, $text);return $text;}function strip_bbcode($text){$pattern[] = "/\[url=([^<> \n]+?)\](.+?)\[\/url\]/i";$pattern[] = "/\[email=([^<> \n]+?)\](.+?)\[\/email\]/i";$pattern[] = "/\[img(=left|=right)?\](([^<> \n]+?)\.(gif|jpg|jpeg|png))\[\/img\]/i";$pattern[] = "/\[[bB]\](.+?)\[\/[bB]\]/s";$pattern[] = "/\[[iI]\](.+?)\[\/[iI]\]/s";$pattern[] = "/\[[uU]\](.+?)\[\/[uU]\]/s";$pattern[] = "/\/s";$pattern[] = "/\(.+?)\[\/center\]/is";$pattern[] = "/\[align(=left|=right|=center|=justify)?\](.+?)\[\/align\]/is";$pattern[] = "/\[font(#[A-F0-9]{6})\](.+?)\[\/font\]/is";$pattern[] = "/\[link=([^<> \n]+?)\](.+?)\[\/link\]/i";$pattern[] = "/\[nbsp]/s";$pattern[] = "/\[div]/s";$pattern[] = "/\[bp]/s";$text = preg_replace($pattern, $replaces, $text);return $text;} Quote
Jordan Palmer Posted February 28, 2010 Posted February 28, 2010 This modification sucks ass -_- Quote
kryptonite Posted March 1, 2010 Posted March 1, 2010 $text = preg_replace($pattern, $replacement, $text); to $text []= preg_replace($pattern, $replacement, $text); thats line 42 maybe im not fully sure Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.