punbb/admin/users.php
changeset 6 5e1f1e916419
child 7 98bbc533541c
equal deleted inserted replaced
5:e3d7322305bf 6:5e1f1e916419
       
     1 <?php
       
     2 /***********************************************************************
       
     3 
       
     4   Copyright (C) 2002-2008  PunBB.org
       
     5 
       
     6   This file is part of PunBB.
       
     7 
       
     8   PunBB is free software; you can redistribute it and/or modify it
       
     9   under the terms of the GNU General Public License as published
       
    10   by the Free Software Foundation; either version 2 of the License,
       
    11   or (at your option) any later version.
       
    12 
       
    13   PunBB is distributed in the hope that it will be useful, but
       
    14   WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16   GNU General Public License for more details.
       
    17 
       
    18   You should have received a copy of the GNU General Public License
       
    19   along with this program; if not, write to the Free Software
       
    20   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
       
    21   MA  02111-1307  USA
       
    22 
       
    23 ************************************************************************/
       
    24 
       
    25 
       
    26 // if (!defined('PUN_ROOT'))
       
    27 // 	define('PUN_ROOT', '../');
       
    28 // require PUN_ROOT.'include/common.php';
       
    29 require PUN_ROOT.'include/common_admin.php';
       
    30 
       
    31 // import globals (I really hope this isn't dangerous)
       
    32 foreach ( $GLOBALS as $key => $_ )
       
    33 {
       
    34   $$key =& $GLOBALS[$key];
       
    35 }
       
    36 
       
    37 ($hook = get_hook('aus_start')) ? eval($hook) : null;
       
    38 
       
    39 if (!$pun_user['is_admmod'])
       
    40 	message($lang_common['No permission']);
       
    41 
       
    42 // Load the admin.php language file
       
    43 require PUN_ROOT.'lang/'.$pun_user['language'].'/admin.php';
       
    44 $GLOBALS['lang_admin'] = $lang_admin;
       
    45 
       
    46 
       
    47 // Show IP statistics for a certain user ID
       
    48 if (isset($_GET['ip_stats']))
       
    49 {
       
    50 	$ip_stats = intval($_GET['ip_stats']);
       
    51 	if ($ip_stats < 1)
       
    52 		message($lang_common['Bad request']);
       
    53 
       
    54 	($hook = get_hook('aus_ip_stats_selected')) ? eval($hook) : null;
       
    55 
       
    56 	$query = array(
       
    57 		'SELECT'	=> 'p.poster_ip, MAX(p.posted) AS last_used, COUNT(p.id) AS used_times',
       
    58 		'FROM'		=> 'posts AS p',
       
    59 		'WHERE'		=> 'p.poster_id='.$ip_stats,
       
    60 		'GROUP BY'	=> 'p.poster_ip',
       
    61 		'ORDER BY'	=> 'last_used DESC'
       
    62 	);
       
    63 
       
    64 	($hook = get_hook('aus_qr_get_user_ips')) ? eval($hook) : null;
       
    65 	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
    66 	$pun_page['num_users'] = $pun_db->num_rows($result);
       
    67 
       
    68 	// Setup breadcrumbs
       
    69 	$pun_page['crumbs'] = array(
       
    70 		array($pun_config['o_board_title'], pun_link($pun_url['index'])),
       
    71 		array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])),
       
    72 		array($lang_admin['Searches'], pun_link($pun_url['admin_users'])),
       
    73 		$lang_admin['User search results']
       
    74 	);
       
    75 
       
    76 	($hook = get_hook('aus_ip_stats_pre_header_load')) ? eval($hook) : null;
       
    77 
       
    78 	define('PUN_PAGE_SECTION', 'users');
       
    79 	define('PUN_PAGE', 'admin-users');
       
    80 	require PUN_ROOT.'header.php';
       
    81 
       
    82 ?>
       
    83 <div id="pun-main" class="main sectioned admin">
       
    84 
       
    85 <?php echo generate_admin_menu(); ?>
       
    86 
       
    87 	<div class="main-head">
       
    88 		<h1><span>{ <?php echo end($pun_page['crumbs']) ?> }</span></h1>
       
    89 	</div>
       
    90 
       
    91 	<div class="main-content frm">
       
    92 		<div class="frm-head">
       
    93 			<h2><span><?php printf($lang_admin['IP addresses found'], $pun_page['num_users']) ?></span></h2>
       
    94 		</div>
       
    95 		<div class="frm-form">
       
    96 			<table cellspacing="0">
       
    97 				<thead>
       
    98 					<tr>
       
    99 						<th class="tcl" scope="col"><?php echo $lang_admin['IP address'] ?></th>
       
   100 						<th class="tc2" scope="col"><?php echo $lang_admin['Last used'] ?></th>
       
   101 						<th class="tc3" scope="col"><?php echo $lang_admin['Times found'] ?></th>
       
   102 <?php ($hook = get_hook('aus_ip_stats_table_header_after_used_times')) ? eval($hook) : null; ?>
       
   103 						<th class="tcr" scope="col"><?php echo $lang_admin['Actions'] ?></th>
       
   104 <?php ($hook = get_hook('aus_ip_stats_table_header_after_actions')) ? eval($hook) : null; ?>
       
   105 					</tr>
       
   106 				</thead>
       
   107 				<tbody>
       
   108 <?php
       
   109 
       
   110 	if ($pun_page['num_users'])
       
   111 	{
       
   112 		while ($cur_ip = $pun_db->fetch_assoc($result))
       
   113 		{
       
   114 			$pun_page['actions'] = '<a href="'.pun_link($pun_url['admin_users']).'&show_users='.$cur_ip['poster_ip'].'">'.$lang_admin['Find more users'].'</a>';
       
   115 
       
   116 ?>
       
   117 					<tr>
       
   118 						<td class="tcl"><a href="<?php echo pun_link($pun_url['get_host'], $cur_ip['poster_ip']) ?>"><?php echo $cur_ip['poster_ip'] ?></a></td>
       
   119 						<td class="tc2"><?php echo format_time($cur_ip['last_used']) ?></td>
       
   120 						<td class="tc3"><?php echo $cur_ip['used_times'] ?></td>
       
   121 <?php ($hook = get_hook('aus_ip_stats_table_contents_after_used_times')) ? eval($hook) : null; ?>
       
   122 						<td class="tcr actions"><?php echo $pun_page['actions'] ?></td>
       
   123 <?php ($hook = get_hook('aus_ip_stats_table_contents_after_actions')) ? eval($hook) : null; ?>
       
   124 					</tr>
       
   125 <?php
       
   126 
       
   127 		}
       
   128 	}
       
   129 	else
       
   130 		echo "\t\t\t\t\t\t".'<tr><td class="tcl" colspan="4">'.$lang_admin['No posts by user'].'</td></tr>'."\n";
       
   131 
       
   132 ?>
       
   133 				</tbody>
       
   134 			</table>
       
   135 		</div>
       
   136 	</div>
       
   137 
       
   138 </div>
       
   139 <?php
       
   140 
       
   141 	require PUN_ROOT.'footer.php';
       
   142 }
       
   143 
       
   144 
       
   145 // Show users that have at one time posted with the specified IP address
       
   146 else if (isset($_GET['show_users']))
       
   147 {
       
   148 	$ip = $_GET['show_users'];
       
   149 
       
   150 	if (!@preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $ip))
       
   151 		message('The supplied IP address is not correctly formatted.');
       
   152 
       
   153 	($hook = get_hook('aus_show_users_selected')) ? eval($hook) : null;
       
   154 
       
   155 	// Load the misc.php language file
       
   156 	require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
       
   157 
       
   158 	$query = array(
       
   159 		'SELECT'	=> 'DISTINCT p.poster_id, p.poster',
       
   160 		'FROM'		=> 'posts AS p',
       
   161 		'WHERE'		=> 'p.poster_ip=\''.$pun_db->escape($ip).'\'',
       
   162 		'ORDER BY'	=> 'p.poster DESC'
       
   163 	);
       
   164 
       
   165 	($hook = get_hook('aus_qr_get_users_matching_ip')) ? eval($hook) : null;
       
   166 	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   167 	$pun_page['num_users'] = $pun_db->num_rows($result);
       
   168 
       
   169 	// Setup breadcrumbs
       
   170 	$pun_page['crumbs'] = array(
       
   171 		array($pun_config['o_board_title'], pun_link($pun_url['index'])),
       
   172 		array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])),
       
   173 		array($lang_admin['Searches'], pun_link($pun_url['admin_users'])),
       
   174 		$lang_admin['User search results']
       
   175 	);
       
   176 
       
   177 	($hook = get_hook('aus_show_users_pre_header_load')) ? eval($hook) : null;
       
   178 
       
   179 	define('PUN_PAGE_SECTION', 'users');
       
   180 	define('PUN_PAGE', 'admin-users');
       
   181 	require PUN_ROOT.'header.php';
       
   182 
       
   183 ?>
       
   184 <div id="pun-main" class="main sectioned admin">
       
   185 
       
   186 <?php echo generate_admin_menu(); ?>
       
   187 
       
   188 	<div class="main-head">
       
   189 		<h1><span>{ <?php echo end($pun_page['crumbs']) ?> }</span></h1>
       
   190 	</div>
       
   191 
       
   192 	<div class="main-content frm">
       
   193 		<div class="frm-head">
       
   194 			<h2><span><?php printf($lang_admin['Users found'], $pun_page['num_users']) ?></span></h2>
       
   195 		</div>
       
   196 		<form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_users']) ?>&amp;action=modify_users">
       
   197 			<div class="hidden">
       
   198 				<input type="hidden" name="csrf_token" value="<?php echo generate_form_token(pun_link($pun_url['admin_users']).'&action=modify_users') ?>" />
       
   199 			</div>
       
   200 			<table cellspacing="0">
       
   201 				<thead>
       
   202 					<tr>
       
   203 						<th class="tcl" scope="col"><?php echo $lang_admin['Username column'] ?></th>
       
   204 						<th class="tc2" scope="col"><?php echo $lang_admin['Title column'] ?></th>
       
   205 						<th class="tc3" scope="col"><?php echo $lang_admin['Posts'] ?></th>
       
   206 <?php ($hook = get_hook('aus_show_users_table_header_after_num_posts')) ? eval($hook) : null; ?>
       
   207 						<th class="tcr actions" scope="col"><?php echo $lang_admin['Actions'] ?></th>
       
   208 <?php ($hook = get_hook('aus_show_users_table_header_after_actions')) ? eval($hook) : null; if ($pun_user['g_id'] == PUN_ADMIN): ?>						<th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th>
       
   209 <?php endif; ?>					</tr>
       
   210 				</thead>
       
   211 				<tbody>
       
   212 <?php
       
   213 
       
   214 	$num_posts = $pun_db->num_rows($result);
       
   215 	if ($num_posts)
       
   216 	{
       
   217 		// Loop through users and print out some info
       
   218 		for ($i = 0; $i < $num_posts; ++$i)
       
   219 		{
       
   220 			list($poster_id, $poster) = $pun_db->fetch_row($result);
       
   221 
       
   222 			$query = array(
       
   223 				'SELECT'	=> 'u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title',
       
   224 				'FROM'		=> 'users AS u',
       
   225 				'JOINS'		=> array(
       
   226 					array(
       
   227 						'INNER JOIN'	=> 'groups AS g',
       
   228 						'ON'			=> 'g.g_id=u.group_id'
       
   229 					)
       
   230 				),
       
   231 				'WHERE'		=> 'u.id>1 AND u.id='.$poster_id
       
   232 			);
       
   233 
       
   234 			($hook = get_hook('aus_qr_get_user_details')) ? eval($hook) : null;
       
   235 			$result2 = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   236 			if ($user_data = $pun_db->fetch_assoc($result2))
       
   237 			{
       
   238 				$pun_page['user_title'] = get_title($user_data);
       
   239 				$pun_page['actions'] = '<span><a href="'.pun_link($pun_url['admin_users']).'&ip_stats='.$user_data['id'].'">'.$lang_admin['View IP stats'].'</a></span> <span><a href="'.pun_link($pun_url['search_user_posts'], $user_data['id']).'">'.$lang_admin['Show posts'].'</a></span>';
       
   240 
       
   241 ?>
       
   242 					<tr>
       
   243 						<td class="tcl"><strong><a href="<?php echo pun_link($pun_url['user'], $user_data['id']) ?>"><?php echo htmlspecialchars($user_data['username']) ?></a></strong> <span class="usermail"><a href="mailto:<?php echo $user_data['email'] ?>"><?php echo $user_data['email'] ?></a></span> <?php if ($user_data['admin_note'] != '') echo '<span class="usernote">'.htmlspecialchars($user_data['admin_note']).'</span>' ?></td>
       
   244 						<td class="tc2"><?php echo $pun_page['user_title'] ?></td>
       
   245 						<td class="tc3"><?php echo $user_data['num_posts'] ?></td>
       
   246 <?php ($hook = get_hook('aus_show_users_table_contents_after_num_posts')) ? eval($hook) : null; ?>
       
   247 						<td class="tcr actions"><?php echo $pun_page['actions'] ?></td>
       
   248 <?php ($hook = get_hook('aus_show_users_table_contents_after_actions')) ? eval($hook) : null; if ($pun_user['g_id'] == PUN_ADMIN): ?>						<td class="tcmod"><input type="checkbox" name="users[<?php echo $user_data['id'] ?>]" value="1" /></td>
       
   249 <?php endif; ?>					</tr>
       
   250 <?php
       
   251 
       
   252 			}
       
   253 			else
       
   254 			{
       
   255 
       
   256 ?>
       
   257 					<tr>
       
   258 						<td class="tcl"><?php echo htmlspecialchars($poster) ?></td>
       
   259 						<td class="tc2"><?php echo $lang_admin['Guest'] ?></td>
       
   260 						<td class="tc3">&#160;</td>
       
   261 <?php ($hook = get_hook('aus_show_users_table_contents_after_num_posts_guest')) ? eval($hook) : null; ?>
       
   262 						<td class="tcr">&#160;</td>
       
   263 <?php ($hook = get_hook('aus_show_users_table_contents_after_actions_guest')) ? eval($hook) : null; if ($pun_user['g_id'] == PUN_ADMIN): ?>						<td class="tcmod">&#160;</td>
       
   264 <?php endif; ?>					</tr>
       
   265 <?php
       
   266 
       
   267 			}
       
   268 		}
       
   269 	}
       
   270 	else
       
   271 		echo "\t\t\t\t\t".'<tr><td class="tcl" colspan="'.(($pun_user['g_id'] == PUN_ADMIN) ? '5' : '4').'">'.$lang_admin['Cannot find IP'].'</td></tr>'."\n";
       
   272 
       
   273 ?>
       
   274 				</tbody>
       
   275 			</table>
       
   276 <?php
       
   277 
       
   278 // Setup control buttons
       
   279 $pun_page['main_submit'] = array(
       
   280 	'<span class="submit"><input type="submit" name="ban_users" value="'.$lang_admin['Ban'].'" /></span>',
       
   281 	'<span class="submit"><input type="submit" name="delete_users" value="'.$lang_admin['Delete'].'" /></span>',
       
   282 	'<span class="submit"><input type="submit" name="change_group" value="'.$lang_admin['Change group'].'" /></span>'
       
   283 );
       
   284 
       
   285 ($hook = get_hook('aus_show_users_pre_moderation_buttons')) ? eval($hook) : null;
       
   286 
       
   287 ?>
       
   288 			<p class="submitting"><?php echo implode("\n\t\t\t", $pun_page['main_submit'])."\n" ?></p>
       
   289 		</form>
       
   290 	</div>
       
   291 
       
   292 </div>
       
   293 <?php
       
   294 
       
   295 	require PUN_ROOT.'footer.php';
       
   296 }
       
   297 
       
   298 
       
   299 else if (isset($_POST['delete_users']) || isset($_POST['delete_users_comply']) || isset($_POST['delete_users_cancel']))
       
   300 {
       
   301 	// User pressed the cancel button
       
   302 	if (isset($_POST['delete_users_cancel']))
       
   303 		pun_redirect(pun_link($pun_url['admin_users']), $lang_common['Cancel redirect']);
       
   304 
       
   305 	if ($session->user_level < USER_LEVEL_ADMIN)
       
   306 		message($lang_common['No permission']);
       
   307 
       
   308 	if (empty($_POST['users']))
       
   309 		message($lang_admin['No users selected']);
       
   310 
       
   311 	($hook = get_hook('aus_delete_users_selected')) ? eval($hook) : null;
       
   312 
       
   313 	if (!is_array($_POST['users']))
       
   314 		$users = explode(',', $_POST['users']);
       
   315 	else
       
   316 		$users = array_keys($_POST['users']);
       
   317 
       
   318 	$users = array_map('intval', $users);
       
   319 
       
   320 	// We check to make sure there are no administrators in this list
       
   321 	$query = array(
       
   322 		'SELECT'	=> '1',
       
   323 		'FROM'		=> 'users AS u',
       
   324 		'WHERE'		=> 'u.id IN ('.implode(',', $users).') AND u.group_id='.PUN_ADMIN
       
   325 	);
       
   326 
       
   327 	($hook = get_hook('aus_qr_check_for_admins')) ? eval($hook) : null;
       
   328 	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   329 	if ($pun_db->num_rows($result) > 0)
       
   330 		message($lang_admin['Delete admin message']);
       
   331 
       
   332 	if (isset($_POST['delete_users_comply']))
       
   333 	{
       
   334 		($hook = get_hook('aus_delete_users_form_submitted')) ? eval($hook) : null;
       
   335 
       
   336 		foreach ($users as $id)
       
   337 		{
       
   338 			// We don't want to delete the Guest user
       
   339 			if ($id > 1)
       
   340 				delete_user($id, true);
       
   341 		}
       
   342 
       
   343 		pun_redirect(pun_link($pun_url['admin_users']), $lang_admin['Users deleted'].' '.$lang_admin['Redirect']);
       
   344 	}
       
   345 
       
   346 	// Setup form
       
   347 	$pun_page['set_count'] = $pun_page['fld_count'] = 0;
       
   348 
       
   349 	// Setup breadcrumbs
       
   350 	$pun_page['crumbs'] = array(
       
   351 		array($pun_config['o_board_title'], pun_link($pun_url['index'])),
       
   352 		array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])),
       
   353 		array($lang_admin['Searches'], pun_link($pun_url['admin_users'])),
       
   354 		$lang_admin['Delete users']
       
   355 	);
       
   356 
       
   357 	($hook = get_hook('aus_delete_users_pre_header_load')) ? eval($hook) : null;
       
   358 
       
   359 	define('PUN_PAGE_SECTION', 'users');
       
   360 	define('PUN_PAGE', 'admin-users');
       
   361 	require PUN_ROOT.'header.php';
       
   362 
       
   363 ?>
       
   364 <div id="pun-main" class="main sectioned admin">
       
   365 
       
   366 <?php echo generate_admin_menu(); ?>
       
   367 
       
   368 	<div class="main-head">
       
   369 		<h1><span>{ <?php echo end($pun_page['crumbs']) ?> }</span></h1>
       
   370 	</div>
       
   371 
       
   372 	<div class="main-content frm">
       
   373 		<div class="frm-head">
       
   374 			<h2><span><?php echo $lang_admin['Confirm delete'] ?></span></h2>
       
   375 		</div>
       
   376 		<div class="frm-info">
       
   377 			<p class="warn"><?php echo $lang_admin['Delete warning'] ?></p>
       
   378 		</div>
       
   379 		<form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_users']) ?>&amp;action=modify_users">
       
   380 			<div class="hidden">
       
   381 				<input type="hidden" name="csrf_token" value="<?php echo generate_form_token(pun_link($pun_url['admin_users']).'&action=modify_users') ?>" />
       
   382 				<input type="hidden" name="users" value="<?php echo implode(',', $users) ?>" />
       
   383 			</div>
       
   384 			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
       
   385 				<legend class="frm-legend"><span><?php echo $lang_admin['Delete posts legend'] ?></span></legend>
       
   386 				<div class="radbox checkbox">
       
   387 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>"><span class="fld-label"><?php echo $lang_admin['Delete posts'] ?></span><br /><input type="checkbox" id="fld<?php echo ++$fld_count ?>" name="delete_posts" value="1" checked="checked" /> <?php echo $lang_admin['Delete posts label'] ?></label>
       
   388 				</div>
       
   389 			</fieldset>
       
   390 			<div class="frm-buttons">
       
   391 				<span class="submit"><input type="submit" name="delete_users_comply" value="<?php echo $lang_admin['Delete'] ?>" /></span>
       
   392 				<span class="cancel"><input type="submit" name="delete_users_cancel" value="<?php echo $lang_common['Cancel'] ?>" /></span>
       
   393 			</div>
       
   394 		</form>
       
   395 	</div>
       
   396 
       
   397 </div>
       
   398 <?php
       
   399 
       
   400 	require PUN_ROOT.'footer.php';
       
   401 }
       
   402 
       
   403 
       
   404 else if (isset($_POST['ban_users']) || isset($_POST['ban_users_comply']))
       
   405 {
       
   406 	if ($session->user_level < USER_LEVEL_ADMIN)
       
   407 		message($lang_common['No permission']);
       
   408 
       
   409 	if (empty($_POST['users']))
       
   410 		message($lang_admin['No users selected']);
       
   411 
       
   412 	($hook = get_hook('aus_ban_users_selected')) ? eval($hook) : null;
       
   413 
       
   414 	if (!is_array($_POST['users']))
       
   415 		$users = explode(',', $_POST['users']);
       
   416 	else
       
   417 		$users = array_keys($_POST['users']);
       
   418 
       
   419 	$users = array_map('intval', $users);
       
   420 
       
   421 	// We check to make sure there are no administrators in this list
       
   422 	$query = array(
       
   423 		'SELECT'	=> '1',
       
   424 		'FROM'		=> 'users AS u',
       
   425 		'WHERE'		=> 'u.id IN ('.implode(',', $users).') AND u.group_id='.PUN_ADMIN
       
   426 	);
       
   427 
       
   428 	($hook = get_hook('aus_qr_check_for_admins2')) ? eval($hook) : null;
       
   429 	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   430 	if ($pun_db->num_rows($result) > 0)
       
   431 		message($lang_admin['Ban admin message']);
       
   432 
       
   433 	if (isset($_POST['ban_users_comply']))
       
   434 	{
       
   435 		$ban_message = trim($_POST['ban_message']);
       
   436 		$ban_expire = trim($_POST['ban_expire']);
       
   437 
       
   438 		($hook = get_hook('aus_ban_users_form_submitted')) ? eval($hook) : null;
       
   439 
       
   440 		if ($ban_expire != '' && $ban_expire != 'Never')
       
   441 		{
       
   442 			$ban_expire = strtotime($ban_expire);
       
   443 
       
   444 			if ($ban_expire == -1 || $ban_expire <= time())
       
   445 				message($lang_admin['Invalid expire message']);
       
   446 		}
       
   447 		else
       
   448 			$ban_expire = 'NULL';
       
   449 
       
   450 		$ban_message = ($ban_message != '') ? '"'.$pun_db->escape($ban_message).'"' : 'NULL';
       
   451 
       
   452 		// Get the latest IPs for the posters and store them for a little later
       
   453 		$query = array(
       
   454 			'SELECT'	=> 'p.poster_id, p.poster_ip',
       
   455 			'FROM'		=> 'posts AS p',
       
   456 			'WHERE'		=> 'p.poster_id IN ('.implode(',', $users).') AND p.poster_id>1',
       
   457 			'GROUP BY'	=> 'p.poster_id',
       
   458 			'ORDER BY'	=> 'p.posted DESC'
       
   459 		);
       
   460 
       
   461 		($hook = get_hook('aus_qr_get_latest_user_ips')) ? eval($hook) : null;
       
   462 		$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   463 
       
   464 		$ips = array();
       
   465 		while ($cur_post = $pun_db->fetch_assoc($result))
       
   466 			$ips[$cur_post['poster_id']] = $cur_post['poster_ip'];
       
   467 
       
   468 		// Get the rest of the data for the posters, merge in the IP information, create a ban
       
   469 		$query = array(
       
   470 			'SELECT'	=> 'u.id, u.username, u.email, u.registration_ip',
       
   471 			'FROM'		=> 'users AS u',
       
   472 			'WHERE'		=> 'id IN ('.implode(',', $users).') AND id>1'
       
   473 		);
       
   474 
       
   475 		($hook = get_hook('aus_qr_get_users')) ? eval($hook) : null;
       
   476 		$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   477 		while ($cur_user = $pun_db->fetch_assoc($result))
       
   478 		{
       
   479 			$ban_ip = isset($ips[$cur_user['id']]) ? $ips[$cur_user['id']] : $cur_user['registration_ip'];
       
   480 
       
   481 			$query = array(
       
   482 				'INSERT'	=> 'username, ip, email, message, expire, ban_creator',
       
   483 				'INTO'		=> 'bans',
       
   484 				'VALUES'	=> '\''.$pun_db->escape($cur_user['username']).'\', \''.$ban_ip.'\', \''.$pun_db->escape($cur_user['email']).'\', '.$ban_message.', '.$ban_expire.', '.$pun_user['id']
       
   485 			);
       
   486 
       
   487 			($hook = get_hook('aus_qr_add_ban')) ? eval($hook) : null;
       
   488 			$pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   489 		}
       
   490 
       
   491 		// Regenerate the bans cache
       
   492 		require_once PUN_ROOT.'include/cache.php';
       
   493 		generate_bans_cache();
       
   494 
       
   495 		pun_redirect(pun_link($pun_url['admin_users']), $lang_admin['Users banned'].' '.$lang_admin['Redirect']);
       
   496 	}
       
   497 
       
   498 	// Setup form
       
   499 	$pun_page['set_count'] = $pun_page['fld_count'] = 0;
       
   500 
       
   501 	// Setup breadcrumbs
       
   502 	$pun_page['crumbs'] = array(
       
   503 		array($pun_config['o_board_title'], pun_link($pun_url['index'])),
       
   504 		array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])),
       
   505 		array($lang_admin['Searches'], pun_link($pun_url['admin_users'])),
       
   506 		$lang_admin['Ban users']
       
   507 	);
       
   508 
       
   509 	($hook = get_hook('aus_ban_users_pre_header_load')) ? eval($hook) : null;
       
   510 
       
   511 	define('PUN_PAGE_SECTION', 'users');
       
   512 	define('PUN_PAGE', 'admin-users');
       
   513 	require PUN_ROOT.'header.php';
       
   514 
       
   515 ?>
       
   516 <div id="pun-main" class="main sectioned admin">
       
   517 
       
   518 <?php echo generate_admin_menu(); ?>
       
   519 
       
   520 	<div class="main-head">
       
   521 		<h1><span>{ <?php echo end($pun_page['crumbs']) ?> }</span></h1>
       
   522 	</div>
       
   523 
       
   524 	<div class="main-content frm">
       
   525 		<div class="frm-head">
       
   526 			<h2><span><?php echo $lang_admin['Ban advanced heading'] ?></span></h2>
       
   527 		</div>
       
   528 		<div class="frm-info">
       
   529 			<p><?php echo $lang_admin['Mass ban info'] ?></p>
       
   530 		</div>
       
   531 		<form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_users']) ?>&amp;action=modify_users">
       
   532 			<div class="hidden">
       
   533 				<input type="hidden" name="csrf_token" value="<?php echo generate_form_token(pun_link($pun_url['admin_users']).'&action=modify_users') ?>" />
       
   534 				<input type="hidden" name="users" value="<?php echo implode(',', $users) ?>" />
       
   535 			</div>
       
   536 			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
       
   537 				<legend class="frm-legend"><span><?php echo $lang_admin['Ban settings legend'] ?></span></legend>
       
   538 				<div class="frm-fld text">
       
   539 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   540 						<span class="fld-label"><?php echo $lang_admin['Ban message'] ?></span><br />
       
   541 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="ban_message" size="50" maxlength="255" /></span>
       
   542 						<span class="fld-help"><?php echo $lang_admin['Ban message info'] ?></span>
       
   543 					</label>
       
   544 				</div>
       
   545 				<div class="frm-fld text">
       
   546 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   547 						<span class="fld-label"><?php echo $lang_admin['Expire date'] ?></span><br />
       
   548 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="ban_expire" size="17" maxlength="10" /></span>
       
   549 						<span class="fld-help"><?php echo $lang_admin['Expire date info'] ?></span>
       
   550 					</label>
       
   551 				</div>
       
   552 			</fieldset>
       
   553 			<div class="frm-buttons">
       
   554 				<span class="submit"><input type="submit" class="button" name="ban_users_comply" value="<?php echo $lang_admin['Ban'] ?>" /></span>
       
   555 			</div>
       
   556 		</form>
       
   557 	</div>
       
   558 
       
   559 </div>
       
   560 <?php
       
   561 
       
   562 	require PUN_ROOT.'footer.php';
       
   563 }
       
   564 
       
   565 
       
   566 else if (isset($_POST['change_group']) || isset($_POST['change_group_comply']) || isset($_POST['change_group_cancel']))
       
   567 {
       
   568 	if ($session->user_level < USER_LEVEL_ADMIN)
       
   569 		message($lang_common['No permission']);
       
   570 
       
   571 	// User pressed the cancel button
       
   572 	if (isset($_POST['change_group_cancel']))
       
   573 		pun_redirect(pun_link($pun_url['admin_users']), $lang_admin['Cancel redirect']);
       
   574 
       
   575 	if (empty($_POST['users']))
       
   576 		message($lang_admin['No users selected']);
       
   577 
       
   578 	($hook = get_hook('aus_change_group_selected')) ? eval($hook) : null;
       
   579 
       
   580 	if (!is_array($_POST['users']))
       
   581 		$users = explode(',', $_POST['users']);
       
   582 	else
       
   583 		$users = array_keys($_POST['users']);
       
   584 
       
   585 	$users = array_map('intval', $users);
       
   586 
       
   587 	if (isset($_POST['change_group_comply']))
       
   588 	{
       
   589 		$move_to_group = intval($_POST['move_to_group']);
       
   590 
       
   591 		($hook = get_hook('aus_change_group_form_submitted')) ? eval($hook) : null;
       
   592 
       
   593 		// We need some information on the group
       
   594 		$query = array(
       
   595 			'SELECT'	=> 'g.g_moderator',
       
   596 			'FROM'		=> 'groups AS g',
       
   597 			'WHERE'		=> 'g.g_id='.$move_to_group
       
   598 		);
       
   599 
       
   600 		($hook = get_hook('aus_qr_get_group_moderator_status')) ? eval($hook) : null;
       
   601 		$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   602 		if ($move_to_group == PUN_GUEST || !$pun_db->num_rows($result))
       
   603 			message($lang_common['Bad request']);
       
   604 
       
   605 		$group_is_mod = $pun_db->result($result);
       
   606 
       
   607 		// Move users
       
   608 		$query = array(
       
   609 			'UPDATE'	=> 'users',
       
   610 			'SET'		=> 'group_id='.$move_to_group,
       
   611 			'WHERE'		=> 'id IN ('.implode(',', $users).') AND id>1'
       
   612 		);
       
   613 
       
   614 		($hook = get_hook('aus_qr_change_user_group')) ? eval($hook) : null;
       
   615 		$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   616 
       
   617 		if ($move_to_group != PUN_ADMIN && $group_is_mod == '0')
       
   618 			clean_forum_moderators();
       
   619 
       
   620 		pun_redirect(pun_link($pun_url['admin_users']), $lang_admin['User groups updated'].' '.$lang_admin['Redirect']);
       
   621 	}
       
   622 
       
   623 	// Setup form
       
   624 	$pun_page['set_count'] = $pun_page['fld_count'] = 0;
       
   625 
       
   626 	// Setup breadcrumbs
       
   627 	$pun_page['crumbs'] = array(
       
   628 		array($pun_config['o_board_title'], pun_link($pun_url['index'])),
       
   629 		array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])),
       
   630 		array($lang_admin['Searches'], pun_link($pun_url['admin_users'])),
       
   631 		$lang_admin['Change group']
       
   632 	);
       
   633 
       
   634 	($hook = get_hook('aus_change_group_pre_header_load')) ? eval($hook) : null;
       
   635 
       
   636 	define('PUN_PAGE_SECTION', 'users');
       
   637 	define('PUN_PAGE', 'admin-users');
       
   638 	require PUN_ROOT.'header.php';
       
   639 
       
   640 ?>
       
   641 <div id="pun-main" class="main sectioned admin">
       
   642 
       
   643 <?php echo generate_admin_menu(); ?>
       
   644 
       
   645 	<div class="main-head">
       
   646 		<h1><span>{ <?php echo end($pun_page['crumbs']) ?> }</span></h1>
       
   647 	</div>
       
   648 
       
   649 	<div class="main-content frm">
       
   650 		<div class="frm-head">
       
   651 			<h2><span><?php echo $lang_admin['Change group head'] ?></span></h2>
       
   652 		</div>
       
   653 		<form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_users']) ?>&amp;action=modify_users">
       
   654 			<div class="hidden">
       
   655 				<input type="hidden" name="csrf_token" value="<?php echo generate_form_token(pun_link($pun_url['admin_users']).'&action=modify_users') ?>" />
       
   656 				<input type="hidden" name="users" value="<?php echo implode(',', $users) ?>" />
       
   657 			</div>
       
   658 			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
       
   659 				<legend class="frm-legend"><span><?php echo $lang_admin['Move users legend'] ?></span></legend>
       
   660 				<div class="frm-fld select">
       
   661 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   662 						<span class="fld-label"><?php echo $lang_admin['Move users to'] ?></span><br />
       
   663 						<span class="fld-input"><select id="fld<?php echo $pun_page['fld_count'] ?>" name="move_to_group">
       
   664 <?php
       
   665 
       
   666 	$query = array(
       
   667 		'SELECT'	=> 'g.g_id, g.g_title',
       
   668 		'FROM'		=> 'groups AS g',
       
   669 		'WHERE'		=> 'g.g_id!='.PUN_GUEST,
       
   670 		'ORDER BY'	=> 'g.g_title'
       
   671 	);
       
   672 
       
   673 	($hook = get_hook('aus_qr_get_groups')) ? eval($hook) : null;
       
   674 	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   675 	while ($cur_group = $pun_db->fetch_assoc($result))
       
   676 	{
       
   677 		if ($cur_group['g_id'] == PUN_MEMBER)	// Pre-select the pre-defined Members group
       
   678 			echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.htmlspecialchars($cur_group['g_title']).'</option>'."\n";
       
   679 		else
       
   680 			echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.htmlspecialchars($cur_group['g_title']).'</option>'."\n";
       
   681 	}
       
   682 
       
   683 ?>
       
   684 						</select></span>
       
   685 					</label>
       
   686 				</div>
       
   687 			</fieldset>
       
   688 			<div class="frm-buttons">
       
   689 				<span class="submit"><input type="submit" name="change_group_comply" value="<?php echo $lang_admin['Change group'] ?>" /></span>
       
   690 				<span class="cancel"><input type="submit" name="change_group_cancel" value="<?php echo $lang_admin['Cancel'] ?>" /></span>
       
   691 			</div>
       
   692 		</form>
       
   693 	</div>
       
   694 
       
   695 </div>
       
   696 <?php
       
   697 
       
   698 	require PUN_ROOT.'footer.php';
       
   699 }
       
   700 
       
   701 
       
   702 else if (isset($_POST['find_user']))
       
   703 {
       
   704 	$form = $_POST['form'];
       
   705 	$form['username'] = $_POST['username'];
       
   706 
       
   707 	($hook = get_hook('aus_find_user_selected')) ? eval($hook) : null;
       
   708 
       
   709 	// trim() all elements in $form
       
   710 	$form = array_map('trim', $form);
       
   711 	$conditions = array();
       
   712 
       
   713 	$posts_greater = trim($_POST['posts_greater']);
       
   714 	$posts_less = trim($_POST['posts_less']);
       
   715 	$last_post_after = trim($_POST['last_post_after']);
       
   716 	$last_post_before = trim($_POST['last_post_before']);
       
   717 	$registered_after = trim($_POST['registered_after']);
       
   718 	$registered_before = trim($_POST['registered_before']);
       
   719 	$order_by = $_POST['order_by'];
       
   720 	$direction = $_POST['direction'];
       
   721 	$user_group = $_POST['user_group'];
       
   722 
       
   723 	if ((!empty($posts_greater) || !empty($posts_less)) && !ctype_digit($posts_greater.$posts_less))
       
   724 		message($lang_admin['Non numeric value message']);
       
   725 
       
   726 	// Try to convert date/time to timestamps
       
   727 	if ($last_post_after != '')
       
   728 		$last_post_after = strtotime($last_post_after);
       
   729 	if ($last_post_before != '')
       
   730 		$last_post_before = strtotime($last_post_before);
       
   731 	if ($registered_after != '')
       
   732 		$registered_after = strtotime($registered_after);
       
   733 	if ($registered_before != '')
       
   734 		$registered_before = strtotime($registered_before);
       
   735 
       
   736 	if ($last_post_after == -1 || $last_post_before == -1 || $registered_after == -1 || $registered_before == -1)
       
   737 		message($lang_admin['Invalid date/time message']);
       
   738 
       
   739 	if ($last_post_after != '')
       
   740 		$conditions[] = 'u.last_post>'.$last_post_after;
       
   741 	if ($last_post_before != '')
       
   742 		$conditions[] = 'u.last_post<'.$last_post_before;
       
   743 	if ($registered_after != '')
       
   744 		$conditions[] = 'u.registered>'.$registered_after;
       
   745 	if ($registered_before != '')
       
   746 		$conditions[] = 'u.registered<'.$registered_before;
       
   747 
       
   748 	$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
       
   749 	while (list($key, $input) = @each($form))
       
   750 	{
       
   751 		if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note')))
       
   752 			$conditions[] = 'u.'.$pun_db->escape($key).' '.$like_command.' \''.$pun_db->escape(str_replace('*', '%', $input)).'\'';
       
   753 	}
       
   754 
       
   755 	if ($posts_greater != '')
       
   756 		$conditions[] = 'u.num_posts>'.$posts_greater;
       
   757 	if ($posts_less != '')
       
   758 		$conditions[] = 'u.num_posts<'.$posts_less;
       
   759 
       
   760 	if ($user_group != 'all')
       
   761 		$conditions[] = 'u.group_id='.intval($user_group);
       
   762 
       
   763 	if (empty($conditions))
       
   764 		message($lang_admin['No search terms message']);
       
   765 
       
   766 
       
   767 	// Load the misc.php language file
       
   768 	require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
       
   769 
       
   770 	// Find any users matching the conditions
       
   771 	$query = array(
       
   772 		'SELECT'	=> 'u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title',
       
   773 		'FROM'		=> 'users AS u',
       
   774 		'JOINS'		=> array(
       
   775 			array(
       
   776 				'LEFT JOIN'		=> 'groups AS g',
       
   777 				'ON'			=> 'g.g_id=u.group_id'
       
   778 			)
       
   779 		),
       
   780 		'WHERE'		=> 'u.id>1 AND '.implode(' AND ', $conditions),
       
   781 		'ORDER BY'	=> $pun_db->escape($order_by).' '.$pun_db->escape($direction)
       
   782 	);
       
   783 
       
   784 	($hook = get_hook('aus_qr_find_users')) ? eval($hook) : null;
       
   785 	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   786 	$pun_page['num_users'] = $pun_db->num_rows($result);
       
   787 
       
   788 
       
   789 	// Setup breadcrumbs
       
   790 	$pun_page['crumbs'] = array(
       
   791 		array($pun_config['o_board_title'], pun_link($pun_url['index'])),
       
   792 		array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])),
       
   793 		array($lang_admin['Searches'], pun_link($pun_url['admin_users'])),
       
   794 		$lang_admin['User search results']
       
   795 	);
       
   796 
       
   797 	($hook = get_hook('aus_find_user_pre_header_load')) ? eval($hook) : null;
       
   798 
       
   799 	define('PUN_PAGE_SECTION', 'users');
       
   800 	define('PUN_PAGE', 'admin-users');
       
   801 	require PUN_ROOT.'header.php';
       
   802 
       
   803 ?>
       
   804 <div id="pun-main" class="main sectioned admin">
       
   805 
       
   806 <?php echo generate_admin_menu(); ?>
       
   807 
       
   808 	<div class="main-head">
       
   809 		<h1><span>{ <?php echo end($pun_page['crumbs']) ?> }</span></h1>
       
   810 	</div>
       
   811 
       
   812 	<div class="main-content frm">
       
   813 		<div class="frm-head">
       
   814 			<h2><span><?php printf($lang_admin['Users found'], $pun_page['num_users']) ?></span></h2>
       
   815 		</div>
       
   816 		<form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_users']) ?>&amp;action=modify_users">
       
   817 			<div class="hidden">
       
   818 				<input type="hidden" name="csrf_token" value="<?php echo generate_form_token(pun_link($pun_url['admin_users']).'&action=modify_users') ?>" />
       
   819 			</div>
       
   820 			<table cellspacing="0">
       
   821 				<thead>
       
   822 					<tr>
       
   823 						<th class="tcl" scope="col"><?php echo $lang_admin['Username column'] ?></th>
       
   824 						<th class="tc2" scope="col"><?php echo $lang_admin['Title column'] ?></th>
       
   825 						<th class="tc3" scope="col"><?php echo $lang_admin['Posts'] ?></th>
       
   826 <?php ($hook = get_hook('aus_find_user_table_header_after_num_posts')) ? eval($hook) : null; ?>
       
   827 						<th class="tcr actions" scope="col"><?php echo $lang_admin['Actions'] ?></th>
       
   828 <?php ($hook = get_hook('aus_find_user_table_header_after_actions')) ? eval($hook) : null; if ($pun_user['g_id'] == PUN_ADMIN): ?>					<th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th>
       
   829 <?php endif; ?>					</tr>
       
   830 				</thead>
       
   831 				<tbody>
       
   832 <?php
       
   833 
       
   834 	if ($pun_page['num_users'])
       
   835 	{
       
   836 		while ($user_data = $pun_db->fetch_assoc($result))
       
   837 		{
       
   838 			$user_title = get_title($user_data);
       
   839 
       
   840 			// This script is a special case in that we want to display "Not verified" for non-verified users
       
   841 			if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned'])
       
   842 				$user_title = '<strong>'.$lang_admin['Not verified'].'</strong>';
       
   843 
       
   844 			$pun_page['actions'] = '<span><a href="'.pun_link($pun_url['admin_users']).'&ip_stats='.$user_data['id'].'">'.$lang_admin['View IP stats'].'</a></span> <span><a href="'.pun_link($pun_url['search_user_posts'], $user_data['id']).'">'.$lang_admin['Show posts'].'</a></span>';
       
   845 
       
   846 ?>
       
   847 					<tr>
       
   848 						<td class="tcl"><?php echo '<strong><a href="'.pun_link($pun_url['user'], $user_data['id']).'">'.htmlspecialchars($user_data['username']).'</a></strong>' ?> <span class="usermail"><a href="mailto:<?php echo $user_data['email'] ?>"><?php echo $user_data['email'] ?></a></span> <?php if ($user_data['admin_note'] != '') echo '<span class="usernote">'.htmlspecialchars($user_data['admin_note']).'</span>' ?></td>
       
   849 						<td class="tc2"><?php echo $user_title ?></td>
       
   850 						<td class="tc3"><?php echo $user_data['num_posts'] ?></td>
       
   851 <?php ($hook = get_hook('aus_find_user_table_contents_after_num_posts')) ? eval($hook) : null; ?>
       
   852 						<td class="tcr actions"><?php echo $pun_page['actions'] ?></td>
       
   853 <?php ($hook = get_hook('aus_find_user_table_contents_after_actions')) ? eval($hook) : null; if ($pun_user['g_id'] == PUN_ADMIN): ?>					<td class="tcmod"><input type="checkbox" name="users[<?php echo $user_data['id'] ?>]" value="1" /></td>
       
   854 <?php endif; ?>					</tr>
       
   855 <?php
       
   856 
       
   857 		}
       
   858 	}
       
   859 	else
       
   860 		echo "\t\t\t\t\t".'<tr><td class="tcl" colspan="'.(($pun_user['g_id'] == PUN_ADMIN) ? '5' : '4').'">'.$lang_admin['No match'].'</td></tr>'."\n";
       
   861 
       
   862 ?>
       
   863 				</tbody>
       
   864 			</table>
       
   865 <?php
       
   866 
       
   867 // Setup control buttons
       
   868 $pun_page['main_submit'] = array(
       
   869 	'<span class="submit"><input type="submit" name="ban_users" value="'.$lang_admin['Ban'].'" /></span>',
       
   870 	'<span class="submit"><input type="submit" name="delete_users" value="'.$lang_admin['Delete'].'" /></span>',
       
   871 	'<span class="submit"><input type="submit" name="change_group" value="'.$lang_admin['Change group'].'" /></span>'
       
   872 );
       
   873 
       
   874 ($hook = get_hook('aus_find_user_pre_moderation_buttons')) ? eval($hook) : null;
       
   875 
       
   876 ?>
       
   877 			<p class="submitting">
       
   878 				<?php echo implode("\n\t\t\t\t", $pun_page['main_submit'])."\n" ?>
       
   879 			</p>
       
   880 		</form>
       
   881 	</div>
       
   882 </div>
       
   883 <?php
       
   884 
       
   885 	require PUN_ROOT.'footer.php';
       
   886 }
       
   887 
       
   888 
       
   889 else
       
   890 {
       
   891 	// Setup form
       
   892 	$pun_page['set_count'] = $pun_page['fld_count'] = 0;
       
   893 	$pun_page['form_action'] = '';
       
   894 
       
   895 	// Setup breadcrumbs
       
   896 	$pun_page['crumbs'] = array(
       
   897 		array($pun_config['o_board_title'], pun_link($pun_url['index'])),
       
   898 		array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])),
       
   899 		$lang_admin['Searches']
       
   900 	);
       
   901 
       
   902 	($hook = get_hook('aus_search_form_pre_header_load')) ? eval($hook) : null;
       
   903 
       
   904 	define('PUN_PAGE_SECTION', 'users');
       
   905 	define('PUN_PAGE', 'admin-users');
       
   906 	require PUN_ROOT.'header.php';
       
   907 
       
   908 ?>
       
   909 <div id="pun-main" class="main sectioned admin">
       
   910 
       
   911 <?php echo generate_admin_menu(); ?>
       
   912 
       
   913 	<div class="main-head">
       
   914 		<h1><span>{ <?php echo end($pun_page['crumbs']) ?> }</span></h1>
       
   915 	</div>
       
   916 
       
   917 	<div class="main-content frm">
       
   918 		<div class="frm-head">
       
   919 			<h2><span><?php echo $lang_admin['User search head'] ?></span></h2>
       
   920 		</div>
       
   921 		<form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_users']) ?>&amp;action=find_user">
       
   922 			<div class="hidden">
       
   923 				<input type="hidden" name="csrf_token" value="<?php echo generate_form_token(pun_link($pun_url['admin_users']).'&action=find_user') ?>" />
       
   924 			</div>
       
   925 <?php ($hook = get_hook('aus_search_pre_user_search_fieldset')) ? eval($hook) : null; ?>
       
   926 			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
       
   927 				<legend class="frm-legend"><strong><?php echo $lang_admin['User search legend'] ?></strong></legend>
       
   928 				<div class="frm-fld text">
       
   929 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   930 						<span class="fld-label"><?php echo $lang_admin['Username'] ?></span><br />
       
   931 						<span class="input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="username" size="25" maxlength="25" /></span>
       
   932 					</label>
       
   933 				</div>
       
   934 				<div class="frm-fld text">
       
   935 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   936 						<span class="fld-label"><?php echo $lang_admin['E-mail address'] ?></span><br />
       
   937 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[email]" size="30" maxlength="80" /></span>
       
   938 					</label>
       
   939 				</div>
       
   940 				<div class="frm-fld text">
       
   941 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   942 						<span class="fld-label"><?php echo $lang_admin['Title'] ?></span><br />
       
   943 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[title]" size="30" maxlength="50" /></span>
       
   944 					</label>
       
   945 				</div>
       
   946 				<div class="frm-fld text">
       
   947 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   948 						<span class="fld-label"><?php echo $lang_admin['Real name'] ?></span><br />
       
   949 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[realname]" size="30" maxlength="40" /></span>
       
   950 					</label>
       
   951 				</div>
       
   952 				<div class="frm-fld text">
       
   953 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   954 						<span class="fld-label"><?php echo $lang_admin['Website'] ?></span><br />
       
   955 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[url]" size="35" maxlength="100" /></span>
       
   956 					</label>
       
   957 				</div>
       
   958 				<div class="frm-fld text">
       
   959 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   960 						<span class="fld-label">Jabber</span><br />
       
   961 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[jabber]" size="30" maxlength="80" /></span>
       
   962 					</label>
       
   963 				</div>
       
   964 				<div class="frm-fld text">
       
   965 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   966 						<span class="fld-label">ICQ</span><br />
       
   967 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[icq]" size="12" maxlength="12" /></span>
       
   968 					</label>
       
   969 				</div>
       
   970 				<div class="frm-fld text">
       
   971 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   972 						<span class="fld-label">MSN Messenger</span><br />
       
   973 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[msn]" size="30" maxlength="80" /></span>
       
   974 					</label>
       
   975 				</div>
       
   976 				<div class="frm-fld text">
       
   977 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   978 						<span class="fld-label">AOL IM</span><br />
       
   979 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[aim]" size="20" maxlength="20" /></span>
       
   980 					</label>
       
   981 				</div>
       
   982 				<div class="frm-fld text">
       
   983 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   984 						<span class="fld-label">Yahoo! Messenger</span><br />
       
   985 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[yahoo]" size="20" maxlength="20" /></span>
       
   986 					</label>
       
   987 				</div>
       
   988 				<div class="frm-fld text">
       
   989 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   990 						<span class="fld-label"><?php echo $lang_admin['Location'] ?></span><br />
       
   991 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[location]" size="30" maxlength="30" /></span>
       
   992 					</label>
       
   993 				</div>
       
   994 				<div class="frm-fld text">
       
   995 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
   996 						<span class="fld-label"><?php echo $lang_admin['Signature'] ?></span><br />
       
   997 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[signature]" size="35" maxlength="512" /></span>
       
   998 					</label>
       
   999 				</div>
       
  1000 				<div class="frm-fld text">
       
  1001 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1002 						<span class="fld-label"><?php echo $lang_admin['Admin note'] ?></span><br />
       
  1003 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="form[admin_note]" size="30" maxlength="30" /></span>
       
  1004 					</label>
       
  1005 				</div>
       
  1006 				<div class="frm-fld text">
       
  1007 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1008 						<span class="fld-label"><?php echo $lang_admin['More posts than'] ?></span><br />
       
  1009 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="posts_greater" size="5" maxlength="8" /></span>
       
  1010 						<span class="fld-extra"><?php echo $lang_admin['Number of posts'] ?></span>
       
  1011 					</label>
       
  1012 				</div>
       
  1013 				<div class="frm-fld text">
       
  1014 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1015 						<span class="fld-label"><?php echo $lang_admin['Less posts than'] ?></span><br />
       
  1016 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="posts_less" size="5" maxlength="8" /></span>
       
  1017 						<span class="fld-extra"><?php echo $lang_admin['Number of posts'] ?></span>
       
  1018 					</label>
       
  1019 				</div>
       
  1020 				<div class="frm-fld text">
       
  1021 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1022 						<span class="fld-label"><?php echo $lang_admin['Last post after'] ?></span><br />
       
  1023 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="last_post_after" size="24" maxlength="19" /></span>
       
  1024  						<span class="fld-extra">(yyyy-mm-dd hh:mm:ss)</span>
       
  1025 					</label>
       
  1026 				</div>
       
  1027 				<div class="frm-fld text">
       
  1028 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1029 						<span class="fld-label"><?php echo $lang_admin['Last post before'] ?></span><br />
       
  1030 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="last_post_before" size="24" maxlength="19" /></span>
       
  1031 						<span class="fld-extra">(yyyy-mm-dd hh:mm:ss)</span>
       
  1032 					</label>
       
  1033 				</div>
       
  1034 				<div class="frm-fld text">
       
  1035 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1036 						<span class="fld-label"><?php echo $lang_admin['Registered after'] ?></span><br />
       
  1037 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="registered_after" size="24" maxlength="19" /></span>
       
  1038 						<span class="fld-extra">(yyyy-mm-dd hh:mm:ss)</span>
       
  1039 					</label>
       
  1040 				</div>
       
  1041 				<div class="frm-fld text">
       
  1042 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1043 						<span class="fld-label"><?php echo $lang_admin['Registered before'] ?></span><br />
       
  1044 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="registered_before" size="24" maxlength="19" /></span>
       
  1045 						<span class="fld-extra">(yyyy-mm-dd hh:mm:ss)</span>
       
  1046 					</label>
       
  1047 				</div>
       
  1048 <?php ($hook = get_hook('aus_search_user_search_end')) ? eval($hook) : null; ?>
       
  1049 			</fieldset>
       
  1050 <?php ($hook = get_hook('aus_search_pre_results_fieldset')) ? eval($hook) : null; ?>
       
  1051 			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
       
  1052 				<legend class="frm-legend"><strong><?php echo $lang_admin['User results legend'] ?></strong></legend>
       
  1053 				<div class="frm-fld select">
       
  1054 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1055 						<span class="fld-label"><?php echo $lang_admin['Order by'] ?></span><br />
       
  1056 						<span class="fld-input"><select id="fld<?php echo $pun_page['fld_count'] ?>" name="order_by">
       
  1057 							<option value="username" selected="selected"><?php echo strtolower($lang_admin['Username']) ?></option>
       
  1058 							<option value="email"><?php echo strtolower($lang_admin['E-mail']) ?></option>
       
  1059 							<option value="num_posts"><?php echo strtolower($lang_admin['Posts']) ?></option>
       
  1060 							<option value="last_post"><?php echo $lang_admin['Last post'] ?></option>
       
  1061 							<option value="registered"><?php echo $lang_admin['Registered'] ?></option>
       
  1062 						</select></span>
       
  1063 					</label>
       
  1064 				</div>
       
  1065 				<div class="frm-fld text">
       
  1066 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1067 						<span class="fld-label"><?php echo $lang_admin['Sort order'] ?></span><br />
       
  1068 						<span class="fld-input"><select id="fld<?php echo $pun_page['fld_count'] ?>" name="direction">
       
  1069 							<option value="ASC" selected="selected"><?php echo $lang_admin['Ascending'] ?></option>
       
  1070 							<option value="DESC"><?php echo $lang_admin['Descending'] ?></option>
       
  1071 						</select></span>
       
  1072 					</label>
       
  1073 				</div>
       
  1074 				<div class="frm-fld text">
       
  1075 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1076 						<span class="fld-label"><?php echo $lang_admin['User group'] ?></span><br />
       
  1077 						<span class="fld-input"><select id="fld<?php echo $pun_page['fld_count'] ?>" name="user_group">
       
  1078 							<option value="all" selected="selected"><?php echo $lang_admin['All groups'] ?></option>
       
  1079 							<option value="<?php echo PUN_UNVERIFIED ?>"><?php echo $lang_admin['Unverified users'] ?></option>
       
  1080 <?php
       
  1081 
       
  1082 	$query = array(
       
  1083 		'SELECT'	=> 'g.g_id, g.g_title',
       
  1084 		'FROM'		=> 'groups AS g',
       
  1085 		'WHERE'		=> 'g.g_id!='.PUN_GUEST,
       
  1086 		'ORDER BY'	=> 'g.g_title'
       
  1087 	);
       
  1088 
       
  1089 	($hook = get_hook('aus_qr_get_groups2')) ? eval($hook) : null;
       
  1090 	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
  1091 	while ($cur_group = $pun_db->fetch_assoc($result))
       
  1092 		echo "\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.htmlspecialchars($cur_group['g_title']).'</option>'."\n";
       
  1093 
       
  1094 ?>
       
  1095 						</select></span>
       
  1096 					</label>
       
  1097 				</div>
       
  1098 <?php ($hook = get_hook('aus_search_results_fieldset_end')) ? eval($hook) : null; ?>
       
  1099 			</fieldset>
       
  1100 			<div class="frm-buttons">
       
  1101 				<span class="submit"><input type="submit" class="button" name="find_user" value="<?php echo $lang_admin['Submit search'] ?>" /></span>
       
  1102 			</div>
       
  1103 		</form>
       
  1104 	</div>
       
  1105 <?php
       
  1106 
       
  1107 // Reset fieldset counter
       
  1108 $pun_page['set_count'] = 0;
       
  1109 
       
  1110 ?>
       
  1111 
       
  1112 	<div class="main-content frm">
       
  1113 		<div class="frm-head">
       
  1114 			<h2><span><?php echo $lang_admin['IP search head'] ?></span></h2>
       
  1115 		</div>
       
  1116 		<form class="frm-form" method="get" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_users']) ?>">
       
  1117 <?php ($hook = get_hook('aus_search_pre_ip_search_fieldset')) ? eval($hook) : null; ?>
       
  1118 			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
       
  1119 				<legend class="frm-legend"><strong><?php echo $lang_admin['IP search legend'] ?></strong></legend>
       
  1120 				<div class="frm-fld text">
       
  1121 					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
       
  1122 						<span class="fld-label"><?php echo $lang_admin['IP address'] ?></span><br />
       
  1123 						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="show_users" size="18" maxlength="15" /></span>
       
  1124 					</label>
       
  1125 				</div>
       
  1126 <?php ($hook = get_hook('aus_search_ip_search_fieldset_end')) ? eval($hook) : null; ?>
       
  1127 			</fieldset>
       
  1128 			<div class="frm-buttons">
       
  1129 				<span class="submit"><input type="submit" value=" <?php echo $lang_admin['Submit search'] ?> " /></span>
       
  1130 			</div>
       
  1131 		</form>
       
  1132 	</div>
       
  1133 
       
  1134 </div>
       
  1135 <?php
       
  1136 
       
  1137 	require PUN_ROOT.'footer.php';
       
  1138 }