Stuart Wright
Well-known member
I have a spreadsheet of 350 user_ids I need to ban.
Is there a quick way to do this please?
Is there a quick way to do this please?
There are common attributes of their accounts. They all set their timezone as Asia/Bangkok and they all registered since 19th Jan and they all use emails with top level domains of @topmail or @xmail or @postx or @xmailer or @mailx or @mailer or @bestmail or @mailerx or @postmail or @xpost plus two dots (e.g. @xpost.asd.ru)Unless there is some common criteria which will enable you to use the Batch Updater Users function, you will have to do them one at a time.
Batch update > Email=xpost.asd.ru > Registered between = 19 Jan-28 Jan > Search > Ban users (permanently)and they all registered since 19th Jan and they all use emails with top level domains of @topmail or @xmail or @postx or @xmailer or @mailx or @mailer or @bestmail or @mailerx or @postmail or @xpost plus two dots (e.g. @xpost.asd.ru)
The 350 emails are different.Batch update > Email=xpost.asd.ru > Registered between = 19 Jan-28 Jan > Search > Ban users (permanently)
He wants to ban them not delete & deleting direct from the db without knowledge of exactly what to delete can cause caching and orphan record issues.use phpmyadmin and sort the fields so that those 350 all come up in a row ---easy to delete then
<?php
return;
$startTime = microtime(true);
$fileDir = dirname(__FILE__) . '/html';
@set_time_limit(120);
ignore_user_abort(true);
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
$dependencies = new XenForo_Dependencies_Public();
$dependencies->preLoadData();
$db = XenForo_Application::get('db');
$user_ids = $db->fetchAll("
$user_ids = $db->fetchAll("
select user.*
from xf_user user
join xf_user_profile on user.user_id = xf_user_profile.user_id
where
user.is_banned = 0 and user.message_count = 0 and user.like_count = 0 and profile.signature = ''
and profile.occupation = ''
and user.user_state = 'email_confirm'
and user.register_date < unix_timestamp('2014-01-01')
and user.register_date > unix_timestamp('2011-01-01')
and user.last_activity < unix_timestamp('2015-01-01')
");
$spamCleanerModel = XenForo_model::create('XenForo_Model_SpamCleaner');
$options = array(
'action_threads' => 1,
'delete_messages' => 1,
'delete_conversations' => 1,
'ban_user' => 1,
'check_ips' => XenForo_Input::UINT,
'email_user' => 0,
'email' => '',
);
$visitor = XenForo_Visitor::setup(1);
print "Profile doing the nuking: ".$visitor['user_id'].'-'.$visitor['username']."\n";
print "Nuking ".count($user_ids )." spam accounts\n";
$count = 0;
foreach($user_ids as $user )
{
print $user['user_id'].'-'.$user['username']."\n";
$log = array();
$errorKey = '';
$log = $spamCleanerModel->cleanUp($user, $options, $log, $errorKey);
if ($log)
{
$count++;
}
else
{
print $errorKey. "\n";
break;
}
}
$time = microtime(true) - $startTime;
echo "\nNuked $count in $time secounds\n";
Thank you.@Stuart Wright I used the following php script to clean up ~200000 spam accounts stuck in waiting from approval for ~5 years.
It will require some SQL experience to modify it, and needs to be run from the commandline to avoid timeouts.
Code:<?php return; $startTime = microtime(true); $fileDir = dirname(__FILE__) . '/html'; @set_time_limit(120); ignore_user_abort(true); require($fileDir . '/library/XenForo/Autoloader.php'); XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library'); XenForo_Application::initialize($fileDir . '/library', $fileDir); XenForo_Application::set('page_start_time', $startTime); $dependencies = new XenForo_Dependencies_Public(); $dependencies->preLoadData(); $db = XenForo_Application::get('db'); $user_ids = $db->fetchAll(" $user_ids = $db->fetchAll(" select user.* from xf_user user join xf_user_profile on user.user_id = xf_user_profile.user_id where user.is_banned = 0 and user.message_count = 0 and user.like_count = 0 and profile.signature = '' and profile.occupation = '' and user.user_state = 'email_confirm' and user.register_date < unix_timestamp('2014-01-01') and user.register_date > unix_timestamp('2011-01-01') and user.last_activity < unix_timestamp('2015-01-01') "); $spamCleanerModel = XenForo_model::create('XenForo_Model_SpamCleaner'); $options = array( 'action_threads' => 1, 'delete_messages' => 1, 'delete_conversations' => 1, 'ban_user' => 1, 'check_ips' => XenForo_Input::UINT, 'email_user' => 0, 'email' => '', ); $visitor = XenForo_Visitor::setup(1); print "Profile doing the nuking: ".$visitor['user_id'].'-'.$visitor['username']."\n"; print "Nuking ".count($user_ids )." spam accounts\n"; $count = 0; foreach($user_ids as $user ) { print $user['user_id'].'-'.$user['username']."\n"; $log = array(); $errorKey = ''; $log = $spamCleanerModel->cleanUp($user, $options, $log, $errorKey); if ($log) { $count++; } else { print $errorKey. "\n"; break; } } $time = microtime(true) - $startTime; echo "\nNuked $count in $time secounds\n";
$user_ids = $db->fetchAll("
$user_ids = $db->fetchAll("
No, erase one of them. I'm assuming he meant to use the shortcut key for "undo" and hit the one that duplicates the line without noticing.Thank you.
Quick question. Are lines 19 and 20 supposed to be identical?
Code:$user_ids = $db->fetchAll(" $user_ids = $db->fetchAll("
Sorry, a copy & paste error.Thank you.
Quick question. Are lines 19 and 20 supposed to be identical?
Code:$user_ids = $db->fetchAll(" $user_ids = $db->fetchAll("
Not a problem. You may need to tune to selection criteria a bit.Also removed the initial 'return;' on line 2.
Nuked 243 in 63.214022874832 seconds.
Many thanks, @Xon.
We use essential cookies to make this site work, and optional cookies to enhance your experience.