Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
2.35% covered (danger)
2.35%
21 / 892
3.85% covered (danger)
3.85%
1 / 26
CRAP
0.00% covered (danger)
0.00%
0 / 1
acp_board
2.35% covered (danger)
2.35%
21 / 892
3.85% covered (danger)
3.85%
1 / 26
17611.35
0.00% covered (danger)
0.00%
0 / 1
 main
0.00% covered (danger)
0.00%
0 / 540
0.00% covered (danger)
0.00%
0 / 1
8190
 select_auth_method
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
1 / 1
4
 mail_auth_select
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
6
 full_folder_select
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
2
 select_acc_activation
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
12
 username_length
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
2
 select_username_chars
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
6
 password_length
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
2
 select_password_chars
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
6
 bump_interval
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 1
6
 language_select
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 phpbb_style_select
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 board_disable
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
6
 board_disable_access
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
2
 quick_reply
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
 timezone_select
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 guest_style_get
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 guest_style_set
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 dateformat_select
0.00% covered (danger)
0.00%
0 / 39
0.00% covered (danger)
0.00%
0 / 1
30
 select_news_forums
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 select_exclude_forums
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_forum_select
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
6
 store_feed_forums
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
6
 enable_mod_rewrite
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
56
 send_test_email
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
2
 webpush_enable
