phpBB
Statistics
| Revision:

root / branches / phpBB-3_0_0 / phpBB / includes / acp / acp_disallow.php

History | View | Annotate | Download (3 kB)

1
<?php
2
/**
3
*
4
* @package acp
5
* @version $Id: acp_disallow.php 11076 2011-03-23 22:30:11Z git-gate $
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 acp
21
*/
22
class acp_disallow
23
{
24
        var $u_action;
25
26
        function main($id, $mode)
27
        {
28
                global $db, $user, $auth, $template, $cache;
29
                global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
30
31
                include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
32
33
                $user->add_lang('acp/posting');
34
35
                // Set up general vars
36
                $this->tpl_name = 'acp_disallow';
37
                $this->page_title = 'ACP_DISALLOW_USERNAMES';
38
39
                $form_key = 'acp_disallow';
40
                add_form_key($form_key);
41
42
                $disallow = (isset($_POST['disallow'])) ? true : false;
43
                $allow = (isset($_POST['allow'])) ? true : false;
44
45
                if (($allow || $disallow) && !check_form_key($form_key))
46
                {
47
                        trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
48
                }
49
50
                if ($disallow)
51
                {
52
                        $disallowed_user = str_replace('*', '%', utf8_normalize_nfc(request_var('disallowed_user', '', true)));
53
54
                        if (!$disallowed_user)
55
                        {
56
                                trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
57
                        }
58
59
                        $sql = 'SELECT disallow_id
60
                                FROM ' . DISALLOW_TABLE . "
61
                                WHERE disallow_username = '" . $db->sql_escape($disallowed_user) . "'";
62
                        $result = $db->sql_query($sql);
63
                        $row = $db->sql_fetchrow($result);
64
                        $db->sql_freeresult($result);
65
66
                        if ($row)
67
                        {
68
                                trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING);
69
                        }
70
71
                        $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user));
72
                        $db->sql_query($sql);
73
74
                        $cache->destroy('_disallowed_usernames');
75
76
                        $message = $user->lang['DISALLOW_SUCCESSFUL'];
77
                        add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user));
78
79
                        trigger_error($message . adm_back_link($this->u_action));
80
                }
81
                else if ($allow)
82
                {
83
                        $disallowed_id = request_var('disallowed_id', 0);
84
85
                        if (!$disallowed_id)
86
                        {
87
                                trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
88
                        }
89
90
                        $sql = 'DELETE FROM ' . DISALLOW_TABLE . '
91
                                WHERE disallow_id = ' . $disallowed_id;
92
                        $db->sql_query($sql);
93
94
                        $cache->destroy('_disallowed_usernames');
95
96
                        add_log('admin', 'LOG_DISALLOW_DELETE');
97
98
                        trigger_error($user->lang['DISALLOWED_DELETED'] . adm_back_link($this->u_action));
99
                }
100
101
                // Grab the current list of disallowed usernames...
102
                $sql = 'SELECT *
103
                        FROM ' . DISALLOW_TABLE;
104
                $result = $db->sql_query($sql);
105
106
                $disallow_select = '';
107
                while ($row = $db->sql_fetchrow($result))
108
                {
109
                        $disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
110
                }
111
                $db->sql_freeresult($result);
112
113
                $template->assign_vars(array(
114
                        'U_ACTION'                                => $this->u_action,
115
                        'S_DISALLOWED_NAMES'        => $disallow_select)
116
                );
117
        }
118
}
119
120
?>