query('SELECT username, email FROM '.$db->prefix.'users WHERE id='.$ban_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) { list($ban_user, $ban_email) = $db->fetch_row($result); $result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE poster_id='.$ban_id.' ORDER BY posted DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) $ban_ip = $db->result($result, 0); } else message('No user by that ID registered.'); } else // Otherwise the username is in POST { $ban_user = trim($_POST['new_ban_user']); if ($ban_user != '') { $result = $db->query('SELECT id, username, email FROM '.$db->prefix.'users WHERE username=\''.escape(strtolower($ban_user)).'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) { list($ban_id, $ban_user, $ban_email) = $db->fetch_row($result); $result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE poster_id='.$ban_id.' ORDER BY posted DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) $ban_ip = $db->result($result, 0); } else message('No user by that username registered. If you want to add a ban not tied to a specific username just leave the username blank.'); } } $page_title = htmlspecialchars($options['board_title']).' / Admin / Bans'; $form_name = 'bans2'; $focus_element = 'new_ban_ip'; require 'header.php'; if ($cur_user['status'] > 1) admin_menu('bans'); else moderator_menu('bans'); ?>