| | |||||
| ||||||||
| CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Resistance is Futile Join Date: Apr 2006 Location: Montreal, Canada
Posts: 1,094
![]() ![]() ![]() ![]() ![]() ![]() | [PHP] Simple BBcode Parse Function Here's a quick function I whipped up for a project and thought some people would have some use for it. Well here it goes, I am working on the list and indent codes. EDIT: Use Dan's BelowUsage: PHP Code: ????: NamePros.com http://www.namepros.com/code/266965-php-simple-bbcode-parse-function.html Colors Fonts Images URLs and Emails Alignment Font Sizes Bold, Underline and Italics Also replaces a url (http://something) with a link. Enjoy.
__________________ Freelance Web Developer PHP, MySQL, XHTML, CSS, Javascript, jQuery, Wordpress Portfolio: www.bundy.ca
Last edited by Kadenz; 12-08-2006 at 06:46 PM.
|
| |
| | #2 (permalink) |
| Buy my domains. Join Date: Feb 2006
Posts: 2,792
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP Code:
Last edited by Dan; 01-10-2007 at 06:59 PM.
|
| |
| | THREAD STARTER #3 (permalink) |
| Resistance is Futile Join Date: Apr 2006 Location: Montreal, Canada
Posts: 1,094
![]() ![]() ![]() ![]() ![]() ![]() | lol, I forgot about that thanks again Dan the Man.
__________________ Freelance Web Developer PHP, MySQL, XHTML, CSS, Javascript, jQuery, Wordpress Portfolio: www.bundy.ca |
| |
| | THREAD STARTER #6 (permalink) | ||||
| Resistance is Futile Join Date: Apr 2006 Location: Montreal, Canada
Posts: 1,094
![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code:
__________________ Freelance Web Developer PHP, MySQL, XHTML, CSS, Javascript, jQuery, Wordpress Portfolio: www.bundy.ca | ||||
| |
| | THREAD STARTER #8 (permalink) |
| Resistance is Futile Join Date: Apr 2006 Location: Montreal, Canada
Posts: 1,094
![]() ![]() ![]() ![]() ![]() ![]() | It's the 7th line down in the arrays. <font color=*****> EDIT: oops, I know what you mean, like the NamePros php bbcode. Well, I have honestly no idea how to do that.
__________________ Freelance Web Developer PHP, MySQL, XHTML, CSS, Javascript, jQuery, Wordpress Portfolio: www.bundy.ca |
| |
| | #9 (permalink) |
| Account Suspended Join Date: Oct 2005 Location: United Kingdom
Posts: 1,554
![]() ![]() ![]() ![]() | im gonna see if i can get javascript to work with it so if you click the button it will enter the bb code in for you then click it agian to close the bb code i know its not gonna be easy but if i can get it done ill post it here |
| |
| | THREAD STARTER #10 (permalink) |
| Resistance is Futile Join Date: Apr 2006 Location: Montreal, Canada
Posts: 1,094
![]() ![]() ![]() ![]() ![]() ![]() | That would be awesome! Thanks.
__________________ Freelance Web Developer PHP, MySQL, XHTML, CSS, Javascript, jQuery, Wordpress Portfolio: www.bundy.ca |
| |
| | #14 (permalink) | ||||
| Senior Member Join Date: Dec 2006 Location: England
Posts: 1,565
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() You would insert the unchanged string into a database (for example) and use this function on the output. That way if you wanted to see the bbcode tags again like in a textarea during edit then simply don't use the function when you output it. And no it won't format paragraphs | ||||
| |
| | #16 (permalink) |
| New Member Join Date: Dec 2006 Location: Melbourne, Australia
Posts: 17
![]() | Looks very nice, however, I noticed two (minor) problems: 1. The Code: "<a href=\"$1\" target=\"_blank\">$2</a>" 2. The Code: "/\[font\=(.+?)\](.+?)\[\/font\]/is", After I fixed these two issues, and try to use the script, I get: Code: Warning: preg_replace() [function.preg-replace]: Empty regular expression in /var/www/temp/testbb.php on line 38 Warning: preg_replace() [function.preg-replace]: Unknown modifier '+' in /var/www/temp/testbb.php on line 38
__________________ Daniel15, Simple Machines Forum (SMF) Customisation Team My sites: [DanSoft Australia] [Daniel15.com] [Dynamic-Sig.com] Need help with SMF? Just ask :) |
| |
| | #18 (permalink) |
| New Member Join Date: Dec 2006 Location: Melbourne, Australia
Posts: 17
![]() | Those little errors are gone, but the two warnings I got are still there... What version of PHP are you using for testing?
__________________ Daniel15, Simple Machines Forum (SMF) Customisation Team My sites: [DanSoft Australia] [Daniel15.com] [Dynamic-Sig.com] Need help with SMF? Just ask :) |
| |
| | #19 (permalink) |
| NamePros Member Join Date: Oct 2005
Posts: 173
![]() | This is some nice coding, although for doing bbcode on my site I have always stuck with using the bbcode engine from forums....I then simply integrate the bbcode engine that is used in the forums on my site with other areas of the site that I need to parse bbcode. But then again that requires you to have forums on your site. Anyway thanks for the code, I'll keep this code handy so that when I need it I can use it. |
| |
| | #20 (permalink) |
| Buy my domains. Join Date: Feb 2006
Posts: 2,792
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | I wasn't testing at all.. ![]() I just tested this and it works though: PHP Code: |
| |
| | #21 (permalink) |
| Senior Member Join Date: May 2005 Location: Ontario Canada
Posts: 3,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP Code:
__________________ |
| |
| | #22 (permalink) | ||||
| Senior Member Join Date: Aug 2005 Location: Uk, South Yorkshire
Posts: 1,228
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=266965 Also, the Code Above, may leave you vulnerable to XSS Attacks, apparently. | ||||
| |