phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Delete user and all users posts


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Wed Jan 27, 2010 2:14 pm 
Post subject: Delete user and all users posts

Hi,

I want to delete a user and all his posts.
I searched for a mod helping me with that and found this:
Code:
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_users.php

#
#-----[ FIND ]------------------------------------------
#
         $sql = "UPDATE " . POSTS_TABLE . "
            SET poster_id = " . DELETED . ", post_username = '$username'
            WHERE poster_id = $user_id";

#
#-----[ REPLACE WITH ]------------------------------------------
#

         $sql = "DELETE FROM " . POSTS_TABLE . "
            WHERE poster_id = $user_id";

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#

# EoM

That does not work, because it seems that all THREADS where this user posted in are deleted. Not only the users posts.

Anyone an idea?

/Holger
Back to top
Ram
Board Member



Joined: 23 Dec 2008

Posts: 100
Location: Somewhere over the rainbow


flag
PostPosted: Wed Jan 27, 2010 3:23 pm 
Post subject: Re: Delete user and all users posts

Try with PHPBB Admin ToolKit v2.1b
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Wed Jan 27, 2010 3:27 pm 
Post subject: Re: Delete user and all users posts

This MOD is better, because Toolkit leaves empty messages marked as posted by guest.


Admin Delete User with All Postings.zip
 Description:

Download
 Filename:  Admin Delete User with All Postings.zip
 Filesize:  19.09 KB
 Downloaded:  1381 Time(s)


_________________
phpBB2 will never die, I hope!
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Wed Jan 27, 2010 3:27 pm 
Post subject: Re: Delete user and all users posts

Ram: Looks great, but I need a simple way (even hardcoded like above) in the ACP. Because it is for a multi-forum installation.

dogs and things: will try that one. Found it already, but it seemed to be "too much".
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Thu Jan 28, 2010 10:44 am 
Post subject: Re: Delete user and all users posts

Maybe Delete All User Posts is better for you?
_________________
phpBB2 will never die, I hope!
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Jan 28, 2010 10:47 am 
Post subject: Re: Delete user and all users posts

dogs and things wrote:
Maybe Delete All User Posts is better for you?

LOL!
http://www.phpbb2refugees.com/viewtopic.php?p=4904#4904
icon_mrgreen.gif
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Thu Jan 28, 2010 1:10 pm 
Post subject: Re: Delete user and all users posts

icon_eek.gif icon_cry.gif

icon_lol.gif

_________________
phpBB2 will never die, I hope!
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Jan 28, 2010 1:15 pm 
Post subject: Re: Delete user and all users posts

Why does the code changes in the first post not work? icon_redface.gif
Back to top
Neomerlin
Board Member



Joined: 20 Feb 2010

Posts: 3


flag
PostPosted: Sat Feb 20, 2010 8:23 pm 
Post subject: Re: Delete user and all users posts

Holger wrote:
Hi,

I want to delete a user and all his posts.
I searched for a mod helping me with that and found this:
Code:
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_users.php

#
#-----[ FIND ]------------------------------------------
#
         $sql = "UPDATE " . POSTS_TABLE . "
            SET poster_id = " . DELETED . ", post_username = '$username'
            WHERE poster_id = $user_id";

#
#-----[ REPLACE WITH ]------------------------------------------
#

         $sql = "DELETE FROM " . POSTS_TABLE . "
            WHERE poster_id = $user_id";

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#

# EoM

That does not work, because it seems that all THREADS where this user posted in are deleted. Not only the users posts.

Anyone an idea?

/Holger


I had the same problem: I wanted to delete a user and all his posts. I tried different solutions, including the ones mentioned here in this thread. My final try was the one i quoted above, but what happend was:

My form now shows that the last post in each forum where one of the deleted threads was (in all of the forums u can see) has been made on the 01 Jan 1970 01:00 am which obviously is wrong.

I think that code i used fucked up my userDB somehow. Can someone help me to show that date right again?

Here's the link to my forum, so you can see what i meant:

http://www.kreativkabel.de/datacore/xas/index.php

I am not new to phpbb, but everything i know is self-teached and i have no idea in terms of coding, so please try to keep it simple icon_smile.gif

Thank you very much for any help to make that thing work again icon_neutral.gif
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Sat Feb 20, 2010 11:38 pm 
Post subject: Re: Delete user and all users posts

Copy this code:
Code:
<?php

## phpBB Sync All
##
## Author: uncle.f < soft at purple-yonder.com >
##
## This script performs the compete sync of all posts/topic/forums statistics
## including the approval data.
##
## Usage: copy this script to the 'admin' directory of your phpBB installation;
## you should get a new 'Sync All' lnk in the admin panel ('Forums' section).
## Simply click on the 'Sync All' link to synchronize everything.
## It would make sense to do that when there is low user activity on your forum,
## especially if it contains a lot of posts.

define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
   $file = basename(__FILE__);
   $module['Forums']['Sync All'] = $file;
   return;
}

$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);

// sync all topics and forums first
sync('all topics');
sync('all forums');

$end_msg = 'Topics and Forums sync is complete!';

// sync users' # of posts counters (only for MySQL 4.1+)
if (substr(SQL_LAYER,0,5) == 'mysql')
{
   $sql = "SHOW VARIABLES LIKE 'version'";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Error gettting MySQL server information!', '', __LINE__, __FILE__, $sql);
   }

   if ( $total = $db->sql_fetchrow($result))
   {
      $db->sql_freeresult($result);

      if (substr($total['Value'],0,3) == '4.1' || substr($total['Value'],0,1) > 4)
      {
         $sql = "UPDATE " . USERS_TABLE . " u SET u.user_posts =
                 (SELECT COUNT(p.poster_id)
                  FROM " . POSTS_TABLE . " p
                  WHERE p.post_approve = 0
                        AND u.user_id = p.poster_id
                  GROUP BY p.poster_id)";

         if ( !$db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, 'Error updating user statistics!', '', __LINE__, __FILE__, $sql);
         }

         $end_msg = 'Topics, Forums and user posts counters sync is complete!';
      }
   }
}

