Chris@76
|
1 <?php
|
Chris@76
|
2 /**********************************************************************************
|
Chris@76
|
3 * ModSettings.php *
|
Chris@76
|
4 ***********************************************************************************
|
Chris@76
|
5 * SMF: Simple Machines Forum *
|
Chris@76
|
6 * Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com) *
|
Chris@76
|
7 * =============================================================================== *
|
Chris@76
|
8 * Software Version: SMF 1.1 *
|
Chris@76
|
9 * Software by: Simple Machines (http://www.simplemachines.org) *
|
Chris@76
|
10 * Copyright 2006 by: Simple Machines LLC (http://www.simplemachines.org) *
|
Chris@76
|
11 * 2001-2006 by: Lewis Media (http://www.lewismedia.com) *
|
Chris@76
|
12 * Support, News, Updates at: http://www.simplemachines.org *
|
Chris@76
|
13 ***********************************************************************************
|
Chris@76
|
14 * This program is free software; you may redistribute it and/or modify it under *
|
Chris@76
|
15 * the terms of the provided license as published by Simple Machines LLC. *
|
Chris@76
|
16 * *
|
Chris@76
|
17 * This program is distributed in the hope that it is and will be useful, but *
|
Chris@76
|
18 * WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY *
|
Chris@76
|
19 * or FITNESS FOR A PARTICULAR PURPOSE. *
|
Chris@76
|
20 * *
|
Chris@76
|
21 * See the "license.txt" file for details of the Simple Machines license. *
|
Chris@76
|
22 * The latest version can always be found at http://www.simplemachines.org. *
|
Chris@76
|
23 **********************************************************************************/
|
Chris@76
|
24 if (!defined('SMF'))
|
Chris@76
|
25 die('Hacking attempt...');
|
Chris@76
|
26
|
Chris@76
|
27 /* This file is here to make it easier for installed mods to have settings
|
Chris@76
|
28 and options. It uses the following functions:
|
Chris@76
|
29
|
Chris@76
|
30 void ModifyFeatureSettings()
|
Chris@76
|
31 // !!!
|
Chris@76
|
32
|
Chris@76
|
33 void ModifyFeatureSettings2()
|
Chris@76
|
34 // !!!
|
Chris@76
|
35
|
Chris@76
|
36 void ModifyBasicSettings()
|
Chris@76
|
37 // !!!
|
Chris@76
|
38
|
Chris@76
|
39 void ModifyLayoutSettings()
|
Chris@76
|
40 // !!!
|
Chris@76
|
41
|
Chris@76
|
42 void ModifyKarmaSettings()
|
Chris@76
|
43 // !!!
|
Chris@76
|
44
|
Chris@76
|
45 Adding new settings to the $modSettings array:
|
Chris@76
|
46 ---------------------------------------------------------------------------
|
Chris@76
|
47 // !!!
|
Chris@76
|
48 */
|
Chris@76
|
49
|
Chris@76
|
50 /* Adding options to one of the setting screens isn't hard. The basic format for a checkbox is:
|
Chris@76
|
51 array('check', 'nameInModSettingsAndSQL'),
|
Chris@76
|
52
|
Chris@76
|
53 And for a text box:
|
Chris@76
|
54 array('text', 'nameInModSettingsAndSQL')
|
Chris@76
|
55 (NOTE: You have to add an entry for this at the bottom!)
|
Chris@76
|
56
|
Chris@76
|
57 In these cases, it will look for $txt['nameInModSettingsAndSQL'] as the description,
|
Chris@76
|
58 and $helptxt['nameInModSettingsAndSQL'] as the help popup description.
|
Chris@76
|
59
|
Chris@76
|
60 Here's a quick explanation of how to add a new item:
|
Chris@76
|
61
|
Chris@76
|
62 * A text input box. For textual values.
|
Chris@76
|
63 ie. array('text', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth',
|
Chris@76
|
64 &$txt['OptionalDescriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),
|
Chris@76
|
65
|
Chris@76
|
66 * A text input box. For numerical values.
|
Chris@76
|
67 ie. array('int', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth',
|
Chris@76
|
68 &$txt['OptionalDescriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),
|
Chris@76
|
69
|
Chris@76
|
70 * A text input box. For floating point values.
|
Chris@76
|
71 ie. array('float', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth',
|
Chris@76
|
72 &$txt['OptionalDescriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),
|
Chris@76
|
73
|
Chris@76
|
74 * A large text input box. Used for textual values spanning multiple lines.
|
Chris@76
|
75 ie. array('large_text', 'nameInModSettingsAndSQL', 'OptionalNumberOfRows',
|
Chris@76
|
76 &$txt['OptionalDescriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),
|
Chris@76
|
77
|
Chris@76
|
78 * A check box. Either one or zero. (boolean)
|
Chris@76
|
79 ie. array('check', 'nameInModSettingsAndSQL', null, &$txt['descriptionOfTheOption'],
|
Chris@76
|
80 'OptionalReferenceToHelpAdmin'),
|
Chris@76
|
81
|
Chris@76
|
82 * A selection box. Used for the selection of something from a list.
|
Chris@76
|
83 ie. array('select', 'nameInModSettingsAndSQL', array('valueForSQL' => &$txt['displayedValue']),
|
Chris@76
|
84 &$txt['descriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),
|
Chris@76
|
85 Note that just saying array('first', 'second') will put 0 in the SQL for 'first'.
|
Chris@76
|
86
|
Chris@76
|
87 * A password input box. Used for passwords, no less!
|
Chris@76
|
88 ie. array('password', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth',
|
Chris@76
|
89 &$txt['descriptionOfTheOption'], 'OptionalReferenceToHelpAdmin'),
|
Chris@76
|
90
|
Chris@76
|
91 For each option:
|
Chris@76
|
92 type (see above), variable name, size/possible values, description, helptext.
|
Chris@76
|
93 OR make type 'rule' for an empty string for a horizontal rule.
|
Chris@76
|
94 OR make type 'heading' with a string for a titled section. */
|
Chris@76
|
95
|
Chris@76
|
96 // This function passes control through to the relevant tab.
|
Chris@76
|
97 function ModifyFeatureSettings()
|
Chris@76
|
98 {
|
Chris@76
|
99 global $context, $txt, $scripturl, $modSettings, $sourcedir;
|
Chris@76
|
100
|
Chris@76
|
101 // You need to be an admin to edit settings!
|
Chris@76
|
102 isAllowedTo('admin_forum');
|
Chris@76
|
103
|
Chris@76
|
104 // All the admin bar, to make it right.
|
Chris@76
|
105 adminIndex('edit_mods_settings');
|
Chris@76
|
106 loadLanguage('Help');
|
Chris@76
|
107 loadLanguage('ModSettings');
|
Chris@76
|
108
|
Chris@76
|
109 // Will need the utility functions from here.
|
Chris@76
|
110 require_once($sourcedir . '/ManageServer.php');
|
Chris@76
|
111
|
Chris@76
|
112 $context['page_title'] = $txt['modSettings_title'];
|
Chris@76
|
113 $context['sub_template'] = 'show_settings';
|
Chris@76
|
114
|
Chris@76
|
115 $subActions = array(
|
Chris@76
|
116 'basic' => 'ModifyBasicSettings',
|
Chris@76
|
117 'layout' => 'ModifyLayoutSettings',
|
Chris@76
|
118 'karma' => 'ModifyKarmaSettings',
|
Chris@76
|
119 );
|
Chris@76
|
120
|
Chris@76
|
121 // By default do the basic settings.
|
Chris@76
|
122 $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'basic';
|
Chris@76
|
123 $context['sub_action'] = $_REQUEST['sa'];
|
Chris@76
|
124
|
Chris@76
|
125 // Load up all the tabs...
|
Chris@76
|
126 $context['admin_tabs'] = array(
|
Chris@76
|
127 'title' => &$txt['modSettings_title'],
|
Chris@76
|
128 'help' => 'modsettings',
|
Chris@76
|
129 'description' => $txt['smf3'],
|
Chris@76
|
130 'tabs' => array(
|
Chris@76
|
131 'basic' => array(
|
Chris@76
|
132 'title' => $txt['mods_cat_features'],
|
Chris@76
|
133 'href' => $scripturl . '?action=featuresettings;sa=basic;sesc=' . $context['session_id'],
|
Chris@76
|
134 ),
|
Chris@76
|
135 'layout' => array(
|
Chris@76
|
136 'title' => $txt['mods_cat_layout'],
|
Chris@76
|
137 'href' => $scripturl . '?action=featuresettings;sa=layout;sesc=' . $context['session_id'],
|
Chris@76
|
138 ),
|
Chris@76
|
139 'karma' => array(
|
Chris@76
|
140 'title' => $txt['smf293'],
|
Chris@76
|
141 'href' => $scripturl . '?action=featuresettings;sa=karma;sesc=' . $context['session_id'],
|
Chris@76
|
142 'is_last' => true,
|
Chris@76
|
143 ),
|
Chris@76
|
144 ),
|
Chris@76
|
145 );
|
Chris@76
|
146
|
Chris@76
|
147 // Select the right tab based on the sub action.
|
Chris@76
|
148 if (isset($context['admin_tabs']['tabs'][$context['sub_action']]))
|
Chris@76
|
149 $context['admin_tabs']['tabs'][$context['sub_action']]['is_selected'] = true;
|
Chris@76
|
150
|
Chris@76
|
151 // Call the right function for this sub-acton.
|
Chris@76
|
152 $subActions[$_REQUEST['sa']]();
|
Chris@76
|
153 }
|
Chris@76
|
154
|
Chris@76
|
155 // This function basically just redirects to the right save function.
|
Chris@76
|
156 function ModifyFeatureSettings2()
|
Chris@76
|
157 {
|
Chris@76
|
158 global $context, $txt, $scripturl, $modSettings, $sourcedir;
|
Chris@76
|
159
|
Chris@76
|
160 isAllowedTo('admin_forum');
|
Chris@76
|
161 loadLanguage('ModSettings');
|
Chris@76
|
162
|
Chris@76
|
163 // Quick session check...
|
Chris@76
|
164 checkSession();
|
Chris@76
|
165
|
Chris@76
|
166 require_once($sourcedir . '/ManageServer.php');
|
Chris@76
|
167
|
Chris@76
|
168 $subActions = array(
|
Chris@76
|
169 'basic' => 'ModifyBasicSettings',
|
Chris@76
|
170 'layout' => 'ModifyLayoutSettings',
|
Chris@76
|
171 'karma' => 'ModifyKarmaSettings',
|
Chris@76
|
172 );
|
Chris@76
|
173
|
Chris@76
|
174 // Default to core (I assume)
|
Chris@76
|
175 $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'basic';
|
Chris@76
|
176
|
Chris@76
|
177 // Actually call the saving function.
|
Chris@76
|
178 $subActions[$_REQUEST['sa']]();
|
Chris@76
|
179 }
|
Chris@76
|
180
|
Chris@76
|
181 function ModifyBasicSettings()
|
Chris@76
|
182 {
|
Chris@76
|
183 global $txt, $scripturl, $context, $settings, $sc, $modSettings;
|
Chris@76
|
184
|
Chris@76
|
185 $config_vars = array(
|
Chris@76
|
186 // Big Options... polls, sticky, bbc....
|
Chris@76
|
187 array('select', 'pollMode', array(&$txt['smf34'], &$txt['smf32'], &$txt['smf33'])),
|
Chris@76
|
188 '',
|
Chris@76
|
189 // Basic stuff, user languages, titles, flash, permissions...
|
Chris@76
|
190 array('check', 'allow_guestAccess'),
|
Chris@76
|
191 array('check', 'userLanguage'),
|
Chris@76
|
192 array('check', 'allow_editDisplayName'),
|
Chris@76
|
193 array('check', 'allow_hideOnline'),
|
Chris@76
|
194 array('check', 'allow_hideEmail'),
|
Chris@76
|
195 array('check', 'guest_hideContacts'),
|
Chris@76
|
196 array('check', 'titlesEnable'),
|
Chris@76
|
197 array('check', 'enable_buddylist'),
|
Chris@76
|
198 array('text', 'default_personalText'),
|
Chris@76
|
199 array('int', 'max_signatureLength'),
|
Chris@76
|
200 '',
|
Chris@76
|
201 // Stats, compression, cookies.... server type stuff.
|
Chris@76
|
202 array('text', 'time_format'),
|
Chris@76
|
203 array('select', 'number_format', array('1234.00' => '1234.00', '1,234.00' => '1,234.00', '1.234,00' => '1.234,00', '1 234,00' => '1 234,00', '1234,00' => '1234,00')),
|
Chris@76
|
204 array('float', 'time_offset'),
|
Chris@76
|
205 array('int', 'failed_login_threshold'),
|
Chris@76
|
206 array('int', 'lastActive'),
|
Chris@76
|
207 array('check', 'trackStats'),
|
Chris@76
|
208 array('check', 'hitStats'),
|
Chris@76
|
209 array('check', 'enableErrorLogging'),
|
Chris@76
|
210 array('check', 'securityDisable'),
|
Chris@76
|
211 '',
|
Chris@76
|
212 // Reactive on email, and approve on delete
|
Chris@76
|
213 array('check', 'send_validation_onChange'),
|
Chris@76
|
214 array('check', 'approveAccountDeletion'),
|
Chris@76
|
215 '',
|
Chris@76
|
216 // Option-ish things... miscellaneous sorta.
|
Chris@76
|
217 array('check', 'allow_disableAnnounce'),
|
Chris@76
|
218 array('check', 'disallow_sendBody'),
|
Chris@76
|
219 array('check', 'modlog_enabled'),
|
Chris@76
|
220 array('check', 'queryless_urls'),
|
Chris@76
|
221 '',
|
Chris@76
|
222 // Width/Height image reduction.
|
Chris@76
|
223 array('int', 'max_image_width'),
|
Chris@76
|
224 array('int', 'max_image_height'),
|
Chris@76
|
225 '',
|
Chris@76
|
226 // Reporting of personal messages?
|
Chris@76
|
227 array('check', 'enableReportPM'),
|
Chris@76
|
228 );
|
Chris@76
|
229
|
Chris@76
|
230 // Saving?
|
Chris@76
|
231 if (isset($_GET['save']))
|
Chris@76
|
232 {
|
Chris@76
|
233 // Fix PM settings.
|
Chris@76
|
234 $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
|
Chris@76
|
235 $save_vars = $config_vars;
|
Chris@76
|
236 $save_vars[] = array('text', 'pm_spam_settings');
|
Chris@76
|
237
|
Chris@76
|
238 saveDBSettings($save_vars);
|
Chris@76
|
239
|
Chris@76
|
240 writeLog();
|
Chris@76
|
241 redirectexit('action=featuresettings;sa=basic');
|
Chris@76
|
242 }
|
Chris@76
|
243
|
Chris@76
|
244 // Hack for PM spam settings.
|
Chris@76
|
245 list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
|
Chris@76
|
246 $config_vars[] = array('int', 'max_pm_recipients');
|
Chris@76
|
247 $config_vars[] = array('int', 'pm_posts_verification');
|
Chris@76
|
248 $config_vars[] = array('int', 'pm_posts_per_hour');
|
Chris@76
|
249
|
Chris@76
|
250 $context['post_url'] = $scripturl . '?action=featuresettings2;save;sa=basic';
|
Chris@76
|
251 $context['settings_title'] = $txt['mods_cat_features'];
|
Chris@76
|
252
|
Chris@76
|
253 prepareDBSettingContext($config_vars);
|
Chris@76
|
254 }
|
Chris@76
|
255
|
Chris@76
|
256 function ModifyLayoutSettings()
|
Chris@76
|
257 {
|
Chris@76
|
258 global $txt, $scripturl, $context, $settings, $sc;
|
Chris@76
|
259
|
Chris@76
|
260 $config_vars = array(
|
Chris@76
|
261 // Compact pages?
|
Chris@76
|
262 array('check', 'compactTopicPagesEnable'),
|
Chris@76
|
263 array('int', 'compactTopicPagesContiguous', null, $txt['smf235'] . '<div class="smalltext">' . str_replace(' ', ' ', '"3" ' . $txt['smf236'] . ': <b>1 ... 4 [5] 6 ... 9</b>') . '<br />' . str_replace(' ', ' ', '"5" ' . $txt['smf236'] . ': <b>1 ... 3 4 [5] 6 7 ... 9</b>') . '</div>'),
|
Chris@76
|
264 '',
|
Chris@76
|
265 // Stuff that just is everywhere - today, search, online, etc.
|
Chris@76
|
266 array('select', 'todayMod', array(&$txt['smf290'], &$txt['smf291'], &$txt['smf292'])),
|
Chris@76
|
267 array('check', 'topbottomEnable'),
|
Chris@76
|
268 array('check', 'onlineEnable'),
|
Chris@76
|
269 array('check', 'enableVBStyleLogin'),
|
Chris@76
|
270 '',
|
Chris@76
|
271 // Pagination stuff.
|
Chris@76
|
272 array('int', 'defaultMaxMembers'),
|
Chris@76
|
273 '',
|
Chris@76
|
274 // This is like debugging sorta.
|
Chris@76
|
275 array('check', 'timeLoadPageEnable'),
|
Chris@76
|
276 array('check', 'disableHostnameLookup'),
|
Chris@76
|
277 '',
|
Chris@76
|
278 // Who's online.
|
Chris@76
|
279 array('check', 'who_enabled'),
|
Chris@76
|
280 );
|
Chris@76
|
281
|
Chris@76
|
282 // Saving?
|
Chris@76
|
283 if (isset($_GET['save']))
|
Chris@76
|
284 {
|
Chris@76
|
285 saveDBSettings($config_vars);
|
Chris@76
|
286 redirectexit('action=featuresettings;sa=layout');
|
Chris@76
|
287
|
Chris@76
|
288 loadUserSettings();
|
Chris@76
|
289 writeLog();
|
Chris@76
|
290 }
|
Chris@76
|
291
|
Chris@76
|
292 $context['post_url'] = $scripturl . '?action=featuresettings2;save;sa=layout';
|
Chris@76
|
293 $context['settings_title'] = $txt['mods_cat_layout'];
|
Chris@76
|
294
|
Chris@76
|
295 prepareDBSettingContext($config_vars);
|
Chris@76
|
296 }
|
Chris@76
|
297
|
Chris@76
|
298 function ModifyKarmaSettings()
|
Chris@76
|
299 {
|
Chris@76
|
300 global $txt, $scripturl, $context, $settings, $sc;
|
Chris@76
|
301
|
Chris@76
|
302 $config_vars = array(
|
Chris@76
|
303 // Karma - On or off?
|
Chris@76
|
304 array('select', 'karmaMode', explode('|', $txt['smf64'])),
|
Chris@76
|
305 '',
|
Chris@76
|
306 // Who can do it.... and who is restricted by time limits?
|
Chris@76
|
307 array('int', 'karmaMinPosts'),
|
Chris@76
|
308 array('float', 'karmaWaitTime'),
|
Chris@76
|
309 array('check', 'karmaTimeRestrictAdmins'),
|
Chris@76
|
310 '',
|
Chris@76
|
311 // What does it look like? [smite]?
|
Chris@76
|
312 array('text', 'karmaLabel'),
|
Chris@76
|
313 array('text', 'karmaApplaudLabel'),
|
Chris@76
|
314 array('text', 'karmaSmiteLabel'),
|
Chris@76
|
315 );
|
Chris@76
|
316
|
Chris@76
|
317 // Saving?
|
Chris@76
|
318 if (isset($_GET['save']))
|
Chris@76
|
319 {
|
Chris@76
|
320 saveDBSettings($config_vars);
|
Chris@76
|
321 redirectexit('action=featuresettings;sa=karma');
|
Chris@76
|
322 }
|
Chris@76
|
323
|
Chris@76
|
324 $context['post_url'] = $scripturl . '?action=featuresettings2;save;sa=karma';
|
Chris@76
|
325 $context['settings_title'] = $txt['smf293'];
|
Chris@76
|
326
|
Chris@76
|
327 prepareDBSettingContext($config_vars);
|
Chris@76
|
328 }
|
Chris@76
|
329
|
Chris@76
|
330 ?> |