Correct bbcode processing code in 3.2.8

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
marcomkp
Registered User
Posts: 9
Joined: Mon Feb 26, 2007 2:25 pm

Correct bbcode processing code in 3.2.8

Post by marcomkp »

Howdy all,

Some time ago I updated a board to 3.2.8. I noticed only today that some custom code is broken post that update.
I have some "plain viewtopic" pages of this kind since 2.x and 3.x -- always worked fine. They are basically like this:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

$pagination = $phpbb_container->get('pagination');

$bbcode_bitfield = '';
$sql = 'SELECT post_text, bbcode_uid, bbcode_bitfield FROM ' . POSTS_TABLE . " WHERE post_id = 123456";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$message = "";

if ($row) {
	$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
	if ($bbcode_bitfield !== '') {
		$bbcode = new bbcode(base64_encode($bbcode_bitfield));
	}
	$message = $row['post_text'];

	if ($row['bbcode_bitfield']) {
		$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
	}

	$message = bbcode_nl2br($message);
	$message = smiley_text($message);
}

$template->assign_vars(array(
	'MESSAGE'	=> $message,
));

// Output the page
page_header("foo foo foo", false);

$template->set_filenames(array(
	'body' => 'whatever.html')
);

page_footer();
Now they don't work anymore. bbcode are sort of applied (i can see html that would replace them), but the bbcode tag is not removed.
I tried snooping the code of 3.2.8 and simplified the above with just:

Code: Select all

if ($row) {
		$uid = $row['bbcode_uid'];
		$bitfield = $row['bbcode_bitfield'];
		$message = $row['post_text'];
		$bbcode = new bbcode($bitfield);
		$bbcode->bbcode_second_pass($message, $uid);
		$message = bbcode_nl2br($message);
		$message = smiley_text($message);

}
But i get the same result. Can anyone point out how to properly (and easily) get bbcode processed?

Thanks
Post Reply

Return to “phpBB Custom Coding”