[BETA] Remove Unactivated Users (Automatically) 0.4.0

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

[BETA] Remove Unactivated Users (Automatically) 0.4.0

Post by alexi02 »

MOD Title: Remove Unactivated Users (Automatically)
MOD Description: Removes each unactivated user after a specified time (by you) automatically.
MOD Version: 0.4.0

MOD Download: Remove Unactivated Users v0.4.0 (11.7 KB)
Last Stable version: N/A

MOD Screenshot: ACP

MOD History:
2006-09-30 - Version 0.4.0
- Uses the CONFIG TABLE instead of a config file
- Removed updating GROUPS_TABLE

2006-08-30 - Version 0.3.1
- Bug fix: Email Deletion Entries text now properly checked
- Bug fix: Lang had 2 entries of 'Email Deletion Entries text'
- Checks if Email Deletion Entries is more than 0 if Email Deletion Log is enabled

2006-08-30 - Version 0.3.0
- Template and Language are no longer hard coded!

2006-08-29 - Version 0.2.0
- Updated the logging of deleted users to occur after successful database queries
- Split log file into two files: Deletion and Error log
- Added 24hr time and GMT difference when logging
- New Feature: Sending an email of the deletion log to an admin once a number of user deletions is meet (clears the deletion log once the email is sent)
- New Feature: Sending an email of the error log to an admin every time there is an error with deleting users (clears the error log once the email is sent)

2006-08-28 - Version 0.1.3
- Bug fix: changed from phpbb_users to USERS_TABLE in remove_unactivated_users.php

2006-08-28 - Version 0.1.2
- Changed writing to log file and deleting users into a function for easier readability
- Added more read/write validation checks
- die() no longer used as it would make the forum inaccessible
- Removed the need for checking whether we are in an admin directory; using $phpbb_root_path instead.

2006-08-28 - Version 0.1.1
- Updated deletion of user to include other tables which are affected when the user first registers

2006-08-27 - Version 0.1.0
- Initial Release (for phpBB 2.0.21)

MOD Notes:
Only to be used on forums with the registration type of User Activations.

This MOD checks each unactivated users' registration date then adds the time specified by you to the registration date and deletes the user if the current time is older than the registration time + time specified.




This is my first MOD, so be nice if you find a problem :). If you have an improvement that can be made then by all means post it. Also it would be nice if people could try this out and report back if it worked fine as right now I only know it works on my server.

I thought I might try making this mod as this post requested it and I also needed it for my forums as well.

I've used the common.php file to include a file which checks to see every unactivated user and whether they should be deleted. I chose the common.php file as it was used by just about every function on the forum. This means it might slow down the speed of forums which have lots of new user registrations every day.

alexi02.
Last edited by alexi02 on Sat Sep 30, 2006 4:21 am, edited 19 times in total.
deejaybet
Registered User
Posts: 1814
Joined: Thu Dec 08, 2005 2:01 pm
Location: Derry, Northern Ireland
Contact:

Post by deejaybet »

automatically?... so what if the accounts are legit and users havent activated yet.. is there some sort of delay first?

actually disregard that.. i looked at the image there now
User avatar
Ramon Fincken
Registered User
Posts: 4835
Joined: Thu Oct 14, 2004 1:04 am
Location: NL, The Netherlands Amsterdam area @GMT +1
Contact:

Post by Ramon Fincken »

OW GOD...

is THIS all you do to remove the users?

Code: Select all

               // Delete the user from the DB table
               $sql = "DELETE FROM phpbb_users
                       WHERE user_actkey = '$db_act_key'";

               if( !$result = $db->sql_query($sql) ) {
                  die("Could not delete rows from phpbb_users table, $sql");
Dutch quality fully managed WordPress hosting - ManagedWPHosting.nl

Before changing a file, some code or installing a MOD >> Make a backup first!

Do you like my mods? paypal me $1 :) forumsoftware[AT}creativepulses[DOT}nl [/size]
PhpBBantispam.com || Instant find your mod here
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw »

Whoops...

You should take a look at usercp_register, and see what belongs to adding a new user. Then look at admin_users.php, and look what it takes to remove them :wink:
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Post by alexi02 »

Ramon Fincken wrote: OW GOD...

is THIS all you do to remove the users?


Sorry :oops:

eviL<3 wrote: You should take a look at usercp_register, and see what belongs to adding a new user. Then look at admin_users.php, and look what it takes to remove them


I've looked at usercp_register.php and found three INSERT statements for registration:

Code: Select all

$sql = "INSERT INTO " . USERS_TABLE . "
$sql = "INSERT INTO " . GROUPS_TABLE . "
$sql = "INSERT INTO " . USER_GROUP_TABLE . "
Then the admin_users.php for deleting users would all I need is this code below? (Not sure if the group_moderator part is needed)

Code: Select all

                       sql = "SELECT g.group_id
                                FROM " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
                                WHERE ug.user_id = $user_id
                                        AND g.group_id = ug.group_id
                                        AND g.group_single_user = 1";
                        if( !($result = $db->sql_query($sql)) )
                        {
                                die("Could not obtain group information for this user, $sql");
                        }
                        $row = $db->sql_fetchrow($result);



                                $sql = "SELECT group_id
                                FROM " . GROUPS_TABLE . "
                                WHERE group_moderator = $user_id";
                        if( !($result = $db->sql_query($sql)) )
                        {
                                die("Could not select groups where user was moderator, $sql");
                        }

                        while ( $row_group = $db->sql_fetchrow($result) )
                        {
                                $group_moderator[] = $row_group['group_id'];
                        }

                        if ( count($group_moderator) )
                        {
                                $update_moderator_id = implode(', ', $group_moderator);

                                $sql = "UPDATE " . GROUPS_TABLE . "
                                        SET group_moderator = " . $userdata['user_id'] . "
                                        WHERE group_moderator IN ($update_moderator_id)";
                                if( !$db->sql_query($sql) )
                                {
                                        die("Could not update group moderators, $sql");
                                }
                        }



                        $sql = "DELETE FROM " . USERS_TABLE . "
                                WHERE user_id = $user_id";
                        if( !$db->sql_query($sql) )
                        {
                               die("Could not delete user, $sql");
                        }



                        $sql = "DELETE FROM " . USER_GROUP_TABLE . "
                                WHERE user_id = $user_id";
                        if( !$db->sql_query($sql) )
                        {
                                die("Could not delete user from user_group table, $sql");
                        }



                        $sql = "DELETE FROM " . GROUPS_TABLE . "
                                WHERE group_id = " . $row['group_id'];
                        if( !$db->sql_query($sql) )
                        {
                                die("Could not delete group for this user, $sql");
                        }
Thanks.
User avatar
Ramon Fincken
Registered User
Posts: 4835
Joined: Thu Oct 14, 2004 1:04 am
Location: NL, The Netherlands Amsterdam area @GMT +1
Contact:

Post by Ramon Fincken »

I've seen series of 11 queries to fully remove a user

just run it through...

Code: Select all

* posts
* PM's
* user table
* Group
* group user
* watch table

etc...
Dutch quality fully managed WordPress hosting - ManagedWPHosting.nl

Before changing a file, some code or installing a MOD >> Make a backup first!

Do you like my mods? paypal me $1 :) forumsoftware[AT}creativepulses[DOT}nl [/size]
PhpBBantispam.com || Instant find your mod here
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Post by alexi02 »

I've seen those but are they really needed?

This MOD only removes users who haven't activated their account at all, therefore they haven't posted, PM'ed, etc. Do you know of anyway which a user would have to re-activate their account for any reason or than the initial registration?

Thanks for replying.
User avatar
Ramon Fincken
Registered User
Posts: 4835
Joined: Thu Oct 14, 2004 1:04 am
Location: NL, The Netherlands Amsterdam area @GMT +1
Contact:

Post by Ramon Fincken »

alexi02 wrote: I've seen those but are they really needed?

This MOD only removes users who haven't activated their account at all, therefore they haven't posted, PM'ed, etc. Do you know of anyway which a user would have to re-activate their account for any reason or than the initial registration?

Thanks for replying.


if a user changes his/her email for example..
or due to mods that require re-activation after the website field has been altered..
Dutch quality fully managed WordPress hosting - ManagedWPHosting.nl

Before changing a file, some code or installing a MOD >> Make a backup first!

Do you like my mods? paypal me $1 :) forumsoftware[AT}creativepulses[DOT}nl [/size]
PhpBBantispam.com || Instant find your mod here
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Post by alexi02 »

Ramon Fincken wrote: if a user changes his/her email for example..
or due to mods that require re-activation after the website field has been altered..


