1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file, unpredictable as this might be, handles basic administration. |
5
|
|
|
* |
6
|
|
|
* @name ElkArte Forum |
7
|
|
|
* @copyright ElkArte Forum contributors |
8
|
|
|
* @license BSD http://opensource.org/licenses/BSD-3-Clause |
9
|
|
|
* |
10
|
|
|
* This file contains code covered by: |
11
|
|
|
* copyright: 2011 Simple Machines (http://www.simplemachines.org) |
12
|
|
|
* license: BSD, See included LICENSE.TXT for terms and conditions. |
13
|
|
|
* |
14
|
|
|
* @version 2.0 dev |
15
|
|
|
* |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Admin controller class. |
20
|
|
|
* |
21
|
|
|
* What it does: |
22
|
|
|
* |
23
|
|
|
* - This class handles the first general admin screens: home, |
24
|
|
|
* - Handles admin area search actions and end admin session. |
25
|
|
|
* |
26
|
|
|
* @package Admin |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
class Admin_Controller extends Action_Controller |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var string[] areas to find current installed status and installed version |
33
|
|
|
*/ |
34
|
|
|
private $_checkFor = array('gd', 'imagick', 'db_server', 'php', 'server', |
35
|
|
|
'zend', 'apc', 'memcache', 'memcached', 'xcache', 'opcache'); |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Pre Dispatch, called before other methods. |
39
|
|
|
* |
40
|
|
|
* - Loads integration hooks |
41
|
|
|
*/ |
42
|
|
|
public function pre_dispatch() |
43
|
|
|
{ |
44
|
|
|
Hooks::instance()->loadIntegrationsSettings(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The main admin handling function. |
49
|
|
|
* |
50
|
|
|
* What it does: |
51
|
|
|
* |
52
|
|
|
* - It initialises all the basic context required for the admin center. |
53
|
|
|
* - It passes execution onto the relevant admin section. |
54
|
|
|
* - If the passed section is not found it shows the admin home page. |
55
|
|
|
* - Accessed by ?action=admin. |
56
|
|
|
*/ |
57
|
|
|
public function action_index() |
58
|
|
|
{ |
59
|
|
|
global $context, $modSettings; |
60
|
|
|
|
61
|
|
|
// Make sure the administrator has a valid session... |
62
|
|
|
validateSession(); |
63
|
|
|
|
64
|
|
|
// Load the language and templates.... |
65
|
|
|
theme()->getTemplates()->loadLanguageFile('Admin'); |
66
|
|
|
theme()->getTemplates()->load('Admin'); |
67
|
|
|
loadCSSFile('admin.css'); |
68
|
|
|
loadJavascriptFile('admin.js', array(), 'admin_script'); |
69
|
|
|
|
70
|
|
|
// The Admin functions require Jquery UI .... |
71
|
|
|
$modSettings['jquery_include_ui'] = true; |
72
|
|
|
|
73
|
|
|
// No indexing evil stuff. |
74
|
|
|
$context['robot_no_index'] = true; |
75
|
|
|
|
76
|
|
|
// Need these to do much |
77
|
|
|
require_once(SUBSDIR . '/Admin.subs.php'); |
78
|
|
|
|
79
|
|
|
// Actually create the menu! |
80
|
|
|
$admin_include_data = $this->loadMenu(); |
81
|
|
|
$this->buildLinktree($admin_include_data); |
82
|
|
|
|
83
|
|
|
// Now - finally - call the right place! |
84
|
|
|
if (isset($admin_include_data['file'])) |
85
|
|
|
require_once($admin_include_data['file']); |
86
|
|
|
|
87
|
|
|
callMenu($admin_include_data); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Load the admin_areas array |
92
|
|
|
* |
93
|
|
|
* What it does: |
94
|
|
|
* |
95
|
|
|
* - Creates the admin menu |
96
|
|
|
* - Allows integrations to add/edit menu with addMenu event and integrate_admin_include |
97
|
|
|
* |
98
|
|
|
* @event integrate_admin_include used add files to include for administration |
99
|
|
|
* @event addMenu passed admin area area, allows active modules registered to this event to add items to the admin menu, |
100
|
|
|
* @event integrate_admin_areas passed admin area area, used to add items to the admin menu |
101
|
|
|
* |
102
|
|
|
* @return false|mixed[] |
103
|
|
|
* @throws Elk_Exception no_access |
104
|
|
|
*/ |
105
|
1 |
|
private function loadMenu() |
106
|
|
|
{ |
107
|
1 |
|
global $txt, $context, $scripturl, $modSettings, $settings; |
108
|
|
|
|
109
|
|
|
// Need these to do much |
110
|
1 |
|
require_once(SUBSDIR . '/Menu.subs.php'); |
111
|
|
|
|
112
|
|
|
// Define the menu structure - see subs/Menu.subs.php for details! |
113
|
|
|
$admin_areas = array( |
114
|
1 |
|
'forum' => array( |
115
|
1 |
|
'title' => $txt['admin_main'], |
116
|
|
|
'permission' => array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'), |
117
|
|
|
'areas' => array( |
118
|
|
|
'index' => array( |
119
|
1 |
|
'label' => $txt['admin_center'], |
120
|
1 |
|
'controller' => 'Admin_Controller', |
121
|
1 |
|
'function' => 'action_home', |
122
|
1 |
|
'icon' => 'transparent.png', |
123
|
1 |
|
'class' => 'admin_img_administration', |
124
|
|
|
), |
125
|
|
|
'credits' => array( |
126
|
1 |
|
'label' => $txt['support_credits_title'], |
127
|
1 |
|
'controller' => 'Admin_Controller', |
128
|
1 |
|
'function' => 'action_credits', |
129
|
1 |
|
'icon' => 'transparent.png', |
130
|
1 |
|
'class' => 'admin_img_support', |
131
|
|
|
), |
132
|
|
|
'maillist' => array( |
133
|
1 |
|
'label' => $txt['mail_center'], |
134
|
1 |
|
'controller' => 'ManageMaillist_Controller', |
135
|
1 |
|
'function' => 'action_index', |
136
|
1 |
|
'icon' => 'transparent.png', |
137
|
1 |
|
'class' => 'admin_img_mail', |
138
|
|
|
'permission' => array('approve_emails', 'admin_forum'), |
139
|
1 |
|
'enabled' => in_array('pe', $context['admin_features']), |
140
|
|
|
'subsections' => array( |
141
|
1 |
|
'emaillist' => array($txt['mm_emailerror'], 'approve_emails'), |
142
|
1 |
|
'emailfilters' => array($txt['mm_emailfilters'], 'admin_forum'), |
143
|
1 |
|
'emailparser' => array($txt['mm_emailparsers'], 'admin_forum'), |
144
|
1 |
|
'emailtemplates' => array($txt['mm_emailtemplates'], 'approve_emails'), |
145
|
1 |
|
'emailsettings' => array($txt['mm_emailsettings'], 'admin_forum'), |
146
|
|
|
), |
147
|
|
|
), |
148
|
|
|
'news' => array( |
149
|
1 |
|
'label' => $txt['news_title'], |
150
|
1 |
|
'controller' => 'ManageNews_Controller', |
151
|
1 |
|
'function' => 'action_index', |
152
|
1 |
|
'icon' => 'transparent.png', |
153
|
1 |
|
'class' => 'admin_img_news', |
154
|
|
|
'permission' => array('edit_news', 'send_mail', 'admin_forum'), |
155
|
|
|
'subsections' => array( |
156
|
1 |
|
'editnews' => array($txt['admin_edit_news'], 'edit_news'), |
157
|
1 |
|
'mailingmembers' => array($txt['admin_newsletters'], 'send_mail'), |
158
|
1 |
|
'settings' => array($txt['settings'], 'admin_forum'), |
159
|
|
|
), |
160
|
|
|
), |
161
|
|
|
'packages' => array( |
162
|
1 |
|
'label' => $txt['package'], |
163
|
1 |
|
'controller' => 'Packages_Controller', |
164
|
1 |
|
'function' => 'action_index', |
165
|
|
|
'permission' => array('admin_forum'), |
166
|
1 |
|
'icon' => 'transparent.png', |
167
|
1 |
|
'class' => 'admin_img_packages', |
168
|
|
|
'subsections' => array( |
169
|
1 |
|
'browse' => array($txt['browse_packages']), |
170
|
1 |
|
'installed' => array($txt['installed_packages']), |
171
|
1 |
|
'perms' => array($txt['package_file_perms']), |
172
|
1 |
|
'options' => array($txt['package_settings']), |
173
|
1 |
|
'servers' => array($txt['download_packages']), |
174
|
1 |
|
'upload' => array($txt['upload_packages']), |
175
|
|
|
), |
176
|
|
|
), |
177
|
|
|
'packageservers' => array( |
178
|
1 |
|
'label' => $txt['package_servers'], |
179
|
1 |
|
'controller' => 'PackageServers_Controller', |
180
|
1 |
|
'function' => 'action_index', |
181
|
|
|
'permission' => array('admin_forum'), |
182
|
1 |
|
'icon' => 'transparent.png', |
183
|
1 |
|
'class' => 'admin_img_packages', |
184
|
|
|
'hidden' => true, |
185
|
|
|
), |
186
|
|
|
'search' => array( |
187
|
|
|
'controller' => 'Admin_Controller', |
188
|
|
|
'function' => 'action_search', |
189
|
|
|
'permission' => array('admin_forum'), |
190
|
|
|
'select' => 'index' |
191
|
|
|
), |
192
|
|
|
'adminlogoff' => array( |
193
|
1 |
|
'controller' => 'Admin_Controller', |
194
|
1 |
|
'function' => 'action_endsession', |
195
|
1 |
|
'label' => $txt['admin_logoff'], |
196
|
1 |
|
'enabled' => empty($modSettings['securityDisable']), |
197
|
1 |
|
'icon' => 'transparent.png', |
198
|
1 |
|
'class' => 'admin_img_exit', |
199
|
|
|
), |
200
|
|
|
), |
201
|
|
|
), |
202
|
|
|
'config' => array( |
203
|
1 |
|
'title' => $txt['admin_config'], |
204
|
|
|
'permission' => array('admin_forum'), |
205
|
|
|
'areas' => array( |
206
|
|
|
'corefeatures' => array( |
207
|
1 |
|
'label' => $txt['core_settings_title'], |
208
|
1 |
|
'controller' => 'CoreFeatures_Controller', |
209
|
1 |
|
'function' => 'action_index', |
210
|
1 |
|
'icon' => 'transparent.png', |
211
|
1 |
|
'class' => 'admin_img_corefeatures', |
212
|
|
|
), |
213
|
|
|
'featuresettings' => array( |
214
|
1 |
|
'label' => $txt['modSettings_title'], |
215
|
1 |
|
'controller' => 'ManageFeatures_Controller', |
216
|
1 |
|
'function' => 'action_index', |
217
|
1 |
|
'icon' => 'transparent.png', |
218
|
1 |
|
'class' => 'admin_img_features', |
219
|
|
|
'subsections' => array( |
220
|
1 |
|
'basic' => array($txt['mods_cat_features']), |
221
|
1 |
|
'layout' => array($txt['mods_cat_layout']), |
222
|
1 |
|
'pmsettings' => array($txt['personal_messages']), |
223
|
1 |
|
'karma' => array($txt['karma'], 'enabled' => in_array('k', $context['admin_features'])), |
224
|
1 |
|
'likes' => array($txt['likes'], 'enabled' => in_array('l', $context['admin_features'])), |
225
|
1 |
|
'mention' => array($txt['mention']), |
226
|
1 |
|
'sig' => array($txt['signature_settings_short']), |
227
|
1 |
|
'profile' => array($txt['custom_profile_shorttitle'], 'enabled' => in_array('cp', $context['admin_features'])), |
228
|
|
|
), |
229
|
|
|
), |
230
|
|
|
'serversettings' => array( |
231
|
1 |
|
'label' => $txt['admin_server_settings'], |
232
|
1 |
|
'controller' => 'ManageServer_Controller', |
233
|
1 |
|
'function' => 'action_index', |
234
|
1 |
|
'icon' => 'transparent.png', |
235
|
1 |
|
'class' => 'admin_img_server', |
236
|
|
|
'subsections' => array( |
237
|
1 |
|
'general' => array($txt['general_settings']), |
238
|
1 |
|
'database' => array($txt['database_paths_settings']), |
239
|
1 |
|
'cookie' => array($txt['cookies_sessions_settings']), |
240
|
1 |
|
'cache' => array($txt['caching_settings']), |
241
|
1 |
|
'loads' => array($txt['loadavg_settings']), |
242
|
1 |
|
'phpinfo' => array($txt['phpinfo_settings']), |
243
|
|
|
), |
244
|
|
|
), |
245
|
|
|
'securitysettings' => array( |
246
|
1 |
|
'label' => $txt['admin_security_moderation'], |
247
|
1 |
|
'controller' => 'ManageSecurity_Controller', |
248
|
1 |
|
'function' => 'action_index', |
249
|
1 |
|
'icon' => 'transparent.png', |
250
|
1 |
|
'class' => 'admin_img_security', |
251
|
|
|
'subsections' => array( |
252
|
1 |
|
'general' => array($txt['mods_cat_security_general']), |
253
|
1 |
|
'spam' => array($txt['antispam_title']), |
254
|
1 |
|
'badbehavior' => array($txt['badbehavior_title']), |
255
|
1 |
|
'moderation' => array($txt['moderation_settings_short'], 'enabled' => !empty($modSettings['warning_enable'])), |
256
|
|
|
), |
257
|
|
|
), |
258
|
|
|
'theme' => array( |
259
|
1 |
|
'label' => $txt['theme_admin'], |
260
|
1 |
|
'controller' => 'ManageThemes_Controller', |
261
|
1 |
|
'function' => 'action_index', |
262
|
1 |
|
'custom_url' => $scripturl . '?action=admin;area=theme', |
263
|
1 |
|
'icon' => 'transparent.png', |
264
|
1 |
|
'class' => 'admin_img_themes', |
265
|
|
|
'subsections' => array( |
266
|
1 |
|
'admin' => array($txt['themeadmin_admin_title']), |
267
|
1 |
|
'list' => array($txt['themeadmin_list_title']), |
268
|
1 |
|
'reset' => array($txt['themeadmin_reset_title']), |
269
|
1 |
|
'themelist' => array($txt['themeadmin_edit_title'], 'active' => array('edit', 'browse')), |
270
|
1 |
|
'edit' => array($txt['themeadmin_edit_title'], 'enabled' => false), |
271
|
1 |
|
'browse' => array($txt['themeadmin_edit_title'], 'enabled' => false), |
272
|
|
|
), |
273
|
|
|
), |
274
|
|
|
'current_theme' => array( |
275
|
1 |
|
'label' => $txt['theme_current_settings'], |
276
|
1 |
|
'controller' => 'ManageThemes_Controller', |
277
|
1 |
|
'function' => 'action_index', |
278
|
1 |
|
'custom_url' => $scripturl . '?action=admin;area=theme;sa=list;th=' . $settings['theme_id'], |
279
|
1 |
|
'icon' => 'transparent.png', |
280
|
1 |
|
'class' => 'admin_img_current_theme', |
281
|
|
|
), |
282
|
|
|
'languages' => array( |
283
|
1 |
|
'label' => $txt['language_configuration'], |
284
|
1 |
|
'controller' => 'ManageLanguages_Controller', |
285
|
1 |
|
'function' => 'action_index', |
286
|
1 |
|
'icon' => 'transparent.png', |
287
|
1 |
|
'class' => 'admin_img_languages', |
288
|
|
|
'subsections' => array( |
289
|
1 |
|
'edit' => array($txt['language_edit']), |
290
|
|
|
// 'add' => array($txt['language_add']), |
291
|
1 |
|
'settings' => array($txt['language_settings']), |
292
|
|
|
), |
293
|
|
|
), |
294
|
|
|
'addonsettings' => array( |
295
|
1 |
|
'label' => $txt['admin_modifications'], |
296
|
1 |
|
'controller' => 'AddonSettings_Controller', |
297
|
1 |
|
'function' => 'action_index', |
298
|
1 |
|
'icon' => 'transparent.png', |
299
|
1 |
|
'class' => 'admin_img_modifications', |
300
|
|
|
'subsections' => array( |
301
|
1 |
|
'general' => array($txt['mods_cat_modifications_misc']), |
302
|
|
|
), |
303
|
|
|
), |
304
|
|
|
), |
305
|
|
|
), |
306
|
|
|
'layout' => array( |
307
|
1 |
|
'title' => $txt['layout_controls'], |
308
|
|
|
'permission' => array('manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum'), |
309
|
|
|
'areas' => array( |
310
|
|
|
'manageboards' => array( |
311
|
1 |
|
'label' => $txt['admin_boards'], |
312
|
1 |
|
'controller' => 'ManageBoards_Controller', |
313
|
1 |
|
'function' => 'action_index', |
314
|
1 |
|
'icon' => 'transparent.png', |
315
|
1 |
|
'class' => 'admin_img_boards', |
316
|
|
|
'permission' => array('manage_boards'), |
317
|
|
|
'subsections' => array( |
318
|
1 |
|
'main' => array($txt['boardsEdit']), |
319
|
1 |
|
'newcat' => array($txt['mboards_new_cat']), |
320
|
1 |
|
'settings' => array($txt['settings'], 'admin_forum'), |
321
|
|
|
), |
322
|
|
|
), |
323
|
|
|
'postsettings' => array( |
324
|
1 |
|
'label' => $txt['manageposts'], |
325
|
1 |
|
'controller' => 'ManagePosts_Controller', |
326
|
1 |
|
'function' => 'action_index', |
327
|
|
|
'permission' => array('admin_forum'), |
328
|
1 |
|
'icon' => 'transparent.png', |
329
|
1 |
|
'class' => 'admin_img_posts', |
330
|
|
|
'subsections' => array( |
331
|
1 |
|
'posts' => array($txt['manageposts_settings']), |
332
|
1 |
|
'bbc' => array($txt['manageposts_bbc_settings']), |
333
|
1 |
|
'censor' => array($txt['admin_censored_words']), |
334
|
1 |
|
'topics' => array($txt['manageposts_topic_settings']), |
335
|
|
|
), |
336
|
|
|
), |
337
|
|
|
'bbc' => array( |
338
|
1 |
|
'label' => $txt['bbc_manage'], |
339
|
1 |
|
'controller' => 'ManageBBC_Controller', |
340
|
1 |
|
'function' => 'action_index', |
341
|
1 |
|
'icon' => 'transparent.png', |
342
|
1 |
|
'class' => 'admin_img_smiley', |
343
|
|
|
'permission' => array('manage_bbc'), |
344
|
|
|
), |
345
|
|
|
'smileys' => array( |
346
|
1 |
|
'label' => $txt['smileys_manage'], |
347
|
1 |
|
'controller' => 'ManageSmileys_Controller', |
348
|
1 |
|
'function' => 'action_index', |
349
|
1 |
|
'icon' => 'transparent.png', |
350
|
1 |
|
'class' => 'admin_img_smiley', |
351
|
|
|
'permission' => array('manage_smileys'), |
352
|
|
|
'subsections' => array( |
353
|
1 |
|
'editsets' => array($txt['smiley_sets']), |
354
|
1 |
|
'addsmiley' => array($txt['smileys_add'], 'enabled' => !empty($modSettings['smiley_enable'])), |
355
|
1 |
|
'editsmileys' => array($txt['smileys_edit'], 'enabled' => !empty($modSettings['smiley_enable'])), |
356
|
1 |
|
'setorder' => array($txt['smileys_set_order'], 'enabled' => !empty($modSettings['smiley_enable'])), |
357
|
1 |
|
'editicons' => array($txt['icons_edit_message_icons'], 'enabled' => !empty($modSettings['messageIcons_enable'])), |
358
|
1 |
|
'settings' => array($txt['settings']), |
359
|
|
|
), |
360
|
|
|
), |
361
|
|
|
'manageattachments' => array( |
362
|
1 |
|
'label' => $txt['attachments_avatars'], |
363
|
1 |
|
'controller' => 'ManageAttachments_Controller', |
364
|
1 |
|
'function' => 'action_index', |
365
|
1 |
|
'icon' => 'transparent.png', |
366
|
1 |
|
'class' => 'admin_img_attachment', |
367
|
|
|
'permission' => array('manage_attachments'), |
368
|
|
|
'subsections' => array( |
369
|
1 |
|
'browse' => array($txt['attachment_manager_browse']), |
370
|
1 |
|
'attachments' => array($txt['attachment_manager_settings']), |
371
|
1 |
|
'avatars' => array($txt['attachment_manager_avatar_settings']), |
372
|
1 |
|
'attachpaths' => array($txt['attach_directories']), |
373
|
1 |
|
'maintenance' => array($txt['attachment_manager_maintenance']), |
374
|
|
|
), |
375
|
|
|
), |
376
|
|
|
'managesearch' => array( |
377
|
1 |
|
'label' => $txt['manage_search'], |
378
|
1 |
|
'controller' => 'ManageSearch_Controller', |
379
|
1 |
|
'function' => 'action_index', |
380
|
1 |
|
'icon' => 'transparent.png', |
381
|
1 |
|
'class' => 'admin_img_search', |
382
|
|
|
'permission' => array('admin_forum'), |
383
|
|
|
'subsections' => array( |
384
|
1 |
|
'weights' => array($txt['search_weights']), |
385
|
1 |
|
'method' => array($txt['search_method']), |
386
|
1 |
|
'managesphinx' => array($txt['search_sphinx']), |
387
|
1 |
|
'settings' => array($txt['settings']), |
388
|
|
|
), |
389
|
|
|
), |
390
|
|
|
), |
391
|
|
|
), |
392
|
|
|
'members' => array( |
393
|
1 |
|
'title' => $txt['admin_manage_members'], |
394
|
|
|
'permission' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'), |
395
|
|
|
'areas' => array( |
396
|
|
|
'viewmembers' => array( |
397
|
1 |
|
'label' => $txt['admin_users'], |
398
|
1 |
|
'controller' => 'ManageMembers_Controller', |
399
|
1 |
|
'function' => 'action_index', |
400
|
1 |
|
'icon' => 'transparent.png', |
401
|
1 |
|
'class' => 'admin_img_members', |
402
|
|
|
'permission' => array('moderate_forum'), |
403
|
|
|
'subsections' => array( |
404
|
1 |
|
'all' => array($txt['view_all_members']), |
405
|
1 |
|
'search' => array($txt['mlist_search']), |
406
|
|
|
), |
407
|
|
|
), |
408
|
|
|
'membergroups' => array( |
409
|
1 |
|
'label' => $txt['admin_groups'], |
410
|
1 |
|
'controller' => 'ManageMembergroups_Controller', |
411
|
1 |
|
'function' => 'action_index', |
412
|
1 |
|
'icon' => 'transparent.png', |
413
|
1 |
|
'class' => 'admin_img_membergroups', |
414
|
|
|
'permission' => array('manage_membergroups'), |
415
|
|
|
'subsections' => array( |
416
|
1 |
|
'index' => array($txt['membergroups_edit_groups'], 'manage_membergroups'), |
417
|
1 |
|
'add' => array($txt['membergroups_new_group'], 'manage_membergroups'), |
418
|
1 |
|
'settings' => array($txt['settings'], 'admin_forum'), |
419
|
|
|
), |
420
|
|
|
), |
421
|
|
|
'permissions' => array( |
422
|
1 |
|
'label' => $txt['edit_permissions'], |
423
|
1 |
|
'controller' => 'ManagePermissions_Controller', |
424
|
1 |
|
'function' => 'action_index', |
425
|
1 |
|
'icon' => 'transparent.png', |
426
|
1 |
|
'class' => 'admin_img_permissions', |
427
|
|
|
'permission' => array('manage_permissions'), |
428
|
|
|
'subsections' => array( |
429
|
1 |
|
'index' => array($txt['permissions_groups'], 'manage_permissions'), |
430
|
1 |
|
'board' => array($txt['permissions_boards'], 'manage_permissions'), |
431
|
1 |
|
'profiles' => array($txt['permissions_profiles'], 'manage_permissions'), |
432
|
1 |
|
'postmod' => array($txt['permissions_post_moderation'], 'manage_permissions', 'enabled' => $modSettings['postmod_active']), |
433
|
1 |
|
'settings' => array($txt['settings'], 'admin_forum'), |
434
|
|
|
), |
435
|
|
|
), |
436
|
|
|
'ban' => array( |
437
|
1 |
|
'label' => $txt['ban_title'], |
438
|
1 |
|
'controller' => 'ManageBans_Controller', |
439
|
1 |
|
'function' => 'action_index', |
440
|
1 |
|
'icon' => 'transparent.png', |
441
|
1 |
|
'class' => 'admin_img_ban', |
442
|
1 |
|
'permission' => 'manage_bans', |
443
|
|
|
'subsections' => array( |
444
|
1 |
|
'list' => array($txt['ban_edit_list']), |
445
|
1 |
|
'add' => array($txt['ban_add_new']), |
446
|
1 |
|
'browse' => array($txt['ban_trigger_browse']), |
447
|
1 |
|
'log' => array($txt['ban_log']), |
448
|
|
|
), |
449
|
|
|
), |
450
|
|
|
'regcenter' => array( |
451
|
1 |
|
'label' => $txt['registration_center'], |
452
|
1 |
|
'controller' => 'ManageRegistration_Controller', |
453
|
1 |
|
'function' => 'action_index', |
454
|
1 |
|
'icon' => 'transparent.png', |
455
|
1 |
|
'class' => 'admin_img_regcenter', |
456
|
|
|
'permission' => array('admin_forum', 'moderate_forum'), |
457
|
|
|
'subsections' => array( |
458
|
1 |
|
'register' => array($txt['admin_browse_register_new'], 'moderate_forum'), |
459
|
1 |
|
'agreement' => array($txt['registration_agreement'], 'admin_forum'), |
460
|
1 |
|
'reservednames' => array($txt['admin_reserved_set'], 'admin_forum'), |
461
|
1 |
|
'settings' => array($txt['settings'], 'admin_forum'), |
462
|
|
|
), |
463
|
|
|
), |
464
|
|
|
'sengines' => array( |
465
|
1 |
|
'label' => $txt['search_engines'], |
466
|
1 |
|
'enabled' => in_array('sp', $context['admin_features']), |
467
|
1 |
|
'controller' => 'ManageSearchEngines_Controller', |
468
|
1 |
|
'function' => 'action_index', |
469
|
1 |
|
'icon' => 'transparent.png', |
470
|
1 |
|
'class' => 'admin_img_engines', |
471
|
1 |
|
'permission' => 'admin_forum', |
472
|
|
|
'subsections' => array( |
473
|
1 |
|
'stats' => array($txt['spider_stats']), |
474
|
1 |
|
'logs' => array($txt['spider_logs']), |
475
|
1 |
|
'spiders' => array($txt['spiders']), |
476
|
1 |
|
'settings' => array($txt['settings']), |
477
|
|
|
), |
478
|
|
|
), |
479
|
|
|
'paidsubscribe' => array( |
480
|
1 |
|
'label' => $txt['paid_subscriptions'], |
481
|
1 |
|
'enabled' => in_array('ps', $context['admin_features']), |
482
|
1 |
|
'controller' => 'ManagePaid_Controller', |
483
|
1 |
|
'icon' => 'transparent.png', |
484
|
1 |
|
'class' => 'admin_img_paid', |
485
|
1 |
|
'function' => 'action_index', |
486
|
1 |
|
'permission' => 'admin_forum', |
487
|
|
|
'subsections' => array( |
488
|
1 |
|
'view' => array($txt['paid_subs_view']), |
489
|
1 |
|
'settings' => array($txt['settings']), |
490
|
|
|
), |
491
|
|
|
), |
492
|
|
|
), |
493
|
|
|
), |
494
|
|
|
'maintenance' => array( |
495
|
1 |
|
'title' => $txt['admin_maintenance'], |
496
|
|
|
'permission' => array('admin_forum'), |
497
|
|
|
'areas' => array( |
498
|
|
|
'maintain' => array( |
499
|
1 |
|
'label' => $txt['maintain_title'], |
500
|
1 |
|
'controller' => 'Maintenance_Controller', |
501
|
1 |
|
'function' => 'action_index', |
502
|
1 |
|
'icon' => 'transparent.png', |
503
|
1 |
|
'class' => 'admin_img_maintain', |
504
|
|
|
'subsections' => array( |
505
|
1 |
|
'routine' => array($txt['maintain_sub_routine'], 'admin_forum'), |
506
|
1 |
|
'database' => array($txt['maintain_sub_database'], 'admin_forum'), |
507
|
1 |
|
'members' => array($txt['maintain_sub_members'], 'admin_forum'), |
508
|
1 |
|
'topics' => array($txt['maintain_sub_topics'], 'admin_forum'), |
509
|
1 |
|
'hooks' => array($txt['maintain_sub_hooks_list'], 'admin_forum'), |
510
|
1 |
|
'attachments' => array($txt['maintain_sub_attachments'], 'admin_forum'), |
511
|
|
|
), |
512
|
|
|
), |
513
|
|
|
'logs' => array( |
514
|
1 |
|
'label' => $txt['logs'], |
515
|
1 |
|
'controller' => 'AdminLog_Controller', |
516
|
1 |
|
'function' => 'action_index', |
517
|
1 |
|
'icon' => 'transparent.png', |
518
|
1 |
|
'class' => 'admin_img_logs', |
519
|
|
|
'subsections' => array( |
520
|
1 |
|
'errorlog' => array($txt['errlog'], 'admin_forum', 'enabled' => !empty($modSettings['enableErrorLogging']), 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc'), |
521
|
1 |
|
'adminlog' => array($txt['admin_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])), |
522
|
1 |
|
'modlog' => array($txt['moderation_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])), |
523
|
1 |
|
'banlog' => array($txt['ban_log'], 'manage_bans'), |
524
|
1 |
|
'spiderlog' => array($txt['spider_logs'], 'admin_forum', 'enabled' => in_array('sp', $context['admin_features'])), |
525
|
1 |
|
'tasklog' => array($txt['scheduled_log'], 'admin_forum'), |
526
|
1 |
|
'badbehaviorlog' => array($txt['badbehavior_log'], 'admin_forum', 'enabled' => !empty($modSettings['badbehavior_enabled']), 'url' => $scripturl . '?action=admin;area=logs;sa=badbehaviorlog;desc'), |
527
|
1 |
|
'pruning' => array($txt['pruning_title'], 'admin_forum'), |
528
|
|
|
), |
529
|
|
|
), |
530
|
|
|
'scheduledtasks' => array( |
531
|
1 |
|
'label' => $txt['maintain_tasks'], |
532
|
1 |
|
'controller' => 'ManageScheduledTasks_Controller', |
533
|
1 |
|
'function' => 'action_index', |
534
|
1 |
|
'icon' => 'transparent.png', |
535
|
1 |
|
'class' => 'admin_img_scheduled', |
536
|
|
|
'subsections' => array( |
537
|
1 |
|
'tasks' => array($txt['maintain_tasks'], 'admin_forum'), |
538
|
1 |
|
'tasklog' => array($txt['scheduled_log'], 'admin_forum'), |
539
|
|
|
), |
540
|
|
|
), |
541
|
|
|
'mailqueue' => array( |
542
|
1 |
|
'label' => $txt['mailqueue_title'], |
543
|
1 |
|
'controller' => 'ManageMail_Controller', |
544
|
1 |
|
'function' => 'action_index', |
545
|
1 |
|
'icon' => 'transparent.png', |
546
|
1 |
|
'class' => 'admin_img_mail', |
547
|
|
|
'subsections' => array( |
548
|
1 |
|
'browse' => array($txt['mailqueue_browse'], 'admin_forum'), |
549
|
1 |
|
'settings' => array($txt['mailqueue_settings'], 'admin_forum'), |
550
|
|
|
), |
551
|
|
|
), |
552
|
|
|
'reports' => array( |
553
|
1 |
|
'enabled' => in_array('rg', $context['admin_features']), |
554
|
1 |
|
'label' => $txt['generate_reports'], |
555
|
1 |
|
'controller' => 'Reports_Controller', |
556
|
1 |
|
'function' => 'action_index', |
557
|
1 |
|
'icon' => 'transparent.png', |
558
|
1 |
|
'class' => 'admin_img_reports', |
559
|
|
|
), |
560
|
|
|
'repairboards' => array( |
561
|
1 |
|
'label' => $txt['admin_repair'], |
562
|
1 |
|
'controller' => 'RepairBoards_Controller', |
563
|
1 |
|
'function' => 'action_repairboards', |
564
|
1 |
|
'select' => 'maintain', |
565
|
|
|
'hidden' => true, |
566
|
|
|
), |
567
|
|
|
), |
568
|
|
|
), |
569
|
|
|
); |
570
|
|
|
|
571
|
1 |
|
$this->_events->trigger('addMenu', array('admin_areas' => &$admin_areas)); |
572
|
|
|
|
573
|
|
|
// Any files to include for administration? |
574
|
1 |
|
call_integration_include_hook('integrate_admin_include'); |
575
|
|
|
|
576
|
1 |
|
$menuOptions = array('hook' => 'admin', 'default_include_dir' => ADMINDIR); |
577
|
|
|
|
578
|
|
|
// Actually create the menu! |
579
|
1 |
|
$admin_include_data = createMenu($admin_areas, $menuOptions); |
580
|
1 |
|
unset($admin_areas); |
581
|
|
|
|
582
|
|
|
// Nothing valid? |
583
|
1 |
|
if ($admin_include_data === false) |
584
|
|
|
{ |
585
|
|
|
throw new Elk_Exception('no_access', false); |
586
|
|
|
} |
587
|
|
|
|
588
|
|
|
// Make a note of the Unique ID for this menu. |
589
|
1 |
|
$context['admin_menu_id'] = $context['max_menu_id']; |
590
|
1 |
|
$context['admin_menu_name'] = 'menu_data_' . $context['admin_menu_id']; |
591
|
|
|
|
592
|
|
|
// Where in the admin are we? |
593
|
1 |
|
$context['admin_area'] = $admin_include_data['current_area']; |
594
|
|
|
|
595
|
1 |
|
return $admin_include_data; |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
/** |
599
|
|
|
* Builds out the navigation link tree for the admin area |
600
|
|
|
* |
601
|
|
|
* @param array $admin_include_data |
602
|
|
|
*/ |
603
|
|
|
private function buildLinktree($admin_include_data) |
604
|
|
|
{ |
605
|
|
|
global $txt, $context, $scripturl; |
606
|
|
|
|
607
|
|
|
// Build the link tree. |
608
|
|
|
$context['linktree'][] = array( |
609
|
|
|
'url' => $scripturl . '?action=admin', |
610
|
|
|
'name' => $txt['admin_center'], |
611
|
|
|
); |
612
|
|
|
|
613
|
|
|
if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
614
|
|
|
$context['linktree'][] = array( |
615
|
|
|
'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
616
|
|
|
'name' => $admin_include_data['label'], |
617
|
|
|
); |
618
|
|
|
|
619
|
|
|
if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']]->getLabel() != $admin_include_data['label']) |
620
|
|
|
$context['linktree'][] = array( |
621
|
|
|
'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
622
|
|
|
'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']]->getLabel(), |
623
|
|
|
); |
624
|
|
|
} |
625
|
|
|
|
626
|
|
|
/** |
627
|
|
|
* The main administration section. |
628
|
|
|
* |
629
|
|
|
* What it does: |
630
|
|
|
* |
631
|
|
|
* - It prepares all the data necessary for the administration front page. |
632
|
|
|
* - It uses the Admin template along with the admin sub template. |
633
|
|
|
* - It requires the moderate_forum, manage_membergroups, manage_bans, |
634
|
|
|
* admin_forum, manage_permissions, manage_attachments, manage_smileys, |
635
|
|
|
* manage_boards, edit_news, or send_mail permission. |
636
|
|
|
* - It uses the index administrative area. |
637
|
|
|
* - Accessed by ?action=admin. |
638
|
|
|
*/ |
639
|
|
|
public function action_home() |
640
|
|
|
{ |
641
|
|
|
global $txt, $scripturl, $context, $user_info, $settings; |
642
|
|
|
|
643
|
|
|
// We need a little help |
644
|
|
|
require_once(SUBSDIR . '/Membergroups.subs.php'); |
645
|
|
|
|
646
|
|
|
// You have to be able to do at least one of the below to see this page. |
647
|
|
|
isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments')); |
648
|
|
|
|
649
|
|
|
// Find all of this forum's administrators... |
650
|
|
View Code Duplication |
if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups')) |
651
|
|
|
{ |
652
|
|
|
// Add a 'more'-link if there are more than 32. |
653
|
|
|
$context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>'; |
654
|
|
|
} |
655
|
|
|
|
656
|
|
|
// This makes it easier to get the latest news with your time format. |
657
|
|
|
$context['time_format'] = urlencode($user_info['time_format']); |
658
|
|
|
$context['forum_version'] = FORUM_VERSION; |
659
|
|
|
|
660
|
|
|
// Get a list of current server versions. |
661
|
|
|
$context['current_versions'] = getServerVersions($this->_checkFor); |
662
|
|
|
$context['can_admin'] = allowedTo('admin_forum'); |
663
|
|
|
$context['sub_template'] = 'admin'; |
664
|
|
|
$context['page_title'] = $txt['admin_center']; |
665
|
|
|
$context[$context['admin_menu_name']]['tab_data'] = array( |
666
|
|
|
'title' => $txt['admin_center'], |
667
|
|
|
'help' => '', |
668
|
|
|
'description' => ' |
669
|
|
|
<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong> |
670
|
|
|
' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $settings['images_url']), |
671
|
|
|
); |
672
|
|
|
|
673
|
|
|
// Load in the admin quick tasks |
674
|
|
|
$context['quick_admin_tasks'] = getQuickAdminTasks(); |
675
|
|
|
} |
676
|
|
|
|
677
|
|
|
/** |
678
|
|
|
* The credits section in admin panel. |
679
|
|
|
* |
680
|
|
|
* What it does: |
681
|
|
|
* |
682
|
|
|
* - Determines the current level of support functions from the server, such as |
683
|
|
|
* current level of caching engine or graphics library's installed. |
684
|
|
|
* - Accessed by ?action=admin;area=credits |
685
|
|
|
*/ |
686
|
|
|
public function action_credits() |
687
|
|
|
{ |
688
|
|
|
global $txt, $scripturl, $context, $user_info; |
689
|
|
|
|
690
|
|
|
// We need a little help from our friends |
691
|
|
|
require_once(SUBSDIR . '/Membergroups.subs.php'); |
692
|
|
|
require_once(SUBSDIR . '/Who.subs.php'); |
693
|
|
|
require_once(SUBSDIR . '/Admin.subs.php'); |
694
|
|
|
|
695
|
|
|
// You have to be able to do at least one of the below to see this page. |
696
|
|
|
isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments')); |
697
|
|
|
|
698
|
|
|
// Find all of this forum's administrators... |
699
|
|
View Code Duplication |
if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups')) |
700
|
|
|
{ |
701
|
|
|
// Add a 'more'-link if there are more than 32. |
702
|
|
|
$context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>'; |
703
|
|
|
} |
704
|
|
|
|
705
|
|
|
// Load credits. |
706
|
|
|
$context[$context['admin_menu_name']]['tab_data'] = array( |
707
|
|
|
'title' => $txt['support_credits_title'], |
708
|
|
|
'help' => '', |
709
|
|
|
'description' => '', |
710
|
|
|
); |
711
|
|
|
theme()->getTemplates()->loadLanguageFile('Who'); |
712
|
|
|
$context += prepareCreditsData(); |
713
|
|
|
|
714
|
|
|
// This makes it easier to get the latest news with your time format. |
715
|
|
|
$context['time_format'] = urlencode($user_info['time_format']); |
716
|
|
|
$context['forum_version'] = FORUM_VERSION; |
717
|
|
|
|
718
|
|
|
// Get a list of current server versions. |
719
|
|
|
$context['current_versions'] = getServerVersions($this->_checkFor); |
720
|
|
|
$context['can_admin'] = allowedTo('admin_forum'); |
721
|
|
|
$context['sub_template'] = 'credits'; |
722
|
|
|
$context['page_title'] = $txt['support_credits_title']; |
723
|
|
|
|
724
|
|
|
// Load in the admin quick tasks |
725
|
|
|
$context['quick_admin_tasks'] = getQuickAdminTasks(); |
726
|
|
|
|
727
|
|
|
$index = 'new_in_' . str_replace(array('ElkArte ', '.'), array('', '_'), FORUM_VERSION); |
728
|
|
|
if (isset($txt[$index])) |
729
|
|
|
{ |
730
|
|
|
$context['latest_updates'] = replaceBasicActionUrl($txt[$index]); |
731
|
|
|
require_once(SUBSDIR . '/Themes.subs.php'); |
732
|
|
|
|
733
|
|
|
updateThemeOptions(array(1, $user_info['id'], 'dismissed_' . $index, 1)); |
734
|
|
|
} |
735
|
|
|
} |
736
|
|
|
|
737
|
|
|
/** |
738
|
|
|
* This function allocates out all the search stuff. |
739
|
|
|
* |
740
|
|
|
* What it does: |
741
|
|
|
* |
742
|
|
|
* - Accessed with /index.php?action=admin;area=search[;search_type=x] |
743
|
|
|
* - Sets up an array of applicable sub-actions (search types) and the function that goes with each |
744
|
|
|
* - Search type specified by "search_type" request variable (either from a |
745
|
|
|
* form or from the query string) Defaults to 'internal' |
746
|
|
|
* Calls the appropriate sub action based on the search_type |
747
|
|
|
*/ |
748
|
|
|
public function action_search() |
749
|
|
|
{ |
750
|
|
|
global $txt, $context; |
751
|
|
|
|
752
|
|
|
// What can we search for? |
753
|
|
|
$subActions = array( |
754
|
|
|
'internal' => array($this, 'action_search_internal', 'permission' => 'admin_forum'), |
755
|
|
|
'online' => array($this, 'action_search_doc', 'permission' => 'admin_forum'), |
756
|
|
|
'member' => array($this, 'action_search_member', 'permission' => 'admin_forum'), |
757
|
|
|
); |
758
|
|
|
|
759
|
|
|
// Set the subaction |
760
|
|
|
$action = new Action(); |
761
|
|
|
$subAction = $action->initialize($subActions, 'internal'); |
762
|
|
|
|
763
|
|
|
// Keep track of what the admin wants in terms of advanced or not |
764
|
|
|
if (empty($context['admin_preferences']['sb']) || $context['admin_preferences']['sb'] != $subAction) |
765
|
|
|
{ |
766
|
|
|
$context['admin_preferences']['sb'] = $subAction; |
767
|
|
|
|
768
|
|
|
// Update the preferences. |
769
|
|
|
require_once(SUBSDIR . '/Admin.subs.php'); |
770
|
|
|
updateAdminPreferences(); |
771
|
|
|
} |
772
|
|
|
|
773
|
|
|
// Setup for the template |
774
|
|
|
$context['search_type'] = $subAction; |
775
|
|
|
$context['search_term'] = $this->_req->getPost('search_term', 'trim|Util::htmlspecialchars[ENT_QUOTES]'); |
776
|
|
|
$context['sub_template'] = 'admin_search_results'; |
777
|
|
|
$context['page_title'] = $txt['admin_search_results']; |
778
|
|
|
|
779
|
|
|
// You did remember to enter something to search for, otherwise its easy |
780
|
|
|
if ($context['search_term'] === '') |
781
|
|
|
$context['search_results'] = array(); |
782
|
|
|
else |
783
|
|
|
$action->dispatch($subAction); |
784
|
|
|
} |
785
|
|
|
|
786
|
|
|
/** |
787
|
|
|
* A complicated but relatively quick internal search. |
788
|
|
|
* |
789
|
|
|
* What it does: |
790
|
|
|
* |
791
|
|
|
* - Can be accessed with /index.php?action=admin;sa=search;search_term=x) or |
792
|
|
|
* from the admin search form ("Task/Setting" option) |
793
|
|
|
* - Polls the controllers for their configuration settings |
794
|
|
|
* - Calls integrate_admin_search to allow addons to add search configs |
795
|
|
|
* - Loads up the "Help" language file and all of the "Manage" language files |
796
|
|
|
* - Loads up information about each item it found for the template |
797
|
|
|
* |
798
|
|
|
* @event integrate_admin_search Allows integration to add areas to the internal admin search |
799
|
|
|
* @event search Allows active modules registered to search to add settings for internal search |
800
|
|
|
*/ |
801
|
1 |
|
public function action_search_internal() |
802
|
|
|
{ |
803
|
1 |
|
global $context, $txt; |
804
|
|
|
|
805
|
|
|
// Try to get some more memory. |
806
|
1 |
|
detectServer()->setMemoryLimit('128M'); |
807
|
|
|
|
808
|
|
|
// Load a lot of language files. |
809
|
|
|
$language_files = array( |
810
|
1 |
|
'Help', 'ManageMail', 'ManageSettings', 'ManageBoards', 'ManagePaid', 'ManagePermissions', 'Search', |
811
|
|
|
'Login', 'ManageSmileys', 'Maillist', 'Mentions' |
812
|
|
|
); |
813
|
|
|
|
814
|
|
|
// All the files we need to include. |
815
|
|
|
$include_files = array( |
816
|
1 |
|
'AddonSettings.controller', 'AdminLog.controller', 'CoreFeatures.controller', |
817
|
|
|
'ManageAttachments.controller', 'ManageAvatars.controller', 'ManageBBC.controller', |
818
|
|
|
'ManageBoards.controller', |
819
|
|
|
'ManageFeatures.controller', 'ManageLanguages.controller', 'ManageMail.controller', |
820
|
|
|
'ManageNews.controller', 'ManagePaid.controller', 'ManagePermissions.controller', |
821
|
|
|
'ManagePosts.controller', 'ManageRegistration.controller', 'ManageSearch.controller', |
822
|
|
|
'ManageSearchEngines.controller', 'ManageSecurity.controller', 'ManageServer.controller', |
823
|
|
|
'ManageSmileys.controller', 'ManageTopics.controller', 'ManageMaillist.controller', |
824
|
|
|
'ManageMembergroups.controller' |
825
|
|
|
); |
826
|
|
|
|
827
|
|
|
// This is a special array of functions that contain setting data |
828
|
|
|
// - we query all these to simply pull all setting bits! |
829
|
|
|
$settings_search = array( |
830
|
1 |
|
array('settings_search', 'area=logs;sa=pruning', 'AdminLog_Controller'), |
831
|
|
|
array('config_vars', 'area=corefeatures', 'CoreFeatures_Controller'), |
832
|
|
|
array('basicSettings_search', 'area=featuresettings;sa=basic', 'ManageFeatures_Controller'), |
833
|
|
|
array('layoutSettings_search', 'area=featuresettings;sa=layout', 'ManageFeatures_Controller'), |
834
|
|
|
array('karmaSettings_search', 'area=featuresettings;sa=karma', 'ManageFeatures_Controller'), |
835
|
|
|
array('likesSettings_search', 'area=featuresettings;sa=likes', 'ManageFeatures_Controller'), |
836
|
|
|
array('mentionSettings_search', 'area=featuresettings;sa=mention', 'ManageFeatures_Controller'), |
837
|
|
|
array('signatureSettings_search', 'area=featuresettings;sa=sig', 'ManageFeatures_Controller'), |
838
|
|
|
array('settings_search', 'area=addonsettings;sa=general', 'AddonSettings_Controller'), |
839
|
|
|
array('settings_search', 'area=manageattachments;sa=attachments', 'ManageAttachments_Controller'), |
840
|
|
|
array('settings_search', 'area=manageattachments;sa=avatars', 'ManageAvatars_Controller'), |
841
|
|
|
array('settings_search', 'area=postsettings;sa=bbc', 'ManageBBC_Controller'), |
842
|
|
|
array('settings_search', 'area=manageboards;sa=settings', 'ManageBoards_Controller'), |
843
|
|
|
array('settings_search', 'area=languages;sa=settings', 'ManageLanguages_Controller'), |
844
|
|
|
array('settings_search', 'area=mailqueue;sa=settings', 'ManageMail_Controller'), |
845
|
|
|
array('settings_search', 'area=maillist;sa=emailsettings', 'ManageMaillist_Controller'), |
846
|
|
|
array('settings_search', 'area=membergroups;sa=settings', 'ManageMembergroups_Controller'), |
847
|
|
|
array('settings_search', 'area=news;sa=settings', 'ManageNews_Controller'), |
848
|
|
|
array('settings_search', 'area=paidsubscribe;sa=settings', 'ManagePaid_Controller'), |
849
|
|
|
array('settings_search', 'area=permissions;sa=settings', 'ManagePermissions_Controller'), |
850
|
|
|
array('settings_search', 'area=postsettings;sa=posts', 'ManagePosts_Controller'), |
851
|
|
|
array('settings_search', 'area=regcenter;sa=settings', 'ManageRegistration_Controller'), |
852
|
|
|
array('settings_search', 'area=managesearch;sa=settings', 'ManageSearch_Controller'), |
853
|
|
|
array('settings_search', 'area=sengines;sa=settings', 'ManageSearchEngines_Controller'), |
854
|
|
|
array('securitySettings_search', 'area=securitysettings;sa=general', 'ManageSecurity_Controller'), |
855
|
|
|
array('spamSettings_search', 'area=securitysettings;sa=spam', 'ManageSecurity_Controller'), |
856
|
|
|
array('moderationSettings_search', 'area=securitysettings;sa=moderation', 'ManageSecurity_Controller'), |
857
|
|
|
array('bbSettings_search', 'area=securitysettings;sa=badbehavior', 'ManageSecurity_Controller'), |
858
|
|
|
array('generalSettings_search', 'area=serversettings;sa=general', 'ManageServer_Controller'), |
859
|
|
|
array('databaseSettings_search', 'area=serversettings;sa=database', 'ManageServer_Controller'), |
860
|
|
|
array('cookieSettings_search', 'area=serversettings;sa=cookie', 'ManageServer_Controller'), |
861
|
|
|
array('cacheSettings_search', 'area=serversettings;sa=cache', 'ManageServer_Controller'), |
862
|
|
|
array('balancingSettings_search', 'area=serversettings;sa=loads', 'ManageServer_Controller'), |
863
|
|
|
array('settings_search', 'area=smileys;sa=settings', 'ManageSmileys_Controller'), |
864
|
|
|
array('settings_search', 'area=postsettings;sa=topics', 'ManageTopics_Controller'), |
865
|
|
|
); |
866
|
|
|
|
867
|
|
|
// Allow integration to add settings to search |
868
|
1 |
|
call_integration_hook('integrate_admin_search', array(&$language_files, &$include_files, &$settings_search)); |
869
|
|
|
|
870
|
|
|
// Allow active modules to add settings for internal search |
871
|
1 |
|
$this->_events->trigger('search', array('language_files' => &$language_files, 'include_files' => &$include_files, 'settings_search' => &$settings_search)); |
872
|
|
|
|
873
|
|
|
// Go through all the search data trying to find this text! |
874
|
1 |
|
$search_term = strtolower(un_htmlspecialchars($context['search_term'])); |
875
|
|
|
|
876
|
1 |
|
$search = new AdminSettings_Search($language_files, $include_files, $settings_search); |
877
|
1 |
|
$search->initSearch($context['admin_menu_name'], array( |
878
|
1 |
|
array('COPPA', 'area=regcenter;sa=settings'), |
879
|
|
|
array('CAPTCHA', 'area=securitysettings;sa=spam'), |
880
|
|
|
)); |
881
|
|
|
|
882
|
1 |
|
$context['page_title'] = $txt['admin_search_results']; |
883
|
1 |
|
$context['search_results'] = $search->doSearch($search_term); |
884
|
1 |
|
} |
885
|
|
|
|
886
|
|
|
/** |
887
|
|
|
* All this does is pass through to manage members. |
888
|
|
|
*/ |
889
|
|
|
public function action_search_member() |
890
|
|
|
{ |
891
|
|
|
global $context; |
892
|
|
|
|
893
|
|
|
// @todo once Action.class is changed |
894
|
|
|
$_REQUEST['sa'] = 'query'; |
895
|
|
|
|
896
|
|
|
// Set the query values |
897
|
|
|
$this->_req->post->sa = 'query'; |
898
|
|
|
$this->_req->post->membername = un_htmlspecialchars($context['search_term']); |
899
|
|
|
$this->_req->post->types = ''; |
900
|
|
|
|
901
|
|
|
$managemembers = new ManageMembers_Controller(new Event_manager()); |
902
|
|
|
$managemembers->pre_dispatch(); |
903
|
|
|
$managemembers->action_index(); |
904
|
|
|
} |
905
|
|
|
|
906
|
|
|
/** |
907
|
|
|
* This file allows the user to search the wiki documentation |
908
|
|
|
* for a little help. |
909
|
|
|
* |
910
|
|
|
* What it does: |
911
|
|
|
* |
912
|
|
|
* - Creates an exception since GitHub does not yet support API wiki searches so the connection |
913
|
|
|
* will fail. |
914
|
|
|
*/ |
915
|
|
|
public function action_search_doc() |
916
|
|
|
{ |
917
|
|
|
global $context; |
918
|
|
|
|
919
|
|
|
$context['doc_apiurl'] = 'https://github.com/elkarte/Elkarte/wiki/api.php'; |
920
|
|
|
$context['doc_scripturl'] = 'https://github.com/elkarte/Elkarte/wiki/'; |
921
|
|
|
|
922
|
|
|
// Set all the parameters search might expect. |
923
|
|
|
$postVars = explode(' ', $context['search_term']); |
924
|
|
|
|
925
|
|
|
// Encode the search data. |
926
|
|
|
foreach ($postVars as $k => $v) |
927
|
|
|
$postVars[$k] = urlencode($v); |
928
|
|
|
|
929
|
|
|
// This is what we will send. |
930
|
|
|
$postVars = implode('+', $postVars); |
931
|
|
|
|
932
|
|
|
// Get the results from the doc site. |
933
|
|
|
require_once(SUBSDIR . '/Package.subs.php'); |
934
|
|
|
// Demo URL: |
935
|
|
|
// https://github.com/elkarte/Elkarte/wiki/api.php?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=template+eval |
936
|
|
|
$search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); |
937
|
|
|
|
938
|
|
|
// If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
939
|
|
|
if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) !== 1) |
940
|
|
|
throw new Elk_Exception('cannot_connect_doc_site'); |
941
|
|
|
|
942
|
|
|
$search_results = !empty($matches[1]) ? $matches[1] : ''; |
943
|
|
|
|
944
|
|
|
// Otherwise we simply walk through the XML and stick it in context for display. |
945
|
|
|
$context['search_results'] = array(); |
946
|
|
|
|
947
|
|
|
// Get the results loaded into an array for processing! |
948
|
|
|
$results = new Xml_Array($search_results, false); |
949
|
|
|
|
950
|
|
|
// Move through the api layer. |
951
|
|
|
if (!$results->exists('api')) |
952
|
|
|
{ |
953
|
|
|
throw new Elk_Exception('cannot_connect_doc_site'); |
954
|
|
|
} |
955
|
|
|
|
956
|
|
|
// Are there actually some results? |
957
|
|
|
if ($results->exists('api/query/search/p')) |
958
|
|
|
{ |
959
|
|
|
$relevance = 0; |
960
|
|
|
foreach ($results->set('api/query/search/p') as $result) |
961
|
|
|
{ |
962
|
|
|
$context['search_results'][$result->fetch('@title')] = array( |
963
|
|
|
'title' => $result->fetch('@title'), |
964
|
|
|
'relevance' => $relevance++, |
965
|
|
|
'snippet' => str_replace('class=\'searchmatch\'', 'class="highlight"', un_htmlspecialchars($result->fetch('@snippet'))), |
966
|
|
|
); |
967
|
|
|
} |
968
|
|
|
} |
969
|
|
|
} |
970
|
|
|
|
971
|
|
|
/** |
972
|
|
|
* This ends a admin session, requiring authentication to access the ACP again. |
973
|
|
|
*/ |
974
|
|
|
public function action_endsession() |
975
|
|
|
{ |
976
|
|
|
// This is so easy! |
977
|
|
|
unset($_SESSION['admin_time']); |
978
|
|
|
|
979
|
|
|
// Clean any admin tokens as well. |
980
|
|
|
cleanTokens(false, '-admin'); |
981
|
|
|
|
982
|
|
|
if (isset($this->_req->query->redir, $this->_req->server->HTTP_REFERER)) |
983
|
|
|
{ |
984
|
|
|
redirectexit($_SERVER['HTTP_REFERER']); |
985
|
|
|
} |
986
|
|
|
|
987
|
|
|
redirectexit(); |
988
|
|
|
} |
989
|
|
|
} |
990
|
|
|
|