De-Spam your Wiki: Difference between revisions

Jump to navigation Jump to search
Created page with " 1. Backup your database: mysqldump -u root --password wikidb > backup.sql 2. To restore your database: mysqladmin -u root -p drop wikidb mysqladmin -u root -p create wik..."
 
No edit summary
 
Line 1: Line 1:
Warnings: These instructions are for more of a private wiki where user_id 0 is the wiki and user_id 1 is the first user, presumably you and all other stuff was created by spammers.  If this is not the case, then do not follow these steps or figure out what the user_id numbers are for the spammers (see notes as appropriate)! 


1.  Backup your database:
1.  Backup your database.  You will be prompted for the root/admin password before the command will commence. The "root" account may also be "admin" or something else, depending how you initially set up your database.  Instructions are only for MySQL database Wikis:
mysqldump -u root --password wikidb > backup.sql


2. To restore your database:
'''mysqldump -u root --password wikidb > backup.sql'''


mysqladmin -u root -p drop wikidb
2.  Next, we begin to restore the database.


mysqladmin -u root -p create wikidb
Since the database has been backed up, we want to completely delete it from MySQL:


mysql -u root -p wikidb < backup.sql
'''mysqladmin -u root -p drop wikidb'''
 
Create the wiki database:
 
'''mysqladmin -u root -p create wikidb'''
 
Import the database from the backup:
 
'''mysql -u root -p wikidb < backup.sql'''


3.  To clean up your database:
3.  To clean up your database:


mysql -u root -p
Login to MySQL:
use wikidb;
 
'''mysql -u root -p'''
 
Select the wikidb database:
 
'''use wikidb;'''
 
Delete all users except user_id 0 and 1 (this is where you may need to selectively delete user_id's if you have a mix of valid and spammer user_id's on your wiki:
 
'''DELETE FROM user WHERE user_id > 1;'''
 
Remove the members of groups that are now not users from the previous step:
 
'''DELETE FROM user_groups WHERE ug_user NOT IN (SELECT user_id FROM user);'''
 
Remove all member properties that are not users from the above steps:
 
'''DELETE FROM user_properties WHERE up_user NOT IN (SELECT user_id FROM user);'''
 
Remove their Talk data:
 
'''DELETE FROM user_newtalk WHERE user_id NOT IN (SELECT user_id FROM user);'''


DELETE FROM user WHERE user_id > 1;
Remove any revisions they made:
DELETE FROM user_groups WHERE ug_user NOT IN (SELECT user_id FROM user);


DELETE FROM user_properties WHERE up_user NOT IN (SELECT user_id FROM user);
'''DELETE FROM revision WHERE rev_user > 1 AND rev_user NOT IN (SELECT user_id FROM user);'''


DELETE FROM user_newtalk WHERE user_id NOT IN (SELECT user_id FROM user);
Reset all pages to 0 revisions:


DELETE FROM revision WHERE rev_user > 1 AND rev_user NOT IN (SELECT user_id FROM user);
'''UPDATE page SET page_latest = 0;'''


UPDATE page SET page_latest = 0;
4. Login to the wiki server and change directory to the wiki home:


4. on the server:
cd one more time to the maintenance directory:


cd ./maintenance
'''cd ./maintenance'''


php ./attachLatest.php --fix
Start the initial cleanup to place the latest revision of each active page as active:


'''php ./attachLatest.php --fix'''


5. in mysql:
5. in mysql:


DELETE FROM page WHERE page_latest = 0;
'''DELETE FROM page WHERE page_latest = 0;'''
 
6. on the server run these two scripts from the ./maintenance directory:


6. on the server:
'''php ./rebuildall.php'''


php ./rebuildall.php
'''php ./purgeOldText.php'''


php ./purgeOldText.php


DONE!
DONE!