De-Spam your Wiki

From The Datapanic Wiki
Revision as of 20:27, 29 April 2015 by Datapanic (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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. 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. Next, we begin to restore the database.

Since the database has been backed up, we want to completely delete it from MySQL:

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:

Login to MySQL:

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);

Remove any revisions they made:

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

Reset all pages to 0 revisions:

UPDATE page SET page_latest = 0;

4. Login to the wiki server and change directory to the wiki home:

cd one more time to the maintenance directory:

cd ./maintenance

Start the initial cleanup to place the latest revision of each active page as active:

php ./attachLatest.php --fix

5. in mysql:

DELETE FROM page WHERE page_latest = 0;

6. on the server run these two scripts from the ./maintenance directory:

php ./rebuildall.php

php ./purgeOldText.php


DONE!