[ Index ] |
PHP Cross Reference of phpBB 3.0 Beta 3 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * @package acp 5 * @version $Id: acp_ban.php,v 1.12 2006/11/03 21:04:08 acydburn Exp $ 6 * @copyright (c) 2005 phpBB Group 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 * 9 */ 10 11 /** 12 * @package acp 13 */ 14 class acp_ban 15 { 16 var $u_action; 17 18 function main($id, $mode) 19 { 20 global $config, $db, $user, $auth, $template, $cache; 21 global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; 22 23 include($phpbb_root_path . 'includes/functions_user.' . $phpEx); 24 25 $bansubmit = (isset($_POST['bansubmit'])) ? true : false; 26 $unbansubmit= (isset($_POST['unbansubmit'])) ? true : false; 27 $current_time = time(); 28 29 $user->add_lang('acp/ban'); 30 $this->tpl_name = 'acp_ban'; 31 32 // Ban submitted? 33 if ($bansubmit) 34 { 35 // Grab the list of entries 36 $ban = request_var('ban', ''); 37 $ban_len = request_var('banlength', 0); 38 $ban_len_other = request_var('banlengthother', ''); 39 $ban_exclude = request_var('banexclude', 0); 40 $ban_reason = request_var('banreason', '', true); 41 $ban_give_reason = request_var('bangivereason', '', true); 42 43 user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason); 44 45 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action)); 46 } 47 else if ($unbansubmit) 48 { 49 $ban = request_var('unban', array('')); 50 51 user_unban($mode, $ban); 52 53 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action)); 54 } 55 56 // Define language vars 57 $this->page_title = $user->lang[strtoupper($mode) . '_BAN']; 58 59 $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN']; 60 $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN']; 61 $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN']; 62 $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN']; 63 $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED']; 64 65 switch ($mode) 66 { 67 case 'user': 68 $l_ban_cell = $user->lang['USERNAME']; 69 break; 70 71 case 'ip': 72 $l_ban_cell = $user->lang['IP_HOSTNAME']; 73 break; 74 75 case 'email': 76 $l_ban_cell = $user->lang['EMAIL_ADDRESS']; 77 break; 78 } 79 80 $this->display_ban_options($mode); 81 82 $template->assign_vars(array( 83 'L_TITLE' => $this->page_title, 84 'L_EXPLAIN' => $l_ban_explain, 85 'L_UNBAN_TITLE' => $l_unban_title, 86 'L_UNBAN_EXPLAIN' => $l_unban_explain, 87 'L_BAN_CELL' => $l_ban_cell, 88 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, 89 'L_NO_BAN_CELL' => $l_no_ban_cell, 90 91 'S_USERNAME_BAN' => ($mode == 'user') ? true : false, 92 93 'U_ACTION' => $this->u_action, 94 'U_FIND_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=acp_ban&field=ban'), 95 ) 96 ); 97 } 98 99 /** 100 * Display ban options 101 */ 102 function display_ban_options($mode) 103 { 104 global $user, $db, $template; 105 106 // Ban length options 107 $ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> '); 108 109 $ban_end_options = ''; 110 foreach ($ban_end_text as $length => $text) 111 { 112 $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>'; 113 } 114 115 switch ($mode) 116 { 117 case 'user': 118 119 $field = 'username'; 120 $l_ban_cell = $user->lang['USERNAME']; 121 122 $sql = 'SELECT b.*, u.user_id, u.username 123 FROM ' . BANLIST_TABLE . ' b, ' . USERS_TABLE . ' u 124 WHERE (b.ban_end >= ' . time() . ' 125 OR b.ban_end = 0) 126 AND u.user_id = b.ban_userid 127 AND b.ban_userid <> 0 128 AND u.user_id <> ' . ANONYMOUS . ' 129 ORDER BY u.username ASC'; 130 break; 131 132 case 'ip': 133 134 $field = 'ban_ip'; 135 $l_ban_cell = $user->lang['IP_HOSTNAME']; 136 137 $sql = 'SELECT * 138 FROM ' . BANLIST_TABLE . ' 139 WHERE (ban_end >= ' . time() . " 140 OR ban_end = 0) 141 AND ban_ip <> ''"; 142 break; 143 144 case 'email': 145 146 $field = 'ban_email'; 147 $l_ban_cell = $user->lang['EMAIL_ADDRESS']; 148 149 $sql = 'SELECT * 150 FROM ' . BANLIST_TABLE . ' 151 WHERE (ban_end >= ' . time() . " 152 OR ban_end = 0) 153 AND ban_email <> ''"; 154 break; 155 } 156 $result = $db->sql_query($sql); 157 158 $banned_options = ''; 159 $ban_length = $ban_reasons = $ban_give_reasons = array(); 160 161 while ($row = $db->sql_fetchrow($result)) 162 { 163 $banned_options .= '<option' . (($row['ban_exclude']) ? ' class="sep"' : '') . ' value="' . $row['ban_id'] . '">' . $row[$field] . '</option>'; 164 165 $time_length = ($row['ban_end']) ? ($row['ban_end'] - $row['ban_start']) / 60 : 0; 166 $ban_length[$row['ban_id']] = (isset($ban_end_text[$time_length])) ? $ban_end_text[$time_length] : $user->lang['UNTIL'] . ' -> ' . $user->format_date($row['ban_end']); 167 168 $ban_reasons[$row['ban_id']] = $row['ban_reason']; 169 $ban_give_reasons[$row['ban_id']] = $row['ban_give_reason']; 170 } 171 $db->sql_freeresult($result); 172 173 if (sizeof($ban_length)) 174 { 175 foreach ($ban_length as $ban_id => $length) 176 { 177 $template->assign_block_vars('ban_length', array( 178 'BAN_ID' => $ban_id, 179 'LENGTH' => $length, 180 'A_LENGTH' => addslashes($length)) 181 ); 182 } 183 } 184 185 if (sizeof($ban_reasons)) 186 { 187 foreach ($ban_reasons as $ban_id => $reason) 188 { 189 $template->assign_block_vars('ban_reason', array( 190 'BAN_ID' => $ban_id, 191 'REASON' => $reason, 192 'A_REASON' => addslashes(htmlspecialchars_decode($reason))) 193 ); 194 } 195 } 196 197 if (sizeof($ban_give_reasons)) 198 { 199 foreach ($ban_give_reasons as $ban_id => $reason) 200 { 201 $template->assign_block_vars('ban_give_reason', array( 202 'BAN_ID' => $ban_id, 203 'REASON' => $reason, 204 'A_REASON' => addslashes(htmlspecialchars_decode($reason))) 205 ); 206 } 207 } 208 209 $template->assign_vars(array( 210 'S_BAN_END_OPTIONS' => $ban_end_options, 211 'S_BANNED_OPTIONS' => ($banned_options) ? true : false, 212 'BANNED_OPTIONS' => $banned_options) 213 ); 214 } 215 } 216 217 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 22 00:35:05 2006 | Cross-referenced by PHPXref 0.6 |