PDA

View Full Version : Phrase BBCODE & HTML


PennylessZ28
01-01-2006, 09:00 PM
This is my method for phrasing BBCODE in the user profile field. I want to allow HTML to pass through aswell.

if ($userinfo['field1'])
{
if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
}
$userinfo['field1'] = $bbcode_parser->parse($userinfo['field1'],0, true);
}

I know that to phrase bbcode you do something like this

require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$parsed_text = $parser->do_parse($text, $do_html, $do_smilies, $do_bbcode, $do_imgcode, $do_nl2br, $cachable);

The parameters for method do_parse() are:

$text = Text to be parsed
$do_html = Whether to allow HTML or not (Default = false)
$do_smilies = Whether to parse smilies or not (Default = true)
$do_bbcode = Whether to parse BB code (Default = true)
$do_imgcode = Whether to parse the [img] BB code or not, independant of $do_bbcode (Default = true)
$do_nl2br = Whether to automatically replace new lines with HTML line breaks or not (Default = true)
This should be set to false if you allow HTML.
$cachable = Whether the post text is cachable or not (Default = false)
So I can use BBCODE in the fields fine, but if I use HTML it comes out screwed up.

PennylessZ28
01-03-2006, 12:40 AM
oh you don't say??

Guest190829
01-03-2006, 12:44 AM
$parsed_text = $parser->do_parse($text, true, true, true, true,true, true);

Try that, and theres security risks for allowing HTML...

The Chief
01-04-2006, 05:29 AM
$parsed_text = $parser->do_parse($text, true, true, true, true,true, true);
ok lets say I would like an input field on my Memberinfo page to enable HTML. So that members can just type in some HTML in the input fields and something would parse it so that when you visit the member's profile page you see the right stuff rather then just seeing the code.

Can this be done? If so, please show me how, I am a PHP newb...

Thanks!

restless
01-09-2006, 05:18 AM
//
// START PHP CODE

if ($userinfo['field1'])
{
if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
}
$userinfo['field1'] = $bbcode_parser->parse($userinfo['field1'],0, true);
$userinfo['field1'] = html_entity_decode($userinfo['field1']);
}

// END PHP CODE
//

works for me: http://vagrantcafe.com/forum/carter

gibhut
01-19-2006, 07:01 PM
What i did was made a new Function for parsing bbcode
take the orginal do_parse function in the class_bbcode.php and copy it. i pasted it and named it do_bulletin_parse
and made this small change in it

// ********************* REMOVE HTML CODES ***************************
if (!$do_html)
{
//$text = htmlspecialchars_uni($text);
}
$html_allowed = $do_html;

$text = $this->parse_whitespace_newlines($text, $do_nl2br);

$body = $bbcode_parser->do_bulletin_parse($body, true, true, true, true,true, true);