Verzeichnisstruktur phpBB-3.0.0
- Veröffentlicht
- 12.12.2007
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
acp_ban.php
001 <?php
002 /**
003 *
004 * @package acp
005 * @version $Id$
006 * @copyright (c) 2005 phpBB Group
007 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
008 *
009 */
010
011 /**
012 * @ignore
013 */
014 if (!defined('IN_PHPBB'))
015 {
016 exit;
017 }
018
019 /**
020 * @package acp
021 */
022 class acp_ban
023 {
024 var $u_action;
025
026 function main($id, $mode)
027 {
028 global $config, $db, $user, $auth, $template, $cache;
029 global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
030
031 include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
032
033 $bansubmit = (isset($_POST['bansubmit'])) ? true : false;
034 $unbansubmit = (isset($_POST['unbansubmit'])) ? true : false;
035 $current_time = time();
036
037 $user->add_lang(array('acp/ban', 'acp/users'));
038 $this->tpl_name = 'acp_ban';
039 $form_key = 'acp_ban';
040 add_form_key($form_key);
041
042 if (($bansubmit || $unbansubmit) && !check_form_key($form_key))
043 {
044 trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
045 }
046
047 // Ban submitted?
048 if ($bansubmit)
049 {
050 // Grab the list of entries
051 $ban = utf8_normalize_nfc(request_var('ban', '', true));
052 $ban_len = request_var('banlength', 0);
053 $ban_len_other = request_var('banlengthother', '');
054 $ban_exclude = request_var('banexclude', 0);
055 $ban_reason = utf8_normalize_nfc(request_var('banreason', '', true));
056 $ban_give_reason = utf8_normalize_nfc(request_var('bangivereason', '', true));
057
058 if ($ban)
059 {
060 user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
061
062 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
063 }
064 }
065 else if ($unbansubmit)
066 {
067 $ban = request_var('unban', array(''));
068
069 if ($ban)
070 {
071 user_unban($mode, $ban);
072
073 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
074 }
075 }
076
077 // Define language vars
078 $this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
079
080 $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
081 $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
082 $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
083 $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
084 $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
085
086 switch ($mode)
087 {
088 case 'user':
089 $l_ban_cell = $user->lang['USERNAME'];
090 break;
091
092 case 'ip':
093 $l_ban_cell = $user->lang['IP_HOSTNAME'];
094 break;
095
096 case 'email':
097 $l_ban_cell = $user->lang['EMAIL_ADDRESS'];
098 break;
099 }
100
101 $this->display_ban_options($mode);
102
103 $template->assign_vars(array(
104 'L_TITLE' => $this->page_title,
105 'L_EXPLAIN' => $l_ban_explain,
106 'L_UNBAN_TITLE' => $l_unban_title,
107 'L_UNBAN_EXPLAIN' => $l_unban_explain,
108 'L_BAN_CELL' => $l_ban_cell,
109 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain,
110 'L_NO_BAN_CELL' => $l_no_ban_cell,
111
112 'S_USERNAME_BAN' => ($mode == 'user') ? true : false,
113
114 'U_ACTION' => $this->u_action,
115 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=acp_ban&field=ban'),
116 ));
117 }
118
119 /**
120 * Display ban options
121 */
122 function display_ban_options($mode)
123 {
124 global $user, $db, $template;
125
126 // Ban length options
127 $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'] . ' -> ');
128
129 $ban_end_options = '';
130 foreach ($ban_end_text as $length => $text)
131 {
132 $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
133 }
134
135 switch ($mode)
136 {
137 case 'user':
138
139 $field = 'username';
140 $l_ban_cell = $user->lang['USERNAME'];
141
142 $sql = 'SELECT b.*, u.user_id, u.username, u.username_clean
143 FROM ' . BANLIST_TABLE . ' b, ' . USERS_TABLE . ' u
144 WHERE (b.ban_end >= ' . time() . '
145 OR b.ban_end = 0)
146 AND u.user_id = b.ban_userid
147 ORDER BY u.username_clean ASC';
148 break;
149
150 case 'ip':
151
152 $field = 'ban_ip';
153 $l_ban_cell = $user->lang['IP_HOSTNAME'];
154
155 $sql = 'SELECT *
156 FROM ' . BANLIST_TABLE . '
157 WHERE (ban_end >= ' . time() . "
158 OR ban_end = 0)
159 AND ban_ip <> ''";
160 break;
161
162 case 'email':
163
164 $field = 'ban_email';
165 $l_ban_cell = $user->lang['EMAIL_ADDRESS'];
166
167 $sql = 'SELECT *
168 FROM ' . BANLIST_TABLE . '
169 WHERE (ban_end >= ' . time() . "
170 OR ban_end = 0)
171 AND ban_email <> ''";
172 break;
173 }
174 $result = $db->sql_query($sql);
175
176 $banned_options = '';
177 $ban_length = $ban_reasons = $ban_give_reasons = array();
178
179 while ($row = $db->sql_fetchrow($result))
180 {
181 $banned_options .= '<option' . (($row['ban_exclude']) ? ' class="sep"' : '') . ' value="' . $row['ban_id'] . '">' . $row[$field] . '</option>';
182
183 $time_length = ($row['ban_end']) ? ($row['ban_end'] - $row['ban_start']) / 60 : 0;
184 $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']);
185
186 $ban_reasons[$row['ban_id']] = $row['ban_reason'];
187 $ban_give_reasons[$row['ban_id']] = $row['ban_give_reason'];
188 }
189 $db->sql_freeresult($result);
190
191 if (sizeof($ban_length))
192 {
193 foreach ($ban_length as $ban_id => $length)
194 {
195 $template->assign_block_vars('ban_length', array(
196 'BAN_ID' => (int) $ban_id,
197 'LENGTH' => $length,
198 'A_LENGTH' => addslashes($length),
199 ));
200 }
201 }
202
203 if (sizeof($ban_reasons))
204 {
205 foreach ($ban_reasons as $ban_id => $reason)
206 {
207 $template->assign_block_vars('ban_reason', array(
208 'BAN_ID' => $ban_id,
209 'REASON' => $reason,
210 'A_REASON' => addslashes(htmlspecialchars_decode($reason)),
211 ));
212 }
213 }
214
215 if (sizeof($ban_give_reasons))
216 {
217 foreach ($ban_give_reasons as $ban_id => $reason)
218 {
219 $template->assign_block_vars('ban_give_reason', array(
220 'BAN_ID' => $ban_id,
221 'REASON' => $reason,
222 'A_REASON' => addslashes(htmlspecialchars_decode($reason)),
223 ));
224 }
225 }
226
227 $template->assign_vars(array(
228 'S_BAN_END_OPTIONS' => $ban_end_options,
229 'S_BANNED_OPTIONS' => ($banned_options) ? true : false,
230 'BANNED_OPTIONS' => $banned_options)
231 );
232 }
233 }
234
235 ?>