FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


BB Code [EDIT: Offering 150 FRIH$]





DanielXP
Im making a new bbcodes for my site this is what i have so far

Code:
<?php
function UnHtml($string)
{
return strtr($string, array_flip(get_html_translation_table()));
}

function bbcode($content){
$content = nl2br(stripslashes($content));
$content = str_replace ("[b]", "<b>", $content);
$content = str_replace ("[/b]", "</b>", $content);
$content = str_replace ("[php]", "&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px solid #000000;'><tr><td><b>PHP:</b></td></tr></table>", highlight_string(UnHtml($content)));
$content = str_replace ("[/php]", "</fieldset>", $content);
return $content;
}
?>


Im trying to add a highlight_string to my [php] bbcode but for this i have to undo the htmlspechar thing, so my friend gave the the UnHtml function. But this is undoing all of the htmlspec....

Please could you help

Thanks DanielXP
DanielXP
could you do this with a preg_replace?

if so could you give me the line code for it
kv
Why do you need to undo htmlspechar? and I don't find htmlspechar in your code. Where have you used it?

Instead of undo, can you try highlight_string before htmlspechar and have rest of conversions after htmlspechar?
DanielXP
Before the code enters into my database it htmlspechar it.

So before i highlight it, it needs to be in html form.
Agent ME
BB code is a bit more complex than that - you need to make sure every opening tag has a closing tag, or else people can reak havoc with the site's look on a page with their BB code.
DanielXP
Agent ME wrote:
BB code is a bit more complex than that - you need to make sure every opening tag has a closing tag, or else people can reak havoc with the site's look on a page with their BB code.


U what?
DanielXP
Ok as this is taking a long time

150 FRIH$ for the person who can give me the code what works on my site.

Thanks
Daniel
DanielXP
Bump

Please i really need this

my site is waiting 2 be released
MrBlueSky
It looks to me you have to put the UnHtml before the other conversion functions, because it reverts the changes made with the str_replace-calls:

Code:

<?php
function UnHtml($string)
{
return strtr($string, array_flip(get_html_translation_table()));
}

function bbcode($content){     
$content = UnHtml($content)                       // <-- changed
$content = nl2br(stripslashes($content));
$content = str_replace ("[b]", "<b>", $content);
$content = str_replace ("[/b]", "</b>", $content);
$content = str_replace ("[php]", "&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px solid #000000;'><tr><td><b>PHP:</b></td></tr></table>", highlight_string($content);     // <-- changed
$content = str_replace ("[/php]", "</fieldset>", $content);
return $content;
}
?>
DanielXP
MrBlueSky wrote:
It looks to me you have to put the UnHtml before the other conversion functions, because it reverts the changes made with the str_replace-calls:

Code:

<?php
function UnHtml($string)
{
return strtr($string, array_flip(get_html_translation_table()));
}

function bbcode($content){     
$content = UnHtml($content)                       // <-- changed
$content = nl2br(stripslashes($content));
$content = str_replace ("[b]", "<b>", $content);
$content = str_replace ("[/b]", "</b>", $content);
$content = str_replace ("[php]", "&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px solid #000000;'><tr><td><b>PHP:</b></td></tr></table>", highlight_string($content);     // <-- changed
$content = str_replace ("[/php]", "</fieldset>", $content);
return $content;
}
?>


Im getting this error
Code:
Parse error: syntax error, unexpected T_VARIABLE in /home/____/public_html/___/bbcodes.php on line 9
MrBlueSky
I'm sorry, i made two mistakes: I forgot a ')' and a semicolon:

Code:

<?php
function UnHtml($string)
{
return strtr($string, array_flip(get_html_translation_table()));
}

function bbcode($content){     
$content = UnHtml($content);                       // <-- semi-collon added
$content = nl2br(stripslashes($content));
$content = str_replace ("[b]", "<b>", $content);
$content = str_replace ("[/b]", "</b>", $content);
$content = str_replace ("[php]", "&nbsp;&nbsp;&nbsp;<fieldset style='width: 450'><table width='100%' cellpadding='0' cellspacing='0' style='border-bottom:1px solid #000000;'><tr><td><b>PHP:</b></td></tr></table>", highlight_string($content));     // <-- closing parenthize added
$content = str_replace ("[/php]", "</fieldset>", $content);
return $content;
}
?>
DanielXP
Just notice that would undo all the html so theres no point doing the htmlspecialcahrs in the fisrt place

Correct?

If your running a tutorials site theres loads of HTML scripts they will be posting, so if i used this then that would just inport the html into the page and not display it
Related topics
150 $FRIH T VALIDATE my page
Offering 1200 frih$ for web design.
20 - 150 FRIH$ for flash assistance
Need a flash banner made !!! 150 frih$ !! URGENT !!!!!!!!!!!
150 frih$ if you make me a login script with....
How to realize "BB-Code"
Coppermine gallery google ad placement 150 frih
PhpInstall.net - Buying a logo - 150 frih$
Need a few images - up to 150 Frih$ PLUS FREE DOMAIN
150 frh$ for menubar Please CLOSE
Win 150 FriH$ - My Sound Teaser Competition.
Treasure Huuunt! - 150 frih$'s
150 FRIH$ for a Banner 468x60 !!
150 Frih$ If Someone Can Find Me A Script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.