0.00% covered (danger)
0.00%
0 / 33
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14/**
15* @todo add cron intervals to server settings? (database_gc, queue_interval, session_gc, search_gc, cache_gc, warnings_gc)
16*/
17
18/**
19* @ignore
20*/
21
22use Minishlink\WebPush\VAPID;
23use phpbb\config\config;
24use phpbb\language\language;
25use phpbb\user;
26
27if (!defined('IN_PHPBB'))
28{
29    exit;
30}
31
32class acp_board
33{
34    var $u_action;
35    var $new_config;
36
37    /** @var config */
38    protected $config;
39
40    /** @var language */
41    protected $language;
42
43    /** @var user */
44    protected $user;
45
46    function main($id, $mode)
47    {
48        global $user, $template, $request, $language;
49        global $config, $phpbb_root_path, $phpEx;
50        global $cache, $phpbb_container, $phpbb_dispatcher, $phpbb_log;
51
52        $this->config = $config;
53        $this->language = $language;
54        $this->user = $user;
55
56        $this->language->add_lang('acp/board');
57
58        $submit = (isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable'])) ? true : false;
59
60        $form_key = 'acp_board';
61        add_form_key($form_key);
62
63        /**
64        *    Validation types are:
65        *        string, int, bool,
66        *        script_path (absolute path in url - beginning with / and no trailing slash),
67        *        rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable)
68        */
69        switch ($mode)
70        {
71            case 'settings':
72                $display_vars = array(
73                    'title'    => 'ACP_BOARD_SETTINGS',
74                    'vars'    => array(
75                        'legend1'                => 'ACP_BOARD_SETTINGS',
76                        'sitename'                => array('lang' => 'SITE_NAME',                'validate' => 'string',    'type' => 'text:40:255', 'explain' => false),
77                        'site_desc'                => array('lang' => 'SITE_DESC',                'validate' => 'string',    'type' => 'text:40:255', 'explain' => false),
78                        'site_home_url'            => array('lang' => 'SITE_HOME_URL',            'validate' => 'url',    'type' => 'url:40:255', 'explain' => true),
79                        'site_home_text'        => array('lang' => 'SITE_HOME_TEXT',        'validate' => 'string',    'type' => 'text:40:255', 'explain' => true),
80                        'board_index_text'        => array('lang' => 'BOARD_INDEX_TEXT',        'validate' => 'string',    'type' => 'text:40:255', 'explain' => true),
81                        'sitename_short'        => array('lang' => 'SITE_NAME_SHORT',        'validate' => 'string',    'type' => 'text:40:12', 'explain' => true),
82                        'board_disable'            => array('lang' => 'DISABLE_BOARD',            'validate' => 'bool',    'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
83                        'board_disable_msg'        => false,
84                        'board_disable_access'    => array('lang' => 'DISABLE_BOARD_ACCESS',     'validate' => 'int',    'type' => 'select', 'method' => 'board_disable_access', 'explain' => true),
85                        'default_lang'            => array('lang' => 'DEFAULT_LANGUAGE',        'validate' => 'lang',    'type' => 'select', 'method' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false),
86                        'default_dateformat'    => array('lang' => 'DEFAULT_DATE_FORMAT',    'validate' => 'string',    'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true),
87                        'board_timezone'        => array('lang' => 'SYSTEM_TIMEZONE',        'validate' => 'timezone',    'type' => 'custom', 'method' => 'timezone_select', 'explain' => true),
88
89                        'legend2'                => 'BOARD_STYLE',
90                        'default_style'            => array('lang' => 'DEFAULT_STYLE',            'validate' => 'int',    'type' => 'select', 'method' => 'phpbb_style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true),
91                        'guest_style'            => array('lang' => 'GUEST_STYLE',            'validate' => 'int',    'type' => 'select', 'method' => 'phpbb_style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true),
92                        'override_user_style'    => array('lang' => 'OVERRIDE_STYLE',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
93
94                        'legend3'                => 'WARNINGS',
95                        'warnings_expire_days'    => array('lang' => 'WARNINGS_EXPIRE',        'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
96
97                        'legend4'                => 'ACP_SUBMIT_CHANGES',
98                    )
99                );
100            break;
101
102            case 'features':
103                $display_vars = array(
104                    'title'    => 'ACP_BOARD_FEATURES',
105                    'vars'    => array(
106                        'legend1'                        => 'ACP_BOARD_FEATURES',
107                        'allow_privmsg'                    => array('lang' => 'BOARD_PM',                        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
108                        'allow_topic_notify'            => array('lang' => 'ALLOW_TOPIC_NOTIFY',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
109                        'allow_forum_notify'            => array('lang' => 'ALLOW_FORUM_NOTIFY',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
110                        'allow_namechange'                => array('lang' => 'ALLOW_NAME_CHANGE',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
111                        'allow_attachments'                => array('lang' => 'ALLOW_ATTACHMENTS',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
112                        'allow_pm_attach'                => array('lang' => 'ALLOW_PM_ATTACHMENTS',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
113                        'allow_pm_report'                => array('lang' => 'ALLOW_PM_REPORT',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
114                        'allow_bbcode'                    => array('lang' => 'ALLOW_BBCODE',                    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
115                        'allow_smilies'                    => array('lang' => 'ALLOW_SMILIES',                    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
116                        'allow_sig'                        => array('lang' => 'ALLOW_SIG',                        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
117                        'allow_board_notifications'        => array('lang' => 'ALLOW_BOARD_NOTIFICATIONS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
118
119                        'allow_nocensors'                => array('lang' => 'ALLOW_NO_CENSORS',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
120                        'allow_bookmarks'                => array('lang' => 'ALLOW_BOOKMARKS',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
121                        'allow_birthdays'                => array('lang' => 'ALLOW_BIRTHDAYS',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
122                        'display_last_subject'            => array('lang' => 'DISPLAY_LAST_SUBJECT',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
123                        'display_unapproved_posts'        => array('lang' => 'DISPLAY_UNAPPROVED_POSTS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
124                        'allow_quick_reply'                => array('lang' => 'ALLOW_QUICK_REPLY',                'validate' => 'bool',    'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),
125
126                        'legend2'                        => 'ACP_SUBMIT_CHANGES',
127                    )
128                );
129            break;
130
131            case 'avatar':
132                /* @var $phpbb_avatar_manager \phpbb\avatar\manager */
133                $phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
134                $avatar_drivers = $phpbb_avatar_manager->get_all_drivers();
135
136                $avatar_vars = array();
137                foreach ($avatar_drivers as $current_driver)
138                {
139                    /** @var \phpbb\avatar\driver\driver_interface $driver */
140                    $driver = $phpbb_avatar_manager->get_driver($current_driver, false);
141
142                    /*
143                    * First grab the settings for enabling/disabling the avatar
144                    * driver and afterwards grab additional settings the driver
145                    * might have.
146                    */
147                    $avatar_vars += $phpbb_avatar_manager->get_avatar_settings($driver);
148                    $avatar_vars += $driver->prepare_form_acp($user);
149                }
150
151                $display_vars = array(
152                    'title'    => 'ACP_AVATAR_SETTINGS',
153                    'vars'    => array(
154                        'legend1'                => 'ACP_AVATAR_SETTINGS',
155                        'avatar_min_width'        => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false),
156                        'avatar_min_height'        => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false),
157                        'avatar_max_width'        => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false),
158                        'avatar_max_height'        => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false),
159                        'allow_avatar'            => array('lang' => 'ALLOW_AVATARS',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
160                        'avatar_min'            => array('lang' => 'MIN_AVATAR_SIZE',        'validate' => 'int:0',    'type' => 'dimension:0', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
161                        'avatar_max'            => array('lang' => 'MAX_AVATAR_SIZE',        'validate' => 'int:0',    'type' => 'dimension:0', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
162                    )
163                );
164
165                if (!empty($avatar_vars))
166                {
167                    $display_vars['vars'] += $avatar_vars;
168                }
169
170                $display_vars['vars']['legend2'] = 'ACP_SUBMIT_CHANGES';
171            break;
172
173            case 'message':
174                $display_vars = array(
175                    'title'    => 'ACP_MESSAGE_SETTINGS',
176                    'lang'    => 'ucp',
177                    'vars'    => array(
178                        'legend1'                => 'GENERAL_SETTINGS',
179                        'allow_privmsg'            => array('lang' => 'BOARD_PM',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
180                        'pm_max_boxes'            => array('lang' => 'BOXES_MAX',                'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true),
181                        'pm_max_msgs'            => array('lang' => 'BOXES_LIMIT',            'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true),
182                        'full_folder_action'    => array('lang' => 'FULL_FOLDER_ACTION',    'validate' => 'int',    'type' => 'select', 'method' => 'full_folder_select', 'explain' => true),
183                        'pm_edit_time'            => array('lang' => 'PM_EDIT_TIME',            'validate' => 'int:0:99999',    'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
184                        'pm_max_recipients'        => array('lang' => 'PM_MAX_RECIPIENTS',        'validate' => 'int:0:99999',    'type' => 'number:0:99999', 'explain' => true),
185
186                        'legend2'                => 'GENERAL_OPTIONS',
187                        'allow_mass_pm'            => array('lang' => 'ALLOW_MASS_PM',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
188                        'auth_bbcode_pm'        => array('lang' => 'ALLOW_BBCODE_PM',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
189                        'auth_smilies_pm'        => array('lang' => 'ALLOW_SMILIES_PM',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
190                        'allow_pm_attach'        => array('lang' => 'ALLOW_PM_ATTACHMENTS',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
191                        'allow_sig_pm'            => array('lang' => 'ALLOW_SIG_PM',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
192                        'print_pm'                => array('lang' => 'ALLOW_PRINT_PM',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
193                        'forward_pm'            => array('lang' => 'ALLOW_FORWARD_PM',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
194                        'auth_img_pm'            => array('lang' => 'ALLOW_IMG_PM',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
195                        'enable_pm_icons'        => array('lang' => 'ENABLE_PM_ICONS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
196
197                        'legend3'                => 'ACP_SUBMIT_CHANGES',
198                    )
199                );
200            break;
201
202            case 'post':
203                $display_vars = array(
204                    'title'    => 'ACP_POST_SETTINGS',
205                    'vars'    => array(
206                        'legend1'                => 'GENERAL_OPTIONS',
207                        'allow_topic_notify'    => array('lang' => 'ALLOW_TOPIC_NOTIFY',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
208                        'allow_forum_notify'    => array('lang' => 'ALLOW_FORUM_NOTIFY',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
209                        'allow_bbcode'            => array('lang' => 'ALLOW_BBCODE',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
210                        'allow_smilies'            => array('lang' => 'ALLOW_SMILIES',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
211                        'allow_post_links'        => array('lang' => 'ALLOW_POST_LINKS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
212                        'allowed_schemes_links'    => array('lang' => 'ALLOWED_SCHEMES_LINKS',    'validate' => 'csv',    'type' => 'text:0:255', 'explain' => true),
213                        'allow_nocensors'        => array('lang' => 'ALLOW_NO_CENSORS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
214                        'allow_bookmarks'        => array('lang' => 'ALLOW_BOOKMARKS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
215                        'enable_post_confirm'    => array('lang' => 'VISUAL_CONFIRM_POST',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
216                        'allow_quick_reply'        => array('lang' => 'ALLOW_QUICK_REPLY',        'validate' => 'bool',    'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),
217
218                        'legend2'                => 'POSTING',
219                        'bump_type'                => false,
220                        'edit_time'                => array('lang' => 'EDIT_TIME',                'validate' => 'int:0:99999',        'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
221                        'delete_time'            => array('lang' => 'DELETE_TIME',            'validate' => 'int:0:99999',        'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
222                        'display_last_edited'    => array('lang' => 'DISPLAY_LAST_EDITED',    'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
223                        'flood_interval'        => array('lang' => 'FLOOD_INTERVAL',        'validate' => 'int:0:9999999999',        'type' => 'number:0:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
224                        'bump_interval'            => array('lang' => 'BUMP_INTERVAL',            'validate' => 'int:0',        'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
225                        'topics_per_page'        => array('lang' => 'TOPICS_PER_PAGE',        'validate' => 'int:1:9999',        'type' => 'number:1:9999', 'explain' => false),
226                        'posts_per_page'        => array('lang' => 'POSTS_PER_PAGE',        'validate' => 'int:1:9999',        'type' => 'number:1:9999', 'explain' => false),
227                        'smilies_per_page'        => array('lang' => 'SMILIES_PER_PAGE',        'validate' => 'int:1:9999',        'type' => 'number:1:9999', 'explain' => false),
228                        'hot_threshold'            => array('lang' => 'HOT_THRESHOLD',            'validate' => 'int:0:9999',        'type' => 'number:0:9999', 'explain' => true),
229                        'max_poll_options'        => array('lang' => 'MAX_POLL_OPTIONS',        'validate' => 'int:2:127',    'type' => 'number:2:127', 'explain' => false),
230                        'max_post_chars'        => array('lang' => 'CHAR_LIMIT',            'validate' => 'int:0:999999',        'type' => 'number:0:999999', 'explain' => true),
231                        'min_post_chars'        => array('lang' => 'MIN_CHAR_LIMIT',        'validate' => 'int:1:999999',        'type' => 'number:1:999999', 'explain' => true),
232                        'max_post_smilies'        => array('lang' => 'SMILIES_LIMIT',            'validate' => 'int:0:9999',        'type' => 'number:0:9999', 'explain' => true),
233                        'max_post_urls'            => array('lang' => 'MAX_POST_URLS',            'validate' => 'int:0:9999',        'type' => 'number:0:9999', 'explain' => true),
234                        'max_post_font_size'    => array('lang' => 'MAX_POST_FONT_SIZE',    'validate' => 'int:0:9999',        'type' => 'number:0:9999', 'explain' => true, 'append' => ' %'),
235                        'max_quote_depth'        => array('lang' => 'QUOTE_DEPTH_LIMIT',        'validate' => 'int:0:9999',        'type' => 'number:0:9999', 'explain' => true),
236
237                        'legend3'                => 'MENTIONS',
238                        'allow_mentions'        => array('lang' => 'ALLOW_MENTIONS',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
239                        'mention_names_limit'    => array('lang' => 'MENTION_NAMES_LIMIT',    'validate' => 'int:1:9999',        'type' => 'number:1:9999', 'explain' => false),
240                        'mention_batch_size'    => array('lang' => 'MENTION_BATCH_SIZE',    'validate' => 'int:1:9999',        'type' => 'number:1:9999', 'explain' => true),
241
242                        'legend4'                => 'ACP_SUBMIT_CHANGES',
243                    )
244                );
245            break;
246
247            case 'signature':
248                $display_vars = array(
249                    'title'    => 'ACP_SIGNATURE_SETTINGS',
250                    'vars'    => array(
251                        'legend1'                => 'GENERAL_OPTIONS',
252                        'allow_sig'                => array('lang' => 'ALLOW_SIG',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
253                        'allow_sig_bbcode'        => array('lang' => 'ALLOW_SIG_BBCODE',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
254                        'allow_sig_img'            => array('lang' => 'ALLOW_SIG_IMG',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
255                        'allow_sig_smilies'        => array('lang' => 'ALLOW_SIG_SMILIES',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
256                        'allow_sig_links'        => array('lang' => 'ALLOW_SIG_LINKS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
257
258                        'legend2'                => 'GENERAL_SETTINGS',
259                        'max_sig_chars'            => array('lang' => 'MAX_SIG_LENGTH',        'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true),
260                        'max_sig_urls'            => array('lang' => 'MAX_SIG_URLS',            'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true),
261                        'max_sig_font_size'        => array('lang' => 'MAX_SIG_FONT_SIZE',        'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true, 'append' => ' %'),
262                        'max_sig_smilies'        => array('lang' => 'MAX_SIG_SMILIES',        'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true),
263                        'max_sig_img_width'        => array('lang' => 'MAX_SIG_IMG_WIDTH',        'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
264                        'max_sig_img_height'    => array('lang' => 'MAX_SIG_IMG_HEIGHT',    'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
265
266                        'legend3'                => 'ACP_SUBMIT_CHANGES',
267                    )
268                );
269            break;
270
271            case 'registration':
272                $display_vars = array(
273                    'title'    => 'ACP_REGISTER_SETTINGS',
274                    'vars'    => array(
275                        'legend1'                => 'GENERAL_SETTINGS',
276                        'max_name_chars'        => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:8:180', 'type' => false, 'method' => false, 'explain' => false,),
277
278                        'require_activation'    => array('lang' => 'ACC_ACTIVATION',    'validate' => 'int',    'type' => 'select', 'method' => 'select_acc_activation', 'explain' => true),
279                        'new_member_post_limit'    => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'number:0:255', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']),
280                        'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
281                        'min_name_chars'        => array('lang' => 'USERNAME_LENGTH',    'validate' => 'int:1',    'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true),
282                        'min_pass_chars'        => array('lang' => 'PASSWORD_LENGTH',    'validate' => 'int:1',    'type' => 'custom', 'method' => 'password_length', 'explain' => true),
283                        'allow_name_chars'        => array('lang' => 'USERNAME_CHARS',    'validate' => 'string',    'type' => 'select', 'method' => 'select_username_chars', 'explain' => true),
284                        'pass_complex'            => array('lang' => 'PASSWORD_TYPE',        'validate' => 'string',    'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
285                        'chg_passforce'            => array('lang' => 'FORCE_PASS_CHANGE',    'validate' => 'int:0:999',    'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
286
287                        'legend2'                => 'GENERAL_OPTIONS',
288                        'allow_namechange'        => array('lang' => 'ALLOW_NAME_CHANGE',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
289                        'allow_emailreuse'        => array('lang' => 'ALLOW_EMAIL_REUSE',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
290                        'enable_confirm'        => array('lang' => 'VISUAL_CONFIRM_REG',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
291                        'max_login_attempts'    => array('lang' => 'MAX_LOGIN_ATTEMPTS',    'validate' => 'int:0:999',    'type' => 'number:0:999', 'explain' => true),
292                        'max_reg_attempts'        => array('lang' => 'REG_LIMIT',                'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true),
293
294                        'legend3'            => 'COPPA',
295                        'coppa_enable'        => array('lang' => 'ENABLE_COPPA',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
296                        'coppa_mail'        => array('lang' => 'COPPA_MAIL',        'validate' => 'string',    'type' => 'textarea:5:40', 'explain' => true),
297                        'coppa_fax'            => array('lang' => 'COPPA_FAX',            'validate' => 'string',    'type' => 'text:25:100', 'explain' => false),
298
299                        'legend4'            => 'ACP_SUBMIT_CHANGES',
300                    )
301                );
302            break;
303
304            case 'feed':
305                $display_vars = array(
306                    'title'    => 'ACP_FEED_MANAGEMENT',
307                    'vars'    => array(
308                        'legend1'                    => 'ACP_FEED_GENERAL',
309                        'feed_enable'                => array('lang' => 'ACP_FEED_ENABLE',                'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true ),
310                        'feed_item_statistics'        => array('lang' => 'ACP_FEED_ITEM_STATISTICS',        'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true),
311                        'feed_http_auth'            => array('lang' => 'ACP_FEED_HTTP_AUTH',            'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true),
312
313                        'legend2'                    => 'ACP_FEED_POST_BASED',
314                        'feed_limit_post'            => array('lang' => 'ACP_FEED_LIMIT',                'validate' => 'int:5:9999',    'type' => 'number:5:9999',                'explain' => true),
315                        'feed_overall'                => array('lang' => 'ACP_FEED_OVERALL',                'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true ),
316                        'feed_forum'                => array('lang' => 'ACP_FEED_FORUM',                'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true ),
317                        'feed_topic'                => array('lang' => 'ACP_FEED_TOPIC',                'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true ),
318
319                        'legend3'                    => 'ACP_FEED_TOPIC_BASED',
320                        'feed_limit_topic'            => array('lang' => 'ACP_FEED_LIMIT',                'validate' => 'int:5:9999',    'type' => 'number:5:9999',                'explain' => true),
321                        'feed_topics_new'            => array('lang' => 'ACP_FEED_TOPICS_NEW',            'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true ),
322                        'feed_topics_active'        => array('lang' => 'ACP_FEED_TOPICS_ACTIVE',        'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true ),
323                        'feed_news_id'                => array('lang' => 'ACP_FEED_NEWS',                    'validate' => 'string',    'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true),
324
325                        'legend4'                    => 'ACP_FEED_SETTINGS_OTHER',
326                        'feed_overall_forums'        => array('lang'    => 'ACP_FEED_OVERALL_FORUMS',        'validate' => 'bool',    'type' => 'radio:enabled_disabled',    'explain' => true ),
327                        'feed_exclude_id'            => array('lang' => 'ACP_FEED_EXCLUDE_ID',            'validate' => 'string',    'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true),
328
329                        'legend5'                    => 'ACP_SUBMIT_CHANGES',
330                    )
331                );
332            break;
333
334            case 'cookie':
335                $display_vars = array(
336                    'title'    => 'ACP_COOKIE_SETTINGS',
337                    'vars'    => array(
338                        'legend1'        => 'ACP_COOKIE_SETTINGS',
339                        'cookie_domain'    => array('lang' => 'COOKIE_DOMAIN',    'validate' => 'string',    'type' => 'text::255', 'explain' => true),
340                        'cookie_name'    => array('lang' => 'COOKIE_NAME',    'validate' => 'string',    'type' => 'text::16', 'explain' => true),
341                        'cookie_path'    => array('lang'    => 'COOKIE_PATH',    'validate' => 'string',    'type' => 'text::255', 'explain' => true),
342                        'cookie_secure'    => array('lang' => 'COOKIE_SECURE',    'validate' => 'bool',    'type' => 'radio:enabled_disabled', 'explain' => true),
343                        'cookie_notice'    => array('lang' => 'COOKIE_NOTICE',    'validate' => 'bool',    'type' => 'radio:enabled_disabled', 'explain' => true),
344
345                        'legend2'        => 'ACP_SUBMIT_CHANGES',
346                    )
347                );
348            break;
349
350            case 'load':
351                $display_vars = array(
352                    'title'    => 'ACP_LOAD_SETTINGS',
353                    'vars'    => array(
354                        'legend1'            => 'GENERAL_SETTINGS',
355                        'limit_load'        => array('lang' => 'LIMIT_LOAD',        'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true),
356                        'session_length'    => array('lang' => 'SESSION_LENGTH',    'validate' => 'int:60:9999999999',    'type' => 'number:60:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
357                        'active_sessions'    => array('lang' => 'LIMIT_SESSIONS',    'validate' => 'int:0:9999',    'type' => 'number:0:9999', 'explain' => true),
358                        'load_online_time'    => array('lang' => 'ONLINE_LENGTH',        'validate' => 'int:0:999',    'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
359                        'read_notification_expire_days'    => array('lang' => 'READ_NOTIFICATION_EXPIRE_DAYS',    'validate' => 'int:0',    'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
360
361                        'legend2'                => 'GENERAL_OPTIONS',
362                        'load_notifications'    => array('lang' => 'LOAD_NOTIFICATIONS',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
363                        'load_db_track'            => array('lang' => 'YES_POST_MARKING',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
364                        'load_db_lastread'        => array('lang' => 'YES_READ_MARKING',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
365                        'load_anon_lastread'    => array('lang' => 'YES_ANON_READ_MARKING',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
366                        'load_online'            => array('lang' => 'YES_ONLINE',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
367                        'load_online_guests'    => array('lang' => 'YES_ONLINE_GUESTS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
368                        'load_onlinetrack'        => array('lang' => 'YES_ONLINE_TRACK',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
369                        'load_birthdays'        => array('lang' => 'YES_BIRTHDAYS',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
370                        'load_unreads_search'    => array('lang' => 'YES_UNREAD_SEARCH',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
371                        'load_moderators'        => array('lang' => 'YES_MODERATORS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
372                        'load_jumpbox'            => array('lang' => 'YES_JUMPBOX',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
373                        'load_user_activity'    => array('lang' => 'LOAD_USER_ACTIVITY',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
374                        'load_user_activity_limit'        => array('lang' => 'LOAD_USER_ACTIVITY_LIMIT',        'validate' => 'int:0:99999999',    'type' => 'number:0:99999999', 'explain' => true),
375                        'load_tplcompile'        => array('lang' => 'RECOMPILE_STYLES',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
376                        'allow_cdn'                => array('lang' => 'ALLOW_CDN',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
377                        'enable_accurate_pm_button'    => array('lang' => 'YES_ACCURATE_PM_BUTTON',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
378                        'allow_live_searches'    => array('lang' => 'ALLOW_LIVE_SEARCHES',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
379
380                        'legend3'                => 'CUSTOM_PROFILE_FIELDS',
381                        'load_cpf_memberlist'    => array('lang' => 'LOAD_CPF_MEMBERLIST',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
382                        'load_cpf_pm'            => array('lang' => 'LOAD_CPF_PM',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain'    => false),
383                        'load_cpf_viewprofile'    => array('lang' => 'LOAD_CPF_VIEWPROFILE',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
384                        'load_cpf_viewtopic'    => array('lang' => 'LOAD_CPF_VIEWTOPIC',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => false),
385
386                        'legend4'                => 'ACP_SUBMIT_CHANGES',
387                    )
388                );
389            break;
390
391            case 'auth':
392                $display_vars = array(
393                    'title'    => 'ACP_AUTH_SETTINGS',
394                    'vars'    => array(
395                        'legend1'        => 'ACP_AUTH_SETTINGS',
396                        'auth_method'    => array('lang' => 'AUTH_METHOD',    'validate' => 'string',    'type' => 'select:1:toggleable', 'method' => 'select_auth_method', 'explain' => false),
397                    )
398                );
399            break;
400
401            case 'server':
402                $display_vars = array(
403                    'title'    => 'ACP_SERVER_SETTINGS',
404                    'vars'    => array(
405                        'legend1'                => 'ACP_SERVER_SETTINGS',
406                        'gzip_compress'            => array('lang' => 'ENABLE_GZIP',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
407                        'use_system_cron'        => array('lang' => 'USE_SYSTEM_CRON',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
408
409                        'legend2'                => 'PATH_SETTINGS',
410                        'enable_mod_rewrite'    => array('lang' => 'MOD_REWRITE_ENABLE',    'validate' => 'bool',    'type' => 'custom', 'method' => 'enable_mod_rewrite', 'explain' => true),
411                        'smilies_path'            => array('lang' => 'SMILIES_PATH',        'validate' => 'rpath',    'type' => 'text:20:255', 'explain' => true),
412                        'icons_path'            => array('lang' => 'ICONS_PATH',        'validate' => 'rpath',    'type' => 'text:20:255', 'explain' => true),
413                        'upload_icons_path'        => array('lang' => 'UPLOAD_ICONS_PATH',    'validate' => 'rpath',    'type' => 'text:20:255', 'explain' => true),
414                        'ranks_path'            => array('lang' => 'RANKS_PATH',        'validate' => 'rpath',    'type' => 'text:20:255', 'explain' => true),
415
416                        'legend3'                => 'SERVER_URL_SETTINGS',
417                        'force_server_vars'        => array('lang' => 'FORCE_SERVER_VARS',    'validate' => 'bool',            'type' => 'radio:yes_no', 'explain' => true),
418                        'server_protocol'        => array('lang' => 'SERVER_PROTOCOL',    'validate' => 'string',            'type' => 'text:10:10', 'explain' => true),
419                        'server_name'            => array('lang' => 'SERVER_NAME',        'validate' => 'string',            'type' => 'text:40:255', 'explain' => true),
420                        'server_port'            => array('lang' => 'SERVER_PORT',        'validate' => 'int:0:99999',            'type' => 'number:0:99999', 'explain' => true),
421                        'script_path'            => array('lang' => 'SCRIPT_PATH',        'validate' => 'script_path',    'type' => 'text::255', 'explain' => true),
422
423                        'legend4'                => 'ACP_SUBMIT_CHANGES',
424                    )
425                );
426            break;
427
428            case 'security':
429                $display_vars = array(
430                    'title'    => 'ACP_SECURITY_SETTINGS',
431                    'vars'    => array(
432                        'legend1'                => 'ACP_SECURITY_SETTINGS',
433                        'allow_autologin'        => array('lang' => 'ALLOW_AUTOLOGIN',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
434                        'allow_password_reset'    => array('lang' => 'ALLOW_PASSWORD_RESET',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
435                        'max_autologin_time'    => array('lang' => 'AUTOLOGIN_LENGTH',        'validate' => 'int:0:99999',    'type' => 'number:0:99999',    'explain' => true,    'append' => ' ' . $user->lang['DAYS']),
436                        'ip_check'                => array('lang' => 'IP_VALID',                'validate' => 'int',    'type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION']], 'explain' => true),
437                        'browser_check'            => array('lang' => 'BROWSER_VALID',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
438                        'forwarded_for_check'    => array('lang' => 'FORWARDED_FOR_VALID',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
439                        'referer_validation'    => array('lang' => 'REFERRER_VALID',        'validate' => 'int:0:3','type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION']], 'explain' => true),
440                        'check_dnsbl'            => array('lang' => 'CHECK_DNSBL',            'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
441                        'email_check_mx'        => array('lang' => 'EMAIL_CHECK_MX',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
442                        'min_pass_chars'        => array('lang' => 'PASSWORD_LENGTH',    'validate' => 'int:1',    'type' => 'custom', 'method' => 'password_length', 'explain' => true),
443                        'pass_complex'            => array('lang' => 'PASSWORD_TYPE',            'validate' => 'string',    'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
444                        'chg_passforce'            => array('lang' => 'FORCE_PASS_CHANGE',        'validate' => 'int:0:999',    'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
445                        'max_login_attempts'    => array('lang' => 'MAX_LOGIN_ATTEMPTS',    'validate' => 'int:0:999',    'type' => 'number:0:999', 'explain' => true),
446                        'ip_login_limit_max'    => array('lang' => 'IP_LOGIN_LIMIT_MAX',    'validate' => 'int:0:999',    'type' => 'number:0:999', 'explain' => true),
447                        'ip_login_limit_time'    => array('lang' => 'IP_LOGIN_LIMIT_TIME',    'validate' => 'int:0:99999',    'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
448                        'ip_login_limit_use_forwarded'    => array('lang' => 'IP_LOGIN_LIMIT_USE_FORWARDED',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
449                        'form_token_lifetime'    => array('lang' => 'FORM_TIME_MAX',            'validate' => 'int:-1:99999',    'type' => 'number:-1:99999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
450                        'form_token_sid_guests'    => array('lang' => 'FORM_SID_GUESTS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
451
452                        'legend2'                => 'ACP_SUBMIT_CHANGES',
453                    )
454                );
455            break;
456
457            case 'email':
458                $display_vars = array(
459                    'title'    => 'ACP_EMAIL_SETTINGS',
460                    'vars'    => array(
461                        'legend1'                => 'GENERAL_SETTINGS',
462                        'email_enable'            => array('lang' => 'ENABLE_EMAIL',            'validate' => 'bool',    'type' => 'radio:enabled_disabled', 'explain' => true),
463                        'board_email_form'        => array('lang' => 'BOARD_EMAIL_FORM',        'validate' => 'bool',    'type' => 'radio:enabled_disabled', 'explain' => true),
464                        'email_package_size'    => array('lang' => 'EMAIL_PACKAGE_SIZE',    'validate' => 'int:0',    'type' => 'number:0:99999', 'explain' => true),
465                        'email_max_chunk_size'    => array('lang' => 'EMAIL_MAX_CHUNK_SIZE',    'validate' => 'int:1:99999',    'type' => 'number:1:99999', 'explain' => true),
466                        'board_contact'            => array('lang' => 'CONTACT_EMAIL',            'validate' => 'email',    'type' => 'email:25:100', 'explain' => true),
467                        'board_contact_name'    => array('lang' => 'CONTACT_EMAIL_NAME',    'validate' => 'string',    'type' => 'text:25:50', 'explain' => true),
468                        'board_email'            => array('lang' => 'ADMIN_EMAIL',            'validate' => 'email',    'type' => 'email:25:100', 'explain' => true),
469                        'email_force_sender'    => array('lang' => 'EMAIL_FORCE_SENDER',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
470                        'board_email_sig'        => array('lang' => 'EMAIL_SIG',                'validate' => 'string',    'type' => 'textarea:5:30', 'explain' => true),
471                        'board_hide_emails'        => array('lang' => 'BOARD_HIDE_EMAILS',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
472                        'send_test_email'        => array('lang' => 'SEND_TEST_EMAIL',        'validate' => 'bool',    'type' => 'custom', 'method' => 'send_test_email', 'explain' => true),
473
474                        'legend2'                => 'SMTP_SETTINGS',
475                        'smtp_delivery'            => array('lang' => 'USE_SMTP',                'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
476                        'smtp_host'                => array('lang' => 'SMTP_SERVER',            'validate' => 'string',    'type' => 'text:25:50', 'explain' => true),
477                        'smtp_port'                => array('lang' => 'SMTP_PORT',                'validate' => 'int:0:99999',    'type' => 'number:0:99999', 'explain' => true),
478                        'smtp_auth_method'        => array('lang' => 'SMTP_AUTH_METHOD',        'validate' => 'string',    'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true),
479                        'smtp_username'            => array('lang' => 'SMTP_USERNAME',            'validate' => 'string',    'type' => 'text:25:255', 'explain' => true),
480                        'smtp_password'            => array('lang' => 'SMTP_PASSWORD',            'validate' => 'string',    'type' => 'password:25:255', 'explain' => true),
481                        'smtp_verify_peer'        => array('lang' => 'SMTP_VERIFY_PEER',        'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
482                        'smtp_verify_peer_name'    => array('lang' => 'SMTP_VERIFY_PEER_NAME',    'validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
483                        'smtp_allow_self_signed'=> array('lang' => 'SMTP_ALLOW_SELF_SIGNED','validate' => 'bool',    'type' => 'radio:yes_no', 'explain' => true),
484
485                        'legend3'                => 'ACP_SUBMIT_CHANGES',
486                    )
487                );
488            break;
489
490            case 'webpush':
491                $display_vars = [
492                    'title'        => 'ACP_WEBPUSH_SETTINGS',
493                    'vars'         => [
494                        'legend1'                    => 'GENERAL_SETTINGS',
495                        'webpush_enable'            => ['lang' => 'WEBPUSH_ENABLE', 'validate' => 'bool', 'type' => 'custom', 'method' => 'webpush_enable', 'explain' => true],
496                        'webpush_vapid_public'        => ['lang' => 'WEBPUSH_VAPID_PUBLIC', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true],
497                        'webpush_vapid_private'        => ['lang' => 'WEBPUSH_VAPID_PRIVATE', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true],
498                        'webpush_method_default_enable'    => ['lang' => 'WEBPUSH_METHOD_DEFAULT_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true],
499                        'webpush_dropdown_subscribe'    => ['lang' => 'WEBPUSH_DROPDOWN_SUBSCRIBE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true],
500
501                        'legend3'                => 'ACP_SUBMIT_CHANGES',
502                    ],
503                ];
504            break;
505
506            default:
507                trigger_error('NO_MODE', E_USER_ERROR);
508            break;
509        }
510
511        /**
512        * Event to add and/or modify acp_board configurations
513        *
514        * @event core.acp_board_config_edit_add
515        * @var    array    display_vars    Array of config values to display and process
516        * @var    string    mode            Mode of the config page we are displaying
517        * @var    boolean    submit            Do we display the form or process the submission
518        * @since 3.1.0-a4
519        */
520        $vars = array('display_vars', 'mode', 'submit');
521        extract($phpbb_dispatcher->trigger_event('core.acp_board_config_edit_add', compact($vars)));
522
523        if (isset($display_vars['lang']))
524        {
525            $user->add_lang($display_vars['lang']);
526        }
527
528        $this->new_config = clone $config;
529        $cfg_array = (isset($_REQUEST['config'])) ? $request->variable('config', array('' => ''), true) : $this->new_config;
530        $error = array();
531
532        // Prevalidate allowed URL schemes
533        if ($mode == 'post')
534        {
535            $schemes = array_filter(explode(',', $cfg_array['allowed_schemes_links']));
536            foreach ($schemes as $scheme)
537            {
538                if (!preg_match('#^[a-z][a-z0-9+\\-.]*$#Di', $scheme))
539                {
540                    $error[] = $this->language->lang('URL_SCHEME_INVALID', $this->language->lang('ALLOWED_SCHEMES_LINKS'), $scheme);
541                }
542            }
543        }
544
545        // We validate the complete config if wished
546        validate_config_vars($display_vars['vars'], $cfg_array, $error);
547
548        if ($submit && !check_form_key($form_key))
549        {
550            $error[] = $user->lang['FORM_INVALID'];
551        }
552        // Do not write values if there is an error
553        if (count($error))
554        {
555            $submit = false;
556        }
557
558        // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
559        foreach ($display_vars['vars'] as $config_name => $data)
560        {
561            if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
562            {
563                continue;
564            }
565
566            if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id')
567            {
568                continue;
569            }
570
571            if ($config_name == 'guest_style')
572            {
573                if (isset($cfg_array[$config_name]))
574                {
575                    $this->guest_style_set($cfg_array[$config_name]);
576                }
577                continue;
578            }
579
580            $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
581
582            if ($submit)
583            {
584                if (isset($data['type']) && strpos($data['type'], 'password') === 0 && $config_value === '********')
585                {
586                    /**
587                     * Do not update password fields if the content is ********,
588                     * because that is the password replacement we use to not
589                     * send the password to the output
590                     */
591                    continue;
592                }
593
594                // Array of emoji-enabled configurations
595                $config_name_ary = [
596                    'sitename',
597                    'sitename_short',
598                    'site_desc',
599                    'site_home_text',
600                    'board_index_text',
601                    'board_disable_msg',
602                    'board_email_sig',
603                ];
604
605                /**
606                 * Event to manage the array of emoji-enabled configurations
607                 *
608                 * @event core.acp_board_config_emoji_enabled
609                 * @var array    config_name_ary        Array of config names to process
610                 * @since 3.3.3-RC1
611                 */
612                $vars = ['config_name_ary'];
613                extract($phpbb_dispatcher->trigger_event('core.acp_board_config_emoji_enabled', compact($vars)));
614
615                if (in_array($config_name, $config_name_ary))
616                {
617                    /**
618                     * Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR.
619                     * Using their Numeric Character Reference's Hexadecimal notation.
620                     */
621                    $config->set($config_name, utf8_encode_ucr($config_value));
622                }
623                else
624                {
625                    $config->set($config_name, $config_value);
626                }
627
628                if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable']))
629                {
630                    enable_bitfield_column_flag(FORUMS_TABLE, 'forum_flags', round(log(FORUM_FLAG_QUICK_REPLY, 2)));
631                }
632            }
633        }
634
635        // Invalidate the text_formatter cache when posting or server options are changed
636        if (preg_match('(^(?:post|server)$)', $mode) && $submit)
637        {
638            $phpbb_container->get('text_formatter.cache')->invalidate();
639        }
640
641        // Store news and exclude ids
642        if ($mode == 'feed' && $submit)
643        {
644            $cache->destroy('_feed_news_forum_ids');
645            $cache->destroy('_feed_excluded_forum_ids');
646
647            $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id');
648            $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id');
649        }
650
651        if ($mode == 'auth')
652        {
653            // Retrieve a list of auth plugins and check their config values
654            /* @var $auth_providers \phpbb\auth\provider_collection */
655            $auth_providers = $phpbb_container->get('auth.provider_collection');
656
657            $updated_auth_settings = false;
658            $old_auth_config = array();
659            foreach ($auth_providers as $provider)
660            {
661                /** @var \phpbb\auth\provider\provider_interface $provider */
662                if ($fields = $provider->acp())
663                {
664                    // Check if we need to create config fields for this plugin and save config when submit was pressed
665                    foreach ($fields as $field)
666                    {
667                        if (!isset($config[$field]))
668                        {
669                            $config->set($field, '');
670                        }
671
672                        if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false)
673                        {
674                            continue;
675                        }
676
677                        if (substr($field, -9) === '_password' && $cfg_array[$field] === '********')
678                        {
679                            // Do not update password fields if the content is ********,
680                            // because that is the password replacement we use to not
681                            // send the password to the output
682                            continue;
683                        }
684
685                        $old_auth_config[$field] = $this->new_config[$field];
686                        $config_value = $cfg_array[$field];
687                        $this->new_config[$field] = $config_value;
688
689                        if ($submit)
690                        {
691                            $updated_auth_settings = true;
692                            $config->set($field, $config_value);
693                        }
694                    }
695                }
696                unset($fields);
697            }
698
699            if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings))
700            {
701                $method = basename($cfg_array['auth_method']);
702                if (array_key_exists('auth.provider.' . $method, (array) $auth_providers))
703                {
704                    $provider = $auth_providers['auth.provider.' . $method];
705                    if ($error = $provider->init())
706                    {
707                        foreach ($old_auth_config as $config_name => $config_value)
708                        {
709                            $config->set($config_name, $config_value);
710                        }
711                        trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
712                    }
713                    $config->set('auth_method', basename($cfg_array['auth_method']));
714                }
715                else
716                {
717                    trigger_error('NO_AUTH_PLUGIN', E_USER_ERROR);
718                }
719            }
720        }
721
722        if ($mode == 'email' && $request->is_set_post('send_test_email'))
723        {
724            if ($config['email_enable'])
725            {
726                include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
727
728                $messenger = new messenger(false);
729                $messenger->template('test');
730                $messenger->set_addresses($user->data);
731                $messenger->anti_abuse_headers($config, $user);
732                $messenger->assign_vars(array(
733                    'USERNAME'    => html_entity_decode($user->data['username'], ENT_COMPAT),
734                    'MESSAGE'    => html_entity_decode($request->variable('send_test_email_text', '', true), ENT_COMPAT),
735                ));
736                $messenger->send(NOTIFY_EMAIL);
737
738                trigger_error($user->lang('TEST_EMAIL_SENT') . adm_back_link($this->u_action));
739            }
740            else
741            {
742                $user->add_lang('memberlist');
743                trigger_error($user->lang('EMAIL_DISABLED') . adm_back_link($this->u_action), E_USER_WARNING);
744            }
745        }
746
747        if ($submit)
748        {
749            $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_' . strtoupper($mode));
750
751            $message = $user->lang('CONFIG_UPDATED');
752            $message_type = E_USER_NOTICE;
753            if (!$config['email_enable'] && in_array($mode, array('email', 'registration')) &&
754                in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN)))
755            {
756                $message .= '<br /><br />' . $user->lang('ACC_ACTIVATION_WARNING');
757                $message_type = E_USER_WARNING;
758            }
759            trigger_error($message . adm_back_link($this->u_action), $message_type);
760        }
761
762        $this->tpl_name = 'acp_board';
763        $this->page_title = $display_vars['title'];
764
765        $template->assign_vars(array(
766            'L_TITLE'            => $user->lang[$display_vars['title']],
767            'L_TITLE_EXPLAIN'    => $user->lang[$display_vars['title'] . '_EXPLAIN'],
768
769            'S_ERROR'            => (count($error)) ? true : false,
770            'ERROR_MSG'            => implode('<br />', $error),
771
772            'U_ACTION'            => $this->u_action)
773        );
774
775        // Output relevant page
776        foreach ($display_vars['vars'] as $config_key => $vars)
777        {
778            if (!is_array($vars) && strpos($config_key, 'legend') === false)
779            {
780                continue;
781            }
782
783            if (strpos($config_key, 'legend') !== false)
784            {
785                $template->assign_block_vars('options', array(
786                    'S_LEGEND'        => true,
787                    'LEGEND'        => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
788                );
789
790                continue;
791            }
792
793            $type = explode(':', $vars['type']);
794
795            $l_explain = '';
796            if ($vars['explain'] && isset($vars['lang_explain']))
797            {
798                $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
799            }
800            else if ($vars['explain'])
801            {
802                $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
803            }
804
805            $content = phpbb_build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
806
807            if (empty($content))
808            {
809                continue;
810            }
811
812            $template->assign_block_vars('options', array(
813                'KEY'            => $config_key,
814                'TITLE'            => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
815                'S_EXPLAIN'        => $vars['explain'] && !empty($l_explain),
816                'TITLE_EXPLAIN'    => $l_explain,
817                'CONTENT'        => $content,
818                )
819            );
820
821            unset($display_vars['vars'][$config_key]);
822        }
823
824        if ($mode == 'auth')
825        {
826            $template->assign_var('S_AUTH', true);
827
828            foreach ($auth_providers as $provider)
829            {
830                $auth_tpl = $provider->get_acp_template($this->new_config);
831                if ($auth_tpl)
832                {
833                    if (array_key_exists('BLOCK_VAR_NAME', $auth_tpl))
834                    {
835                        foreach ($auth_tpl['BLOCK_VARS'] as $block_vars)
836                        {
837                            $template->assign_block_vars($auth_tpl['BLOCK_VAR_NAME'], $block_vars);
838                        }
839                    }
840                    $template->assign_vars($auth_tpl['TEMPLATE_VARS']);
841                    $template->assign_block_vars('auth_tpl', array(
842                        'TEMPLATE_FILE'    => $auth_tpl['TEMPLATE_FILE'],
843                    ));
844                }
845            }
846        }
847    }
848
849    /**
850    * Select auth method
851    */
852    function select_auth_method($selected_method, $key = '')
853    {
854        global $phpbb_container;
855
856        /* @var $auth_providers \phpbb\auth\provider_collection */
857        $auth_providers = $phpbb_container->get('auth.provider_collection');
858        $auth_plugins = [];
859
860        foreach ($auth_providers as $key => $value)
861        {
862            if (!($value instanceof \phpbb\auth\provider\provider_interface))
863            {
864                continue;
865            }
866            $auth_plugins[] = str_replace('auth.provider.', '', $key);
867        }
868
869        sort($auth_plugins);
870
871        $auth_select_options = [];
872        foreach ($auth_plugins as $method)
873        {
874            $auth_select_options[] = [
875                'value'        => $method,
876                'selected'    => $selected_method == $method,
877                'label'        => ucfirst($method),
878                'data'         => [
879                    'toggle-setting' => "#auth_{$method}_settings",
880                ],
881            ];
882        }
883
884        return [
885            'options' => $auth_select_options,
886        ];
887    }
888
889    /**
890    * Select mail authentication method
891    */
892    function mail_auth_select($selected_method, $key = '')
893    {
894        global $user;
895
896        $auth_methods = ['PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP'];
897        $s_smtp_auth_options = [];
898
899        foreach ($auth_methods as $method)
900        {
901            $s_smtp_auth_options[] = [
902                'value'        => $method,
903                'selected'    => $selected_method == $method,
904                'label'        => $user->lang('SMTP_' . str_replace('-', '_', $method)),
905            ];
906        }
907
908        return [
909            'options' => $s_smtp_auth_options,
910        ];
911    }
912
913    /**
914    * Select full folder action
915    */
916    function full_folder_select($value, $key = '')
917    {
918        global $user;
919
920        $full_folder_select_options = [
921            0    => [
922                'value'        => 1,
923                'selected'    => $value == 1,
924                'label'        => $user->lang('DELETE_OLDEST_MESSAGES'),
925            ],
926            1    => [
927                'value'        => 2,
928                'selected'    => $value == 2,
929                'label'        => $user->lang('HOLD_NEW_MESSAGES_SHORT'),
930            ],
931        ];
932
933        return [
934            'options' => $full_folder_select_options,
935        ];
936    }
937
938    /**
939    * Select account activation method
940    */
941    function select_acc_activation($selected_value, $value)
942    {
943        global $user, $config;
944
945        $act_ary = [
946            'ACC_DISABLE'    => [true, USER_ACTIVATION_DISABLE],
947            'ACC_NONE'        => [true, USER_ACTIVATION_NONE],
948            'ACC_USER'        => [$config['email_enable'], USER_ACTIVATION_SELF],
949            'ACC_ADMIN'        => [$config['email_enable'], USER_ACTIVATION_ADMIN],
950        ];
951
952        $act_options = [];
953        foreach ($act_ary as $key => $data)
954        {
955            list($available, $value) = $data;
956            $act_options[] = [
957                'value'        => $value,
958                'selected'    => $selected_value == $value,
959                'label'        => $user->lang($key),
960                'class'        => !$available ? 'disabled-option' : '',
961            ];
962        }
963
964        return [
965            'options' => $act_options,
966        ];
967    }
968
969    /**
970    * Maximum/Minimum username length
971    */
972    function username_length($value, $key = '')
973    {
974        global $user;
975
976        return [
977            [
978                'tag'        => 'input',
979                'id'        => $key,
980                'type'        => 'number',
981                'name'        => 'config[min_name_chars]',
982                'min'        => 1,
983                'max'        => 999,
984                'value'        => $value,
985                'append'    => $user->lang('MIN_CHARS') . '&nbsp;&nbsp;',
986            ],
987            [
988                'tag'        => 'input',
989                'type'        => 'number',
990                'name'        => 'config[max_name_chars]',
991                'min'        => 8,
992                'max'        => 180,
993                'value'        => $this->new_config['max_name_chars'],
994                'append'    => $user->lang('MAX_CHARS'),
995            ],
996        ];
997    }
998
999    /**
1000    * Allowed chars in usernames
1001    */
1002    function select_username_chars($selected_value, $key)
1003    {
1004        global $user;
1005
1006        $user_char_ary = ['USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII'];
1007        $user_char_options = [];
1008        foreach ($user_char_ary as $user_type)
1009        {
1010            $user_char_options[] = [
1011                'value'        => $user_type,
1012                'selected'    => $selected_value == $user_type,
1013                'label'        => $user->lang($user_type),
1014            ];
1015        }
1016
1017        return [
1018            'options' => $user_char_options,
1019        ];
1020    }
1021
1022    /**
1023    * Minimum password length
1024    */
1025    function password_length($value, $key)
1026    {
1027        global $user;
1028
1029        return [
1030            [
1031                'tag'        => 'input',
1032                'id'        => $key,
1033                'type'        => 'number',
1034                'name'        => 'config[min_pass_chars]',
1035                'value'        => $value,
1036                'append'    => $user->lang('MIN_CHARS'),
1037            ],
1038        ];
1039    }
1040
1041    /**
1042    * Required chars in passwords
1043    */
1044    function select_password_chars($selected_value, $key)
1045    {
1046        global $user;
1047
1048        $pass_type_ary = array('PASS_TYPE_ANY', 'PASS_TYPE_CASE', 'PASS_TYPE_ALPHA', 'PASS_TYPE_SYMBOL');
1049        $pass_char_options = [];
1050        foreach ($pass_type_ary as $pass_type)
1051        {
1052            $pass_char_options[] = [
1053                'tag'        => 'select',
1054                'value'     => $pass_type,
1055                'selected'    => $selected_value == $pass_type,
1056                'label'        => $user->lang[$pass_type],
1057            ];
1058        }
1059
1060        return [
1061            'options' => $pass_char_options,
1062        ];
1063    }
1064
1065    /**
1066    * Select bump interval
1067    */
1068    public function bump_interval($value, $key): array
1069    {
1070        $bump_type_options = [];
1071        $types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS');
1072        foreach ($types as $type => $lang)
1073        {
1074            $bump_type_options[] = [
1075                'value'        => $type,
1076                'selected'    => $this->new_config['bump_type'] == $type,
1077                'label'        => $this->language->lang($lang),
1078            ];
1079        }
1080
1081        return [
1082            [
1083                'tag'        => 'input',
1084                'id'        => $key,
1085                'type'        => 'text',
1086                'size'        => 3,
1087                'maxlength'    => 4,
1088                'name'        => 'config[bump_interval]',
1089                'value'        => $value,
1090            ],
1091            [
1092                'tag'        => 'select',
1093                'name'        => 'config[bump_type]',
1094                'options'    => $bump_type_options,
1095            ],
1096        ];
1097    }
1098
1099    /**
1100     * Wrapper function for phpbb_language_select()
1101     *
1102     * @param string $default
1103     * @param array $langdata
1104     *
1105     * @return array
1106     */
1107    public function language_select(string $default = '', array $langdata = []): array
1108    {
1109        global $db;
1110
1111        return ['options' => phpbb_language_select($db, $default, $langdata)];
1112    }
1113
1114    /**
1115     * Wrapper function for style_select()
1116     *
1117     * @param int|string $default    Style ID to be selected in the dropdown list
1118     * @param bool $all                Flag indicating if all styles data including inactive should be fetched
1119     *
1120     * @return array
1121     */
1122    public function phpbb_style_select(int|string $default, bool $all): array
1123    {
1124        global $db;
1125
1126        return ['options' => style_select($default, $all)];
1127    }
1128
1129    /**
1130    * Board disable option and message
1131    */
1132    function board_disable($value, $key)
1133    {
1134        $options = phpbb_build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
1135
1136        return [
1137            array_merge(['tag'    => 'radio'], $options),
1138            [
1139                'tag'            => 'input',
1140                'type'            => 'text',
1141                'name'            => 'config[board_disable_msg]',
1142                'maxlength'        => 255,
1143                'size'            => 40,
1144                'id'            => $key,
1145                'value'            => $this->new_config['board_disable_msg'] ?: '',
1146            ],
1147        ];
1148    }
1149
1150    /**
1151     * Board disable access for which group: admins: 0; plus global moderators: 1 and plus all moderators: 2
1152     *
1153     * @param int $value Value from config
1154     *
1155     * @return array Options array for select
1156     */
1157    public function board_disable_access(int $value) : array
1158    {
1159        return ['options' => [
1160            [
1161                'value'        => 0,
1162                'selected'    => $value == 0,
1163                'label'        => $this->language->lang('DISABLE_BOARD_ACCESS_ADMIN'),
1164            ],
1165            [
1166                'value'        => 1,
1167                'selected'    => $value == 1,
1168                'label'        => $this->language->lang('DISABLE_BOARD_ACCESS_ADMIN_GLOB_MODS'),
1169            ],
1170            [
1171                'value'        => 2,
1172                'selected'    => $value == 2,
1173                'label'        => $this->language->lang('DISABLE_BOARD_ACCESS_ADMIN_ALL_MODS'),
1174            ],
1175        ]];
1176    }
1177
1178    /**
1179    * Global quick reply enable/disable setting and button to enable in all forums
1180    */
1181    function quick_reply($value, $key)
1182    {
1183        global $language;
1184
1185        $options = phpbb_build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
1186
1187        return [
1188            array_merge(['tag'    => 'radio', 'append' => '<br><br>'], $options),
1189            [
1190                'tag'            => 'input',
1191                'type'            => 'submit',
1192                'class'            => 'button2',
1193                'name'            => $key . '_enable',
1194                'id'            => $key . '_enable',
1195                'value'            => $language->lang('ALLOW_QUICK_REPLY_BUTTON'),
1196            ],
1197        ];
1198    }
1199
1200    /**
1201    * Select guest timezone
1202    */
1203    function timezone_select($value, $key)
1204    {
1205        $timezone_select = phpbb_timezone_select($this->user, $value, true);
1206
1207        return [
1208            'tag'            => 'select',
1209            'name'            => 'config[' . $key . ']',
1210            'options'        => $timezone_select,
1211        ];
1212    }
1213
1214    /**
1215    * Get guest style
1216    */
1217    public function guest_style_get()
1218    {
1219        global $db;
1220
1221        $sql = 'SELECT user_style
1222            FROM ' . USERS_TABLE . '
1223            WHERE user_id = ' . ANONYMOUS;
1224        $result = $db->sql_query($sql);
1225
1226        $style = (int) $db->sql_fetchfield('user_style');
1227        $db->sql_freeresult($result);
1228
1229        return $style;
1230    }
1231
1232    /**
1233    * Set guest style
1234    *
1235    * @param    int        $style_id    The style ID
1236    */
1237    public function guest_style_set($style_id)
1238    {
1239        global $db;
1240
1241        $sql = 'UPDATE ' . USERS_TABLE . '
1242            SET user_style = ' . (int) $style_id . '
1243            WHERE user_id = ' . ANONYMOUS;
1244        $db->sql_query($sql);
1245    }
1246
1247    /**
1248     * Create select for default date format
1249     *
1250     * @param string $value Current date format value
1251     * @param string $key Date format key
1252     *
1253     * @return array Date format select data
1254     */
1255    public function dateformat_select(string $value, string $key): array
1256    {
1257        // Let the format_date function operate with the acp values
1258        $old_tz = $this->user->timezone;
1259        try
1260        {
1261            $this->user->timezone = new DateTimeZone($this->config['board_timezone']);
1262        }
1263        catch (\Exception $e)
1264        {
1265            // If the board timezone is invalid, we just use the users timezone.
1266        }
1267
1268        $dateformat_options = [];
1269
1270        $dateformats = $this->language->lang_raw('dateformats');
1271        if (!is_array($dateformats))
1272        {
1273            $dateformats = [];
1274        }
1275
1276        foreach ($dateformats as $format => $null)
1277        {
1278            $dateformat_options[] = [
1279                'value'            => $format,
1280                'selected'        => $format == $value,
1281                'label'            => $this->user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $this->language->lang('VARIANT_DATE_SEPARATOR') . $this->user->format_date(time(), $format, true) : '')
1282            ];
1283        }
1284
1285        // Add custom entry
1286        $dateformat_options[] = [
1287            'value'            => 'custom',
1288            'selected'        => !isset($dateformats[$value]),
1289            'label'            => $this->language->lang('CUSTOM_DATEFORMAT'),
1290        ];
1291
1292        // Reset users date options
1293        $this->user->timezone = $old_tz;
1294
1295        return [
1296            [
1297                'tag'        => 'select',
1298                'name'        => 'dateoptions',
1299                'id'        => 'dateoptions',
1300                'options'    => $dateformat_options,
1301                'data'        => [
1302                    'dateoption'            => $key,
1303                    'dateoption-default'    => $value,
1304                ]
1305            ],
1306            [
1307                'tag'        => 'input',
1308                'type'        => 'text',
1309                'name'        => "config[$key]",
1310                'id'        => $key,
1311                'value'        => $value,
1312                'maxlength'    => 64,
1313            ]
1314        ];
1315    }
1316
1317    /**
1318     * Select for multiple forums
1319     *
1320     * @param mixed $value Config value, unused
1321     * @param string $key Config key
1322     *
1323     * @return array Forum select data
1324     */
1325    public function select_news_forums($value, string $key)
1326    {
1327        return $this->get_forum_select($key);
1328    }
1329
1330    /**
1331     * Select for multiple forums to exclude
1332     *
1333     * @param mixed $value Config value, unused
1334     * @param string $key Config key
1335     *
1336     * @return array Forum select data
1337     */
1338    public function select_exclude_forums($value, string $key): array
1339    {
1340        return $this->get_forum_select($key, FORUM_OPTION_FEED_EXCLUDE);
1341    }
1342
1343    /**
1344     * Get forum select data for specified key and option
1345     *
1346     * @param string $key Config key
1347     * @param int $forum_option Forum option bit
1348     *
1349     * @return array Forum select data
1350     */
1351    protected function get_forum_select(string $key, int $forum_option = FORUM_OPTION_FEED_NEWS): array
1352    {
1353        $forum_list = make_forum_select(false, false, true, true, true, false, true);
1354
1355        // Build forum options
1356        $forum_options = [];
1357        foreach ($forum_list as $f_id => $f_row)
1358        {
1359            $forum_options[] = [
1360                'value'        => $f_id,
1361                'selected'    => phpbb_optionget($forum_option, $f_row['forum_options']),
1362                'disabled'    => $f_row['disabled'],
1363                'label'        => $f_row['padding'] . $f_row['forum_name'],
1364            ];
1365        }
1366
1367        return [
1368            'tag'        => 'select',
1369            'id'        => $key,
1370            'name'        => $key . '[]',
1371            'multiple'    => true,
1372            'options'    => $forum_options,
1373        ];
1374    }
1375
1376    function store_feed_forums($option, $key)
1377    {
1378        global $db, $cache, $request;
1379
1380        // Get key
1381        $values = $request->variable($key, array(0 => 0));
1382
1383        // Empty option bit for all forums
1384        $sql = 'UPDATE ' . FORUMS_TABLE . '
1385            SET forum_options = forum_options - ' . (1 << $option) . '
1386            WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0');
1387        $db->sql_query($sql);
1388
1389        // Already emptied for all...
1390        if (count($values))
1391        {
1392            // Set for selected forums
1393            $sql = 'UPDATE ' . FORUMS_TABLE . '
1394                SET forum_options = forum_options + ' . (1 << $option) . '
1395                WHERE ' . $db->sql_in_set('forum_id', $values);
1396            $db->sql_query($sql);
1397        }
1398
1399        // Empty sql cache for forums table because options changed
1400        $cache->destroy('sql', FORUMS_TABLE);
1401    }
1402
1403    /**
1404    * Option to enable/disable removal of 'app.php' from URLs
1405    *
1406    * Note that if mod_rewrite is on, URLs without app.php will still work,
1407    * but any paths generated by the controller helper url() method will not
1408    * contain app.php.
1409    *
1410    * @param int $value The current config value
1411    * @param string $key The config key
1412    * @return string The HTML for the form field
1413    */
1414    function enable_mod_rewrite($value, $key)
1415    {
1416        global $language;
1417
1418        // Determine whether mod_rewrite is enabled on the server
1419        // NOTE: This only works on Apache servers on which PHP is NOT
1420        // installed as CGI. In that case, there is no way for PHP to
1421        // determine whether or not the Apache module is enabled.
1422        //
1423        // To be clear on the value of $mod_rewite:
1424        // null = Cannot determine whether or not the server has mod_rewrite
1425        //        enabled
1426        // false = Can determine that the server does NOT have mod_rewrite
1427        //         enabled
1428        // true = Can determine that the server DOES have mod_rewrite_enabled
1429        $mod_rewrite = null;
1430        if (function_exists('apache_get_modules'))
1431        {
1432            $mod_rewrite = (bool) in_array('mod_rewrite', apache_get_modules());
1433        }
1434
1435        // If $message is false, mod_rewrite is enabled.
1436        // Otherwise, it is not and we need to:
1437        // 1) disable the form field
1438        // 2) make sure the config value is set to 0
1439        // 3) append the message to the return
1440        $value = ($mod_rewrite === false) ? 0 : $value;
1441        $message = $mod_rewrite === null ? 'MOD_REWRITE_INFORMATION_UNAVAILABLE' : ($mod_rewrite === false ? 'MOD_REWRITE_DISABLED' : false);
1442
1443        $options = phpbb_build_radio($value, $key, [1 => 'YES', 0 => 'NO']);
1444        foreach ($options['buttons'] as $i => $button)
1445        {
1446            $options['buttons'][$i]['disabled'] = $message === 'MOD_REWRITE_DISABLED';
1447        }
1448
1449        $tpl = array_merge(
1450            [
1451                'tag'    => 'radio',
1452                'append' => ($message !== false) ? '<br><span>' . $language->lang($message) . '</span>' : '',
1453            ],
1454            $options
1455        );
1456
1457        return $tpl;
1458    }
1459
1460    function send_test_email($value, $key)
1461    {
1462        global $user;
1463
1464        return [
1465            [
1466                'tag'        => 'input',
1467                'type'        => 'submit',
1468                'name'        => $key,
1469                'id'        => $key,
1470                'class'        => 'button2',
1471                'value'        => $user->lang('SEND_TEST_EMAIL'),
1472            ],
1473            [
1474                'tag'            => 'textarea',
1475                'name'            => $key . '_text',
1476                'id'            => $key . '_text',
1477                'placeholder'    => $user->lang('MESSAGE'),
1478            ],
1479        ];
1480    }
1481
1482    /**
1483     * Generate form data for web push enable
1484     *
1485     * @param string $value Webpush enable value
1486     * @param string $key Webpush enable config key
1487     *
1488     * @return array[] Form data
1489     */
1490    public function webpush_enable($value, $key): array
1491    {
1492        return [
1493            [
1494                'tag'        => 'radio',
1495                'buttons'    => [
1496                    [
1497                        'name'        => "config[$key]",
1498                        'label'        => $this->language->lang('YES'),
1499                        'type'        => 'radio',
1500                        'class'        => 'radio',
1501                        'value'        => 1,
1502                        'checked'    => $value,
1503                    ],
1504                    [
1505                        'name'        => "config[$key]",
1506                        'label'        => $this->language->lang('NO'),
1507                        'type'        => 'radio',
1508                        'class'        => 'radio',
1509                        'value'        => 0,
1510                        'checked'    => !$value,
1511                    ],
1512                ],
1513            ],
1514            [
1515                'tag'        => 'input',
1516                'class'        => 'button2',
1517                'name'        => "config[$key]",
1518                'type'        => 'button',
1519                'value'        => $this->language->lang('WEBPUSH_GENERATE_VAPID_KEYS'),
1520                'data'        => [
1521                    'ajax'    => 'generate_vapid_keys',
1522                ]
1523            ],
1524        ];
1525    }
1526}