~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/php/phpBB3/includes/mcp/mcp_ban.php

Merge setup-stuff.

phpBB is gone, configuration, setup and jail building are completely redone.

Please read doc/setup/install_proc.txt, or you'll not get far.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
*
4
 
* @package mcp
5
 
* @version $Id: mcp_ban.php,v 1.17 2007/10/05 14:36:33 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
 
* @ignore
13
 
*/
14
 
if (!defined('IN_PHPBB'))
15
 
{
16
 
        exit;
17
 
}
18
 
 
19
 
/**
20
 
* @package mcp
21
 
*/
22
 
class mcp_ban
23
 
{
24
 
        var $u_action;
25
 
 
26
 
        function main($id, $mode)
27
 
        {
28
 
                global $config, $db, $user, $auth, $template, $cache;
29
 
                global $phpbb_root_path, $phpEx;
30
 
 
31
 
                include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
32
 
 
33
 
                // Include the admin banning interface...
34
 
                include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx);
35
 
 
36
 
                $bansubmit              = (isset($_POST['bansubmit'])) ? true : false;
37
 
                $unbansubmit    = (isset($_POST['unbansubmit'])) ? true : false;
38
 
                $current_time   = time();
39
 
 
40
 
                $user->add_lang(array('acp/ban', 'acp/users'));
41
 
                $this->tpl_name = 'mcp_ban';
42
 
 
43
 
                // Ban submitted?
44
 
                if ($bansubmit)
45
 
                {
46
 
                        // Grab the list of entries
47
 
                        $ban                            = request_var('ban', '', ($mode === 'user') ? true : false);
48
 
 
49
 
                        if ($mode === 'user')
50
 
                        {
51
 
                                $ban = utf8_normalize_nfc($ban);
52
 
                        }
53
 
 
54
 
                        $ban_len                        = request_var('banlength', 0);
55
 
                        $ban_len_other          = request_var('banlengthother', '');
56
 
                        $ban_exclude            = request_var('banexclude', 0);
57
 
                        $ban_reason                     = utf8_normalize_nfc(request_var('banreason', '', true));
58
 
                        $ban_give_reason        = utf8_normalize_nfc(request_var('bangivereason', '', true));
59
 
 
60
 
                        if ($ban)
61
 
                        {
62
 
                                if (confirm_box(true))
63
 
                                {
64
 
                                        user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
65
 
 
66
 
                                        trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">&laquo; ' . $user->lang['BACK_TO_PREV'] . '</a>');
67
 
                                }
68
 
                                else
69
 
                                {
70
 
                                        confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
71
 
                                                'mode'                          => $mode,
72
 
                                                'ban'                           => $ban,
73
 
                                                'bansubmit'                     => true,
74
 
                                                'banlength'                     => $ban_len,
75
 
                                                'banlengthother'        => $ban_len_other,
76
 
                                                'banexclude'            => $ban_exclude,
77
 
                                                'banreason'                     => $ban_reason,
78
 
                                                'bangivereason'         => $ban_give_reason)));
79
 
                                }
80
 
                        }
81
 
                }
82
 
                else if ($unbansubmit)
83
 
                {
84
 
                        $ban = request_var('unban', array(''));
85
 
 
86
 
                        if ($ban)
87
 
                        {
88
 
                                if (confirm_box(true))
89
 
                                {
90
 
                                        user_unban($mode, $ban);
91
 
 
92
 
                                        trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">&laquo; ' . $user->lang['BACK_TO_PREV'] . '</a>');
93
 
                                }
94
 
                                else
95
 
                                {
96
 
                                        confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
97
 
                                                'mode'                  => $mode,
98
 
                                                'unbansubmit'   => true,
99
 
                                                'unban'                 => $ban)));
100
 
                                }
101
 
                        }
102
 
                }
103
 
 
104
 
                // Ban length options
105
 
                $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'] . ' -&gt; ');
106
 
 
107
 
                $ban_end_options = '';
108
 
                foreach ($ban_end_text as $length => $text)
109
 
                {
110
 
                        $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
111
 
                }
112
 
 
113
 
                // Define language vars
114
 
                $this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
115
 
 
116
 
                $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
117
 
                $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
118
 
                $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
119
 
                $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
120
 
                $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
121
 
 
122
 
                switch ($mode)
123
 
                {
124
 
                        case 'user':
125
 
                                $l_ban_cell = $user->lang['USERNAME'];
126
 
                        break;
127
 
 
128
 
                        case 'ip':
129
 
                                $l_ban_cell = $user->lang['IP_HOSTNAME'];
130
 
                        break;
131
 
 
132
 
                        case 'email':
133
 
                                $l_ban_cell = $user->lang['EMAIL_ADDRESS'];
134
 
                        break;
135
 
                }
136
 
 
137
 
                acp_ban::display_ban_options($mode);
138
 
 
139
 
                $template->assign_vars(array(
140
 
                        'L_TITLE'                               => $this->page_title,
141
 
                        'L_EXPLAIN'                             => $l_ban_explain,
142
 
                        'L_UNBAN_TITLE'                 => $l_unban_title,
143
 
                        'L_UNBAN_EXPLAIN'               => $l_unban_explain,
144
 
                        'L_BAN_CELL'                    => $l_ban_cell,
145
 
                        'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain,
146
 
                        'L_NO_BAN_CELL'                 => $l_no_ban_cell,
147
 
 
148
 
                        'S_USERNAME_BAN'        => ($mode == 'user') ? true : false,
149
 
 
150
 
                        'U_ACTION'                      => $this->u_action,
151
 
                        'U_FIND_USERNAME'       => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=mcp_ban&amp;field=ban'),
152
 
                ));
153
 
 
154
 
                if ($mode != 'user')
155
 
                {
156
 
                        return;
157
 
                }
158
 
 
159
 
                // As a "service" we will check if any post id is specified and populate the username of the poster id if given
160
 
                $post_id = request_var('p', 0);
161
 
                $user_id = request_var('u', 0);
162
 
                $username = false;
163
 
 
164
 
                if ($user_id && $user_id <> ANONYMOUS)
165
 
                {
166
 
                        $sql = 'SELECT username
167
 
                                FROM ' . USERS_TABLE . '
168
 
                                WHERE user_id = ' . $user_id;
169
 
                        $result = $db->sql_query($sql);
170
 
                        $username = (string) $db->sql_fetchfield('username');
171
 
                        $db->sql_freeresult($result);
172
 
                }
173
 
                else if ($post_id)
174
 
                {
175
 
                        $post_info = get_post_data($post_id, 'm_ban');
176
 
 
177
 
                        if (sizeof($post_info) && !empty($post_info[$post_id]))
178
 
                        {
179
 
                                $username = $post_info[$post_id]['username'];
180
 
                        }
181
 
                }
182
 
 
183
 
                if ($username)
184
 
                {
185
 
                        $template->assign_var('USERNAMES', $username);
186
 
                }
187
 
        }
188
 
}
189
 
 
190
 
?>
 
 
b'\\ No newline at end of file'