diff -r e3d7322305bf -r 5e1f1e916419 punbb/admin/users.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/punbb/admin/users.php Sat Apr 05 23:56:45 2008 -0400 @@ -0,0 +1,1138 @@ + $_ ) +{ + $$key =& $GLOBALS[$key]; +} + +($hook = get_hook('aus_start')) ? eval($hook) : null; + +if (!$pun_user['is_admmod']) + message($lang_common['No permission']); + +// Load the admin.php language file +require PUN_ROOT.'lang/'.$pun_user['language'].'/admin.php'; +$GLOBALS['lang_admin'] = $lang_admin; + + +// Show IP statistics for a certain user ID +if (isset($_GET['ip_stats'])) +{ + $ip_stats = intval($_GET['ip_stats']); + if ($ip_stats < 1) + message($lang_common['Bad request']); + + ($hook = get_hook('aus_ip_stats_selected')) ? eval($hook) : null; + + $query = array( + 'SELECT' => 'p.poster_ip, MAX(p.posted) AS last_used, COUNT(p.id) AS used_times', + 'FROM' => 'posts AS p', + 'WHERE' => 'p.poster_id='.$ip_stats, + 'GROUP BY' => 'p.poster_ip', + 'ORDER BY' => 'last_used DESC' + ); + + ($hook = get_hook('aus_qr_get_user_ips')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + $pun_page['num_users'] = $pun_db->num_rows($result); + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + array($lang_admin['Searches'], pun_link($pun_url['admin_users'])), + $lang_admin['User search results'] + ); + + ($hook = get_hook('aus_ip_stats_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE_SECTION', 'users'); + define('PUN_PAGE', 'admin-users'); + require PUN_ROOT.'header.php'; + +?> +
+ + + +
+

{ }

+
+ +
+
+

