I've been at this since Christmas eve and I still can't figure it out! I'm trying to correctly set the bitfield value for a converted phpBB2 database which had a custom BBcode in it called [clog]. After conversion to phpBB3, these tags just display as [clog]whatever[/clog]. I thought I'd be clever and just write a one-off fixer script to work through the posts table and sort all this out, but I have not got it to work (surprise, surprise).
The code is as follows and was mostly created by following the useful discussion here. So...
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$sql = "SELECT * FROM `phpbb3_posts` WHERE `post_text` LIKE '%[clog:%' LIMIT 0,30;";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$count++;
$uid = $row["bbcode_uid"];
$text = $row["post_text"];
$bitfield = $options = '';
$allow_bbcode = $allow_urls = $allow_smilies = true;
generate_text_for_storage($text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
echo "<p><strong>Record:".$count." (" . $row["post_id"] . ")<br/>Bitfield:".$bitfield."<br/>UID:" . $uid . "</strong><br/>" . $text . "</p>";
$update_sql = "UPDATE `phpbb3_posts` SET `post_text` = '" . $text . "',
`bbcode_bitfield` = '" . $bitfield . "',
`bbcode_uid` = '" . $uid . "'
WHERE `post_id` =" . $row["post_id"] . " LIMIT 1 ;";
//$db->sql_query($update_sql);
}
$db->sql_freeresult($result);
?>
Code: Select all
Record:1 (28623)
Bitfield:
UID:
In the 10 days before the forum turns one year old on December 30th. That's the plan anyway... So to start things off, I'm announcing a nifty new BBCode!!! [center][b:1uhfqbbj][u:1uhfqbbj][size=167:1uhfqbbj][clog:1uhfqbbj][/size:1uhfqbbj][/u:1uhfqbbj][/b:1uhfqbbj][/center] What's a BBCode? Looking in the FAQ would be a start (except I just noticed that it's down). BBCodes are the little "tags" that you can use in your post to make it more interesting, eye catching, etc. What does this new one do? It slices, dices, italicizes and links species names, all in one fell swoop! Here's how to use it: [size=167:1uhfqbbj][code:1uhfqbbj][clog]Hypancistrus zebra[/clog][/code:1uhfqbbj][/size:1uhfqbbj] Would automatically spit out: [clog:1uhfqbbj]Hypancistrus zebra[/clog:1uhfqbbj] A live, clickable link without having to root through the huge Cat-eLog. Of course, spelling counts, and at present it is a bit a bit picky about spaces.
Many thanks,
Jools