Author |
Message |
Holger Board Member
Joined: 19 Jan 2009
Posts: 509 Location: Hanover
|
Posted: Wed Jan 27, 2010 10:14 am 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
|
|
Back to top |
|
|
dogs and things Board Member
Joined: 18 Nov 2008
Posts: 628 Location: Spain
|
Posted: Wed Jan 27, 2010 11:27 am Post subject: Re: Delete user and all users posts |
|
|
This MOD is better, because Toolkit leaves empty messages marked as posted by guest.
Description: |
|
Download |
Filename: |
Admin Delete User with All Postings.zip |
Filesize: |
19.09 KB |
Downloaded: |
2604 Time(s) |
_________________ phpBB2 will never die, I hope! |
|
Back to top |
|
|
Holger Board Member
Joined: 19 Jan 2009
Posts: 509 Location: Hanover
|
Posted: Wed Jan 27, 2010 11:27 am 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: 628 Location: Spain
|
Posted: Thu Jan 28, 2010 6: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
|
|
Back to top |
|
|
dogs and things Board Member
Joined: 18 Nov 2008
Posts: 628 Location: Spain
|
Posted: Thu Jan 28, 2010 9:10 am Post subject: Re: Delete user and all users posts |
|
|
_________________ phpBB2 will never die, I hope! |
|
Back to top |
|
|
Holger Board Member
Joined: 19 Jan 2009
Posts: 509 Location: Hanover
|
Posted: Thu Jan 28, 2010 9:15 am Post subject: Re: Delete user and all users posts |
|
|
Why does the code changes in the first post not work?
|
|
Back to top |
|
|
Neomerlin Board Member
Joined: 20 Feb 2010
Posts: 3
|
Posted: Sat Feb 20, 2010 4: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
Thank you very much for any help to make that thing work again
|
|
Back to top |
|
|
dogs and things Board Member
Joined: 18 Nov 2008
Posts: 628 Location: Spain
|
Posted: Sat Feb 20, 2010 7: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
|
Posted: Sat Feb 20, 2010 10:21 pm 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: 628 Location: Spain
|
Posted: Sun Feb 21, 2010 5: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
|
Posted: Sun Feb 21, 2010 9:21 pm Post subject: Re: Delete user and all users posts |
|
|
Thank you very much
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
|
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Sun Feb 21, 2010 11:39 pm 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
|
|
Back to top |
|
|
Slackervaara Board Member
Joined: 01 Jan 2009
Posts: 70
|
Posted: Mon Feb 22, 2010 1: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 |
|
|
|