forked from MightyGorgon/icy_phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_users.php
136 lines (115 loc) · 4.48 KB
/
delete_users.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*
* @Extra credits for this file
* Niels Chr. Rød ([email protected]) - (http://mods.db9.dk)
*
*/
/*
#########################################################
## phpBB2 drop-in mod, that checks for unused accounts for X days use the script while logged in as ADMIN, add the days=X as a extra parameter
## e.g. delete_users.php?mode=not_login&days=10 will delete all accounts who have never logged in and are older than 10 days
##
## And zero postes
## e.g. delete_users.php?mode=zero_poster&days=10 will delete all accounts who have never posted and are older than 10 days
##
## You can also delete specific users
## e.g. delete_users.php?mode=user_name&del_user=Niels
## or delete_users.php?mode=user_id&del_user=18
## Will delete a specific user either by name or by id, remember that is is NOT case sensitive
## if the user have posted, then his/her posts will be converted to posted by guest, and the users
## name will still be shown
##
#########################################################
## Added by Mighty Gorgon:
## Possibility to recall it directly from command line with progress status.
##
## First set this
## define('KILL_CONFIRM', true);
##
## Then recall this address
## delete_users.php?mode=prune_mg&users_number=50&days=360
##
#########################################################
*/
define('CTRACKER_DISABLED', true);
// to enable email notification to the user, after deletion, enable this
define('NOTIFY_USERS', true);
// to disable confirmation when executing PRUNE_MG
define('KILL_CONFIRM', false);
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/digest_constants.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/functions_users_delete.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
@set_time_limit(180);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
$sql = 'SELECT user_level FROM ' . USERS_TABLE . ' WHERE user_id="' . $user->data['user_id'] . '" LIMIT 1';
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($user_row['user_level'] != ADMIN)
{
message_die(GENERAL_ERROR, $lang['Not_Authorized']);
}
$del_user = request_var('del_user', 0);
$del_user = ($del_user < 2) ? 0 : $del_user;
$mode = request_var('mode', '');
$days = request_var('days', 0);
if ($mode == 'prune_mg')
{
$users_number = request_var('users_number', 0);
$users_number = ($users_number == 0) ? '50' : $users_number;
}
if(isset($_POST['cancel']))
{
redirect(append_sid($_POST['ref_url'], true));
}
if(!isset($_POST['confirm']) && !KILL_CONFIRM)
{
$ref_url = explode('/', $_SERVER['HTTP_REFERER']);
$s_hidden_fields = '';
$s_hidden_fields .= '<input type="hidden" name="ref_url" value="' . htmlspecialchars($ref_url[sizeof($ref_url) - 1]) . '" />';
$s_hidden_fields .= '<input type="hidden" name="del_user" value="' . $del_user . '" />';
$s_hidden_fields .= '<input type="hidden" name="mode" value="' . $mode . '" />';
$s_hidden_fields .= '<input type="hidden" name="days" value="' . $days . '" />';
$template->assign_vars(array(
'MESSAGE_TITLE' => $lang['Confirm'],
'MESSAGE_TEXT' => $lang['Confirm_delete_user'],
'L_YES' => $lang['Yes'],
'L_NO' => $lang['No'],
'S_CONFIRM_ACTION' => append_sid('delete_users.' . PHP_EXT),
'S_HIDDEN_FIELDS' => $s_hidden_fields
)
);
full_page_generation('confirm_body.tpl', $lang['Confirm'], '', '');
}
// Recall kill script!
include(IP_ROOT_PATH . 'includes/users_delete_inc.' . PHP_EXT);
$message = '<b>Mode</b>: [ <span class="topic_glo">' . $mode_des . '</span> ]<br />' . (($i) ? sprintf($lang['Prune_users_number'], $i) . $name_list : $lang['Prune_no_users']);
if (($mode == 'prune_mg') && ($users_number == $i))
{
$redirect_url = append_sid('delete_users.' . PHP_EXT . '?mode=' . $mode . '&users_number=' . $users_number . '&days=' . $days);
meta_refresh(3, $redirect_url);
$message = '<span class="topic_glo">' . $lang['InProgress'] . '</span><br /><br />' . $message;
}
else
{
$message .= '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid(CMS_PAGE_FORUM) . '">', '</a>');
}
message_die(GENERAL_MESSAGE, $message);
?>