+
+
+ + + + + + + + + + + + +fetch_assoc($result)) + { + $pun_page['actions'] = ''.$lang_admin['Find more users'].''; + +?> + + + + + + + + +'."\n"; + +?> + +
'.$lang_admin['No posts by user'].'
+
+
+ +
+ 'DISTINCT p.poster_id, p.poster', + 'FROM' => 'posts AS p', + 'WHERE' => 'p.poster_ip=\''.$pun_db->escape($ip).'\'', + 'ORDER BY' => 'p.poster DESC' + ); + + ($hook = get_hook('aus_qr_get_users_matching_ip')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + $pun_page['num_users'] = $pun_db->num_rows($result); + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + array($lang_admin['Searches'], pun_link($pun_url['admin_users'])), + $lang_admin['User search results'] + ); + + ($hook = get_hook('aus_show_users_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE_SECTION', 'users'); + define('PUN_PAGE', 'admin-users'); + require PUN_ROOT.'header.php'; + +?> +
+ + + +
+

{ }

+
+ +
+
+

+
+
+ + + + + + + + + + + + + +num_rows($result); + if ($num_posts) + { + // Loop through users and print out some info + for ($i = 0; $i < $num_posts; ++$i) + { + list($poster_id, $poster) = $pun_db->fetch_row($result); + + $query = array( + 'SELECT' => 'u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title', + 'FROM' => 'users AS u', + 'JOINS' => array( + array( + 'INNER JOIN' => 'groups AS g', + 'ON' => 'g.g_id=u.group_id' + ) + ), + 'WHERE' => 'u.id>1 AND u.id='.$poster_id + ); + + ($hook = get_hook('aus_qr_get_user_details')) ? eval($hook) : null; + $result2 = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if ($user_data = $pun_db->fetch_assoc($result2)) + { + $pun_page['user_title'] = get_title($user_data); + $pun_page['actions'] = ''.$lang_admin['View IP stats'].''.$lang_admin['Show posts'].''; + +?> + + + + + + + + + + + + + + + + + +'."\n"; + +?> + +
'.htmlspecialchars($user_data['admin_note']).'' ?>
    
'.$lang_admin['Cannot find IP'].'
+', + '', + '' +); + +($hook = get_hook('aus_show_users_pre_moderation_buttons')) ? eval($hook) : null; + +?> +

+
+
+ +
+user_level < USER_LEVEL_ADMIN) + message($lang_common['No permission']); + + if (empty($_POST['users'])) + message($lang_admin['No users selected']); + + ($hook = get_hook('aus_delete_users_selected')) ? eval($hook) : null; + + if (!is_array($_POST['users'])) + $users = explode(',', $_POST['users']); + else + $users = array_keys($_POST['users']); + + $users = array_map('intval', $users); + + // We check to make sure there are no administrators in this list + $query = array( + 'SELECT' => '1', + 'FROM' => 'users AS u', + 'WHERE' => 'u.id IN ('.implode(',', $users).') AND u.group_id='.PUN_ADMIN + ); + + ($hook = get_hook('aus_qr_check_for_admins')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if ($pun_db->num_rows($result) > 0) + message($lang_admin['Delete admin message']); + + if (isset($_POST['delete_users_comply'])) + { + ($hook = get_hook('aus_delete_users_form_submitted')) ? eval($hook) : null; + + foreach ($users as $id) + { + // We don't want to delete the Guest user + if ($id > 1) + delete_user($id, true); + } + + pun_redirect(pun_link($pun_url['admin_users']), $lang_admin['Users deleted'].' '.$lang_admin['Redirect']); + } + + // Setup form + $pun_page['set_count'] = $pun_page['fld_count'] = 0; + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + array($lang_admin['Searches'], pun_link($pun_url['admin_users'])), + $lang_admin['Delete users'] + ); + + ($hook = get_hook('aus_delete_users_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE_SECTION', 'users'); + define('PUN_PAGE', 'admin-users'); + require PUN_ROOT.'header.php'; + +?> +
+ + + +
+

{ }

+
+ +
+
+

+
+
+

+
+
+ +
+ +
+ +
+
+
+ + +
+
+
+ +
+user_level < USER_LEVEL_ADMIN) + message($lang_common['No permission']); + + if (empty($_POST['users'])) + message($lang_admin['No users selected']); + + ($hook = get_hook('aus_ban_users_selected')) ? eval($hook) : null; + + if (!is_array($_POST['users'])) + $users = explode(',', $_POST['users']); + else + $users = array_keys($_POST['users']); + + $users = array_map('intval', $users); + + // We check to make sure there are no administrators in this list + $query = array( + 'SELECT' => '1', + 'FROM' => 'users AS u', + 'WHERE' => 'u.id IN ('.implode(',', $users).') AND u.group_id='.PUN_ADMIN + ); + + ($hook = get_hook('aus_qr_check_for_admins2')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if ($pun_db->num_rows($result) > 0) + message($lang_admin['Ban admin message']); + + if (isset($_POST['ban_users_comply'])) + { + $ban_message = trim($_POST['ban_message']); + $ban_expire = trim($_POST['ban_expire']); + + ($hook = get_hook('aus_ban_users_form_submitted')) ? eval($hook) : null; + + if ($ban_expire != '' && $ban_expire != 'Never') + { + $ban_expire = strtotime($ban_expire); + + if ($ban_expire == -1 || $ban_expire <= time()) + message($lang_admin['Invalid expire message']); + } + else + $ban_expire = 'NULL'; + + $ban_message = ($ban_message != '') ? '"'.$pun_db->escape($ban_message).'"' : 'NULL'; + + // Get the latest IPs for the posters and store them for a little later + $query = array( + 'SELECT' => 'p.poster_id, p.poster_ip', + 'FROM' => 'posts AS p', + 'WHERE' => 'p.poster_id IN ('.implode(',', $users).') AND p.poster_id>1', + 'GROUP BY' => 'p.poster_id', + 'ORDER BY' => 'p.posted DESC' + ); + + ($hook = get_hook('aus_qr_get_latest_user_ips')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + + $ips = array(); + while ($cur_post = $pun_db->fetch_assoc($result)) + $ips[$cur_post['poster_id']] = $cur_post['poster_ip']; + + // Get the rest of the data for the posters, merge in the IP information, create a ban + $query = array( + 'SELECT' => 'u.id, u.username, u.email, u.registration_ip', + 'FROM' => 'users AS u', + 'WHERE' => 'id IN ('.implode(',', $users).') AND id>1' + ); + + ($hook = get_hook('aus_qr_get_users')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + while ($cur_user = $pun_db->fetch_assoc($result)) + { + $ban_ip = isset($ips[$cur_user['id']]) ? $ips[$cur_user['id']] : $cur_user['registration_ip']; + + $query = array( + 'INSERT' => 'username, ip, email, message, expire, ban_creator', + 'INTO' => 'bans', + 'VALUES' => '\''.$pun_db->escape($cur_user['username']).'\', \''.$ban_ip.'\', \''.$pun_db->escape($cur_user['email']).'\', '.$ban_message.', '.$ban_expire.', '.$pun_user['id'] + ); + + ($hook = get_hook('aus_qr_add_ban')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + } + + // Regenerate the bans cache + require_once PUN_ROOT.'include/cache.php'; + generate_bans_cache(); + + pun_redirect(pun_link($pun_url['admin_users']), $lang_admin['Users banned'].' '.$lang_admin['Redirect']); + } + + // Setup form + $pun_page['set_count'] = $pun_page['fld_count'] = 0; + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + array($lang_admin['Searches'], pun_link($pun_url['admin_users'])), + $lang_admin['Ban users'] + ); + + ($hook = get_hook('aus_ban_users_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE_SECTION', 'users'); + define('PUN_PAGE', 'admin-users'); + require PUN_ROOT.'header.php'; + +?> +
+ + + +
+

{ }

+
+ +
+
+

+
+
+

