bradrn wrote: ↑Tue Mar 17, 2020 7:57 am
EDIT: Oops, just realised that the script I gave only works for the unstripped database, which needs to be loaded into phpBB in order for the
$db calls to work. It’s getting very late here now, so I’ll have another look at getting it working with the publicly available stripped version tomorrow. But it doesn’t look too difficult to get it working: simply replace the query using
$db with the equivalent query using MySQLi. (Although admittedly, every time so far that I’ve said something ‘doesn’t look too difficult’, that’s exactly what it’s turned out to be… Hopefully this time will go better!)
I made another version of the script which works with a stripped database. Assuming you’ve loaded the stripped version (I posted a link earlier) into MySQL as database
old_zbb_stripped, the following script should work:
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = 'php';
include('./common.php');
include('./includes/bbcode.php');
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$post_id = $_GET['pid'];
$sql = 'SELECT enable_bbcode, enable_smilies, enable_magic_url, post_text, bbcode_uid, bbcode_bitfield FROM bradser_posts WHERE post_id = ' . $post_id;
$mysqli = mysqli_connect('localhost:3306', 'root', 'passwd', 'old_zbb_stripped');
$res = mysqli_query($mysqli, $sql);
$row = mysqli_fetch_assoc($res);
$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) +
(($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) +
(($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
$text = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
echo $text;
This version also has another slight improvement: the post to parse is now given as a GET parameter rather than being hard-coded into the script. So if you place this script into your phpBB directory, run
php -S localhost:8000, and then navigate to
http://localhost:8000/parse-bbcode.php?pid=<my_post_id>, you should get the post corresponding to
<my_post_id>.
EDIT: A small change to the script gives you a webpage with all the posts in a topic:
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = 'php';
include('./common.php');
include('./includes/bbcode.php');
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$topic_id = $_GET['tid'];
$sql = 'SELECT enable_bbcode, enable_smilies, enable_magic_url, post_text, bbcode_uid, bbcode_bitfield FROM bradser_posts
WHERE topic_id = ' . $topic_id . '
ORDER BY post_time ASC';
$mysqli = mysqli_connect('localhost:3306', 'root', 'passwd', 'old_zbb_stripped');
$res = mysqli_query($mysqli, $sql);
$res->data_seek(0);
while($row = $res->fetch_assoc()) {
$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) +
(($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) +
(($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
$text = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
echo $text;
echo '<hr>';
}
So now you can save this as e.g.
parse-bbcode-topics.php, and then go to
http://localhost:8000/parse-bbcode-topi ... <topic_id> to get all the posts for a particular topic.