PDA

View Full Version : BBCode


Fireballchad
09-10-2009, 07:39 PM
Ok well I managed to get Bloodrun's forum to allow bbcode in post also.
$a_answer=$_POST['a_answer'];
// CONVERT ALL HTML SPECIAL CHARS TO THERE ENTITIES
$a_answer = htmlentities($a_answer, ENT_QUOTES);

// PARSE BB CODE
$a_answer = preg_replace('|\[b\](.+?)\[\/b\]|i', '<strong>$1</strong>', $a_answer);
$a_answer = preg_replace('|\[i\](.+?)\[\/i\]|i', '<em>$1</em>', $a_answer);
$a_answer = preg_replace('|\[u\](.+?)\[\/u\]|i', '<u>$1</u>', $a_answer);
$a_answer = preg_replace('|\[img\](.+?)\[\/img\]|i', '<img src=$1>', $a_answer);
$a_answer = preg_replace('|\[url=(.+?)\](.+?)\[\/url\]|i', '<a href=$1>$2</a>', $a_answer);
$a_answer = preg_replace('|\[color=(.+?[^;])\](.+?)\[\/color\]|i', '<span style="color:$1;">$2</span>', $a_answer);
$a_answer = preg_replace('|\[size=(.+?[^;])\](.+?)\[\/size\]|i', '<span style="font-size:$1;">$2</span>', $a_answer);
$a_answer = preg_replace('|\[left\](.+?)\[\/left\]|i', '<span style="text-align: left;">$1</span>', $a_answer);
$a_answer = preg_replace('|\[right\](.+?)\[\/right\]|i', '<span style="text-align: right;">$1</span>', $a_answer);
$a_answer = preg_replace('|\[center\](.+?)\[\/center\]|i', '<center>$1</center>', $a_answer);

$a_answer = mysql_real_escape_string($a_answer);
Thats how I managed to do it. First of all is it secure, secondly how do I make it change back to bbcode when you want to edit it? Right now it converts it to HTML and then when you go to edit your post or sig it is now HTML and not BBCode that you originally typed it in.

Bloodrun
09-14-2009, 06:54 AM
Well with the release of the next one, that problem is solved. The only thing it won't yet allow, is things like youtube videos.

Fireballchad
09-14-2009, 08:30 PM
Well with the release of the next one, that problem is solved. The only thing it won't yet allow, is things like youtube videos.


Ah ok, still learning how to do this will benefit me in the future just in case you don't post a new update xD

Bloodrun
09-15-2009, 04:51 PM
Well with the release of the next one, that problem is solved. The only thing it won't yet allow, is things like youtube videos.


Ah ok, still learning how to do this will benefit me in the future just in case you don't post a new update xD


Yes it will help you =D

And by the looks of it, that update won't be anytime soon =/

Fireballchad
09-16-2009, 07:25 PM
Well with the release of the next one, that problem is solved. The only thing it won't yet allow, is things like youtube videos.


Ah ok, still learning how to do this will benefit me in the future just in case you don't post a new update xD


Yes it will help you =D

And by the looks of it, that update won't be anytime soon =/


ya since you dont have a computer and such? Anyways i've been caught up in school stuff, so my updates to my site are getting harder to do also :(

Bloodrun
09-19-2009, 08:09 AM
Well with the release of the next one, that problem is solved. The only thing it won't yet allow, is things like youtube videos.


Ah ok, still learning how to do this will benefit me in the future just in case you don't post a new update xD


Yes it will help you =D

And by the looks of it, that update won't be anytime soon =/


ya since you dont have a computer and such? Anyways i've been caught up in school stuff, so my updates to my site are getting harder to do also :(


I have a computer, just not a conssistant amount of internet access.
Im hoping that will all change within the next two months >.<