1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file, unpredictable as this might be, handles basic administration. |
||
5 | * |
||
6 | * Simple Machines Forum (SMF) |
||
7 | * |
||
8 | * @package SMF |
||
9 | * @author Simple Machines https://www.simplemachines.org |
||
10 | * @copyright 2022 Simple Machines and individual contributors |
||
11 | * @license https://www.simplemachines.org/about/smf/license.php BSD |
||
12 | * |
||
13 | * @version 2.1.0 |
||
14 | */ |
||
15 | |||
16 | if (!defined('SMF')) |
||
17 | die('No direct access...'); |
||
18 | |||
19 | /** |
||
20 | * The main admin handling function.<br> |
||
21 | * It initialises all the basic context required for the admin center.<br> |
||
22 | * It passes execution onto the relevant admin section.<br> |
||
23 | * If the passed section is not found it shows the admin home page. |
||
24 | */ |
||
25 | function AdminMain() |
||
26 | { |
||
27 | global $txt, $context, $scripturl, $modSettings, $settings; |
||
28 | global $smcFunc, $sourcedir, $options, $boarddir; |
||
29 | |||
30 | // Load the language and templates.... |
||
31 | loadLanguage('Admin'); |
||
32 | loadTemplate('Admin'); |
||
33 | loadJavaScriptFile('admin.js', array('minimize' => true), 'smf_admin'); |
||
34 | loadCSSFile('admin.css', array(), 'smf_admin'); |
||
35 | |||
36 | // No indexing evil stuff. |
||
37 | $context['robot_no_index'] = true; |
||
38 | |||
39 | require_once($sourcedir . '/Subs-Menu.php'); |
||
40 | |||
41 | // Some preferences. |
||
42 | $context['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
||
43 | |||
44 | /** @var array $admin_areas Defines the menu structure for the admin center. See {@link Subs-Menu.php Subs-Menu.php} for details! */ |
||
45 | $admin_areas = array( |
||
46 | 'forum' => array( |
||
47 | 'title' => $txt['admin_main'], |
||
48 | 'permission' => array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'), |
||
49 | 'areas' => array( |
||
50 | 'index' => array( |
||
51 | 'label' => $txt['admin_center'], |
||
52 | 'function' => 'AdminHome', |
||
53 | 'icon' => 'administration', |
||
54 | ), |
||
55 | 'credits' => array( |
||
56 | 'label' => $txt['support_credits_title'], |
||
57 | 'function' => 'AdminHome', |
||
58 | 'icon' => 'support', |
||
59 | ), |
||
60 | 'news' => array( |
||
61 | 'label' => $txt['news_title'], |
||
62 | 'file' => 'ManageNews.php', |
||
63 | 'function' => 'ManageNews', |
||
64 | 'icon' => 'news', |
||
65 | 'permission' => array('edit_news', 'send_mail', 'admin_forum'), |
||
66 | 'subsections' => array( |
||
67 | 'editnews' => array($txt['admin_edit_news'], 'edit_news'), |
||
68 | 'mailingmembers' => array($txt['admin_newsletters'], 'send_mail'), |
||
69 | 'settings' => array($txt['settings'], 'admin_forum'), |
||
70 | ), |
||
71 | ), |
||
72 | 'packages' => array( |
||
73 | 'label' => $txt['package'], |
||
74 | 'file' => 'Packages.php', |
||
75 | 'function' => 'Packages', |
||
76 | 'permission' => array('admin_forum'), |
||
77 | 'icon' => 'packages', |
||
78 | 'subsections' => array( |
||
79 | 'browse' => array($txt['browse_packages']), |
||
80 | 'packageget' => array($txt['download_packages'], 'url' => $scripturl . '?action=admin;area=packages;sa=packageget;get'), |
||
81 | 'perms' => array($txt['package_file_perms']), |
||
82 | 'options' => array($txt['package_settings']), |
||
83 | ), |
||
84 | ), |
||
85 | 'search' => array( |
||
86 | 'function' => 'AdminSearch', |
||
87 | 'permission' => array('admin_forum'), |
||
88 | 'select' => 'index' |
||
89 | ), |
||
90 | 'adminlogoff' => array( |
||
91 | 'label' => $txt['admin_logoff'], |
||
92 | 'function' => 'AdminEndSession', |
||
93 | 'enabled' => empty($modSettings['securityDisable']), |
||
94 | 'icon' => 'exit', |
||
95 | ), |
||
96 | |||
97 | ), |
||
98 | ), |
||
99 | 'config' => array( |
||
100 | 'title' => $txt['admin_config'], |
||
101 | 'permission' => array('admin_forum'), |
||
102 | 'areas' => array( |
||
103 | 'featuresettings' => array( |
||
104 | 'label' => $txt['modSettings_title'], |
||
105 | 'file' => 'ManageSettings.php', |
||
106 | 'function' => 'ModifyFeatureSettings', |
||
107 | 'icon' => 'features', |
||
108 | 'subsections' => array( |
||
109 | 'basic' => array($txt['mods_cat_features']), |
||
110 | 'bbc' => array($txt['manageposts_bbc_settings']), |
||
111 | 'layout' => array($txt['mods_cat_layout']), |
||
112 | 'sig' => array($txt['signature_settings_short']), |
||
113 | 'profile' => array($txt['custom_profile_shorttitle']), |
||
114 | 'likes' => array($txt['likes']), |
||
115 | 'mentions' => array($txt['mentions']), |
||
116 | 'alerts' => array($txt['notifications']), |
||
117 | ), |
||
118 | ), |
||
119 | 'antispam' => array( |
||
120 | 'label' => $txt['antispam_title'], |
||
121 | 'file' => 'ManageSettings.php', |
||
122 | 'function' => 'ModifyAntispamSettings', |
||
123 | 'icon' => 'security', |
||
124 | ), |
||
125 | 'languages' => array( |
||
126 | 'label' => $txt['language_configuration'], |
||
127 | 'file' => 'ManageLanguages.php', |
||
128 | 'function' => 'ManageLanguages', |
||
129 | 'icon' => 'languages', |
||
130 | 'subsections' => array( |
||
131 | 'edit' => array($txt['language_edit']), |
||
132 | 'add' => array($txt['language_add']), |
||
133 | 'settings' => array($txt['language_settings']), |
||
134 | ), |
||
135 | ), |
||
136 | 'current_theme' => array( |
||
137 | 'label' => $txt['theme_current_settings'], |
||
138 | 'file' => 'Themes.php', |
||
139 | 'function' => 'ThemesMain', |
||
140 | 'custom_url' => $scripturl . '?action=admin;area=theme;sa=list;th=' . $settings['theme_id'], |
||
141 | 'icon' => 'current_theme', |
||
142 | ), |
||
143 | 'theme' => array( |
||
144 | 'label' => $txt['theme_admin'], |
||
145 | 'file' => 'Themes.php', |
||
146 | 'function' => 'ThemesMain', |
||
147 | 'custom_url' => $scripturl . '?action=admin;area=theme', |
||
148 | 'icon' => 'themes', |
||
149 | 'subsections' => array( |
||
150 | 'admin' => array($txt['themeadmin_admin_title']), |
||
151 | 'list' => array($txt['themeadmin_list_title']), |
||
152 | 'reset' => array($txt['themeadmin_reset_title']), |
||
153 | 'edit' => array($txt['themeadmin_edit_title']), |
||
154 | ), |
||
155 | ), |
||
156 | 'modsettings' => array( |
||
157 | 'label' => $txt['admin_modifications'], |
||
158 | 'file' => 'ManageSettings.php', |
||
159 | 'function' => 'ModifyModSettings', |
||
160 | 'icon' => 'modifications', |
||
161 | 'subsections' => array( |
||
162 | 'general' => array($txt['mods_cat_modifications_misc']), |
||
163 | // Mod Authors for a "ADD AFTER" on this line. Ensure you end your change with a comma. For example: |
||
164 | // 'shout' => array($txt['shout']), |
||
165 | // Note the comma!! The setting with automatically appear with the first mod to be added. |
||
166 | ), |
||
167 | ), |
||
168 | ), |
||
169 | ), |
||
170 | 'layout' => array( |
||
171 | 'title' => $txt['layout_controls'], |
||
172 | 'permission' => array('manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum'), |
||
173 | 'areas' => array( |
||
174 | 'manageboards' => array( |
||
175 | 'label' => $txt['admin_boards'], |
||
176 | 'file' => 'ManageBoards.php', |
||
177 | 'function' => 'ManageBoards', |
||
178 | 'icon' => 'boards', |
||
179 | 'permission' => array('manage_boards'), |
||
180 | 'subsections' => array( |
||
181 | 'main' => array($txt['boards_edit']), |
||
182 | 'newcat' => array($txt['mboards_new_cat']), |
||
183 | 'settings' => array($txt['settings'], 'admin_forum'), |
||
184 | ), |
||
185 | ), |
||
186 | 'postsettings' => array( |
||
187 | 'label' => $txt['manageposts'], |
||
188 | 'file' => 'ManagePosts.php', |
||
189 | 'function' => 'ManagePostSettings', |
||
190 | 'permission' => array('admin_forum'), |
||
191 | 'icon' => 'posts', |
||
192 | 'subsections' => array( |
||
193 | 'posts' => array($txt['manageposts_settings']), |
||
194 | 'censor' => array($txt['admin_censored_words']), |
||
195 | 'topics' => array($txt['manageposts_topic_settings']), |
||
196 | 'drafts' => array($txt['manage_drafts']), |
||
197 | ), |
||
198 | ), |
||
199 | 'managecalendar' => array( |
||
200 | 'label' => $txt['manage_calendar'], |
||
201 | 'file' => 'ManageCalendar.php', |
||
202 | 'function' => 'ManageCalendar', |
||
203 | 'icon' => 'calendar', |
||
204 | 'permission' => array('admin_forum'), |
||
205 | 'inactive' => empty($modSettings['cal_enabled']), |
||
206 | 'subsections' => empty($modSettings['cal_enabled']) ? array() : array( |
||
207 | 'holidays' => array($txt['manage_holidays'], 'admin_forum'), |
||
208 | 'settings' => array($txt['calendar_settings'], 'admin_forum'), |
||
209 | ), |
||
210 | ), |
||
211 | 'managesearch' => array( |
||
212 | 'label' => $txt['manage_search'], |
||
213 | 'file' => 'ManageSearch.php', |
||
214 | 'function' => 'ManageSearch', |
||
215 | 'icon' => 'search', |
||
216 | 'permission' => array('admin_forum'), |
||
217 | 'subsections' => array( |
||
218 | 'weights' => array($txt['search_weights']), |
||
219 | 'method' => array($txt['search_method']), |
||
220 | 'settings' => array($txt['settings']), |
||
221 | ), |
||
222 | ), |
||
223 | 'smileys' => array( |
||
224 | 'label' => $txt['smileys_manage'], |
||
225 | 'file' => 'ManageSmileys.php', |
||
226 | 'function' => 'ManageSmileys', |
||
227 | 'icon' => 'smiley', |
||
228 | 'permission' => array('manage_smileys'), |
||
229 | 'subsections' => array( |
||
230 | 'editsets' => array($txt['smiley_sets']), |
||
231 | 'addsmiley' => array($txt['smileys_add'], 'enabled' => !empty($modSettings['smiley_enable'])), |
||
232 | 'editsmileys' => array($txt['smileys_edit'], 'enabled' => !empty($modSettings['smiley_enable'])), |
||
233 | 'setorder' => array($txt['smileys_set_order'], 'enabled' => !empty($modSettings['smiley_enable'])), |
||
234 | 'editicons' => array($txt['icons_edit_message_icons'], 'enabled' => !empty($modSettings['messageIcons_enable'])), |
||
235 | 'settings' => array($txt['settings']), |
||
236 | ), |
||
237 | ), |
||
238 | 'manageattachments' => array( |
||
239 | 'label' => $txt['attachments_avatars'], |
||
240 | 'file' => 'ManageAttachments.php', |
||
241 | 'function' => 'ManageAttachments', |
||
242 | 'icon' => 'attachment', |
||
243 | 'permission' => array('manage_attachments'), |
||
244 | 'subsections' => array( |
||
245 | 'browse' => array($txt['attachment_manager_browse']), |
||
246 | 'attachments' => array($txt['attachment_manager_settings']), |
||
247 | 'avatars' => array($txt['attachment_manager_avatar_settings']), |
||
248 | 'attachpaths' => array($txt['attach_directories']), |
||
249 | 'maintenance' => array($txt['attachment_manager_maintenance']), |
||
250 | ), |
||
251 | ), |
||
252 | 'sengines' => array( |
||
253 | 'label' => $txt['search_engines'], |
||
254 | 'inactive' => empty($modSettings['spider_mode']), |
||
255 | 'file' => 'ManageSearchEngines.php', |
||
256 | 'icon' => 'engines', |
||
257 | 'function' => 'SearchEngines', |
||
258 | 'permission' => 'admin_forum', |
||
259 | 'subsections' => empty($modSettings['spider_mode']) ? array() : array( |
||
260 | 'stats' => array($txt['spider_stats']), |
||
261 | 'logs' => array($txt['spider_logs']), |
||
262 | 'spiders' => array($txt['spiders']), |
||
263 | 'settings' => array($txt['settings']), |
||
264 | ), |
||
265 | ), |
||
266 | ), |
||
267 | ), |
||
268 | 'members' => array( |
||
269 | 'title' => $txt['admin_manage_members'], |
||
270 | 'permission' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'), |
||
271 | 'areas' => array( |
||
272 | 'viewmembers' => array( |
||
273 | 'label' => $txt['admin_users'], |
||
274 | 'file' => 'ManageMembers.php', |
||
275 | 'function' => 'ViewMembers', |
||
276 | 'icon' => 'members', |
||
277 | 'permission' => array('moderate_forum'), |
||
278 | 'subsections' => array( |
||
279 | 'all' => array($txt['view_all_members']), |
||
280 | 'search' => array($txt['mlist_search']), |
||
281 | ), |
||
282 | ), |
||
283 | 'membergroups' => array( |
||
284 | 'label' => $txt['admin_groups'], |
||
285 | 'file' => 'ManageMembergroups.php', |
||
286 | 'function' => 'ModifyMembergroups', |
||
287 | 'icon' => 'membergroups', |
||
288 | 'permission' => array('manage_membergroups'), |
||
289 | 'subsections' => array( |
||
290 | 'index' => array($txt['membergroups_edit_groups'], 'manage_membergroups'), |
||
291 | 'add' => array($txt['membergroups_new_group'], 'manage_membergroups'), |
||
292 | 'settings' => array($txt['settings'], 'admin_forum'), |
||
293 | ), |
||
294 | ), |
||
295 | 'permissions' => array( |
||
296 | 'label' => $txt['edit_permissions'], |
||
297 | 'file' => 'ManagePermissions.php', |
||
298 | 'function' => 'ModifyPermissions', |
||
299 | 'icon' => 'permissions', |
||
300 | 'permission' => array('manage_permissions'), |
||
301 | 'subsections' => array( |
||
302 | 'index' => array($txt['permissions_groups'], 'manage_permissions'), |
||
303 | 'board' => array($txt['permissions_boards'], 'manage_permissions'), |
||
304 | 'profiles' => array($txt['permissions_profiles'], 'manage_permissions'), |
||
305 | 'postmod' => array($txt['permissions_post_moderation'], 'manage_permissions'), |
||
306 | 'settings' => array($txt['settings'], 'admin_forum'), |
||
307 | ), |
||
308 | ), |
||
309 | 'regcenter' => array( |
||
310 | 'label' => $txt['registration_center'], |
||
311 | 'file' => 'ManageRegistration.php', |
||
312 | 'function' => 'RegCenter', |
||
313 | 'icon' => 'regcenter', |
||
314 | 'permission' => array('admin_forum', 'moderate_forum'), |
||
315 | 'subsections' => array( |
||
316 | 'register' => array($txt['admin_browse_register_new'], 'moderate_forum'), |
||
317 | 'agreement' => array($txt['registration_agreement'], 'admin_forum'), |
||
318 | 'policy' => array($txt['privacy_policy'], 'admin_forum'), |
||
319 | 'reservednames' => array($txt['admin_reserved_set'], 'admin_forum'), |
||
320 | 'settings' => array($txt['settings'], 'admin_forum'), |
||
321 | ), |
||
322 | ), |
||
323 | 'warnings' => array( |
||
324 | 'label' => $txt['warnings'], |
||
325 | 'file' => 'ManageSettings.php', |
||
326 | 'function' => 'ModifyWarningSettings', |
||
327 | 'icon' => 'warning', |
||
328 | 'inactive' => $modSettings['warning_settings'][0] == 0, |
||
329 | 'permission' => array('admin_forum'), |
||
330 | ), |
||
331 | 'ban' => array( |
||
332 | 'label' => $txt['ban_title'], |
||
333 | 'file' => 'ManageBans.php', |
||
334 | 'function' => 'Ban', |
||
335 | 'icon' => 'ban', |
||
336 | 'permission' => 'manage_bans', |
||
337 | 'subsections' => array( |
||
338 | 'list' => array($txt['ban_edit_list']), |
||
339 | 'add' => array($txt['ban_add_new']), |
||
340 | 'browse' => array($txt['ban_trigger_browse']), |
||
341 | 'log' => array($txt['ban_log']), |
||
342 | ), |
||
343 | ), |
||
344 | 'paidsubscribe' => array( |
||
345 | 'label' => $txt['paid_subscriptions'], |
||
346 | 'inactive' => empty($modSettings['paid_enabled']), |
||
347 | 'file' => 'ManagePaid.php', |
||
348 | 'icon' => 'paid', |
||
349 | 'function' => 'ManagePaidSubscriptions', |
||
350 | 'permission' => 'admin_forum', |
||
351 | 'subsections' => empty($modSettings['paid_enabled']) ? array() : array( |
||
352 | 'view' => array($txt['paid_subs_view']), |
||
353 | 'settings' => array($txt['settings']), |
||
354 | ), |
||
355 | ), |
||
356 | ), |
||
357 | ), |
||
358 | 'maintenance' => array( |
||
359 | 'title' => $txt['admin_maintenance'], |
||
360 | 'permission' => array('admin_forum'), |
||
361 | 'areas' => array( |
||
362 | 'serversettings' => array( |
||
363 | 'label' => $txt['admin_server_settings'], |
||
364 | 'file' => 'ManageServer.php', |
||
365 | 'function' => 'ModifySettings', |
||
366 | 'icon' => 'server', |
||
367 | 'subsections' => array( |
||
368 | 'general' => array($txt['general_settings']), |
||
369 | 'database' => array($txt['database_settings']), |
||
370 | 'cookie' => array($txt['cookies_sessions_settings']), |
||
371 | 'security' => array($txt['security_settings']), |
||
372 | 'cache' => array($txt['caching_settings']), |
||
373 | 'export' => array($txt['export_settings']), |
||
374 | 'loads' => array($txt['load_balancing_settings']), |
||
375 | 'phpinfo' => array($txt['phpinfo_settings']), |
||
376 | ), |
||
377 | ), |
||
378 | 'maintain' => array( |
||
379 | 'label' => $txt['maintain_title'], |
||
380 | 'file' => 'ManageMaintenance.php', |
||
381 | 'icon' => 'maintain', |
||
382 | 'function' => 'ManageMaintenance', |
||
383 | 'subsections' => array( |
||
384 | 'routine' => array($txt['maintain_sub_routine'], 'admin_forum'), |
||
385 | 'database' => array($txt['maintain_sub_database'], 'admin_forum'), |
||
386 | 'members' => array($txt['maintain_sub_members'], 'admin_forum'), |
||
387 | 'topics' => array($txt['maintain_sub_topics'], 'admin_forum'), |
||
388 | 'hooks' => array($txt['hooks_title_list'], 'admin_forum'), |
||
389 | ), |
||
390 | ), |
||
391 | 'scheduledtasks' => array( |
||
392 | 'label' => $txt['maintain_tasks'], |
||
393 | 'file' => 'ManageScheduledTasks.php', |
||
394 | 'icon' => 'scheduled', |
||
395 | 'function' => 'ManageScheduledTasks', |
||
396 | 'subsections' => array( |
||
397 | 'tasks' => array($txt['maintain_tasks'], 'admin_forum'), |
||
398 | 'tasklog' => array($txt['scheduled_log'], 'admin_forum'), |
||
399 | 'settings' => array($txt['scheduled_tasks_settings'], 'admin_forum'), |
||
400 | ), |
||
401 | ), |
||
402 | 'mailqueue' => array( |
||
403 | 'label' => $txt['mailqueue_title'], |
||
404 | 'file' => 'ManageMail.php', |
||
405 | 'function' => 'ManageMail', |
||
406 | 'icon' => 'mail', |
||
407 | 'subsections' => array( |
||
408 | 'browse' => array($txt['mailqueue_browse'], 'admin_forum'), |
||
409 | 'settings' => array($txt['mailqueue_settings'], 'admin_forum'), |
||
410 | 'test' => array($txt['mailqueue_test'], 'admin_forum'), |
||
411 | ), |
||
412 | ), |
||
413 | 'reports' => array( |
||
414 | 'label' => $txt['generate_reports'], |
||
415 | 'file' => 'Reports.php', |
||
416 | 'function' => 'ReportsMain', |
||
417 | 'icon' => 'reports', |
||
418 | ), |
||
419 | 'logs' => array( |
||
420 | 'label' => $txt['logs'], |
||
421 | 'function' => 'AdminLogs', |
||
422 | 'icon' => 'logs', |
||
423 | 'subsections' => array( |
||
424 | 'errorlog' => array($txt['errorlog'], 'admin_forum', 'enabled' => !empty($modSettings['enableErrorLogging']), 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc'), |
||
425 | 'adminlog' => array($txt['admin_log'], 'admin_forum', 'enabled' => !empty($modSettings['adminlog_enabled'])), |
||
426 | 'modlog' => array($txt['moderation_log'], 'admin_forum', 'enabled' => !empty($modSettings['modlog_enabled'])), |
||
427 | 'banlog' => array($txt['ban_log'], 'manage_bans'), |
||
428 | 'spiderlog' => array($txt['spider_logs'], 'admin_forum', 'enabled' => !empty($modSettings['spider_mode'])), |
||
429 | 'tasklog' => array($txt['scheduled_log'], 'admin_forum'), |
||
430 | 'settings' => array($txt['log_settings'], 'admin_forum'), |
||
431 | ), |
||
432 | ), |
||
433 | 'repairboards' => array( |
||
434 | 'label' => $txt['admin_repair'], |
||
435 | 'file' => 'RepairBoards.php', |
||
436 | 'function' => 'RepairBoards', |
||
437 | 'select' => 'maintain', |
||
438 | 'hidden' => true, |
||
439 | ), |
||
440 | ), |
||
441 | ), |
||
442 | ); |
||
443 | |||
444 | // Any files to include for administration? |
||
445 | if (!empty($modSettings['integrate_admin_include'])) |
||
446 | { |
||
447 | $admin_includes = explode(',', $modSettings['integrate_admin_include']); |
||
448 | foreach ($admin_includes as $include) |
||
449 | { |
||
450 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
||
451 | if (file_exists($include)) |
||
452 | require_once($include); |
||
453 | } |
||
454 | } |
||
455 | |||
456 | // Make sure the administrator has a valid session... |
||
457 | validateSession(); |
||
458 | |||
459 | // Actually create the menu! |
||
460 | $admin_include_data = createMenu($admin_areas, array('do_big_icons' => true)); |
||
461 | unset($admin_areas); |
||
462 | |||
463 | // Nothing valid? |
||
464 | if ($admin_include_data == false) |
||
465 | fatal_lang_error('no_access', false); |
||
466 | |||
467 | // Build the link tree. |
||
468 | $context['linktree'][] = array( |
||
469 | 'url' => $scripturl . '?action=admin', |
||
470 | 'name' => $txt['admin_center'], |
||
471 | ); |
||
472 | if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
||
473 | $context['linktree'][] = array( |
||
474 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
||
475 | 'name' => $admin_include_data['label'], |
||
476 | ); |
||
477 | if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
||
478 | $context['linktree'][] = array( |
||
479 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
||
480 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
||
481 | ); |
||
482 | |||
483 | // Make a note of the Unique ID for this menu. |
||
484 | $context['admin_menu_id'] = $context['max_menu_id']; |
||
485 | $context['admin_menu_name'] = 'menu_data_' . $context['admin_menu_id']; |
||
486 | |||
487 | // Where in the admin are we? |
||
488 | $context['admin_area'] = $admin_include_data['current_area']; |
||
489 | |||
490 | // Now - finally - call the right place! |
||
491 | if (isset($admin_include_data['file'])) |
||
492 | require_once($sourcedir . '/' . $admin_include_data['file']); |
||
493 | |||
494 | // Get the right callable. |
||
495 | $call = call_helper($admin_include_data['function'], true); |
||
496 | |||
497 | // Is it valid? |
||
498 | if (!empty($call)) |
||
499 | call_user_func($call); |
||
500 | } |
||
501 | |||
502 | /** |
||
503 | * The main administration section. |
||
504 | * It prepares all the data necessary for the administration front page. |
||
505 | * It uses the Admin template along with the admin sub template. |
||
506 | * It requires the moderate_forum, manage_membergroups, manage_bans, |
||
507 | * admin_forum, manage_permissions, manage_attachments, manage_smileys, |
||
508 | * manage_boards, edit_news, or send_mail permission. |
||
509 | * It uses the index administrative area. |
||
510 | * It can be found by going to ?action=admin. |
||
511 | */ |
||
512 | function AdminHome() |
||
513 | { |
||
514 | global $sourcedir, $txt, $scripturl, $context, $user_info; |
||
515 | |||
516 | // You have to be able to do at least one of the below to see this page. |
||
517 | isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments')); |
||
518 | |||
519 | // Find all of this forum's administrators... |
||
520 | require_once($sourcedir . '/Subs-Membergroups.php'); |
||
521 | if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups')) |
||
522 | { |
||
523 | // Add a 'more'-link if there are more than 32. |
||
524 | $context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>'; |
||
525 | } |
||
526 | |||
527 | // Load the credits stuff. |
||
528 | require_once($sourcedir . '/Who.php'); |
||
529 | Credits(true); |
||
530 | |||
531 | // This makes it easier to get the latest news with your time format. |
||
532 | $context['time_format'] = urlencode($user_info['time_format']); |
||
533 | $context['forum_version'] = SMF_FULL_VERSION; |
||
534 | |||
535 | // Get a list of current server versions. |
||
536 | require_once($sourcedir . '/Subs-Admin.php'); |
||
537 | $checkFor = array( |
||
538 | 'gd', |
||
539 | 'imagemagick', |
||
540 | 'db_server', |
||
541 | 'apcu', |
||
542 | 'memcacheimplementation', |
||
543 | 'memcachedimplementation', |
||
544 | 'postgres', |
||
545 | 'sqlite', |
||
546 | 'zend', |
||
547 | 'filebased', |
||
548 | 'php', |
||
549 | 'server', |
||
550 | ); |
||
551 | $context['current_versions'] = getServerVersions($checkFor); |
||
552 | |||
553 | $context['can_admin'] = allowedTo('admin_forum'); |
||
554 | |||
555 | $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; |
||
556 | $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; |
||
557 | if ($context['admin_area'] != 'credits') |
||
558 | $context[$context['admin_menu_name']]['tab_data'] = array( |
||
559 | 'title' => $txt['admin_center'], |
||
560 | 'help' => '', |
||
561 | 'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong> |
||
562 | ' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']), |
||
563 | ); |
||
564 | |||
565 | // Lastly, fill in the blanks in the support resources paragraphs. |
||
566 | $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], |
||
567 | 'https://wiki.simplemachines.org/', |
||
568 | 'https://wiki.simplemachines.org/smf/features2', |
||
569 | 'https://wiki.simplemachines.org/smf/options2', |
||
570 | 'https://wiki.simplemachines.org/smf/themes2', |
||
571 | 'https://wiki.simplemachines.org/smf/packages2' |
||
572 | ); |
||
573 | $txt['support_resources_p2'] = sprintf($txt['support_resources_p2'], |
||
574 | 'https://www.simplemachines.org/community/', |
||
575 | 'https://www.simplemachines.org/redirect/english_support', |
||
576 | 'https://www.simplemachines.org/redirect/international_support_boards', |
||
577 | 'https://www.simplemachines.org/redirect/smf_support', |
||
578 | 'https://www.simplemachines.org/redirect/customize_support' |
||
579 | ); |
||
580 | |||
581 | if ($context['admin_area'] == 'admin') |
||
582 | loadJavaScriptFile('admin.js', array('defer' => false, 'minimize' => true), 'smf_admin'); |
||
583 | } |
||
584 | |||
585 | /** |
||
586 | * Get one of the admin information files from Simple Machines. |
||
587 | */ |
||
588 | function DisplayAdminFile() |
||
589 | { |
||
590 | global $context, $modSettings, $smcFunc; |
||
591 | |||
592 | setMemoryLimit('32M'); |
||
593 | |||
594 | if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) |
||
595 | fatal_lang_error('no_access', false); |
||
596 | |||
597 | // Strip off the forum cache part or we won't find it... |
||
598 | $_REQUEST['filename'] = str_replace($context['browser_cache'], '', $_REQUEST['filename']); |
||
599 | |||
600 | $request = $smcFunc['db_query']('', ' |
||
601 | SELECT data, filetype |
||
602 | FROM {db_prefix}admin_info_files |
||
603 | WHERE filename = {string:current_filename} |
||
604 | LIMIT 1', |
||
605 | array( |
||
606 | 'current_filename' => $_REQUEST['filename'], |
||
607 | ) |
||
608 | ); |
||
609 | |||
610 | if ($smcFunc['db_num_rows']($request) == 0) |
||
611 | fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
||
612 | |||
613 | list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request); |
||
614 | $smcFunc['db_free_result']($request); |
||
615 | |||
616 | // @todo Temp |
||
617 | // Figure out if sesc is still being used. |
||
618 | if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') |
||
619 | $file_data = ' |
||
620 | if (!(\'smfForum_sessionvar\' in window)) |
||
621 | window.smfForum_sessionvar = \'sesc\'; |
||
622 | ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'=')); |
||
623 | |||
624 | $context['template_layers'] = array(); |
||
625 | // Lets make sure we aren't going to output anything nasty. |
||
626 | @ob_end_clean(); |
||
627 | if (!empty($modSettings['enableCompressedOutput'])) |
||
628 | @ob_start('ob_gzhandler'); |
||
629 | else |
||
630 | @ob_start(); |
||
631 | |||
632 | // Make sure they know what type of file we are. |
||
633 | header('content-type: ' . $filetype); |
||
634 | echo $file_data; |
||
635 | obExit(false); |
||
636 | } |
||
637 | |||
638 | /** |
||
639 | * This function allocates out all the search stuff. |
||
640 | */ |
||
641 | function AdminSearch() |
||
642 | { |
||
643 | global $txt, $context, $smcFunc, $sourcedir; |
||
644 | |||
645 | isAllowedTo('admin_forum'); |
||
646 | |||
647 | // What can we search for? |
||
648 | $subActions = array( |
||
649 | 'internal' => 'AdminSearchInternal', |
||
650 | 'online' => 'AdminSearchOM', |
||
651 | 'member' => 'AdminSearchMember', |
||
652 | ); |
||
653 | |||
654 | $context['search_type'] = !isset($_REQUEST['search_type']) || !isset($subActions[$_REQUEST['search_type']]) ? 'internal' : $_REQUEST['search_type']; |
||
655 | $context['search_term'] = isset($_REQUEST['search_term']) ? $smcFunc['htmlspecialchars']($_REQUEST['search_term'], ENT_QUOTES) : ''; |
||
656 | |||
657 | $context['sub_template'] = 'admin_search_results'; |
||
658 | $context['page_title'] = $txt['admin_search_results']; |
||
659 | |||
660 | // Keep track of what the admin wants. |
||
661 | if (empty($context['admin_preferences']['sb']) || $context['admin_preferences']['sb'] != $context['search_type']) |
||
662 | { |
||
663 | $context['admin_preferences']['sb'] = $context['search_type']; |
||
664 | |||
665 | // Update the preferences. |
||
666 | require_once($sourcedir . '/Subs-Admin.php'); |
||
667 | updateAdminPreferences(); |
||
668 | } |
||
669 | |||
670 | if (trim($context['search_term']) == '') |
||
671 | $context['search_results'] = array(); |
||
672 | else |
||
673 | call_helper($subActions[$context['search_type']]); |
||
674 | } |
||
675 | |||
676 | /** |
||
677 | * A complicated but relatively quick internal search. |
||
678 | */ |
||
679 | function AdminSearchInternal() |
||
680 | { |
||
681 | global $context, $txt, $helptxt, $scripturl, $sourcedir; |
||
682 | |||
683 | // Try to get some more memory. |
||
684 | setMemoryLimit('128M'); |
||
685 | |||
686 | // Load a lot of language files. |
||
687 | $language_files = array( |
||
688 | 'Help', 'ManageMail', 'ManageSettings', 'ManageCalendar', 'ManageBoards', 'ManagePaid', 'ManagePermissions', 'Search', |
||
689 | 'Login', 'ManageSmileys', 'Drafts', |
||
690 | ); |
||
691 | |||
692 | // All the files we need to include. |
||
693 | $include_files = array( |
||
694 | 'ManageSettings', 'ManageBoards', 'ManageNews', 'ManageAttachments', 'ManageCalendar', 'ManageMail', 'ManagePaid', 'ManagePermissions', |
||
695 | 'ManagePosts', 'ManageRegistration', 'ManageSearch', 'ManageSearchEngines', 'ManageServer', 'ManageSmileys', 'ManageLanguages', |
||
696 | ); |
||
697 | |||
698 | // This is a special array of functions that contain setting data - we query all these to simply pull all setting bits! |
||
699 | $settings_search = array( |
||
700 | array('ModifyBasicSettings', 'area=featuresettings;sa=basic'), |
||
701 | array('ModifyBBCSettings', 'area=featuresettings;sa=bbc'), |
||
702 | array('ModifyLayoutSettings', 'area=featuresettings;sa=layout'), |
||
703 | array('ModifyLikesSettings', 'area=featuresettings;sa=likes'), |
||
704 | array('ModifyMentionsSettings', 'area=featuresettings;sa=mentions'), |
||
705 | array('ModifySignatureSettings', 'area=featuresettings;sa=sig'), |
||
706 | array('ModifyAntispamSettings', 'area=antispam'), |
||
707 | array('ModifyWarningSettings', 'area=warnings'), |
||
708 | array('ModifyGeneralModSettings', 'area=modsettings;sa=general'), |
||
709 | // Mod authors if you want to be "real freaking good" then add any setting pages for your mod BELOW this line! |
||
710 | array('ManageAttachmentSettings', 'area=manageattachments;sa=attachments'), |
||
711 | array('ManageAvatarSettings', 'area=manageattachments;sa=avatars'), |
||
712 | array('ModifyCalendarSettings', 'area=managecalendar;sa=settings'), |
||
713 | array('EditBoardSettings', 'area=manageboards;sa=settings'), |
||
714 | array('ModifyMailSettings', 'area=mailqueue;sa=settings'), |
||
715 | array('ModifyNewsSettings', 'area=news;sa=settings'), |
||
716 | array('GeneralPermissionSettings', 'area=permissions;sa=settings'), |
||
717 | array('ModifyPostSettings', 'area=postsettings;sa=posts'), |
||
718 | array('ModifyTopicSettings', 'area=postsettings;sa=topics'), |
||
719 | array('ModifyDraftSettings', 'area=postsettings;sa=drafts'), |
||
720 | array('EditSearchSettings', 'area=managesearch;sa=settings'), |
||
721 | array('EditSmileySettings', 'area=smileys;sa=settings'), |
||
722 | array('ModifyGeneralSettings', 'area=serversettings;sa=general'), |
||
723 | array('ModifyDatabaseSettings', 'area=serversettings;sa=database'), |
||
724 | array('ModifyCookieSettings', 'area=serversettings;sa=cookie'), |
||
725 | array('ModifyGeneralSecuritySettings', 'area=serversettings;sa=security'), |
||
726 | array('ModifyCacheSettings', 'area=serversettings;sa=cache'), |
||
727 | array('ModifyLanguageSettings', 'area=languages;sa=settings'), |
||
728 | array('ModifyRegistrationSettings', 'area=regcenter;sa=settings'), |
||
729 | array('ManageSearchEngineSettings', 'area=sengines;sa=settings'), |
||
730 | array('ModifySubscriptionSettings', 'area=paidsubscribe;sa=settings'), |
||
731 | array('ModifyLogSettings', 'area=logs;sa=settings'), |
||
732 | ); |
||
733 | |||
734 | call_integration_hook('integrate_admin_search', array(&$language_files, &$include_files, &$settings_search)); |
||
735 | |||
736 | loadLanguage(implode('+', $language_files)); |
||
737 | |||
738 | foreach ($include_files as $file) |
||
739 | require_once($sourcedir . '/' . $file . '.php'); |
||
740 | |||
741 | /* This is the huge array that defines everything... it's a huge array of items formatted as follows: |
||
742 | 0 = Language index (Can be array of indexes) to search through for this setting. |
||
743 | 1 = URL for this indexes page. |
||
744 | 2 = Help index for help associated with this item (If different from 0) |
||
745 | */ |
||
746 | |||
747 | $search_data = array( |
||
748 | // All the major sections of the forum. |
||
749 | 'sections' => array( |
||
750 | ), |
||
751 | 'settings' => array( |
||
752 | array('COPPA', 'area=regcenter;sa=settings'), |
||
753 | array('CAPTCHA', 'area=antispam'), |
||
754 | ), |
||
755 | ); |
||
756 | |||
757 | // Go through the admin menu structure trying to find suitably named areas! |
||
758 | foreach ($context[$context['admin_menu_name']]['sections'] as $section) |
||
759 | { |
||
760 | foreach ($section['areas'] as $menu_key => $menu_item) |
||
761 | { |
||
762 | $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key); |
||
763 | if (!empty($menu_item['subsections'])) |
||
764 | foreach ($menu_item['subsections'] as $key => $sublabel) |
||
765 | { |
||
766 | if (isset($sublabel['label'])) |
||
767 | $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key); |
||
768 | } |
||
769 | } |
||
770 | } |
||
771 | |||
772 | foreach ($settings_search as $setting_area) |
||
773 | { |
||
774 | // Get a list of their variables. |
||
775 | $config_vars = call_user_func($setting_area[0], true); |
||
776 | |||
777 | foreach ($config_vars as $var) |
||
778 | if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
||
779 | $search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && in_array($var[2], array('file', 'db'))) || isset($var[3]) ? (in_array($var[2], array('file', 'db')) ? $var[1] : $var[3]) : ''); |
||
780 | } |
||
781 | |||
782 | $context['page_title'] = $txt['admin_search_results']; |
||
783 | $context['search_results'] = array(); |
||
784 | |||
785 | $search_term = strtolower(un_htmlspecialchars($context['search_term'])); |
||
786 | // Go through all the search data trying to find this text! |
||
787 | foreach ($search_data as $section => $data) |
||
788 | { |
||
789 | foreach ($data as $item) |
||
790 | { |
||
791 | $found = false; |
||
792 | if (!is_array($item[0])) |
||
793 | $item[0] = array($item[0]); |
||
794 | foreach ($item[0] as $term) |
||
795 | { |
||
796 | if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false)) |
||
797 | { |
||
798 | $found = $term; |
||
799 | break; |
||
800 | } |
||
801 | } |
||
802 | |||
803 | if ($found) |
||
804 | { |
||
805 | // Format the name - and remove any descriptions the entry may have. |
||
806 | $name = isset($txt[$found]) ? $txt[$found] : (isset($txt['setting_' . $found]) ? $txt['setting_' . $found] : (!empty($item['alttxt']) ? $item['alttxt'] : $found)); |
||
807 | $name = preg_replace('~<(?:div|span)\sclass="smalltext">.+?</(?:div|span)>~', '', $name); |
||
808 | |||
809 | $context['search_results'][] = array( |
||
810 | 'url' => (substr($item[1], 0, 4) == 'area' ? $scripturl . '?action=admin;' . $item[1] : $item[1]) . ';' . $context['session_var'] . '=' . $context['session_id'] . ((substr($item[1], 0, 4) == 'area' && $section == 'settings' ? '#' . $item[0][0] : '')), |
||
811 | 'name' => $name, |
||
812 | 'type' => $section, |
||
813 | 'help' => shorten_subject(isset($item[2]) ? strip_tags($helptxt[$item[2]]) : (isset($helptxt[$found]) ? strip_tags($helptxt[$found]) : ''), 255), |
||
814 | ); |
||
815 | } |
||
816 | } |
||
817 | } |
||
818 | } |
||
819 | |||
820 | /** |
||
821 | * All this does is pass through to manage members. |
||
822 | * {@see ViewMembers()} |
||
823 | */ |
||
824 | function AdminSearchMember() |
||
825 | { |
||
826 | global $context, $sourcedir; |
||
827 | |||
828 | require_once($sourcedir . '/ManageMembers.php'); |
||
829 | $_REQUEST['sa'] = 'query'; |
||
830 | |||
831 | $_POST['membername'] = un_htmlspecialchars($context['search_term']); |
||
832 | $_POST['types'] = ''; |
||
833 | |||
834 | ViewMembers(); |
||
835 | } |
||
836 | |||
837 | /** |
||
838 | * This file allows the user to search the SM online manual for a little of help. |
||
839 | */ |
||
840 | function AdminSearchOM() |
||
841 | { |
||
842 | global $context, $sourcedir; |
||
843 | |||
844 | $context['doc_apiurl'] = 'https://wiki.simplemachines.org/api.php'; |
||
845 | $context['doc_scripturl'] = 'https://wiki.simplemachines.org/smf/'; |
||
846 | |||
847 | // Set all the parameters search might expect. |
||
848 | $postVars = explode(' ', $context['search_term']); |
||
849 | |||
850 | // Encode the search data. |
||
851 | foreach ($postVars as $k => $v) |
||
852 | $postVars[$k] = urlencode($v); |
||
853 | |||
854 | // This is what we will send. |
||
855 | $postVars = implode('+', $postVars); |
||
856 | |||
857 | // Get the results from the doc site. |
||
858 | // Demo URL: |
||
859 | // https://wiki.simplemachines.org/api.php?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=template+eval |
||
860 | $search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); |
||
861 | |||
862 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
||
863 | if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api\b[^>]*>.+?</api>)~is', $search_results, $matches) != true) |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
864 | fatal_lang_error('cannot_connect_doc_site'); |
||
865 | |||
866 | $search_results = $matches[1]; |
||
867 | |||
868 | // Otherwise we simply walk through the XML and stick it in context for display. |
||
869 | $context['search_results'] = array(); |
||
870 | require_once($sourcedir . '/Class-Package.php'); |
||
871 | |||
872 | // Get the results loaded into an array for processing! |
||
873 | $results = new xmlArray($search_results, false); |
||
874 | |||
875 | // Move through the api layer. |
||
876 | if (!$results->exists('api')) |
||
877 | fatal_lang_error('cannot_connect_doc_site'); |
||
878 | |||
879 | // Are there actually some results? |
||
880 | if ($results->exists('api/query/search/p')) |
||
881 | { |
||
882 | $relevance = 0; |
||
883 | foreach ($results->set('api/query/search/p') as $result) |
||
884 | { |
||
885 | $context['search_results'][$result->fetch('@title')] = array( |
||
886 | 'title' => $result->fetch('@title'), |
||
887 | 'relevance' => $relevance++, |
||
888 | 'snippet' => str_replace('class=\'searchmatch\'', 'class="highlight"', un_htmlspecialchars($result->fetch('@snippet'))), |
||
889 | ); |
||
890 | } |
||
891 | } |
||
892 | } |
||
893 | |||
894 | /** |
||
895 | * This function decides which log to load. |
||
896 | */ |
||
897 | function AdminLogs() |
||
898 | { |
||
899 | global $sourcedir, $context, $txt, $scripturl, $modSettings; |
||
900 | |||
901 | // These are the logs they can load. |
||
902 | $log_functions = array( |
||
903 | 'errorlog' => array('ManageErrors.php', 'ViewErrorLog'), |
||
904 | 'adminlog' => array('Modlog.php', 'ViewModlog', 'disabled' => empty($modSettings['adminlog_enabled'])), |
||
905 | 'modlog' => array('Modlog.php', 'ViewModlog', 'disabled' => empty($modSettings['modlog_enabled'])), |
||
906 | 'banlog' => array('ManageBans.php', 'BanLog'), |
||
907 | 'spiderlog' => array('ManageSearchEngines.php', 'SpiderLogs'), |
||
908 | 'tasklog' => array('ManageScheduledTasks.php', 'TaskLog'), |
||
909 | 'settings' => array('ManageSettings.php', 'ModifyLogSettings'), |
||
910 | ); |
||
911 | |||
912 | // If it's not got a sa set it must have come here for first time, pretend error log should be reversed. |
||
913 | if (!isset($_REQUEST['sa'])) |
||
914 | $_REQUEST['desc'] = true; |
||
915 | |||
916 | // Setup some tab stuff. |
||
917 | $context[$context['admin_menu_name']]['tab_data'] = array( |
||
918 | 'title' => $txt['logs'], |
||
919 | 'help' => '', |
||
920 | 'description' => $txt['maintain_info'], |
||
921 | 'tabs' => array( |
||
922 | 'errorlog' => array( |
||
923 | 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc', |
||
924 | 'description' => sprintf($txt['errorlog_desc'], $txt['remove']), |
||
925 | ), |
||
926 | 'adminlog' => array( |
||
927 | 'description' => $txt['admin_log_desc'], |
||
928 | ), |
||
929 | 'modlog' => array( |
||
930 | 'description' => $txt['moderation_log_desc'], |
||
931 | ), |
||
932 | 'banlog' => array( |
||
933 | 'description' => $txt['ban_log_description'], |
||
934 | ), |
||
935 | 'spiderlog' => array( |
||
936 | 'description' => $txt['spider_log_desc'], |
||
937 | ), |
||
938 | 'tasklog' => array( |
||
939 | 'description' => $txt['scheduled_log_desc'], |
||
940 | ), |
||
941 | 'settings' => array( |
||
942 | 'description' => $txt['log_settings_desc'], |
||
943 | ), |
||
944 | ), |
||
945 | ); |
||
946 | |||
947 | call_integration_hook('integrate_manage_logs', array(&$log_functions)); |
||
948 | |||
949 | $subAction = isset($_REQUEST['sa']) && isset($log_functions[$_REQUEST['sa']]) && empty($log_functions[$_REQUEST['sa']]['disabled']) ? $_REQUEST['sa'] : 'errorlog'; |
||
950 | |||
951 | require_once($sourcedir . '/' . $log_functions[$subAction][0]); |
||
952 | call_helper($log_functions[$subAction][1]); |
||
953 | } |
||
954 | |||
955 | /** |
||
956 | * This ends a admin session, requiring authentication to access the ACP again. |
||
957 | */ |
||
958 | function AdminEndSession() |
||
959 | { |
||
960 | // This is so easy! |
||
961 | unset($_SESSION['admin_time']); |
||
962 | |||
963 | // Clean any admin tokens as well. |
||
964 | foreach ($_SESSION['token'] as $key => $token) |
||
965 | if (strpos($key, '-admin') !== false) |
||
966 | unset($_SESSION['token'][$key]); |
||
967 | |||
968 | redirectexit(); |
||
969 | } |
||
970 | |||
971 | ?> |