Firefox PHP

Mass user deletion

Posted by epicure 
Mass user deletion
July 25, 2005 12:09PM
Hi,

Is there a way to mass-delete "inactive" users, say, users who has not logged in for 6 months or posted less than 2 messages in a year?

I was thinking about deleting them by brute-force from the phorum_users table using an SQL query. However, I am not sure whether that would mess up the database, whether corresponding deletion needs to be carried out in other tables, etc..

Thanks!
Re: Mass user deletion
July 25, 2005 01:37PM
> Is there a way to mass-delete "inactive" users, say, users who has not logged in for 6 months or posted less than 2 messages in a year?

no, you need to write a script for that

> I was thinking about deleting them by brute-force from the phorum_users table using an SQL query. However, I am not sure whether that would mess up the database,

It needs some more deletions, you would have orphaned entries just taking up space if you delete them in the table directly.

look at the include/users.php, there is a function to delete users.


Thomas Seifert
Re: Mass user deletion
July 25, 2005 02:12PM
Try using SQL query.

So far the only way I know of. Had the same problem, needed to delete many users that were not active. Simple SELECT queury helped me. I made search for numer of posts = 0, but I'm sure you could make similar for a date last active field.

After selecting - simply delete the records. Might leave some junk, though, if the users used to be active, I think.



___
Polskie Centrum WebKomiksu
Re: Mass user deletion
July 26, 2005 10:51AM
It will leave a lot of junk. Would be best to write a script to remove them using the Phorum API provided.

Brian - Cowboy Ninja Coder - Personal Blog - Twitter
Re: Mass user deletion
August 04, 2005 10:44PM
godai Wrote:
> Simple SELECT queury helped me. I made
> search for numer of posts = 0, but I'm sure you
> could make similar for a date last active field.

Thanks. :)

My database was convered from Phorum 3.4.x to Phorum 5 using the script 'phorum3to5convert.php'. I checked the database and, curiously, it appears that all the users in the table phorum_users have both their 'date_last_active' fields and 'date_added' fields set to the date of conversion. Some of the users did log-in to the phorum afterwards but the date does not seem to change anymore. What is the problem here?

Another question: if an entry in phorum_users has its 'active' field equals -2, does that mean the user is not actived yet?

Also thanks to Thomas. I will take a look at the code in users.php.





Edited 1 time(s). Last edit at 08/04/2005 11:02PM by epicure.
Re: Mass user deletion
August 31, 2005 11:25AM
Did you ever write a script to do this?

I have one that takes a comma delimited list of User IDs (obtained via SQL) and deletes them cleanly using phorum_user_delete().

If anyone wants me to post this I can do so.

/\dam

--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
pat
Re: Mass user deletion
August 31, 2005 02:42PM
Yes, please do so.

thanx
pat
Re: Mass user deletion
September 01, 2005 07:58AM
Ok, please bear in mind that I knocked this script up very quickly for myself. I therefore haven't changed the Phorum admin interface or anything, so you have to call the script directly. Please see the relevant security warnings in the code.

<?php
	// Script Name: bulk_user_delete.php
	// Author: Adam Sheik (www.sheik.co.uk)
	// Date: August 2005
	// Phorum version supported: Phorum 5.x
	// *******************************************
	// Installation Instructions: Copy this script into your Phorum
	// directory (where common.php lives) and access it directly from
	// your browser to test it.
	// Uncomment the relevant line below to use it properly, but see the
	// security warning below!
	// *******************************************
	// Overview:
	// *very* basic script to take a comma separated list of user IDs
	// (obtained via an SQL statement based on # of posts, date of
	// last activity etc) and delete them.
	// This script is so basic in fact, I'm only releasing it because a user
	// on phorum.org asked me to.
	// WARNING - this script has *no* security, do not leave it on your server
	// without commenting out the "phorum_user_delete()" line. I can't stress
	// the importance of this enough - if you leave this script live and
	// someone accesses it, they can delete all your users!

	// ALSO - it can take a while to delete hundreds of users at once if
	// you have a lot of messages. Unless your PHP timeout is set to over
	// 60 seconds I would recommend deleting users in batches of 50 or so.

	include_once "./common.php";
	include_once "./include/users.php";

	// script to delete multiple users
	$action = $_GET["action"];
	if ($action == "delete"){
		$userarray = explode(",",$_POST["userids"]);
		$count = count($userarray);
		if($count > 0) {
			foreach($userarray as $thisid) {
				// comment out one or other of the next lines
				// depending on whether you want the script to
				// actually delete users
				
				// DANGEROUS LINE
				// phorum_user_delete((int)$thisid); // cast input to integer!
				
				// TEST LINE
				echo "Would have deleted user $thisid if this script was live<br/>";
			}
			echo "$count User(s) deleted.<br />";
		}
	}
	else{
		// this form isn't pretty, but it works great in a Lynx browser ;-)
		echo "<form action=\"mass_user_delete.php?action=delete\" method=\"post\">\n";
		echo "User IDs to Delete <small>(comma separated)</small> :";
		echo "<input type=\"text\" name=\"userids\" size=\"60\">";
		echo "<br/><input type=\"submit\">\n";
		echo "</form>\n";
	}
?>

--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Re: Mass user deletion
February 08, 2013 10:35PM
The script is no longer valid for 5.1.
Which line i need to update so that the script can work?
Re: Mass user deletion
February 09, 2013 05:44AM
If you mean that it doesn't work for 5.2, then I think this is what you need to change in here:

phorum_user_delete -> phorum_api_user_delete


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 1 time(s). Last edit at 02/09/2013 05:45AM by Maurice Makaay.
Sorry, only registered users may post in this forum.

Click here to login