vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   SQL Querry required for Deleting users not active. (https://vborg.vbsupport.ru/showthread.php?t=302633)

alirex 09-25-2013 11:23 AM

SQL Querry required for Deleting users not active.
 
Dear All

I need an SQL query to run from phpmyAdmin to remove all the users who are not active since 100 days. I tried from adminCP but looks like it is huge number of spammer and non active users which make my whole site getting slower. So i feel its good to run a query instead of doing it from AdminCP.

So if someone know kindly give answer.

Thank You in Advance.

I have searched from google alot but looks like i am not able to find one

ForceHSS 09-25-2013 11:32 AM

have you tried doing it with prune options. Also best not to delete users with posts just make a new group and move them to that one

alirex 09-25-2013 01:43 PM

Quote:

Originally Posted by ForceHSS (Post 2447903)
have you tried doing it with prune options. Also best not to delete users with posts just make a new group and move them to that one

I actually mentioned in my post but anyways.. I have tried from admincp to prune but it start lagging my site bcoz too many users are in the list.

My forum is readonly so there is no such loss for me, most of my active users are visitors they dont care to make account. Most of accounts are of Bots/Spammer/Spider etc

ChilaxinC 09-25-2013 03:12 PM

I am not responsible for any damage caused by you following this!
***THIS IS NOT RECOMMENDED FOR USERS WITH POSTS***
I put that disclaimer, but I did test it myself just to be sure ;)

In phpMyAdmin, under your vBulletin database, look for the table "user".

This shows you all sorts of information, including the "lastactivity". This is based on Unix time, for example on my users table last activity, the first date I see is: 1380060934, which is 9/24/13 5:15:34pm EST

You can choose a date that you would like to remove users before, you wanted 100 days ago, which is June 17, 2013 ( Add/subtract Dates Here )

Go here to get the Unix time of a date: http://www.unixtimestamp.com/index.php

June 17, 2013 in Unix time is: 1371445200

Now to delete the users before that timestamp should look something like:
Code:

DELETE FROM user WHERE lastactivity < '1371445200'
*** DO NOT USE THIS IF YOUR USERS HAVE POSTS***

If your users may have posts use the below code instead, the above was only for alirex's special case.
Code:

DELETE FROM user WHERE lastactivity < '1371445200' AND posts = '0'

alirex 09-25-2013 05:27 PM

Quote:

Originally Posted by ChilaxinC (Post 2447938)
I am not responsible for any damage caused by you following this!
I put that disclaimer, but I did test it myself just to be sure ;)

In phpMyAdmin, under your vBulletin database, look for the table "user".

This shows you all sorts of information, including the "lastactivity". This is based on Unix time, for example on my users table last activity, the first date I see is: 1380060934, which is 9/24/13 5:15:34pm EST

You can choose a date that you would like to remove users before, you wanted 100 days ago, which is June 17, 2013 ( Add/subtract Dates Here )

Go here to get the Unix time of a date: http://www.unixtimestamp.com/index.php

June 17, 2013 in Unix time is: 1371445200

Now to delete the users before that timestamp should look something like:
Code:

DELETE FROM user WHERE lastactivity < '1371445200'


Thank you , it works without problem. Its really helpfull query specially when alot of spammer need to be remove. From admincp it was easy if number of members are less. But now its good.

Thanks once again.

ForceHSS 09-25-2013 05:34 PM

I hope you only deleted the members with 0 posts if I was not so busy I could of helped more

alirex 09-25-2013 05:36 PM

Quote:

Originally Posted by ForceHSS (Post 2447950)
I hope you only deleted the members with 0 posts if I was not so busy I could of helped more

Yes as i said above it is read only forum , so guest and registered members are not able to make any post. Only staff can post content rest all are watching it or discussing in shoutbox.

ForceHSS 09-25-2013 05:39 PM

So u deleted members with 0 posts good will be less problems

ChilaxinC 09-25-2013 08:12 PM

Quote:

Originally Posted by alirex (Post 2447947)
Thank you , it works without problem. Its really helpfull query specially when alot of spammer need to be remove. From admincp it was easy if number of members are less. But now its good.

Thanks once again.

No problem at all, and like ForceHSS said this is not recommended to use if you have a forum with users that have posts, but a simple change to the query could prevent problems of that nature:
Code:

DELETE FROM user WHERE lastactivity < '1371445200' AND posts = '0'
Now it is only deleting users that have 0 posts and the last activity was before the timestamp.

Zachery 09-25-2013 10:35 PM

You should really use the prune function, and decrease the number of users you're doing in a single pass. You're not removing all of the user data correctly if you only drop from the user table.


All times are GMT. The time now is 06:08 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01006 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete