How to recover vandalised / deleted post from one user in phpbb

When you have trouble with vandalised / deleted post at your phpp forum and you need revert all changes for one user with this manual:

0. backup current active live phpbb database  !! (strongly recomended!!)

1. restore backup database to any new database (with new name)

2. to any folder on your www server put this php file:

$connection = mysql_connect('localhost', 'user' , 'pass') or die("unable to connect server!  Mysql says: " . mysql_error());
mysql_select_db('database_name', $connection) or die("unable to connect database.  Mysql says: " . mysql_error());

mysql_query("set names 'utf8'");

$vandal_id = xxx; // insert user id from phpbb
$results_items = mysql_query("SELECT * FROM `phpbb_posts` WHERE `poster_id` = ");
$numrows_items = mysql_num_rows ($results_items) or die (include ("any sql select error"));        

for($i=0; $i<$numrows_items; $i++):
$post_id=mysql_Result($results_items, $i, "post_id");
$post_text=mysql_Result($results_items, $i, "post_text");
echo "UPDATE `database_name`.`phpbb_posts` SET `post_text` = '".$post_text."' WHERE `phpbb_posts`.`post_id` = ".$post_id.";<br>";

3.  edit this with your right data:

database_name and prefix in select
$vandal_id = xxx;

4. run url with php file. On screen you now have select with recovered post text in ready to use select!

5. Copy to clipboard first select line (from select to 😉

6. Open live sql database in phpmyadmin or adminer. Paste this line to sql input dialog  and run. And test result twice in live forum!

7. If test is OK. Cut and Paste all select lines and run this select in phpmyadmin!

Done.. Enjoy!


Leave a Reply