message_die(GENERAL_MESSAGE, $end_msg);

?>

Save it as admin_sync_all.php and ftp it to your board's admin folder.

You now see under the administer forums section a new link, sync_all, click it and wait while the script performs the complete sync of all posts/topic/forums statistics, when it ends you'll see a confirmation message.

This files comes as a bonus with the Approval MOD and works very nicely for me, I don´t know if it will work for you.

See if it fixes your problem.

_________________
phpBB2 will never die, I hope!
Back to top
Neomerlin
Board Member



Joined: 20 Feb 2010

Posts: 3


flag
PostPosted: Sun Feb 21, 2010 2:21 am 
Post subject: Re: Delete user and all users posts

dogs and things wrote:
Copy this code:
Code:
<?php

## phpBB Sync All
##
## Author: uncle.f < soft at purple-yonder.com >
##
## This script performs the compete sync of all posts/topic/forums statistics
## including the approval data.
##
## Usage: copy this script to the 'admin' directory of your phpBB installation;
## you should get a new 'Sync All' lnk in the admin panel ('Forums' section).
## Simply click on the 'Sync All' link to synchronize everything.
## It would make sense to do that when there is low user activity on your forum,
## especially if it contains a lot of posts.

define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
   $file = basename(__FILE__);
   $module['Forums']['Sync All'] = $file;
   return;
}

$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);

// sync all topics and forums first
sync('all topics');
sync('all forums');

$end_msg = 'Topics and Forums sync is complete!';

// sync users' # of posts counters (only for MySQL 4.1+)
if (substr(SQL_LAYER,0,5) == 'mysql')
{
   $sql = "SHOW VARIABLES LIKE 'version'";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Error gettting MySQL server information!', '', __LINE__, __FILE__, $sql);
   }

   if ( $total = $db->sql_fetchrow($result))
   {
      $db->sql_freeresult($result);

      if (substr($total['Value'],0,3) == '4.1' || substr($total['Value'],0,1) > 4)
      {
         $sql = "UPDATE " . USERS_TABLE . " u SET u.user_posts =
                 (SELECT COUNT(p.poster_id)
                  FROM " . POSTS_TABLE . " p
                  WHERE p.post_approve = 0
                        AND u.user_id = p.poster_id
                  GROUP BY p.poster_id)";

         if ( !$db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, 'Error updating user statistics!', '', __LINE__, __FILE__, $sql);
         }

         $end_msg = 'Topics, Forums and user posts counters sync is complete!';
      }
   }
}

message_die(GENERAL_MESSAGE, $end_msg);

?>

Save it as admin_sync_all.php and ftp it to your board's admin folder.

You now see under the administer forums section a new link, sync_all, click it and wait while the script performs the complete sync of all posts/topic/forums statistics, when it ends you'll see a confirmation message.

This files comes as a bonus with the Approval MOD and works very nicely for me, I don´t know if it will work for you.

See if it fixes your problem.


Thank you, but it gave me the following error message:

Error updating user statistics!

DEBUG MODE

SQL Error : 1054 Unknown column 'p.post_approve' in 'where clause'

UPDATE phpbb_users u SET u.user_posts = (SELECT COUNT(p.poster_id) FROM phpbb_posts p WHERE p.post_approve = 0 AND u.user_id = p.poster_id GROUP BY p.poster_id)

Line : 60
File : admin_sync_all.php
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Sun Feb 21, 2010 9:13 am 
Post subject: Re: Delete user and all users posts

I guessed that would happen,

Try to remove
Code:
p.post_approve = 0
                        AND
from the query so that it looks like
Code:
         $sql = "UPDATE " . USERS_TABLE . " u SET u.user_posts =
                 (SELECT COUNT(p.poster_id)
                  FROM " . POSTS_TABLE . " p
                  WHERE u.user_id = p.poster_id
                  GROUP BY p.poster_id)";
and try again.
_________________
phpBB2 will never die, I hope!
Back to top
Neomerlin
Board Member



Joined: 20 Feb 2010

Posts: 3


flag
PostPosted: Mon Feb 22, 2010 1:21 am 
Post subject: Re: Delete user and all users posts

Thank you very much icon_smile.gif

It all works now.

I just hope I can get rid of all the bots and spammers somehow - even a better captcha didnt help against them signing up for my forum - and i couldnt find any captcha that has to be done before posting (is there one?). Maybe i should upgrade to phpbb3 - i just dont think my theme will work then and i put way too much work into configuring it all.

Anyway, thanks icon_smile.gif
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Mon Feb 22, 2010 3:39 am 
Post subject: Re: Delete user and all users posts

Have you tried the Anti-Bot Question MOD? No spam at all since I've started using it and it is enabled for both registration and guest posting. Its biggest strength is probably the fact that if a particular bot is set to answer correctly to your questions, you can just change them icon_razz.gif
Back to top
Slackervaara
Board Member



Joined: 01 Jan 2009

Posts: 70



PostPosted: Mon Feb 22, 2010 5:54 am 
Post subject: Re: Delete user and all users posts

I recommend bbantispam - easy to install and one have to answer a question the first time only. have not had a single spam since I installed it 3 years ago.
http://www.bbantispam.com/
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0255 seconds using 17 queries. (SQL 0.0027 Parse 0.0027 Other 0.0201)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo