Skip to content

Instantly share code, notes, and snippets.

@Elsensee
Last active August 29, 2015 14:12
Show Gist options
  • Save Elsensee/0266db7a7f53f5d353b2 to your computer and use it in GitHub Desktop.
Save Elsensee/0266db7a7f53f5d353b2 to your computer and use it in GitHub Desktop.
Updates the bitfield of posts with a specific bbcode so they can be parsed again. (phpBB 3.1!!!) No idea if it works - did it in 10 minutes xD
<?php
define('OLD_ID', 13);
define('NEW_ID', 14);
define('LIKE_WHAT', '[light');
/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$start = $request->variable('start', 0);
$sql = 'SELECT post_id, post_text, bbcode_bitfield
FROM ' . POSTS_TABLE . "
WHERE bbcode_bitfield <> ''
AND bbcode_uid <> ''
AND post_text " . $db->sql_like_expression($db->get_any_char() . LIKE_WHAT . $db->get_any_char());
$result = $db->sql_query_limit($sql, 500, $start);
$affectedrows = $db->sql_affectedrows();
$db->sql_transaction('begin');
while ($row = $db->sql_fetchrow($result))
{
$bitfield = new bitfield($row['bbcode_bitfield']);
$bitfield->clear(OLD_ID);
$bitfield->set(NEW_ID);
$sql = 'UPDATE ' . POSTS_TABLE . "
SET bbcode_bitfield = '" . $db->sql_escape($bitfield->get_base64()) . "'
WHERE post_id = " . (int) $row['post_id'];
$db->sql_query($sql);
}
$db->sql_transaction('commit');
$db->sql_freeresult($result);
if ($affectedrows == 500)
{
meta_refresh(3, append_sid($phpbb_root_path . 'update_bbcode.php?start=' . ($start+500)));
trigger_error('NEXT: ' . ($start + 500));
}
trigger_error('DONE!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment