Most of them (1200 of them in fact) are gone now. There's still a few lingering spam accounts left, but I can handle those on a case by case basis. The criteria for member deletion were members whose birthdays are today, don't have any posts, icq, aim, yahoo or msn contact information, no website, no avatar, no location, and no photo. The IP addresses of these members have also been banned. There were 725 IP's banned in total, and I suspect most of them belong to proxies, TOR nodes, or compromised residential Internet users. If you think your IP or forum user got caught up in all this please let me know and we'll make sure you're unbanned, though you'll have to register for a new account again. If any other IPB users ran into this here's the script that cleans things up:
CODE
<?php
mysql_connect('localhost', 'myusername', 'mypassword');
mysql_select_db('mydatabase');
/**
* Gather the bad users.
*/
$result = mysql_query('select m.id, m.name, m.ip_address'
.' from ibf_members m, ibf_member_extra e'
.' where e.id=m.id'
.' and m.bday_day=28'
.' and m.bday_month=3'
.' and m.bday_year=1983'
.' and m.posts=0'
.' and m.time_offset=0'
.' and e.icq_number=0'
.' and e.aim_name=\'\''
.' and e.yahoo=\'\''
.' and e.msnname=\'\''
.' and e.avatar_location=\'\''
.' and e.location=\'\''
.' and e.signature=\'\''
.' and e.photo_location=\'\''
.' and e.website=\'\'');
if (mysql_num_rows($result) == 0) {
echo 'No users found. Exiting.';
exit;
}
while (($row = mysql_fetch_assoc($result))) {
echo 'Removing account '.$row['name']."\n";
/**
* Delete the user
*/
$result2 = mysql_query('update ibf_profile_comments set comment_by_member_id=0 where comment_by_member_id='.$row['id']);
$result2 = mysql_query('update ibf_profile_ratings set rating_by_member_id=0 where rating_by_member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_profile_comments where comment_for_member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_profile_comments where rating_for_member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_profile_portal where pp_member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_profile_friends where friends_member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_profile_friends where friends_friend_id='.$row['id']);
$result2 = mysql_query('delete from ibf_pfields_content where member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_member_extra where id='.$row['id']);
$result2 = mysql_query('delete from ibf_members_converge where converge_id='.$row['id']);
$result2 = mysql_query('delete from ibf_tracker where member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_forum_tracker where member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_warn_logs where wlog_mid='.$row['id']);
$result2 = mysql_query('delete from ibf_validating where member_id='.$row['id']);
$result2 = mysql_query('delete from ibf_members where id='.$row['id']);
/**
* Ban the ip address
*/
$result3 = mysql_query('select ban_id from ibf_banfilters where ban_type=\'ip\' and ban_content=\''.$row['ip_address'].'\'');
if (mysql_num_rows($result3) == 0) {
echo 'Banning IP '.$row['ip_address']."\n";
$result4 = mysql_query('insert into ibf_banfilters (ban_type, ban_content, ban_date) values (\'ip\', \''.$row['ip_address'].'\', '.time().')');
}
else {
echo $row['ip_address']." already found in banlist. Skipping.\n";
}
}
/**
* Fix the birthday cache by making sure each birthday belongs to an existing member.
*/
echo "Updating birthday cache.\n";
$result = mysql_query('select cs_value from ibf_cache_store where cs_key=\'birthdays\'');
$old_serialized_array = mysql_result($result, 0, 'cs_value');
$old_array = unserialize($old_serialized_array);
foreach ($old_array as $key => $member) {
$result = mysql_query('select id from ibf_members where id='.$member['id']);
if (mysql_num_rows($result) != 0) {
$new_array[$key] = $member;
}
}
$result = mysql_query('update ibf_cache_store set cs_value=\''.serialize($new_array).'\' where cs_key=\'birthdays\'');
mysql_close();
?>