Forum Moderators: coopster

Message Too Old, No Replies

The best free bbcode library?

and perhaps the best code for stripping HTML out of a user's submission

         

Fuzzplug Jones

9:22 pm on Sep 3, 2006 (gmt 0)

10+ Year Member



Hello,

I have a bunch of self-written libraries that allow me to deploy CMS-ish features (news, blogs, file libraries, user management, etc) on the sites I design. When I need something that functions like the products already out there, I don't want to re-invent the wheel.

And so I need something that parses "bbcode" or whatever it's called that allows forum users to do certain formatting things without allowing them to enter real HTML and thus perhaps mess up the entire site with weird layouts or redirects to child porn sites, etc.

I have seen the occasional bbcode parser library out there on the internet, I wondered if anyone here had experience with them and could tell me which are the best, most supported, and obviously free that I can incorporate into my libraries.

Also, along with this it would be essential to strip HTML out of a user's submissions. Is there a quick, reliable way to do that in PHP or is there a good function already written out there where I can just pass a variable to it and have it return that variable with all the HTML stripped?

TIA

barns101

9:36 pm on Sep 3, 2006 (gmt 0)

10+ Year Member



I'm not sure about the BB code, but to get rid of HTML (and other code) you can use the strip_tags() [php.net] function.

puckparches

9:42 pm on Sep 3, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



What forum program are you using?

inquireorenquire

4:46 am on Sep 4, 2006 (gmt 0)

10+ Year Member



You can approximate BBcode by using a series of preg_replace() expressions, e.g.

$text=preg_replace("/\[b\](.*?)\[\/b\]/im","<b>$1</b>",$text);

Fuzzplug Jones

4:05 pm on Sep 4, 2006 (gmt 0)

10+ Year Member




What forum program are you using?

As I said in my original message this is a self-written library of functions that will add functionality similar to a Content-Management System in the sites I design.

[edited by: Fuzzplug_Jones at 4:07 pm (utc) on Sep. 4, 2006]

Fuzzplug Jones

4:06 pm on Sep 4, 2006 (gmt 0)

10+ Year Member




You can approximate BBcode by using a series of preg_replace() expressions, e.g.

$text=preg_replace("/\[b\](.*?)\[\/b\]/im","<b>$1</b>",$text);

I know that, in fact I have done that. But for a full set of codes, I would rather not re-invent the wheel if there is a good library out there, as I said above.

henry0

5:03 pm on Sep 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I knew I have seen it somewhere...
Did you search?

I found it again
HERE IT IS
[pear.php.net]

further check WorldPress they offer a pluggin for BB code you might be able to tweak it

Fuzzplug Jones

6:19 pm on Sep 4, 2006 (gmt 0)

10+ Year Member



Thank you, like I said I searched, but I wanted some personal feedback on which is the best.

This requires a PEAR.php, where do i get it?

[edited by: Fuzzplug_Jones at 6:23 pm (utc) on Sep. 4, 2006]

henry0

8:29 pm on Sep 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?php phpinfo();?>
Run this test to figure if it is installed on your production server

if not contact your host and ask to crank it on :)

Nowadays PEAR comes with PHP
but on your local machine you very probably need to install it

Do a search for installing PEAR on a local machine there are many good tutorials.

Fuzzplug Jones

12:01 am on Sep 5, 2006 (gmt 0)

10+ Year Member



Ok but is the PEAR library the best one?

henry0

11:35 am on Sep 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let's put it that way if the PEAR pack does not do it
I will not look further (my very own $0.10)
and I will simply try to figure out what I really want my users to do
and hard code just a few items.
Look at what's allowed on this board it is in my mind plenty enough
After all BBcode is supposed to be a light formatting tool.

However this is a good topic; as you do I would like to read more feedback about your BBcode question

jatar_k

4:28 pm on Sep 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> but is the PEAR library the best one?

trouble is there is no such thing as "best" as everyone's situation or requirement is different.

is it a viable solution, yes, definitely.

try it out and see if it does what you need.