RideMonkey!
08-13-2013, 03:16 PM
I've written up the following to do some database purging of spam that has accumulated. I've commented what each section is designed to do - could someone take a look and see if A) it makes sense, or B) I'm missing anything?
# Remove all moderated visitor messages
delete from `visitormessage` where visitormessage.state = 'moderation'
# Ban all users who have left a visitor message containing a URL, have no posts and haven't logged on in 6 months
update `user`
left join (visitormessage)
on (user.userid=visitormessage.postuserid)
set user.usergroupid='14', user.displaygroupid='14'
where visitormessage.pagetext like '%url%' and
user.posts < 1 and
user.lastactivity < UNIX_TIMESTAMP('2013-02-12 00:00:00')
# Delete all visitor messages for banned users with fewer than 5 posts
delete `visitormessage` from `visitormessage`
left join (user)
on (user.userid=visitormessage.postuserid)
where user.usergroupid='14' and
user.posts < 5
# Delete user homepages for banned users, or those with no posts
update `user` set homepage='' where usergroupid='14'
update `user` set homepage='' where posts < 1
# Delete signatures for banned users
update `usertextfield`
left join (user)
on (user.userid = usertextfield.userid)
set signature=''
where user.usergroupid='14'
# Delete URL-containing signatures from users with no posts
update `usertextfield`
left join (user)
on (user.userid = usertextfield.userid)
set usertextfield.signature=''
where usertextfield.signature like '%url%' and
user.posts < 1
# Remove all moderated visitor messages
delete from `visitormessage` where visitormessage.state = 'moderation'
# Ban all users who have left a visitor message containing a URL, have no posts and haven't logged on in 6 months
update `user`
left join (visitormessage)
on (user.userid=visitormessage.postuserid)
set user.usergroupid='14', user.displaygroupid='14'
where visitormessage.pagetext like '%url%' and
user.posts < 1 and
user.lastactivity < UNIX_TIMESTAMP('2013-02-12 00:00:00')
# Delete all visitor messages for banned users with fewer than 5 posts
delete `visitormessage` from `visitormessage`
left join (user)
on (user.userid=visitormessage.postuserid)
where user.usergroupid='14' and
user.posts < 5
# Delete user homepages for banned users, or those with no posts
update `user` set homepage='' where usergroupid='14'
update `user` set homepage='' where posts < 1
# Delete signatures for banned users
update `usertextfield`
left join (user)
on (user.userid = usertextfield.userid)
set signature=''
where user.usergroupid='14'
# Delete URL-containing signatures from users with no posts
update `usertextfield`
left join (user)
on (user.userid = usertextfield.userid)
set usertextfield.signature=''
where usertextfield.signature like '%url%' and
user.posts < 1