Thanks for letting me know. I'll have to include some sort of a check to see that the user hasn't logged in at all (user_lastvisit in the users table might do well). Edit: v0.1.1 released with the deletion of other tables fix.
User avatar
Ramon Fincken
Registered User
Posts: 4835
Joined: Thu Oct 14, 2004 1:04 am
Location: NL, The Netherlands Amsterdam area @GMT +1
Contact:

Post by Ramon Fincken »

alexi02 wrote:
Ramon Fincken wrote: if a u[ .. ]as been altered..


Thanks for letting me know. I'll have to include some sort of a check to see that the user hasn't logged in at all (user_lastvisit in the users table might do well). Edit: v0.1.1 released with the deletion of other tables fix.

user_lastvisit in the users table might do well


exactly ! if that is erm... either NULL or 0 you got a 'bingo' on that user :)
do a double check if we are not confioused by the user_session time..
Dutch quality fully managed WordPress hosting - ManagedWPHosting.nl

Before changing a file, some code or installing a MOD >> Make a backup first!

Do you like my mods? paypal me $1 :) forumsoftware[AT}creativepulses[DOT}nl [/size]
PhpBBantispam.com || Instant find your mod here
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Post by alexi02 »

Ramon Fincken wrote: exactly ! if that is erm... either NULL or 0 you got a 'bingo' on that user :)
do a double check if we are not confioused by the user_session time..


I've checked this website: http://www.phpbbdoctor.com/doc_columns.php?id=24 and user_lastvisit is what we were thinking.
User avatar
Ramon Fincken
Registered User
Posts: 4835
Joined: Thu Oct 14, 2004 1:04 am
Location: NL, The Netherlands Amsterdam area @GMT +1
Contact:

Post by Ramon Fincken »

alexi02 wrote:
Ramon Fincken wrote: exactly ! if that is erm... either NULL or 0 you got a 'bingo' on that user :)
do a double check if we are not confioused by the user_session time..


I've checked this website: http://www.phpbbdoctor.com/doc_columns.php?id=24 and user_lastvisit is what we were thinking.


ok, thats the site of drathbun, cool guy with lots of phpbb knowledge.
I leave you alone handling this, good luck, in the end you'll have a great mod !!
Dutch quality fully managed WordPress hosting - ManagedWPHosting.nl

Before changing a file, some code or installing a MOD >> Make a backup first!

Do you like my mods? paypal me $1 :) forumsoftware[AT}creativepulses[DOT}nl [/size]
PhpBBantispam.com || Instant find your mod here
User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun »

With MySQL the default value for the user_lastvisit is zero. So if a user has never logged in (which is actually different from "visited") this value will be zero. A clarification: a user may register for your board, and even activate their account, but if they never actually log in then the user_lastvisit is still zero.

I use this to remove user that are active but have not visited within 90 days of their registration.

I use the user_active flag to remove users that registered but never activated (probably due to bots, or using a bad email address) within 30 days. FWIW, both of these processes are run via perl scripts run via cron, rather than by some sort of admin process.

Glad to see that the information on my site has been useful to you. :-) I need to get back and update the information as there are some new tables (confirm) and columns (number of login tries) that have been added since I input all of that data.

Good luck with your project. 8)
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Post by alexi02 »

Updated.

2006-08-28 - Version 0.1.2
- Changed writing to log file and deleting users into a function for easier readability
- Added more read/write validation checks
- die() no longer used as it would make the forum inaccessible
- Removed the need for checking whether we are in an admin directory; using $phpbb_root_path instead.

Edit:
Updated again.

2006-08-28 - Version 0.1.3
- Bug fix: changed from phpbb_users to USERS_TABLE in remove_unactivated_users.php
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Post by alexi02 »

Updated with a new email feature and changed to ALPHA. (Where are the phpBB standards for saying what it takes for MODs to be ALPHA, BETA, etc ?)

2006-08-29 - Version 0.2.0
- Updated the logging of deleted users to occur after successful database queries
- Split log file into two files: Deletion and Error log
- Added 24hr time and GMT difference when logging
- New Feature: Sending an email of the deletion log to an admin once a number of user deletions is meet (clears the deletion log once the email is sent)
- New Feature: Sending an email of the error log to an admin every time there is an error with deleting users (clears the error log once the email is sent)
Post Reply

Return to “[2.0.x] MODs in Development”