Jump to content


BBCode Parser Help


2 replies to this topic

#1 Jynxis

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Location:The Shadows

Posted 11 May 2007 - 11:37 PM

Okay so, I have this BBCode parser, and it works quite well, but for some strange reason I cannot figure out why its not working.

This is my script, it also uses geshi.(for text coloring,etc.)
function parseCode($source,$lang="html"){
			$geshi = &new GeSHi($source, $lang,'');
			$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 55);
			return $geshi->parse_code();
		
}
function bbcode($string) {

$replace = array(
    '@\[b\](.*?)\[/b\]@si',
    '@\[url=(.*?)\](.*?)\[/url\]@si',
	'@\[code lang=(.*?)\](.*?)\[/code\]@si',
	'@\[code\](.*?)\[/code\]@si',
	'@\[FONT=(.*?)\](.*?)\[/FONT\]@si',
    '@\[u\](.*?)\[/u\]@si',
    '@\[marquee\](.*?)\[/marquee\]@si',
	'@\[IMG\](.*?)\[/IMG\]@si',
	'@<script[^>]*?>.*?</script>@si',
	'@\[quote\](.*?)\[/quote\]@si',
//'@(?i)http(.*?)@si'
);

$replacements = array ('<b>\\1</b>',
'<a href="\\1" target="_blank">\\2</a>',
'<div class="CDCodeTitle"><code>$1 Code:</code></div>'.
$this->parseCode(htmlentities('$2'),'$1'),
'<div class="CDCodeTitle"><code>Code:</code></div>'.
$this->parseCode(htmlentities('$1')),
'<font color="\\1">\\2</font>',
'<U>\\1</U>',
'<marquee>\\1</marquee>',
'<img src="\\1" border=0 alt="USER POSTED IMAGE">',
'chr(\1)',
'<div class="CDCodeTitle">Quote:</div>
 <div class="CDCodeBox"> <font color=orange>\\1</font></div>',
//'<a href=\\1>\\1</a>'
);
$smileys1 = array(
    '>:(',
	':(',
	':)',
	';)',
	'LOL',
	':google:',
	':OWNED:',
	':D',
	':YeahThat:',
	':FLOUR',
	':FINGER:',
	'STFU',
	':BUMP:',
	':NEWBIE:',
	':ANTIOLD:',
	':tid:',
	'when its done',
	':CLOSED:',
	':WORD:'
);
$smileys2 = array(
    '<img src="smilies/angry.gif" />',
	'<img src="smilies/sad.gif" />',
	'<img src="smilies/smile.gif" />',
	'<img src="smilies/wink.gif" />',
	'<img src="smilies/lol.gif" />',
	'<img src="smilies/google.gif" />',
	'<img src="smilies/owned.gif" />',
	'<img src="smilies/offtopic.gif" />',
	'<img src="smilies/yeahthat.gif" />',
	'<img src="smilies/flour.gif" />',
	'<img src="smilies/finger.gif" />',
	'<img src="smilies/gramps4.gif" />',
	'<img src="smilies/bump.gif" />',
	'<img src="smilies/newbie.gif" />',
	'<img src="smilies/anti-old.gif" />',
	'<img src="smilies/ttidead.gif" />',
	'<img src="smilies/whenitsdone.gif" />',
	'<img src="smilies/closed.gif" />',
	'<img src="smilies/signs_word.gif" />'
);

$string = preg_replace($replace, $replacements, $string); // CDCode Filter
$string = str_replace($smileys1, $smileys2, $string); // SMileys filter
return $string;

}

i know im doing something wrong.


My problem is this: I cannot figure out how to make it show the html instead of the parsed results, when using the codebox.
I tried using a second replacement for JUST the codebox, but it didnt work.

currently, its trying to show an image instead of just showing the html

Edited by PlaGuEX, 12 May 2007 - 01:19 AM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 12 May 2007 - 12:36 AM

http://www.pixel2life.com/forums/index.php...0&hl=bbcode

Please use the forum search nex time...

p.s. I removed the badwords array from the code.

#3 Jynxis

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Location:The Shadows

Posted 12 May 2007 - 01:01 AM

actually.. i did search before my post.nothing came up.. for what i searched for.

I did see that post, but i tried it .. for about 3 hours.. and it frustrated me even more than i already am/was.
Which isnt all that hard to believe, since i've been very aggitated,edgy, for a few months now.

Edited by PlaGuEX, 12 May 2007 - 01:29 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users