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

View | Annotate | Download (46.1 KB)

1
<?php
2
/**
3
*
4
* @package acp
5
* @version $Id: acp_board.php 10080 2009-08-31 14:57:04Z nickvergessen $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8
*
9
* @todo add cron intervals to server settings? (database_gc, queue_interval, session_gc, search_gc, cache_gc, warnings_gc)
10
*/
11
12
/**
13
* @ignore
14
*/
15
if (!defined('IN_PHPBB'))
16
{
17
        exit;
18
}
19
20
/**
21
* @package acp
22
*/
23
class acp_board
24
{
25
        var $u_action;
26
        var $new_config = array();
27
28
        function main($id, $mode)
29
        {
30
                global $db, $user, $auth, $template;
31
                global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
32
33
                $user->add_lang('acp/board');
34
35
                $action        = request_var('action', '');
36
                $submit = (isset($_POST['submit'])) ? true : false;
37
38
                $form_key = 'acp_board';
39
                add_form_key($form_key);
40
41
                /**
42
                *        Validation types are:
43
                *                string, int, bool,
44
                *                script_path (absolute path in url - beginning with / and no trailing slash),
45
                *                rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable)
46
                */
47
                switch ($mode)
48
                {
49
                        case 'settings':
50
                                $display_vars = array(
51
                                        'title'        => 'ACP_BOARD_SETTINGS',
52
                                        'vars'        => array(
53
                                                'legend1'                                => 'ACP_BOARD_SETTINGS',
54
                                                'sitename'                                => array('lang' => 'SITE_NAME',                                'validate' => 'string',        'type' => 'text:40:255', 'explain' => false),
55
                                                'site_desc'                                => array('lang' => 'SITE_DESC',                                'validate' => 'string',        'type' => 'text:40:255', 'explain' => false),
56
                                                'board_disable'                        => array('lang' => 'DISABLE_BOARD',                        'validate' => 'bool',        'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
57
                                                'board_disable_msg'                => false,
58
                                                'default_lang'                        => array('lang' => 'DEFAULT_LANGUAGE',                'validate' => 'lang',        'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false),
59
                                                'default_dateformat'        => array('lang' => 'DEFAULT_DATE_FORMAT',        'validate' => 'string',        'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true),
60
                                                'board_timezone'                => array('lang' => 'SYSTEM_TIMEZONE',                'validate' => 'string',        'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => false),
61
                                                'board_dst'                                => array('lang' => 'SYSTEM_DST',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
62
                                                'default_style'                        => array('lang' => 'DEFAULT_STYLE',                        'validate' => 'int',        'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
63
                                                'override_user_style'        => array('lang' => 'OVERRIDE_STYLE',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
64
65
                                                'legend2'                                => 'WARNINGS',
66
                                                'warnings_expire_days'        => array('lang' => 'WARNINGS_EXPIRE',                'validate' => 'int',        'type' => 'text:3:4', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
67
68
                                                'legend3'                                        => 'ACP_SUBMIT_CHANGES',
69
                                        )
70
                                );
71
                        break;
72
73
                        case 'features':
74
                                $display_vars = array(
75
                                        'title'        => 'ACP_BOARD_FEATURES',
76
                                        'vars'        => array(
77
                                                'legend1'                                => 'ACP_BOARD_FEATURES',
78
                                                'allow_privmsg'                        => array('lang' => 'BOARD_PM',                                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
79
                                                'allow_topic_notify'        => array('lang' => 'ALLOW_TOPIC_NOTIFY',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
80
                                                'allow_forum_notify'        => array('lang' => 'ALLOW_FORUM_NOTIFY',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
81
                                                'allow_namechange'                => array('lang' => 'ALLOW_NAME_CHANGE',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
82
                                                'allow_attachments'                => array('lang' => 'ALLOW_ATTACHMENTS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
83
                                                'allow_pm_attach'                => array('lang' => 'ALLOW_PM_ATTACHMENTS',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
84
                                                'allow_pm_report'                => array('lang' => 'ALLOW_PM_REPORT',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
85
                                                'allow_bbcode'                        => array('lang' => 'ALLOW_BBCODE',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
86
                                                'allow_smilies'                        => array('lang' => 'ALLOW_SMILIES',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
87
                                                'allow_sig'                                => array('lang' => 'ALLOW_SIG',                                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
88
                                                'allow_nocensors'                => array('lang' => 'ALLOW_NO_CENSORS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
89
                                                'allow_bookmarks'                => array('lang' => 'ALLOW_BOOKMARKS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
90
                                                'allow_birthdays'                => array('lang' => 'ALLOW_BIRTHDAYS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
91
                                                'allow_quick_reply'                => array('lang' => 'ALLOW_QUICK_REPLY',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
92
93
                                                'legend2'                                => 'ACP_LOAD_SETTINGS',
94
                                                'load_birthdays'                => array('lang' => 'YES_BIRTHDAYS',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
95
                                                'load_moderators'                => array('lang' => 'YES_MODERATORS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
96
                                                'load_jumpbox'                        => array('lang' => 'YES_JUMPBOX',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
97
                                                'load_cpf_memberlist'        => array('lang' => 'LOAD_CPF_MEMBERLIST',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
98
                                                'load_cpf_viewprofile'        => array('lang' => 'LOAD_CPF_VIEWPROFILE',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
99
                                                'load_cpf_viewtopic'        => array('lang' => 'LOAD_CPF_VIEWTOPIC',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
100
101
                                                'legend3'                                        => 'ACP_SUBMIT_CHANGES',
102
                                        )
103
                                );
104
                        break;
105
106
                        case 'avatar':
107
                                $display_vars = array(
108
                                        'title'        => 'ACP_AVATAR_SETTINGS',
109
                                        'vars'        => array(
110
                                                'legend1'                                => 'ACP_AVATAR_SETTINGS',
111
112
                                                'avatar_min_width'                => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
113
                                                'avatar_min_height'                => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
114
                                                'avatar_max_width'                => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
115
                                                'avatar_max_height'                => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
116
117
                                                'allow_avatar'                        => array('lang' => 'ALLOW_AVATARS',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
118
                                                'allow_avatar_local'        => array('lang' => 'ALLOW_LOCAL',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
119
                                                'allow_avatar_remote'        => array('lang' => 'ALLOW_REMOTE',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
120
                                                'allow_avatar_upload'        => array('lang' => 'ALLOW_UPLOAD',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
121
                                                'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
122
                                                'avatar_filesize'                => array('lang' => 'MAX_FILESIZE',                        'validate' => 'int:0',        'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
123
                                                'avatar_min'                        => array('lang' => 'MIN_AVATAR_SIZE',                'validate' => 'int:0',        'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
124
                                                'avatar_max'                        => array('lang' => 'MAX_AVATAR_SIZE',                'validate' => 'int:0',        'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
125
                                                'avatar_path'                        => array('lang' => 'AVATAR_STORAGE_PATH',        'validate' => 'rwpath',        'type' => 'text:20:255', 'explain' => true),
126
                                                'avatar_gallery_path'        => array('lang' => 'AVATAR_GALLERY_PATH',        'validate' => 'rpath',        'type' => 'text:20:255', 'explain' => true)
127
                                        )
128
                                );
129
                        break;
130
131
                        case 'message':
132
                                $display_vars = array(
133
                                        'title'        => 'ACP_MESSAGE_SETTINGS',
134
                                        'lang'        => 'ucp',
135
                                        'vars'        => array(
136
                                                'legend1'                                => 'GENERAL_SETTINGS',
137
                                                'allow_privmsg'                        => array('lang' => 'BOARD_PM',                                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
138
                                                'pm_max_boxes'                        => array('lang' => 'BOXES_MAX',                                'validate' => 'int:0',        'type' => 'text:4:4', 'explain' => true),
139
                                                'pm_max_msgs'                        => array('lang' => 'BOXES_LIMIT',                        'validate' => 'int:0',        'type' => 'text:4:4', 'explain' => true),
140
                                                'full_folder_action'        => array('lang' => 'FULL_FOLDER_ACTION',        'validate' => 'int',        'type' => 'select', 'method' => 'full_folder_select', 'explain' => true),
141
                                                'pm_edit_time'                        => array('lang' => 'PM_EDIT_TIME',                        'validate' => 'int:0',        'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
142
                                                'pm_max_recipients'                => array('lang' => 'PM_MAX_RECIPIENTS',                'validate' => 'int:0',        'type' => 'text:5:5', 'explain' => true),
143
144
                                                'legend2'                                => 'GENERAL_OPTIONS',
145
                                                'allow_mass_pm'                        => array('lang' => 'ALLOW_MASS_PM',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
146
                                                'auth_bbcode_pm'                => array('lang' => 'ALLOW_BBCODE_PM',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
147
                                                'auth_smilies_pm'                => array('lang' => 'ALLOW_SMILIES_PM',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
148
                                                'allow_pm_attach'                => array('lang' => 'ALLOW_PM_ATTACHMENTS',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
149
                                                'allow_sig_pm'                        => array('lang' => 'ALLOW_SIG_PM',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
150
                                                'print_pm'                                => array('lang' => 'ALLOW_PRINT_PM',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
151
                                                'forward_pm'                        => array('lang' => 'ALLOW_FORWARD_PM',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
152
                                                'auth_img_pm'                        => array('lang' => 'ALLOW_IMG_PM',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
153
                                                'auth_flash_pm'                        => array('lang' => 'ALLOW_FLASH_PM',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
154
                                                'enable_pm_icons'                => array('lang' => 'ENABLE_PM_ICONS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
155
156
                                                'legend3'                                        => 'ACP_SUBMIT_CHANGES',
157
                                        )
158
                                );
159
                        break;
160
161
                        case 'post':
162
                                $display_vars = array(
163
                                        'title'        => 'ACP_POST_SETTINGS',
164
                                        'vars'        => array(
165
                                                'legend1'                                => 'GENERAL_OPTIONS',
166
                                                'allow_topic_notify'        => array('lang' => 'ALLOW_TOPIC_NOTIFY',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
167
                                                'allow_forum_notify'        => array('lang' => 'ALLOW_FORUM_NOTIFY',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
168
                                                'allow_bbcode'                        => array('lang' => 'ALLOW_BBCODE',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
169
                                                'allow_post_flash'                => array('lang' => 'ALLOW_POST_FLASH',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
170
                                                'allow_smilies'                        => array('lang' => 'ALLOW_SMILIES',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
171
                                                'allow_post_links'                => array('lang' => 'ALLOW_POST_LINKS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
172
                                                'allow_nocensors'                => array('lang' => 'ALLOW_NO_CENSORS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
173
                                                'allow_bookmarks'                => array('lang' => 'ALLOW_BOOKMARKS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
174
                                                'enable_post_confirm'        => array('lang' => 'VISUAL_CONFIRM_POST',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
175
                                                'allow_quick_reply'                => array('lang' => 'ALLOW_QUICK_REPLY',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
176
177
                                                'legend2'                                => 'POSTING',
178
                                                'bump_type'                                => false,
179
                                                'edit_time'                                => array('lang' => 'EDIT_TIME',                                'validate' => 'int:0',                'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
180
                                                'delete_time'                        => array('lang' => 'DELETE_TIME',                        'validate' => 'int:0',                'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
181
                                                'display_last_edited'        => array('lang' => 'DISPLAY_LAST_EDITED',        'validate' => 'bool',                'type' => 'radio:yes_no', 'explain' => true),
182
                                                'flood_interval'                => array('lang' => 'FLOOD_INTERVAL',                'validate' => 'int:0',                'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
183
                                                'bump_interval'                        => array('lang' => 'BUMP_INTERVAL',                        'validate' => 'int:0',                'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
184
                                                'topics_per_page'                => array('lang' => 'TOPICS_PER_PAGE',                'validate' => 'int:1',                'type' => 'text:3:4', 'explain' => false),
185
                                                'posts_per_page'                => array('lang' => 'POSTS_PER_PAGE',                'validate' => 'int:1',                'type' => 'text:3:4', 'explain' => false),
186
                                                'smilies_per_page'                => array('lang' => 'SMILIES_PER_PAGE',                'validate' => 'int:1',                'type' => 'text:3:4', 'explain' => false),
187
                                                'hot_threshold'                        => array('lang' => 'HOT_THRESHOLD',                        'validate' => 'int:0',                'type' => 'text:3:4', 'explain' => true),
188
                                                'max_poll_options'                => array('lang' => 'MAX_POLL_OPTIONS',                'validate' => 'int:2:127',        'type' => 'text:4:4', 'explain' => false),
189
                                                'max_post_chars'                => array('lang' => 'CHAR_LIMIT',                        'validate' => 'int:0',                'type' => 'text:4:6', 'explain' => true),
190
                                                'min_post_chars'                => array('lang' => 'MIN_CHAR_LIMIT',                'validate' => 'int:0',                'type' => 'text:4:6', 'explain' => true),
191
                                                'max_post_smilies'                => array('lang' => 'SMILIES_LIMIT',                        'validate' => 'int:0',                'type' => 'text:4:4', 'explain' => true),
192
                                                'max_post_urls'                        => array('lang' => 'MAX_POST_URLS',                        'validate' => 'int:0',                'type' => 'text:5:4', 'explain' => true),
193
                                                'max_post_font_size'        => array('lang' => 'MAX_POST_FONT_SIZE',        'validate' => 'int:0',                'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
194
                                                'max_quote_depth'                => array('lang' => 'QUOTE_DEPTH_LIMIT',                'validate' => 'int:0',                'type' => 'text:4:4', 'explain' => true),
195
                                                'max_post_img_width'        => array('lang' => 'MAX_POST_IMG_WIDTH',        'validate' => 'int:0',                'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
196
                                                'max_post_img_height'        => array('lang' => 'MAX_POST_IMG_HEIGHT',        'validate' => 'int:0',                'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
197
198
                                                'legend3'                                        => 'ACP_SUBMIT_CHANGES',
199
                                        )
200
                                );
201
                        break;
202
203
                        case 'signature':
204
                                $display_vars = array(
205
                                        'title'        => 'ACP_SIGNATURE_SETTINGS',
206
                                        'vars'        => array(
207
                                                'legend1'                                => 'GENERAL_OPTIONS',
208
                                                'allow_sig'                                => array('lang' => 'ALLOW_SIG',                                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
209
                                                'allow_sig_bbcode'                => array('lang' => 'ALLOW_SIG_BBCODE',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
210
                                                'allow_sig_img'                        => array('lang' => 'ALLOW_SIG_IMG',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
211
                                                'allow_sig_flash'                => array('lang' => 'ALLOW_SIG_FLASH',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
212
                                                'allow_sig_smilies'                => array('lang' => 'ALLOW_SIG_SMILIES',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
213
                                                'allow_sig_links'                => array('lang' => 'ALLOW_SIG_LINKS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
214
215
                                                'legend2'                                => 'GENERAL_SETTINGS',
216
                                                'max_sig_chars'                        => array('lang' => 'MAX_SIG_LENGTH',                'validate' => 'int:0',        'type' => 'text:5:4', 'explain' => true),
217
                                                'max_sig_urls'                        => array('lang' => 'MAX_SIG_URLS',                        'validate' => 'int:0',        'type' => 'text:5:4', 'explain' => true),
218
                                                'max_sig_font_size'                => array('lang' => 'MAX_SIG_FONT_SIZE',                'validate' => 'int:0',        'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
219
                                                'max_sig_smilies'                => array('lang' => 'MAX_SIG_SMILIES',                'validate' => 'int:0',        'type' => 'text:5:4', 'explain' => true),
220
                                                'max_sig_img_width'                => array('lang' => 'MAX_SIG_IMG_WIDTH',                'validate' => 'int:0',        'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
221
                                                'max_sig_img_height'        => array('lang' => 'MAX_SIG_IMG_HEIGHT',        'validate' => 'int:0',        'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
222
223
                                                'legend3'                                        => 'ACP_SUBMIT_CHANGES',
224
                                        )
225
                                );
226
                        break;
227
228
                        case 'registration':
229
                                $display_vars = array(
230
                                        'title'        => 'ACP_REGISTER_SETTINGS',
231
                                        'vars'        => array(
232
                                                'legend1'                                => 'GENERAL_SETTINGS',
233
                                                'max_name_chars'                => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:8:180', 'type' => false, 'method' => false, 'explain' => false,),
234
                                                'max_pass_chars'                => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,),
235
236
                                                'require_activation'        => array('lang' => 'ACC_ACTIVATION',        'validate' => 'int',        'type' => 'custom', 'method' => 'select_acc_activation', 'explain' => true),
237
                                                'new_member_post_limit'        => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'text:4:4', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']),
238
                                                'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
239
                                                'min_name_chars'                => array('lang' => 'USERNAME_LENGTH',        'validate' => 'int:1',        'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true),
240
                                                'min_pass_chars'                => array('lang' => 'PASSWORD_LENGTH',        'validate' => 'int:1',        'type' => 'custom', 'method' => 'password_length', 'explain' => true),
241
                                                'allow_name_chars'                => array('lang' => 'USERNAME_CHARS',        'validate' => 'string',        'type' => 'select', 'method' => 'select_username_chars', 'explain' => true),
242
                                                'pass_complex'                        => array('lang' => 'PASSWORD_TYPE',                'validate' => 'string',        'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
243
                                                'chg_passforce'                        => array('lang' => 'FORCE_PASS_CHANGE',        'validate' => 'int:0',        'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
244
245
                                                'legend2'                                => 'GENERAL_OPTIONS',
246
                                                'allow_namechange'                => array('lang' => 'ALLOW_NAME_CHANGE',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
247
                                                'allow_emailreuse'                => array('lang' => 'ALLOW_EMAIL_REUSE',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
248
                                                'enable_confirm'                => array('lang' => 'VISUAL_CONFIRM_REG',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
249
                                                'max_login_attempts'        => array('lang' => 'MAX_LOGIN_ATTEMPTS',        'validate' => 'int:0',        'type' => 'text:3:3', 'explain' => true),
250
                                                'max_reg_attempts'                => array('lang' => 'REG_LIMIT',                                'validate' => 'int:0',        'type' => 'text:4:4', 'explain' => true),
251
252
                                                'legend3'                        => 'COPPA',
253
                                                'coppa_enable'                => array('lang' => 'ENABLE_COPPA',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
254
                                                'coppa_mail'                => array('lang' => 'COPPA_MAIL',                'validate' => 'string',        'type' => 'textarea:5:40', 'explain' => true),
255
                                                'coppa_fax'                        => array('lang' => 'COPPA_FAX',                        'validate' => 'string',        'type' => 'text:25:100', 'explain' => false),
256
257
                                                'legend4'                        => 'ACP_SUBMIT_CHANGES',
258
                                        )
259
                                );
260
                        break;
261
262
                        case 'feed':
263
                                $display_vars = array(
264
                                        'title'        => 'ACP_FEED_MANAGEMENT',
265
                                        'vars'        => array(
266
                                                'legend1'                                        => 'ACP_FEED_GENERAL',
267
                                                'feed_enable'                                => array('lang' => 'ACP_FEED_ENABLE',                                'validate' => 'bool',        'type' => 'radio:enabled_disabled',        'explain' => true ),
268
                                                'feed_item_statistics'                => array('lang' => 'ACP_FEED_ITEM_STATISTICS',                'validate' => 'bool',        'type' => 'radio:enabled_disabled',        'explain' => true),
269
                                                'feed_limit'                                => array('lang' => 'ACP_FEED_LIMIT',                                'validate' => 'int:5',        'type' => 'text:3:4',                                'explain' => true),
270
                                                'feed_overall_forums'                => array('lang'        => 'ACP_FEED_OVERALL_FORUMS',                'validate' => 'bool',        'type' => 'radio:enabled_disabled',        'explain' => true ),
271
                                                'feed_overall_forums_limit'        => array('lang' => 'ACP_FEED_OVERALL_FORUMS_LIMIT',        'validate' => 'int:5',        'type' => 'text:3:4',                                'explain' => false),
272
                                                'feed_overall_topics'                => array('lang' => 'ACP_FEED_OVERALL_TOPIC',                'validate' => 'bool',        'type' => 'radio:enabled_disabled',        'explain' => true ),
273
                                                'feed_overall_topics_limit'        => array('lang' => 'ACP_FEED_OVERALL_TOPIC_LIMIT',        'validate' => 'int:5',        'type' => 'text:3:4',                                'explain' => false),
274
                                                'feed_forum'                                => array('lang' => 'ACP_FEED_FORUM',                                'validate' => 'bool',        'type' => 'radio:enabled_disabled',        'explain' => true ),
275
                                                'feed_topic'                                => array('lang' => 'ACP_FEED_TOPIC',                                'validate' => 'bool',        'type' => 'radio:enabled_disabled',        'explain' => true ),
276
                                                'feed_news_id'                                => array('lang' => 'ACP_FEED_NEWS',                                        'validate' => 'string',        'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true),
277
                                                'feed_exclude_id'                        => array('lang' => 'ACP_FEED_EXCLUDE_ID',                        'validate' => 'string',        'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true),
278
                                        )
279
                                );
280
                        break;
281
282
                        case 'cookie':
283
                                $display_vars = array(
284
                                        'title'        => 'ACP_COOKIE_SETTINGS',
285
                                        'vars'        => array(
286
                                                'legend1'                => 'ACP_COOKIE_SETTINGS',
287
                                                'cookie_domain'        => array('lang' => 'COOKIE_DOMAIN',        'validate' => 'string',        'type' => 'text::255', 'explain' => false),
288
                                                'cookie_name'        => array('lang' => 'COOKIE_NAME',        'validate' => 'string',        'type' => 'text::16', 'explain' => false),
289
                                                'cookie_path'        => array('lang'        => 'COOKIE_PATH',        'validate' => 'string',        'type' => 'text::255', 'explain' => false),
290
                                                'cookie_secure'        => array('lang' => 'COOKIE_SECURE',        'validate' => 'bool',        'type' => 'radio:disabled_enabled', 'explain' => true)
291
                                        )
292
                                );
293
                        break;
294
295
                        case 'load':
296
                                $display_vars = array(
297
                                        'title'        => 'ACP_LOAD_SETTINGS',
298
                                        'vars'        => array(
299
                                                'legend1'                        => 'GENERAL_SETTINGS',
300
                                                'limit_load'                => array('lang' => 'LIMIT_LOAD',                'validate' => 'string',        'type' => 'text:4:4', 'explain' => true),
301
                                                'session_length'        => array('lang' => 'SESSION_LENGTH',        'validate' => 'int:60',        'type' => 'text:5:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
302
                                                'active_sessions'        => array('lang' => 'LIMIT_SESSIONS',        'validate' => 'int:0',        'type' => 'text:4:4', 'explain' => true),
303
                                                'load_online_time'        => array('lang' => 'ONLINE_LENGTH',                'validate' => 'int:0',        'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
304
305
                                                'legend2'                                => 'GENERAL_OPTIONS',
306
                                                'load_db_track'                        => array('lang' => 'YES_POST_MARKING',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
307
                                                'load_db_lastread'                => array('lang' => 'YES_READ_MARKING',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
308
                                                'load_anon_lastread'        => array('lang' => 'YES_ANON_READ_MARKING',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
309
                                                'load_online'                        => array('lang' => 'YES_ONLINE',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
310
                                                'load_online_guests'        => array('lang' => 'YES_ONLINE_GUESTS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
311
                                                'load_onlinetrack'                => array('lang' => 'YES_ONLINE_TRACK',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
312
                                                'load_birthdays'                => array('lang' => 'YES_BIRTHDAYS',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
313
                                                'load_moderators'                => array('lang' => 'YES_MODERATORS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
314
                                                'load_jumpbox'                        => array('lang' => 'YES_JUMPBOX',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
315
                                                'load_user_activity'        => array('lang' => 'LOAD_USER_ACTIVITY',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
316
                                                'load_tplcompile'                => array('lang' => 'RECOMPILE_STYLES',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
317
318
                                                'legend3'                                => 'CUSTOM_PROFILE_FIELDS',
319
                                                'load_cpf_memberlist'        => array('lang' => 'LOAD_CPF_MEMBERLIST',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
320
                                                'load_cpf_viewprofile'        => array('lang' => 'LOAD_CPF_VIEWPROFILE',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
321
                                                'load_cpf_viewtopic'        => array('lang' => 'LOAD_CPF_VIEWTOPIC',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => false),
322
323
                                                'legend4'                                        => 'ACP_SUBMIT_CHANGES',
324
                                        )
325
                                );
326
                        break;
327
328
                        case 'auth':
329
                                $display_vars = array(
330
                                        'title'        => 'ACP_AUTH_SETTINGS',
331
                                        'vars'        => array(
332
                                                'legend1'                => 'ACP_AUTH_SETTINGS',
333
                                                'auth_method'        => array('lang' => 'AUTH_METHOD',        'validate' => 'string',        'type' => 'select', 'method' => 'select_auth_method', 'explain' => false)
334
                                        )
335
                                );
336
                        break;
337
338
                        case 'server':
339
                                $display_vars = array(
340
                                        'title'        => 'ACP_SERVER_SETTINGS',
341
                                        'vars'        => array(
342
                                                'legend1'                                => 'ACP_SERVER_SETTINGS',
343
                                                'gzip_compress'                        => array('lang' => 'ENABLE_GZIP',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
344
345
                                                'legend2'                                => 'PATH_SETTINGS',
346
                                                'smilies_path'                        => array('lang' => 'SMILIES_PATH',                'validate' => 'rpath',        'type' => 'text:20:255', 'explain' => true),
347
                                                'icons_path'                        => array('lang' => 'ICONS_PATH',                'validate' => 'rpath',        'type' => 'text:20:255', 'explain' => true),
348
                                                'upload_icons_path'                => array('lang' => 'UPLOAD_ICONS_PATH',        'validate' => 'rpath',        'type' => 'text:20:255', 'explain' => true),
349
                                                'ranks_path'                        => array('lang' => 'RANKS_PATH',                'validate' => 'rpath',        'type' => 'text:20:255', 'explain' => true),
350
351
                                                'legend3'                                => 'SERVER_URL_SETTINGS',
352
                                                'force_server_vars'                => array('lang' => 'FORCE_SERVER_VARS',        'validate' => 'bool',                        'type' => 'radio:yes_no', 'explain' => true),
353
                                                'server_protocol'                => array('lang' => 'SERVER_PROTOCOL',        'validate' => 'string',                        'type' => 'text:10:10', 'explain' => true),
354
                                                'server_name'                        => array('lang' => 'SERVER_NAME',                'validate' => 'string',                        'type' => 'text:40:255', 'explain' => true),
355
                                                'server_port'                        => array('lang' => 'SERVER_PORT',                'validate' => 'int:0',                        'type' => 'text:5:5', 'explain' => true),
356
                                                'script_path'                        => array('lang' => 'SCRIPT_PATH',                'validate' => 'script_path',        'type' => 'text::255', 'explain' => true),
357
358
                                                'legend4'                                        => 'ACP_SUBMIT_CHANGES',
359
                                        )
360
                                );
361
                        break;
362
363
                        case 'security':
364
                                $display_vars = array(
365
                                        'title'        => 'ACP_SECURITY_SETTINGS',
366
                                        'vars'        => array(
367
                                                'legend1'                                => 'ACP_SECURITY_SETTINGS',
368
                                                'allow_autologin'                => array('lang' => 'ALLOW_AUTOLOGIN',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
369
                                                'max_autologin_time'        => array('lang' => 'AUTOLOGIN_LENGTH',                'validate' => 'int:0',        'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
370
                                                'ip_check'                                => array('lang' => 'IP_VALID',                                'validate' => 'int',        'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true),
371
                                                'browser_check'                        => array('lang' => 'BROWSER_VALID',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
372
                                                'forwarded_for_check'        => array('lang' => 'FORWARDED_FOR_VALID',        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
373
                                                'referer_validation'        => array('lang' => 'REFERER_VALID',                'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true),
374
                                                'check_dnsbl'                        => array('lang' => 'CHECK_DNSBL',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
375
                                                'email_check_mx'                => array('lang' => 'EMAIL_CHECK_MX',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
376
                                                'pass_complex'                        => array('lang' => 'PASSWORD_TYPE',                        'validate' => 'string',        'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
377
                                                'chg_passforce'                        => array('lang' => 'FORCE_PASS_CHANGE',                'validate' => 'int:0',        'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
378
                                                'max_login_attempts'        => array('lang' => 'MAX_LOGIN_ATTEMPTS',        'validate' => 'int:0',        'type' => 'text:3:3', 'explain' => true),
379
                                                'tpl_allow_php'                        => array('lang' => 'TPL_ALLOW_PHP',                        'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
380
                                                'form_token_lifetime'        => array('lang' => 'FORM_TIME_MAX',                        'validate' => 'int:-1',        'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
381
                                                'form_token_sid_guests'        => array('lang' => 'FORM_SID_GUESTS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
382
383
                                        )
384
                                );
385
                        break;
386
387
                        case 'email':
388
                                $display_vars = array(
389
                                        'title'        => 'ACP_EMAIL_SETTINGS',
390
                                        'vars'        => array(
391
                                                'legend1'                                => 'GENERAL_SETTINGS',
392
                                                'email_enable'                        => array('lang' => 'ENABLE_EMAIL',                        'validate' => 'bool',        'type' => 'radio:enabled_disabled', 'explain' => true),
393
                                                'board_email_form'                => array('lang' => 'BOARD_EMAIL_FORM',                'validate' => 'bool',        'type' => 'radio:enabled_disabled', 'explain' => true),
394
                                                'email_function_name'        => array('lang' => 'EMAIL_FUNCTION_NAME',        'validate' => 'string',        'type' => 'text:20:50', 'explain' => true),
395
                                                'email_package_size'        => array('lang' => 'EMAIL_PACKAGE_SIZE',        'validate' => 'int:0',        'type' => 'text:5:5', 'explain' => true),
396
                                                'board_contact'                        => array('lang' => 'CONTACT_EMAIL',                        'validate' => 'string',        'type' => 'text:25:100', 'explain' => true),
397
                                                'board_email'                        => array('lang' => 'ADMIN_EMAIL',                        'validate' => 'string',        'type' => 'text:25:100', 'explain' => true),
398
                                                'board_email_sig'                => array('lang' => 'EMAIL_SIG',                                'validate' => 'string',        'type' => 'textarea:5:30', 'explain' => true),
399
                                                'board_hide_emails'                => array('lang' => 'BOARD_HIDE_EMAILS',                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
400
401
                                                'legend2'                                => 'SMTP_SETTINGS',
402
                                                'smtp_delivery'                        => array('lang' => 'USE_SMTP',                                'validate' => 'bool',        'type' => 'radio:yes_no', 'explain' => true),
403
                                                'smtp_host'                                => array('lang' => 'SMTP_SERVER',                        'validate' => 'string',        'type' => 'text:25:50', 'explain' => false),
404
                                                'smtp_port'                                => array('lang' => 'SMTP_PORT',                                'validate' => 'int:0',        'type' => 'text:4:5', 'explain' => true),
405
                                                'smtp_auth_method'                => array('lang' => 'SMTP_AUTH_METHOD',                'validate' => 'string',        'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true),
406
                                                'smtp_username'                        => array('lang' => 'SMTP_USERNAME',                        'validate' => 'string',        'type' => 'text:25:255', 'explain' => true),
407
                                                'smtp_password'                        => array('lang' => 'SMTP_PASSWORD',                        'validate' => 'string',        'type' => 'password:25:255', 'explain' => true),
408
409
                                                'legend3'                                        => 'ACP_SUBMIT_CHANGES',
410
                                        )
411
                                );
412
                        break;
413
414
                        default:
415
                                trigger_error('NO_MODE', E_USER_ERROR);
416
                        break;
417
                }
418
419
                if (isset($display_vars['lang']))
420
                {
421
                        $user->add_lang($display_vars['lang']);
422
                }
423
424
                $this->new_config = $config;
425
                $cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
426
                $error = array();
427
428
                // We validate the complete config if whished
429
                validate_config_vars($display_vars['vars'], $cfg_array, $error);
430
431
                if ($submit && !check_form_key($form_key))
432
                {
433
                        $error[] = $user->lang['FORM_INVALID'];
434
                }
435
                // Do not write values if there is an error
436
                if (sizeof($error))
437
                {
438
                        $submit = false;
439
                }
440
441
                // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
442
                foreach ($display_vars['vars'] as $config_name => $null)
443
                {
444
                        if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
445
                        {
446
                                continue;
447
                        }
448
449
                        if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id')
450
                        {
451
                                continue;
452
                        }
453
454
                        $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
455
456
                        if ($config_name == 'email_function_name')
457
                        {
458
                                $this->new_config['email_function_name'] = trim(str_replace(array('(', ')'), array('', ''), $this->new_config['email_function_name']));
459
                                $this->new_config['email_function_name'] = (empty($this->new_config['email_function_name']) || !function_exists($this->new_config['email_function_name'])) ? 'mail' : $this->new_config['email_function_name'];
460
                                $config_value = $this->new_config['email_function_name'];
461
                        }
462
463
                        if ($submit)
464
                        {
465
                                set_config($config_name, $config_value);
466
                        }
467
                }
468
469
                // Store news and exclude ids
470
                if ($mode == 'feed' && $submit)
471
                {
472
                        $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id');
473
                        $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id');
474
                }
475
476
                if ($mode == 'auth')
477
                {
478
                        // Retrieve a list of auth plugins and check their config values
479
                        $auth_plugins = array();
480
481
                        $dp = @opendir($phpbb_root_path . 'includes/auth');
482
483
                        if ($dp)
484
                        {
485
                                while (($file = readdir($dp)) !== false)
486
                                {
487
                                        if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
488
                                        {
489
                                                $auth_plugins[] = basename(preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file));
490
                                        }
491
                                }
492
                                closedir($dp);
493
494
                                sort($auth_plugins);
495
                        }
496
497
                        $updated_auth_settings = false;
498
                        $old_auth_config = array();
499
                        foreach ($auth_plugins as $method)
500
                        {
501
                                if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
502
                                {
503
                                        include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
504
505
                                        $method = 'acp_' . $method;
506
                                        if (function_exists($method))
507
                                        {
508
                                                if ($fields = $method($this->new_config))
509
                                                {
510
                                                        // Check if we need to create config fields for this plugin and save config when submit was pressed
511
                                                        foreach ($fields['config'] as $field)
512
                                                        {
513
                                                                if (!isset($config[$field]))
514
                                                                {
515
                                                                        set_config($field, '');
516
                                                                }
517
518
                                                                if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false)
519
                                                                {
520
                                                                        continue;
521
                                                                }
522
523
                                                                $old_auth_config[$field] = $this->new_config[$field];
524
                                                                $config_value = $cfg_array[$field];
525
                                                                $this->new_config[$field] = $config_value;
526
527
                                                                if ($submit)
528
                                                                {
529
                                                                        $updated_auth_settings = true;
530
                                                                        set_config($field, $config_value);
531
                                                                }
532
                                                        }
533
                                                }
534
                                                unset($fields);
535
                                        }
536
                                }
537
                        }
538
539
                        if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings))
540
                        {
541
                                $method = basename($cfg_array['auth_method']);
542
                                if ($method && in_array($method, $auth_plugins))
543
                                {
544
                                        include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
545
546
                                        $method = 'init_' . $method;
547
                                        if (function_exists($method))
548
                                        {
549
                                                if ($error = $method())
550
                                                {
551
                                                        foreach ($old_auth_config as $config_name => $config_value)
552
                                                        {
553
                                                                set_config($config_name, $config_value);
554
                                                        }
555
                                                        trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
556
                                                }
557
                                        }
558
                                        set_config('auth_method', basename($cfg_array['auth_method']));
559
                                }
560
                                else
561
                                {
562
                                        trigger_error('NO_AUTH_PLUGIN', E_USER_ERROR);
563
                                }
564
                        }
565
                }
566
567
                if ($submit)
568
                {
569
                        add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));
570
571
                        trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
572
                }
573
574
                $this->tpl_name = 'acp_board';
575
                $this->page_title = $display_vars['title'];
576
577
                $template->assign_vars(array(
578
                        'L_TITLE'                        => $user->lang[$display_vars['title']],
579
                        'L_TITLE_EXPLAIN'        => $user->lang[$display_vars['title'] . '_EXPLAIN'],
580
581
                        'S_ERROR'                        => (sizeof($error)) ? true : false,
582
                        'ERROR_MSG'                        => implode('<br />', $error),
583
584
                        'U_ACTION'                        => $this->u_action)
585
                );
586
587
                // Output relevant page
588
                foreach ($display_vars['vars'] as $config_key => $vars)
589
                {
590
                        if (!is_array($vars) && strpos($config_key, 'legend') === false)
591
                        {
592
                                continue;
593
                        }
594
595
                        if (strpos($config_key, 'legend') !== false)
596
                        {
597
                                $template->assign_block_vars('options', array(
598
                                        'S_LEGEND'                => true,
599
                                        'LEGEND'                => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
600
                                );
601
602
                                continue;
603
                        }
604
605
                        $type = explode(':', $vars['type']);
606
607
                        $l_explain = '';
608
                        if ($vars['explain'] && isset($vars['lang_explain']))
609
                        {
610
                                $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
611
                        }
612
                        else if ($vars['explain'])
613
                        {
614
                                $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
615
                        }
616
617
                        $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
618
619
                        if (empty($content))
620
                        {
621
                                continue;
622
                        }
623
624
                        $template->assign_block_vars('options', array(
625
                                'KEY'                        => $config_key,
626
                                'TITLE'                        => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
627
                                'S_EXPLAIN'                => $vars['explain'],
628
                                'TITLE_EXPLAIN'        => $l_explain,
629
                                'CONTENT'                => $content,
630
                                )
631
                        );
632
633
                        unset($display_vars['vars'][$config_key]);
634
                }
635
636
                if ($mode == 'auth')
637
                {
638
                        $template->assign_var('S_AUTH', true);
639
640
                        foreach ($auth_plugins as $method)
641
                        {
642
                                if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
643
                                {
644
                                        $method = 'acp_' . $method;
645
                                        if (function_exists($method))
646
                                        {
647
                                                $fields = $method($this->new_config);
648
649
                                                if ($fields['tpl'])
650
                                                {
651
                                                        $template->assign_block_vars('auth_tpl', array(
652
                                                                'TPL'        => $fields['tpl'])
653
                                                        );
654
                                                }
655
                                                unset($fields);
656
                                        }
657
                                }
658
                        }
659
                }
660
        }
661
662
        /**
663
        * Select auth method
664
        */
665
        function select_auth_method($selected_method, $key = '')
666
        {
667
                global $phpbb_root_path, $phpEx;
668
669
                $auth_plugins = array();
670
671
                $dp = @opendir($phpbb_root_path . 'includes/auth');
672
673
                if (!$dp)
674
                {
675
                        return '';
676
                }
677
678
                while (($file = readdir($dp)) !== false)
679
                {
680
                        if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
681
                        {
682
                                $auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file);
683
                        }
684
                }
685
                closedir($dp);
686
687
                sort($auth_plugins);
688
689
                $auth_select = '';
690
                foreach ($auth_plugins as $method)
691
                {
692
                        $selected = ($selected_method == $method) ? ' selected="selected"' : '';
693
                        $auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>';
694
                }
695
696
                return $auth_select;
697
        }
698
699
        /**
700
        * Select mail authentication method
701
        */
702
        function mail_auth_select($selected_method, $key = '')
703
        {
704
                global $user;
705
706
                $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
707
                $s_smtp_auth_options = '';
708
709
                foreach ($auth_methods as $method)
710
                {
711
                        $s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $user->lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
712
                }
713
714
                return $s_smtp_auth_options;
715
        }
716
717
        /**
718
        * Select full folder action
719
        */
720
        function full_folder_select($value, $key = '')
721
        {
722
                global $user;
723
724
                return '<option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DELETE_OLDEST_MESSAGES'] . '</option><option value="2"' . (($value == 2) ? ' selected="selected"' : '') . '>' . $user->lang['HOLD_NEW_MESSAGES_SHORT'] . '</option>';
725
        }
726
727
        /**
728
        * Select ip validation
729
        */
730
        function select_ip_check($value, $key = '')
731
        {
732
                $radio_ary = array(4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION');
733
734
                return h_radio('config[ip_check]', $radio_ary, $value, $key);
735
        }
736
737
        /**
738
        * Select referer validation
739
        */
740
        function select_ref_check($value, $key = '')
741
        {
742
                $radio_ary = array(REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION');
743
744
                return h_radio('config[referer_validation]', $radio_ary, $value, $key);
745
        }
746
747
        /**
748
        * Select account activation method
749
        */
750
        function select_acc_activation($value, $key = '')
751
        {
752
                global $user, $config;
753
754
                $radio_ary = array(USER_ACTIVATION_DISABLE => 'ACC_DISABLE', USER_ACTIVATION_NONE => 'ACC_NONE');
755
                if ($config['email_enable'])
756
                {
757
                        $radio_ary += array(USER_ACTIVATION_SELF => 'ACC_USER', USER_ACTIVATION_ADMIN => 'ACC_ADMIN');
758
                }
759
760
                return h_radio('config[require_activation]', $radio_ary, $value, $key);
761
        }
762
763
        /**
764
        * Maximum/Minimum username length
765
        */
766
        function username_length($value, $key = '')
767
        {
768
                global $user;
769
770
                return '<input id="' . $key . '" type="text" size="3" maxlength="3" name="config[min_name_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input type="text" size="3" maxlength="3" name="config[max_name_chars]" value="' . $this->new_config['max_name_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
771
        }
772
773
        /**
774
        * Allowed chars in usernames
775
        */
776
        function select_username_chars($selected_value, $key)
777
        {
778
                global $user;
779
780
                $user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII');
781
                $user_char_options = '';
782
                foreach ($user_char_ary as $user_type)
783
                {
784
                        $selected = ($selected_value == $user_type) ? ' selected="selected"' : '';
785
                        $user_char_options .= '<option value="' . $user_type . '"' . $selected . '>' . $user->lang[$user_type] . '</option>';
786
                }
787
788
                return $user_char_options;
789
        }
790
791
        /**
792
        * Maximum/Minimum password length
793
        */
794
        function password_length($value, $key)
795
        {
796
                global $user;
797
798
                return '<input id="' . $key . '" type="text" size="3" maxlength="3" name="config[min_pass_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input type="text" size="3" maxlength="3" name="config[max_pass_chars]" value="' . $this->new_config['max_pass_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
799
        }
800
801
        /**
802
        * Required chars in passwords
803
        */
804
        function select_password_chars($selected_value, $key)
805
        {
806
                global $user;
807
808
                $pass_type_ary = array('PASS_TYPE_ANY', 'PASS_TYPE_CASE', 'PASS_TYPE_ALPHA', 'PASS_TYPE_SYMBOL');
809
                $pass_char_options = '';
810
                foreach ($pass_type_ary as $pass_type)
811
                {
812
                        $selected = ($selected_value == $pass_type) ? ' selected="selected"' : '';
813
                        $pass_char_options .= '<option value="' . $pass_type . '"' . $selected . '>' . $user->lang[$pass_type] . '</option>';
814
                }
815
816
                return $pass_char_options;
817
        }
818
819
        /**
820
        * Select bump interval
821
        */
822
        function bump_interval($value, $key)
823
        {
824
                global $user;
825
826
                $s_bump_type = '';
827
                $types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS');
828
                foreach ($types as $type => $lang)
829
                {
830
                        $selected = ($this->new_config['bump_type'] == $type) ? ' selected="selected"' : '';
831
                        $s_bump_type .= '<option value="' . $type . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
832
                }
833
834
                return '<input id="' . $key . '" type="text" size="3" maxlength="4" name="config[bump_interval]" value="' . $value . '" />&nbsp;<select name="config[bump_type]">' . $s_bump_type . '</select>';
835
        }
836
837
        /**
838
        * Board disable option and message
839
        */
840
        function board_disable($value, $key)
841
        {
842
                global $user;
843
844
                $radio_ary = array(1 => 'YES', 0 => 'NO');
845
846
                return h_radio('config[board_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[board_disable_msg]" maxlength="255" size="40" value="' . $this->new_config['board_disable_msg'] . '" />';
847
        }
848
849
        /**
850
        * Select default dateformat
851
        */
852
        function dateformat_select($value, $key)
853
        {
854
                global $user, $config;
855
856
                // Let the format_date function operate with the acp values
857
                $old_tz = $user->timezone;
858
                $old_dst = $user->dst;
859
860
                $user->timezone = $config['board_timezone'];
861
                $user->dst = $config['board_dst'];
862
863
                $dateformat_options = '';
864
865
                foreach ($user->lang['dateformats'] as $format => $null)
866
                {
867
                        $dateformat_options .= '<option value="' . $format . '"' . (($format == $value) ? ' selected="selected"' : '') . '>';
868
                        $dateformat_options .= $user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : '');
869
                        $dateformat_options .= '</option>';
870
                }
871
872
                $dateformat_options .= '<option value="custom"';
873
                if (!isset($user->lang['dateformats'][$value]))
874
                {
875
                        $dateformat_options .= ' selected="selected"';
876
                }
877
                $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';
878
879
                // Reset users date options
880
                $user->timezone = $old_tz;
881
                $user->dst = $old_dst;
882
883
                return "<select name=\"dateoptions\" id=\"dateoptions\" onchange=\"if (this.value == 'custom') { document.getElementById('" . addslashes($key) . "').value = '" . addslashes($value) . "'; } else { document.getElementById('" . addslashes($key) . "').value = this.value; }\">$dateformat_options</select>
884
                <input type=\"text\" name=\"config[$key]\" id=\"$key\" value=\"$value\" maxlength=\"30\" />";
885
        }
886
887
        /**
888
        * Select multiple forums
889
        */
890
        function select_news_forums($value, $key)
891
        {
892
                global $user, $config;
893
894
                $forum_list = make_forum_select(false, false, true, true, true, false, true);
895
896
                // Build forum options
897
                $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
898
                foreach ($forum_list as $f_id => $f_row)
899
                {
900
                        $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_NEWS, $f_row['forum_options']);
901
902
                        $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
903
                }
904
                $s_forum_options .= '</select>';
905
906
                return $s_forum_options;
907
        }
908
909
        function select_exclude_forums($value, $key)
910
        {
911
                global $user, $config;
912
913
                $forum_list = make_forum_select(false, false, true, false, false, false, true);
914
915
                // Build forum options
916
                $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
917
                foreach ($forum_list as $f_id => $f_row)
918
                {
919
                        $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']);
920
921
                        $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
922
                }
923
                $s_forum_options .= '</select>';
924
925
                return $s_forum_options;
926
        }
927
928
        function store_feed_forums($option, $key)
929
        {
930
                global $db, $cache;
931
932
                // Get key
933
                $values = request_var($key, array(0 => 0));
934
935
                // Empty option bit for all forums
936
                $sql = 'UPDATE ' . FORUMS_TABLE . '
937
                        SET forum_options = forum_options - ' . (1 << $option) . '
938
                        WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0');
939
                $db->sql_query($sql);
940
941
                // Already emptied for all...
942
                if (sizeof($values))
943
                {
944
                        // Set for selected forums
945
                        $sql = 'UPDATE ' . FORUMS_TABLE . '
946
                                SET forum_options = forum_options + ' . (1 << $option) . '
947
                                WHERE ' . $db->sql_in_set('forum_id', $values);
948
                        $db->sql_query($sql);
949
                }
950
951
                // Empty sql cache for forums table because options changed
952
                $cache->destroy('sql', FORUMS_TABLE);
953
        }
954
955
}
956
957
?>