Log in

View Full Version : parse_bbcode


nsanden
04-03-2004, 07:41 PM
Hi, i'm new to hacking/modifying VB. Can someone tell me why the following code returns {i}test{/i}: (Note: i changed [ ] to { } so this forum doesnt parse it)

<?php
require_once("forums/includes/functions.php");
require_once("forums/includes/functions_bbcodeparse.php");
echo parse_bbcode("{i}test{/i}");
?>

Xenon
04-03-2004, 07:47 PM
parse_bbcode parses code depending on the signature settings, or specific forumsettings

if you want to explicitly parse some code, you have to use parse_bbcode2

Boofo
04-03-2004, 07:57 PM
parse_bbcode parses code depending on the signature settings, or specific forumsettings

if you want to explicitly parse some code, you have to use parse_bbcode2

What file do you need to include to use parse_bbcode2?

Xenon
04-03-2004, 08:00 PM
functions_bbcodeparse.php ;)

nsanden
04-03-2004, 08:08 PM
Thanks Xenon,

<?php
require_once("forums/includes/functions.php");
require_once("forums/includes/functions_bbcodeparse.php");
echo parse_bbcode2('test', 0, 0, 0, 1, 0, 1);
?>

I wish i could say that worked but I get an error saying call to a member of a non-existant object. Looked into it, seems it tries to use the DB_Sql_vb class in db_mysql.php... So i figured if i instantiated that class and included config.php and db_mysql.php maybe the problem would go away...

<?php

require_once('forums/includes/config.php');
require_once('forums/includes/db_mysql.php');

$DB_site = new DB_Sql_vb;

$DB_site->appname = 'vBulletin';
$DB_site->appshortname = 'vBulletin (' . VB_AREA . ')';
$DB_site->database = $dbname;

$DB_site->connect($servername, $dbusername, $dbpassword, $usepconnect);

require_once("forums/includes/functions.php");
require_once("forums/includes/functions_bbcodeparse.php");

echo parse_bbcode2('test', 0, 0, 0, 1, 0, 1);

?>

When i do that i get the VB error:

There seems to have been a slight problem with the database.
Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.

Boofo
04-03-2004, 08:08 PM
When I tried that with this it gave me an error:

require_once('./includes/functions_bbcodeparse.php');
$profilefield['value'] = parse_bbcode2(unhtmlspecialchars($profilefield['value']));

Xenon
04-03-2004, 08:12 PM
bob, you may look at the signature of that function first ;)

@nsanden: you should require global.php before :)

Boofo
04-03-2004, 08:28 PM
bob, you may look at the signature of that function first ;)

@nsanden: you should require global.php before :)

I looked in the functions_bbcodeparse.php and tried to add the numbers after it but it still gave me the error. It only worked when I took out the unhtmlspecialchars and I don't want to turn on html to filter those. Am I doing something wrong?

nsanden
04-03-2004, 08:31 PM
You actually got it to work? Can you show me your working code?

I still can't get it to work...

http://www.savingadvice.com/forums/test.php
http://www.savingadvice.com/forums/test.php?source=1

nsanden
04-03-2004, 08:37 PM
Wow i take that back! Finally works!!! Appreciate the help guys.

Boofo
04-03-2004, 08:39 PM
How did you get it to work?

nsanden
04-03-2004, 08:41 PM
Source:
http://www.savingadvice.com/forums/test.php?source=1

Xenon
04-03-2004, 08:45 PM
ah sorry bob, i just overlooked it ;)

take out the htmlspecial chars thing, as parse_bbcode2 has that built in as well ;)

Boofo
04-03-2004, 08:48 PM
ok, but how do I change the amp sign to this:

&

without turning on the html? ;)

Xenon
04-04-2004, 06:04 PM
you mean replacing a &amp; with &?

just use a str_replace after the bbcode parser :)

Dean C
04-04-2004, 06:24 PM
$var = str_replace('&', '&amp;', $var);

:)

Boofo
04-04-2004, 07:31 PM
Thanks Stefan and Dean. ;)

Are there other codes I'm going to have to parse like this or will the parse_bbcode2 cover all of them other than the & sign?