Topic: Autoremove not activated User Accounts (bots) by rules
Is there a way through a plugin or a few lines to autoremove users which haven't activated their accounts within one our (e.g. bots)?
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 discussion → Autoremove not activated User Accounts (bots) by rules
Is there a way through a plugin or a few lines to autoremove users which haven't activated their accounts within one our (e.g. bots)?
User Management Created by Connorhd. The User Management plugin can be used to prune user accounts based on the age of the account and the number of posts made by the users. Additionally, the plugin can also be used to add new users.
Hi,
I just tried it on my forum. It doesn't exactly what I was looking for.
I'd like to have it automated. Every interested user should be able to check their mails whithin one hour and register. If not, it's most likely
a bot.
cron job?? you want that, but i dont know much about them
Writing on a script as we speak which does what I want. Then gonna add it to the cron job.
mysql_select_db("pun") or die
("Database doesn't exist");
$query = 'DELETE FROM '.$db_prefix.'users WHERE (registered > '.(time()-(60*60*24)).') AND (registered < '.(time()-(60*60)).') AND (registered = last_visit) AND (id > 2)';
@mysql_query($query) or die (mysql_error());
@mysql_close($db);
//print $query;
?>
how about this in a cronjob?
Add a check for no posts too, just to make sure.
Where is $db_prefix set, where is mysql_connect called (other than implicitly by the mysql_select_db call)?
How about this:
$db_type = 'mysql';
$db_host = 'localhost';
$db_name = 'xxx';
$db_username = 'xxx';
$db_password = 'xxx';
$db_prefix = '';
$p_connect = false;
//include("dbconnect.php");
$db = @mysql_connect($db_host, $db_username, $db_password) or die
("Keine Verbindung moeglich");
$query = 'DELETE FROM '.$db_prefix.'users WHERE (registered > '.(time()-(60*60*24)).') AND (registered < '.(time()-(60*60)).') AND (registered = last_visit) AND (id > 2) AND (num_posts = 0)';
Any idea on how to optimize this code except for using hard values for time ?
Since you're interested in removing accounts that have not been activated you might be interested in knowing that unactivated accounts have a group ID of 3200 and as such "(registered = last_visit)" works but may perform extremely slightly worse than "g_id = 3200".
I'm not quite sure what you intend with "(registered > '.(time()-(60*60*24)).') AND (registered < '.(time()-(60*60)).')". If you wish to remove users that have not activated themselves after an hour, would not simply using ".time() - 3600.' > registered" work?
Finally, from a purely stylistic perspective, you don't need parentheses around each portion of the WHERE clause. You only need to use them if you're grouping multiple restrictions together. For instance, "(foo = bar OR alpha = beta) AND (a < b OR b > c)".
Since you're interested in removing accounts that have not been activated you might be interested in knowing that unactivated accounts have a group ID of 3200 and as such "(registered = last_visit)" works but may perform extremely slightly worse than "g_id = 3200".
I'm not quite sure what you intend with "(registered > '.(time()-(60*60*24)).') AND (registered < '.(time()-(60*60)).')". If you wish to remove users that have not activated themselves after an hour, would not simply using ".time() - 3600.' > registered" work?
Finally, from a purely stylistic perspective, you don't need parentheses around each portion of the WHERE clause. You only need to use them if you're grouping multiple restrictions together. For instance, "(foo = bar OR alpha = beta) AND (a < b OR b > c)".
"g_id = 3200". = good point /thx for the advice.
(time()-(60*60*24) is supposed to check the users in the database only back by a certain value of days (this case 24h).
So I don't have to check users I have checked already days before. My be faster than checking all of them. Tell me if I'm
wrong or how to do it better.
stylistic perspective: You are right for sure! We (a friend and me) are both novices to php and therefore don't know better than that.
Hence, advice is always welcome.
g_id=3200 and registration time not in the past hour should be enough
Isn't the group id for unverified users 32000 and not 3200?
Yes, that's what we all meant
If you use the group_id, a new index is required to avoid a tablescan. This will be clearly the fastest method, cause the most operations on this table are read operations.
But for the registered column an index already exists. Therefore you can use something like this (a mix of your ideas):
$query = 'DELETE FROM '.$db_prefix.'users WHERE registered BETWEEN '.(time()-(60*60*24)).' AND '.(time()-(60*60)).' AND group_id = 32000 AND id > 2 AND num_posts = 0';
This will result in a range condition using the index of 'registered' with an additional scan for the other columns. I think it will be not noticeable slower than the group_id index matching and you have not to create an new index.
Both methods are good, the one requires a little bit more space in the database (and backup) and one more index must be organized on write access, in the other you have to use a range condition instead of matching.
Hey just registered again under my real username since I decided to stay here for a while and using punbb.
It's me, testingpunbb btw.
We just managed as of today to implement reCaptcha in our testforum thanks to smartys, which came
up with an tutorial he found on google.
Now we are curious if one of you guys maybe thinks of making a recaptcha plugin for V1.3 ?
Any interest in this at all?
Since 1.3 has no official release, no, not at this point. In the future? Sure
PunBB Forums → PunBB 1.2 discussion → Autoremove not activated User Accounts (bots) by rules
Powered by PunBB, supported by Informer Technologies, Inc.