Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

50 users online



PHP BBCode

PHP BBCode

Currently viewing this thread: 1 (0 members and 1 guests)


konigwolf

konigwolf

Lead Administrator And Owner Of http://www.dragondiscussion.com
Status: Offline!

PHP BBCode

Im trying to make include(), and highlight_string() bbcode's but am not having any luck im trying to use it with content located in a mysql database.

___________________

Signature Suspended as it is in violation with the signature rules

swish

swish

Status: Offline!

hahah yeah ive read the stickes and tried heaps of stuff but im still at the same stage as you...

___________________

Graphic and Web Design services at flowtone.com

mdstudiosnet

mdstudiosnet

Status: Offline!

bbcode? like make it? or something..my friend said to try string replaces.

___________________

- Mike

Ynhockey

Ynhockey

Neverside Newbie
Status: Offline!

preg_replace() is the key. Learning how to use it might be a pain though... but I've seen some tutorials around, search Google.

___________________

Learn HTML

Stevie

Stevie

Neversidian
Status: Offline!

I wrote this a while back - http://www.net-riches.com/filesys/bbcode.html

___________________

"Hey, **** YOU!"

Last edited by Stevie, December 21st, 2003 05:28 PM (Edited 1 times)

konigwolf

konigwolf

Lead Administrator And Owner Of http://www.dragondiscussion.com
Status: Offline!

I've been using str_replace, and have errors with parsing it doesn't get parsed cause its already working on the client side by then.

EDIT: Also could you please explain to me why there are all those slashes.

___________________

Signature Suspended as it is in violation with the signature rules

Last edited by konigwolf, December 23rd, 2003 03:37 PM (Edited 1 times)

Tristan_Wells

Tristan_Wells

I lived, Ill die
Status: Offline!

Those slashes are to make the regex work I believe. Also you can't parse regex with str_replace(); and I would think regex is required for what your trying to do.

___________________

<?php signature(); ?>

CDude

CDude

nothing
Status: Offline!
Code:


function parse_bb ( $str )
{
$search = array
(
'#\[B\](.+?)\[\/B\]#is',
'#\[I\](.+?)\[\/I\]#is',
'#\[U\](.+?)\[\/U\]#is',
'#\[COLOR=([a-z0-9\#]+?)\](.+?)\[\/COLOR\]#mis',
);

$replace = array
(
'<strong>$1</strong>',
'<em>$1</em>',
'<span style="border-bottom: 1px solid;">$1</span>',
'<span style="color:$1">$2</span>',
);

return preg_replace ( $search, $replace, $str );
}

god damn vbb

___________________

http://celerondude.com

konigwolf

konigwolf

Lead Administrator And Owner Of http://www.dragondiscussion.com
Status: Offline!

Will that work with sumthin like.

Code:


<?
function parse_bb (file_get_contents("main.php"))
{
$search = array
(
'#\[B\](.+?)\[\/B\]#is',
'#\[I\](.+?)\[\/I\]#is',
'#\[U\](.+?)\[\/U\]#is',
'#\[COLOR=([a-z0-9\#]+?)\](.+?)\[\/COLOR\]#mis',
'#\[INC\](.+?)\[\/INC\]#is',
);

$replace = array
(
'<strong>$1</strong>',
'<em>$1</em>',
'<span style="border-bottom: 1px solid;">$1</span>',
'<span style="color:$1">$2</span>',
'inlcude($1)',
);

return preg_replace ( $search, $replace, file_get_contents("main.php"));
}
?>


So main.php would be the database driven site. So would it still parse it if it came out of a database.

___________________

Signature Suspended as it is in violation with the signature rules

Phil

Phil

with Mr. Jones
Status: Offline!

do you realize just how stupid security wise an include bbcode is or do you need my help?

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.009 seconds.