+
+
+ +
+ +
+ +
+
+ +
+
+
+ +
+
+
+ +
+user_level < USER_LEVEL_ADMIN) + message($lang_common['No permission']); + + // User pressed the cancel button + if (isset($_POST['change_group_cancel'])) + pun_redirect(pun_link($pun_url['admin_users']), $lang_admin['Cancel redirect']); + + if (empty($_POST['users'])) + message($lang_admin['No users selected']); + + ($hook = get_hook('aus_change_group_selected')) ? eval($hook) : null; + + if (!is_array($_POST['users'])) + $users = explode(',', $_POST['users']); + else + $users = array_keys($_POST['users']); + + $users = array_map('intval', $users); + + if (isset($_POST['change_group_comply'])) + { + $move_to_group = intval($_POST['move_to_group']); + + ($hook = get_hook('aus_change_group_form_submitted')) ? eval($hook) : null; + + // We need some information on the group + $query = array( + 'SELECT' => 'g.g_moderator', + 'FROM' => 'groups AS g', + 'WHERE' => 'g.g_id='.$move_to_group + ); + + ($hook = get_hook('aus_qr_get_group_moderator_status')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if ($move_to_group == PUN_GUEST || !$pun_db->num_rows($result)) + message($lang_common['Bad request']); + + $group_is_mod = $pun_db->result($result); + + // Move users + $query = array( + 'UPDATE' => 'users', + 'SET' => 'group_id='.$move_to_group, + 'WHERE' => 'id IN ('.implode(',', $users).') AND id>1' + ); + + ($hook = get_hook('aus_qr_change_user_group')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + + if ($move_to_group != PUN_ADMIN && $group_is_mod == '0') + clean_forum_moderators(); + + pun_redirect(pun_link($pun_url['admin_users']), $lang_admin['User groups updated'].' '.$lang_admin['Redirect']); + } + + // Setup form + $pun_page['set_count'] = $pun_page['fld_count'] = 0; + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + array($lang_admin['Searches'], pun_link($pun_url['admin_users'])), + $lang_admin['Change group'] + ); + + ($hook = get_hook('aus_change_group_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE_SECTION', 'users'); + define('PUN_PAGE', 'admin-users'); + require PUN_ROOT.'header.php'; + +?> +
+ + + +
+

{ }

+
+ +
+
+

+
+
+ +
+ +
+ +
+
+
+ + +
+
+
+ +
+'.$last_post_after; + if ($last_post_before != '') + $conditions[] = 'u.last_post<'.$last_post_before; + if ($registered_after != '') + $conditions[] = 'u.registered>'.$registered_after; + if ($registered_before != '') + $conditions[] = 'u.registered<'.$registered_before; + + $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; + while (list($key, $input) = @each($form)) + { + if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note'))) + $conditions[] = 'u.'.$pun_db->escape($key).' '.$like_command.' \''.$pun_db->escape(str_replace('*', '%', $input)).'\''; + } + + if ($posts_greater != '') + $conditions[] = 'u.num_posts>'.$posts_greater; + if ($posts_less != '') + $conditions[] = 'u.num_posts<'.$posts_less; + + if ($user_group != 'all') + $conditions[] = 'u.group_id='.intval($user_group); + + if (empty($conditions)) + message($lang_admin['No search terms message']); + + + // Load the misc.php language file + require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php'; + + // Find any users matching the conditions + $query = array( + 'SELECT' => 'u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title', + 'FROM' => 'users AS u', + 'JOINS' => array( + array( + 'LEFT JOIN' => 'groups AS g', + 'ON' => 'g.g_id=u.group_id' + ) + ), + 'WHERE' => 'u.id>1 AND '.implode(' AND ', $conditions), + 'ORDER BY' => $pun_db->escape($order_by).' '.$pun_db->escape($direction) + ); + + ($hook = get_hook('aus_qr_find_users')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + $pun_page['num_users'] = $pun_db->num_rows($result); + + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + array($lang_admin['Searches'], pun_link($pun_url['admin_users'])), + $lang_admin['User search results'] + ); + + ($hook = get_hook('aus_find_user_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE_SECTION', 'users'); + define('PUN_PAGE', 'admin-users'); + require PUN_ROOT.'header.php'; + +?> +
+ + + +
+

{ }

+
+ +
+
+

+
+
+ + + + + + + + + + + + + +fetch_assoc($result)) + { + $user_title = get_title($user_data); + + // This script is a special case in that we want to display "Not verified" for non-verified users + if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned']) + $user_title = ''.$lang_admin['Not verified'].''; + + $pun_page['actions'] = ''.$lang_admin['View IP stats'].''.$lang_admin['Show posts'].''; + +?> + + + + + + + + +'."\n"; + +?> + +
'.htmlspecialchars($user_data['username']).'' ?> '.htmlspecialchars($user_data['admin_note']).'' ?>
'.$lang_admin['No match'].'
+', + '', + '' +); + +($hook = get_hook('aus_find_user_pre_moderation_buttons')) ? eval($hook) : null; + +?> +

+ +

+
+
+
+ +
+ + + +
+

{ }

+
+ +
+
+

+
+
+ + +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+
+ +
+
+
+ + +
+
+

+
+
+ +
+ +
+ +
+ +
+
+ +
+
+
+ +
+