punbb/admin_users.php
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
child 3 c0c445d4a13e
equal deleted inserted replaced
1:8f6143115bf5 2:a8a21e1c7afa
    24 
    24 
    25 
    25 
    26 // Tell header.php to use the admin template
    26 // Tell header.php to use the admin template
    27 define('PUN_ADMIN_CONSOLE', 1);
    27 define('PUN_ADMIN_CONSOLE', 1);
    28 
    28 
    29 define('PUN_ROOT', './');
    29 //define('PUN_ROOT', './');
    30 require PUN_ROOT.'include/common.php';
    30 //require PUN_ROOT.'include/common.php';
       
    31 
       
    32 global $pun_db, $pun_user, $pun_config, $lang_common;
       
    33 
    31 require PUN_ROOT.'include/common_admin.php';
    34 require PUN_ROOT.'include/common_admin.php';
    32 
    35 
    33 
    36 
    34 if ($pun_user['g_id'] > PUN_MOD)
    37 if ($pun_user['g_id'] < PUN_MOD)
    35 	message($lang_common['No permission']);
    38 	message($lang_common['No permission']);
    36 
    39 
    37 
    40 
    38 // Show IP statistics for a certain user ID
    41 // Show IP statistics for a certain user ID
    39 if (isset($_GET['ip_stats']))
    42 if (isset($_GET['ip_stats']))
    67 				</tr>
    70 				</tr>
    68 			</thead>
    71 			</thead>
    69 			<tbody>
    72 			<tbody>
    70 <?php
    73 <?php
    71 
    74 
    72 	$result = $db->query('SELECT poster_ip, MAX(posted) AS last_used, COUNT(id) AS used_times FROM '.$db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip ORDER BY last_used DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    75 	$result = $pun_db->query('SELECT poster_ip, MAX(posted) AS last_used, COUNT(id) AS used_times FROM '.$pun_db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip ORDER BY last_used DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error());
    73 	if ($db->num_rows($result))
    76 	if ($pun_db->num_rows($result))
    74 	{
    77 	{
    75 		while ($cur_ip = $db->fetch_assoc($result))
    78 		while ($cur_ip = $pun_db->fetch_assoc($result))
    76 		{
    79 		{
    77 
    80 
    78 ?>
    81 ?>
    79 				<tr>
    82 				<tr>
    80 					<td class="tcl"><a href="moderate.php?get_host=<?php echo $cur_ip['poster_ip'] ?>"><?php echo $cur_ip['poster_ip'] ?></a></td>
    83 					<td class="tcl"><a href="moderate.php?get_host=<?php echo $cur_ip['poster_ip'] ?>"><?php echo $cur_ip['poster_ip'] ?></a></td>
   141 				</tr>
   144 				</tr>
   142 			</thead>
   145 			</thead>
   143 			<tbody>
   146 			<tbody>
   144 <?php
   147 <?php
   145 
   148 
   146 	$result = $db->query('SELECT DISTINCT poster_id, poster FROM '.$db->prefix.'posts WHERE poster_ip=\''.$db->escape($ip).'\' ORDER BY poster DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
   149 	$result = $pun_db->query('SELECT DISTINCT poster_id, poster FROM '.$pun_db->prefix.'posts WHERE poster_ip=\''.$pun_db->escape($ip).'\' ORDER BY poster DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error());
   147 	$num_posts = $db->num_rows($result);
   150 	$num_posts = $pun_db->num_rows($result);
   148 
   151 
   149 	if ($num_posts)
   152 	if ($num_posts)
   150 	{
   153 	{
   151 		// Loop through users and print out some info
   154 		// Loop through users and print out some info
   152 		for ($i = 0; $i < $num_posts; ++$i)
   155 		for ($i = 0; $i < $num_posts; ++$i)
   153 		{
   156 		{
   154 			list($poster_id, $poster) = $db->fetch_row($result);
   157 			list($poster_id, $poster) = $pun_db->fetch_row($result);
   155 
   158 
   156 			$result2 = $db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND u.id='.$poster_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
   159 			$result2 = $pun_db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$pun_db->prefix.'users AS u INNER JOIN '.$pun_db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND u.id='.$poster_id) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
   157 
   160 
   158 			if (($user_data = $db->fetch_assoc($result2)))
   161 			if (($user_data = $pun_db->fetch_assoc($result2)))
   159 			{
   162 			{
   160 				$user_title = get_title($user_data);
   163 				$user_title = get_title($user_data);
   161 
   164 
   162 				$actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">View IP stats</a> - <a href="search.php?action=show_user&amp;user_id='.$user_data['id'].'">Show posts</a>';
   165 				$actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">View IP stats</a> - <a href="search.php?action=show_user&amp;user_id='.$user_data['id'].'">Show posts</a>';
   163 
   166 
   256 
   259 
   257 	$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
   260 	$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
   258 	while (list($key, $input) = @each($form))
   261 	while (list($key, $input) = @each($form))
   259 	{
   262 	{
   260 		if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note')))
   263 		if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note')))
   261 			$conditions[] = 'u.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\'';
   264 			$conditions[] = 'u.'.$pun_db->escape($key).' '.$like_command.' \''.$pun_db->escape(str_replace('*', '%', $input)).'\'';
   262 	}
   265 	}
   263 
   266 
   264 	if ($posts_greater != '')
   267 	if ($posts_greater != '')
   265 		$conditions[] = 'u.num_posts>'.$posts_greater;
   268 		$conditions[] = 'u.num_posts>'.$posts_greater;
   266 	if ($posts_less != '')
   269 	if ($posts_less != '')
   299 				</tr>
   302 				</tr>
   300 			</thead>
   303 			</thead>
   301 			<tbody>
   304 			<tbody>
   302 <?php
   305 <?php
   303 
   306 
   304 	$result = $db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND '.implode(' AND ', $conditions).' ORDER BY '.$db->escape($order_by).' '.$db->escape($direction)) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
   307 	$result = $pun_db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$pun_db->prefix.'users AS u LEFT JOIN '.$pun_db->prefix.'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)) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
   305 	if ($db->num_rows($result))
   308 	if ($pun_db->num_rows($result))
   306 	{
   309 	{
   307 		while ($user_data = $db->fetch_assoc($result))
   310 		while ($user_data = $pun_db->fetch_assoc($result))
   308 		{
   311 		{
   309 			$user_title = get_title($user_data);
   312 			$user_title = get_title($user_data);
   310 
   313 
   311 			// This script is a special case in that we want to display "Not verified" for non-verified users
   314 			// This script is a special case in that we want to display "Not verified" for non-verified users
   312 			if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned'])
   315 			if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned'])
   464 									<td>
   467 									<td>
   465 										<select name="user_group" tabindex="22">
   468 										<select name="user_group" tabindex="22">
   466 												<option value="all" selected="selected">All groups</option>
   469 												<option value="all" selected="selected">All groups</option>
   467 <?php
   470 <?php
   468 
   471 
   469 	$result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
   472 	$result = $pun_db->query('SELECT g_id, g_title FROM '.$pun_db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $pun_db->error());
   470 
   473 
   471 	while ($cur_group = $db->fetch_assoc($result))
   474 	while ($cur_group = $pun_db->fetch_assoc($result))
   472 		echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
   475 		echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
   473 
   476 
   474 ?>
   477 ?>
   475 										</select>
   478 										</select>
   476 									</td>
   479 									</td>