diff --git a/phpBB/admin/admin_prune_users.php b/phpBB/admin/admin_prune_users.php new file mode 100644 index 0000000000..c2c6f2b9a5 --- /dev/null +++ b/phpBB/admin/admin_prune_users.php @@ -0,0 +1,268 @@ +get_acl_admin('user') ) + { + return; + } + + $filename = basename(__FILE__); + $module['Users']['Prune_users'] = $filename . $SID; + + return; +} + +define('IN_PHPBB', 1); +// +// Include files +// +$phpbb_root_path = '../'; +require($phpbb_root_path . 'extension.inc'); +require('pagestart.' . $phpEx); + +// +// Do we have forum admin permissions? +// +if ( !$acl->get_acl_admin('user') ) +{ + return; +} + +// +// Set mode +// +if( isset( $HTTP_POST_VARS['mode'] ) || isset( $HTTP_GET_VARS['mode'] ) ) +{ + $mode = ( isset( $HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; +} +else +{ + $mode = ''; +} + +// +// +// +if ( isset($HTTP_POST_VARS['prune']) ) +{ + if ( empty($HTTP_POST_VARS['confirm']) ) + { + $values = array('prune', 'deactivate', 'delete', 'users', 'username', 'email', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count'); + + $l_message = '
' . $lang['Confirm_prune_users'] . '

  '; + + foreach ( $values as $field ) + { + $l_message .= ( !empty($HTTP_POST_VARS[$field]) ) ? '' : ''; + } + + $l_message .= '
'; + + page_header($lang['Prune_users']); + +?> + +

+ +

+ + '<', 'gt' => '>', 'eq' => '='); + $sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit'); + + $where_sql = ''; + $where_sql .= ( $username ) ? " AND username LIKE '" . str_replace('*', '%', $username) ."'" : ''; + $where_sql .= ( $email ) ? " AND user_email LIKE '" . str_replace('*', '%', $email) ."' " : ''; + $where_sql .= ( $joined ) ? " AND user_regdate " . $key_match[$joined_select] . " " . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : ''; + $where_sql .= ( $count ) ? " AND user_posts " . $key_match[$count_select] . " $count " : ''; + $where_sql .= ( $active ) ? " AND user_lastvisit " . $key_match[$active_select] . " " . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : ''; + } + + $sql = "SELECT username, user_id FROM " . USERS_TABLE . " + WHERE user_id <> " . ANONYMOUS . " + $where_sql"; + $result = $db->sql_query($sql); + + $where_sql = ''; + $user_ids = array(); + $usernames = array(); + if ( $row = $db->sql_fetchrow($result) ) + { + do + { + $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $row['user_id']; + $user_ids[] = $row['user_id']; + $usernames[] = $row['username']; + } + while ( $row = $db->sql_fetchrow($result) ); + + $where_sql = " AND user_id IN ($where_sql)"; + } + $db->sql_freeresult($result); + + if ( $where_sql != '' ) + { + $sql = ''; + if ( !empty($HTTP_POST_VARS['prune']) ) + { + if ( !empty($HTTP_POST_VARS['deleteposts']) ) + { + // + // Call unified post deletion routine? + // + } + else + { + for($i = 0; $i < sizeof($user_ids); $i++) + { + $sql = "UPDATE " . POSTS_TABLE . " + SET poster_id = " . ANONYMOUS . ", post_username = '" . $usernames[$i] . "' + WHERE user_id = " . $userids[$i]; +// $db->sql_query($sql); + } + } + + unset($user_ids); + unset($usernames); + + $sql = "DELETE FROM " . USERS_TABLE; + } + else if ( !empty($HTTP_POST_VARS['deactivate']) ) + { + $sql = "UPDATE " . USERS_TABLE . " SET user_active = 0"; + } + $sql .= " WHERE user_id <> " . ANONYMOUS . " + $where_sql"; +// $db->sql_query($sql); + } + + message_die(MESSAGE, $lang['Success_user_prune']); + } +} + +// +// +// +$find_count = array('lt' => $lang['Less_than'], 'eq' => $lang['Equal_to'], 'gt' => $lang['More_than']); +$s_find_count = ''; +foreach ( $find_count as $key => $value ) +{ + $selected = ( $key == 'eq' ) ? ' selected="selected"' : ''; + $s_find_count .= ''; +} + +$find_time = array('lt' => $lang['Before'], 'gt' => $lang['After']); +$s_find_join_time = ''; +foreach ( $find_time as $key => $value ) +{ + $s_find_join_time .= ''; +} +$s_find_active_time = ''; +foreach ( $find_time as $key => $value ) +{ + $s_find_active_time .= ''; +} + +// +// +// +page_header($lang['Prune_users']); + +?> + +

+ +

+ +
"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:
:
:
:
:
:
:
  
    ', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=650');return false;" />
+ + \ No newline at end of file diff --git a/phpBB/language/lang_english/lang_admin.php b/phpBB/language/lang_english/lang_admin.php index 35cfa86f1d..ec5e136e19 100644 --- a/phpBB/language/lang_english/lang_admin.php +++ b/phpBB/language/lang_english/lang_admin.php @@ -314,6 +314,21 @@ $lang['Pollcreate'] = 'Poll create'; $lang['Auth_updated'] = 'Permissions have been updated'; +// +// Prune users +// +$lang['Prune_users'] = 'Prune Users'; +$lang['Prune_users_explain'] = 'Here you can delete (or deactivate) users from you board. This can be done in a variety of ways; by post count, last activity, etc. Each of these criteria can be combined, i.e. you can prune users last active before 2002-01-01 with fewer than 10 posts. Alternatively you can enter a list of users directly into the text box, any criteria entered will be ignored. Take care with this facility! Once a user is deleted there is no way back.'; +$lang['Select_users_explain'] = 'If you want to prune specifc users rather than use the criteria above you can enter their usernames here, one per line. Use the find username facility if you wish.'; +$lang['Last_active_explain'] = 'Enter a date in yyyy-mm-dd format.'; +$lang['Joined_explain'] = 'Enter a date in yyyy-mm-dd format.'; + +$lang['Deactivate'] = 'Deactivate'; +$lang['Delete_user_posts'] = 'Delete pruned user posts'; +$lang['Delete_user_posts_explain'] = 'Setting this to yes will remove all posts made by the pruned users.'; + +$lang['Confirm_prune_users'] = 'Are you sure you wish to prune the selected users?'; +$lang['Success_user_prune'] = 'The selected users have been pruned successfully'; // // Banning