acl_get('a_userdel')) { return; } $module['USER']['PRUNE_USERS'] = basename(__FILE__) . $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 (!$auth->acl_get('a_userdel')) { trigger_error($user->lang['NO_ADMIN']); } // Set mode $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : ''; // Do prune if (isset($_POST['prune'])) { if (empty($_POST['confirm'])) { $values = array('prune', 'deactivate', 'delete', 'users', 'username', 'email', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'deleteposts'); $l_message = '
' . $user->lang['Confirm_prune_users'] . '

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

lang['PRUNE_USERS']; ?>

lang['PRUNE_USERS_EXPLAIN']; ?>

lang['CONFIRM'], $l_message, false); page_footer(); } else if (isset($_POST['confirm'])) { if (!empty($_POST['users'])) { $users = explode("\n", urldecode($_POST['users'])); $where_sql = ''; foreach ($users as $username) { $where_sql .= (($where_sql != '') ? ', ' : '') . '\'' . trim($username) . '\''; } $where_sql = " AND username IN ($where_sql)"; } else { $username = (!empty($_POST['username'])) ? urldecode($_POST['username']) : ''; $email = (!empty($_POST['email'])) ? urldecode($_POST['email']) : ''; $joined_select = (!empty($_POST['joined_select'])) ? $_POST['joined_select'] : 'lt'; $active_select = (!empty($_POST['active_select'])) ? $_POST['active_select'] :'lt'; $count_select = (!empty($_POST['count_select'])) ? $_POST['count_select'] : 'eq'; $joined = (!empty($_POST['joined'])) ? explode('-', $_POST['joined']) : array(); $active = (!empty($_POST['active'])) ? explode('-', $_POST['active']) :array(); $count = (!empty($_POST['count'])) ? intval($_POST['count']) : ''; $key_match = array('lt' => '<', '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($_POST['delete'])) { if (!empty($_POST['deleteposts'])) { $l_admin_log = 'log_prune_user_del_del'; // // Call unified post deletion routine? // } else { $l_admin_log = 'log_prune_user_del_anon'; 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); } } $sql = "DELETE FROM " . USERS_TABLE; } else if (!empty($_POST['deactivate'])) { $l_admin_log = 'log_prune_user_deac'; $sql = "UPDATE " . USERS_TABLE . " SET user_active = 0"; } $sql .= " WHERE user_id <> " . ANONYMOUS . " $where_sql"; // $db->sql_query($sql); add_log('admin', $l_admin_log, implode(', ', $usernames)); unset($user_ids); unset($usernames); } message_die(MESSAGE, $user->lang['Success_user_prune']); } } // // // $find_count = array('lt' => $user->lang['Less_than'], 'eq' => $user->lang['Equal_to'], 'gt' => $user->lang['More_than']); $s_find_count = ''; foreach ($find_count as $key => $value) { $selected = ($key == 'eq') ? ' selected="selected"' : ''; $s_find_count .= ''; } $find_time = array('lt' => $user->lang['Before'], 'gt' => $user->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($user->lang['Prune_users']); ?>

lang['Prune_users']; ?>

lang['Prune_users_explain']; ?>

">
lang['Prune_users']; ?>
lang['USERNAME']; ?>:
lang['Email']; ?>:
lang['Joined']; ?>:
lang['Joined_explain']; ?>
lang['Last_active']; ?>:
lang['Last_active_explain']; ?>
lang['Posts']; ?>:
lang['Prune_users']; ?>:
lang['Select_users_explain']; ?>
lang['Delete_user_posts']; ?>:
lang['Delete_user_posts_explain']; ?>
lang['Yes']; ?>    lang['No']; ?>
    ', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=650');return false;" />