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