diff options
Diffstat (limited to 'phpBB/admin/admin_prune_users.php')
-rw-r--r-- | phpBB/admin/admin_prune_users.php | 96 |
1 files changed, 40 insertions, 56 deletions
diff --git a/phpBB/admin/admin_prune_users.php b/phpBB/admin/admin_prune_users.php index 7bd0e59160..8d2b57b418 100644 --- a/phpBB/admin/admin_prune_users.php +++ b/phpBB/admin/admin_prune_users.php @@ -19,61 +19,45 @@ * ***************************************************************************/ -if ( !empty($setmodules) ) +if (!empty($setmodules)) { - if ( !$auth->acl_get('a_user') ) + if (!$auth->acl_get('a_userdel')) { return; } - $filename = basename(__FILE__); - $module['Users']['Prune_users'] = $filename . $SID; + $module['Users']['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_user') ) +if (!$auth->acl_get('a_userdel')) { - return; + trigger_error($user->lang['NO_ADMIN']); } -// // Set mode -// -if( isset( $_POST['mode'] ) || isset( $_GET['mode'] ) ) -{ - $mode = ( isset( $_POST['mode']) ) ? $_POST['mode'] : $_GET['mode']; -} -else -{ - $mode = ''; -} +$mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : ''; -// -// -// -if ( isset($_POST['prune']) ) +// Do prune +if (isset($_POST['prune'])) { - if ( empty($_POST['confirm']) ) + if (empty($_POST['confirm'])) { $values = array('prune', 'deactivate', 'delete', 'users', 'username', 'email', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'deleteposts'); $l_message = '<form method="post" action="admin_prune_users.' . $phpEx . $SID . '">' . $user->lang['Confirm_prune_users'] . '<br /><br /><input class="liteoption" type="submit" name="confirm" value="' . $user->lang['Yes'] . '" /> <input class="liteoption" type="submit" name="cancel" value="' . $user->lang['No'] . '" />'; - foreach ( $values as $field ) + foreach ($values as $field) { - $l_message .= ( !empty($_POST[$field]) ) ? '<input type="hidden" name="' . $field . '" value="' . urlencode($_POST[$field]) . '" />' : ''; + $l_message .= (!empty($_POST[$field])) ? '<input type="hidden" name="' . $field . '" value="' . urlencode($_POST[$field]) . '" />' : ''; } $l_message .= '</form>'; @@ -92,40 +76,40 @@ if ( isset($_POST['prune']) ) page_footer(); } - else if ( isset($_POST['confirm']) ) + else if (isset($_POST['confirm'])) { - if ( !empty($_POST['users']) ) + if (!empty($_POST['users'])) { $users = explode("\n", urldecode($_POST['users'])); $where_sql = ''; - foreach ( $users as $username ) + foreach ($users as $username) { - $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . '\'' . trim($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']) : ''; + $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']) : ''; + $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])) : ''; + $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 . " @@ -136,26 +120,26 @@ if ( isset($_POST['prune']) ) $where_sql = ''; $user_ids = array(); $usernames = array(); - if ( $row = $db->sql_fetchrow($result) ) + if ($row = $db->sql_fetchrow($result)) { do { - $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $row['user_id']; + $where_sql .= (($where_sql != '') ? ', ' : '') . $row['user_id']; $user_ids[] = $row['user_id']; $usernames[] = $row['username']; } - while ( $row = $db->sql_fetchrow($result) ); + while ($row = $db->sql_fetchrow($result)); $where_sql = " AND user_id IN ($where_sql)"; } $db->sql_freeresult($result); - if ( $where_sql != '' ) + if ($where_sql != '') { $sql = ''; - if ( !empty($_POST['delete']) ) + if (!empty($_POST['delete'])) { - if ( !empty($_POST['deleteposts']) ) + if (!empty($_POST['deleteposts'])) { $l_admin_log = 'log_prune_user_del_del'; @@ -178,7 +162,7 @@ if ( isset($_POST['prune']) ) $sql = "DELETE FROM " . USERS_TABLE; } - else if ( !empty($_POST['deactivate']) ) + else if (!empty($_POST['deactivate'])) { $l_admin_log = 'log_prune_user_deac'; @@ -203,20 +187,20 @@ if ( isset($_POST['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 ) +foreach ($find_count as $key => $value) { - $selected = ( $key == 'eq' ) ? ' selected="selected"' : ''; + $selected = ($key == 'eq') ? ' selected="selected"' : ''; $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $find_time = array('lt' => $user->lang['Before'], 'gt' => $user->lang['After']); $s_find_join_time = ''; -foreach ( $find_time as $key => $value ) +foreach ($find_time as $key => $value) { $s_find_join_time .= '<option value="' . $key . '">' . $value . '</option>'; } $s_find_active_time = ''; -foreach ( $find_time as $key => $value ) +foreach ($find_time as $key => $value) { $s_find_active_time .= '<option value="' . $key . '">' . $value . '</option>'; } @@ -237,7 +221,7 @@ page_header($user->lang['Prune_users']); <th colspan="2"><?php echo $user->lang['Prune_users']; ?></th> </tr> <tr> - <td class="row1"><?php echo $user->lang['Username']; ?>: </td> + <td class="row1"><?php echo $user->lang['USERNAME']; ?>: </td> <td class="row2"><input class="post" type="text" name="username" /></td> </tr> <tr> |