Add BBCode to PMs


Real quick.

Go to where you have your inbox/pm system stored.

Where you have

PHP Code
  1. <?php


replace it with:

PHP Code
  1. <?php
  2. function BBCODE($content){ //define the function of bbcode
  3. $content = nl2br($content); //replaces returns with br's
  4. $match = array(
  5. '#\[b\](.*?)\[\/b\]#se',
  6. '#\[i\](.*?)\[\/i\]#se',
  7. '#\[u\](.*?)\[\/u\]#se',
  8. '#\[url=(.*?)\](.*?)\[\/url\]#se',
  9. '#\[url\](.*?)\[\/url\]#se',
  10. '#\[img\](.*?)\[\/img\]#se',
  11. '#\[code\](.*?)\[\/code\]#se',
  12. '#\[php\](.*?)\[\/php\]#se',
  13. '#\[html\](.*?)\[\/html\]#se',
  14. '#\[print\](.*?)\[\/print\]#se'
  15. ); //codes used in posts
  16. $replace = array(
  17. "'<b>\\1</b>'",
  18. "'<i>\\1</i>'",
  19. "'<u>\\1</u>'",
  20. "'<a href=\"\\1\" target=\"_BLANK\">\\2</a>'",
  21. "'<a href=\"\\1\" target=\"_BLANK\">\\1</a>'",
  22. "'<img border=\"0\" src=\"\\1\">'",
  23. "'<u><b>Code:</b></u>
  24. <div style=\"border: 1px dotted #000000; width: 370px; background-color: #CCCCCC;\">
  25. '.highlight_string(stripslashes(str_replace('', '', '$1')), true).'</div>'",
  26. "'<u><b>PHP Code:</b></u>
  27. <div style=\"border: 1px solid #42AC47; width: 370px;background-color: #B1E2B4;> '.highlight_string(stripslashes(str_replace('', '', '$1')), true).'</div>'",
  28. "'<u><b>HTML Code:</b></u>
  29. <div style=\"border: 1px solid #42AC47; width: 370px;background-color: #CCCCCC;> '.highlight_string(stripslashes(str_replace('', '', '$1')), true).'</div>'",
  30. "'<u><b>Print Out:</b></u>
  31. <div style=\"border: 1px dotted #000000; width: 370px; background-color: #CCCCCC;>
  32. '.highlight_string(stripslashes(str_replace('', '', '$1')), true).'</div>'"
  33. ); //replacements
  34. return preg_replace($match, $replace, $content); //match, and replace
  35. } //end the function


Now go down to case 'view':

and above the first echo add

PHP Code
  1. $bbmsg = BBCODE($message);


then go down a little more. Replace $message with $bbmsg.

Now go to case 'compose'.

Where it says:
PHP Code
  1. <b>Subject</b>: <input type=\"text\" name=\"title\" size=\"20\">


Add below it:
PHP Code
  1. <br><div style='padding-left: 5px; padding-top:5px;'>
  2. <input type='button' value='B' name='btnBold' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<b>&#39;,&#39;</b>&#39;);'>
  3. <input type='button' value='I' name='btnItalic' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<i>&#39;,&#39;</i>&#39;);'>
  4. <input type='button' value='U' name='btnUnderline' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<u>&#39;,&#39;</u>&#39;);'>
  5. <input type='button' value='IMG' name='btnImg' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<img src="&#39;,&#39;" alt="TutorialNinja Image">&#39;);''>
  6. <input type='button' value='PHP' name='btnPHP' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;[php]&#39;,&#39;
&#39;);'></div>
[/php]

And you are done. That BBcode should appear above the message body and below the message title. Enjoy.
UrbanTwitch's Avatar
Views:
4,370
Rating:
Posted on Saturday 13th September 2008 at 12:03 PM
Dalez
Dalez's Avatar
This part:
Code
<div style='padding-left: 5px; padding-top:5px;'>
<input type='button' value='B' name='btnBold' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<b>&#39;,&#39;</b>&#39;);'>
<input type='button' value='I' name='btnItalic' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<i>&#39;,&#39;</i>&#39;);'>
<input type='button' value='U' name='btnUnderline' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<u>&#39;,&#39;</u>&#39;);'>
<input type='button' value='IMG' name='btnImg' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<img src="&#39;,&#39;" />&#39;);''>
<input type='button' value='URL' name='btnUrl' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;&#39;,&#39;&#39;);'>
<input type='button' value='PHP' name='btnPHP' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;[php]&#39;,&#39;


Is the little buttons that you press to make them enter into the box named: TheTextArea.

^^
Posted on Thursday 11th September 2008 at 11:24 PM
Dava
Dava's Avatar
a screenshot would help
Posted on Thursday 11th September 2008 at 09:10 PM
jambomb
jambomb's Avatar
This part its well buggerd lol

Code


<div style='padding-left: 5px; padding-top:5px;'>
<input type='button' value='B' name='btnBold' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<b>&#39;,&#39;</b>&#39;);'>
<input type='button' value='I' name='btnItalic' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<i>&#39;,&#39;</i>&#39;);'>
<input type='button' value='U' name='btnUnderline' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<u>&#39;,&#39;</u>&#39;);'>
<input type='button' value='IMG' name='btnImg' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;<img src="&#39;,&#39;" />&#39;);''>
<input type='button' value='URL' name='btnUrl' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;&#39;,&#39;&#39;);'>
<input type='button' value='PHP' name='btnPHP' onclick='wrapText(document.getElementById(&#39;TheTextArea&#39;),&#39;[php]&#39;,&#39;

Posted on Thursday 11th September 2008 at 04:44 PM
Dava
Dava's Avatar
what do u mean messed up
Posted on Thursday 11th September 2008 at 03:51 PM
jambomb
jambomb's Avatar
I know but the codes messed up on my screen then and it doesnt work
Posted on Wednesday 10th September 2008 at 11:06 PM
Dava
Dava's Avatar
jambomb its pretty easy if you read
Posted on Wednesday 10th September 2008 at 04:51 PM
Posted on Monday 18th August 2008 at 01:45 PM
jambomb
jambomb's Avatar
please can some one simple this out a bit ? :)
Posted on Saturday 16th August 2008 at 12:13 PM
Posted on Thursday 14th August 2008 at 03:15 PM
jambomb
jambomb's Avatar
This is really confusing can some 1 just simple it out a bit :S