Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

mcp.php

Zuletzt modifiziert: 02.04.2025, 15:01 - Dateigröße: 9.81 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  /**
015  * @ignore
016  */
017  define('IN_PHPBB', true);
018  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
019  $phpEx = substr(strrchr(__FILE__, '.'), 1);
020  include($phpbb_root_path . 'common.' . $phpEx);
021  include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
022  include($phpbb_root_path . 'includes/functions_mcp.' . $phpEx);
023  require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
024   
025  // Start session management
026  $user->session_begin();
027  $auth->acl($user->data);
028  $user->setup('mcp');
029   
030  $module = new p_master();
031   
032  // Setting a variable to let the style designer know where he is...
033  $template->assign_var('S_IN_MCP', true);
034   
035  // Basic parameter data
036  $id = $request->variable('i', '');
037   
038  $mode = $request->variable('mode', array(''));
039  $mode = count($mode) ? array_shift($mode) : $request->variable('mode', '');
040   
041  // Only Moderators can go beyond this point
042  if (!$user->data['is_registered'])
043  {
044      if ($user->data['is_bot'])
045      {
046          redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
047      }
048   
049      login_box('', $user->lang['LOGIN_EXPLAIN_MCP']);
050  }
051   
052  $quickmod = (isset($_REQUEST['quickmod'])) ? true : false;
053  $action = $request->variable('action', '');
054  $action_ary = $request->variable('action', array('' => 0));
055   
056  $forum_action = $request->variable('forum_action', '');
057  if ($forum_action !== '' && $request->variable('sort', false, false, \phpbb\request\request_interface::POST))
058  {
059      $action = $forum_action;
060  }
061   
062  if (count($action_ary))
063  {
064      $action = key($action_ary);
065  }
066  unset($action_ary);
067   
068  if ($mode == 'topic_logs')
069  {
070      $id = 'logs';
071      $quickmod = false;
072  }
073   
074  $post_id = $request->variable('p', 0);
075  $topic_id = $request->variable('t', 0);
076  $forum_id = $request->variable('f', 0);
077  $report_id = $request->variable('r', 0);
078  $user_id = $request->variable('u', 0);
079  $username = $request->variable('username', '', true);
080   
081  if ($post_id)
082  {
083      // We determine the topic and forum id here, to make sure the moderator really has moderative rights on this post
084      $sql = 'SELECT topic_id, forum_id
085          FROM ' . POSTS_TABLE . '
086          WHERE post_id = ' . (int) $post_id;
087      $result = $db->sql_query($sql);
088      $row = $db->sql_fetchrow($result);
089      $db->sql_freeresult($result);
090   
091      $topic_id = $row['topic_id'] ?? false;
092      $forum_id = $row['forum_id'] ?? false;
093  }
094  else if ($topic_id)
095  {
096      $sql = 'SELECT forum_id
097          FROM ' . TOPICS_TABLE . '
098          WHERE topic_id = ' . (int) $topic_id;
099      $result = $db->sql_query($sql);
100      $row = $db->sql_fetchrow($result);
101      $db->sql_freeresult($result);
102   
103      $forum_id = $row['forum_id'] ?? false;
104  }
105   
106  // If the user doesn't have any moderator powers (globally or locally) he can't access the mcp
107  if (!$auth->acl_getf_global('m_'))
108  {
109      // Except he is using one of the quickmod tools for users
110      $user_quickmod_actions = array(
111          'lock'            => 'f_user_lock',
112          'make_sticky'    => 'f_sticky',
113          'make_announce'    => 'f_announce',
114          'make_global'    => 'f_announce_global',
115          'make_normal'    => array('f_announce', 'f_announce_global', 'f_sticky')
116      );
117   
118      $allow_user = false;
119      if ($quickmod && isset($user_quickmod_actions[$action]) && $user->data['is_registered'] && $auth->acl_gets($user_quickmod_actions[$action], $forum_id))
120      {
121          $topic_info = phpbb_get_topic_data(array($topic_id));
122          if ($topic_info[$topic_id]['topic_poster'] == $user->data['user_id'])
123          {
124              $allow_user = true;
125          }
126      }
127   
128      /**
129      * Allow modification of the permissions to access the mcp file
130      *
131      * @event core.mcp_modify_permissions
132      * @var    array        user_quickmod_actions            Array holding the quickmod actions and their respectiev permissions
133      * @var    bool        quickmod                        Whether or not the action is performed via QuickMod
134      * @var    bool        allow_user                        Boolean holding if the user can access the mcp
135      * @var    int            forum_id                        The current forum ID
136      * @var    int            topic_id                        The current topic ID
137      * @since 3.3.3-RC1
138      */
139      $vars = array(
140          'user_quickmod_actions',
141          'quickmod',
142          'allow_user',
143          'forum_id',
144          'topic_id',
145      );
146      extract($phpbb_dispatcher->trigger_event('core.mcp_modify_permissions', compact($vars)));
147   
148      if (!$allow_user)
149      {
150          send_status_line(403, 'Forbidden');
151          trigger_error('NOT_AUTHORISED');
152      }
153  }
154   
155  // if the user cannot read the forum he tries to access then we won't allow mcp access either
156  if ($forum_id && !$auth->acl_get('f_read', $forum_id))
157  {
158      send_status_line(403, 'Forbidden');
159      trigger_error('NOT_AUTHORISED');
160  }
161   
162  /**
163  * Allow applying additional permissions to MCP access besides f_read
164  *
165  * @event core.mcp_global_f_read_auth_after
166  * @var    string        action            The action the user tried to execute
167  * @var    int            forum_id        The forum the user tried to access
168  * @var    string        mode            The MCP module the user is trying to access
169  * @var    p_master    module            Module system class
170  * @var    bool        quickmod        True if the user is accessing using quickmod tools
171  * @var    int            topic_id        The topic the user tried to access
172  * @since 3.1.3-RC1
173  */
174  $vars = array(
175      'action',
176      'forum_id',
177      'mode',
178      'module',
179      'quickmod',
180      'topic_id',
181  );
182  extract($phpbb_dispatcher->trigger_event('core.mcp_global_f_read_auth_after', compact($vars)));
183   
184  if ($forum_id)
185  {
186      $module->acl_forum_id = $forum_id;
187  }
188   
189  // Instantiate module system and generate list of available modules
190  $module->list_modules('mcp');
191   
192  if ($quickmod)
193  {
194      $mode = 'quickmod';
195   
196      switch ($action)
197      {
198          case 'lock':
199          case 'unlock':
200          case 'lock_post':
201          case 'unlock_post':
202          case 'make_sticky':
203          case 'make_announce':
204          case 'make_global':
205          case 'make_normal':
206          case 'fork':
207          case 'move':
208          case 'delete_post':
209          case 'delete_topic':
210          case 'restore_topic':
211              $module->load('mcp', 'main', 'quickmod');
212              return;
213          break;
214   
215          case 'topic_logs':
216              // Reset start parameter if we jumped from the quickmod dropdown
217              if ($request->variable('start', 0))
218              {
219                  $request->overwrite('start', 0);
220              }
221   
222              $module->set_active('logs', 'topic_logs');
223          break;
224   
225          case 'merge_topic':
226              $module->set_active('main', 'forum_view');
227          break;
228   
229          case 'split':
230          case 'merge':
231              $module->set_active('main', 'topic_view');
232          break;
233   
234          default:
235              // If needed, the flag can be set to true within event listener
236              // to indicate that the action was handled properly
237              // and to pass by the trigger_error() call below
238              $is_valid_action = false;
239   
240              /**
241              * This event allows you to add custom quickmod options
242              *
243              * @event core.modify_quickmod_options
244              * @var    object    module            Instance of module system class
245              * @var    string    action            Quickmod option
246              * @var    bool    is_valid_action    Flag indicating if the action was handled properly
247              * @since 3.1.0-a4
248              */
249              $vars = array('module', 'action', 'is_valid_action');
250              extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_options', compact($vars)));
251   
252              if (!$is_valid_action)
253              {
254                  trigger_error($user->lang('QUICKMOD_ACTION_NOT_ALLOWED', $action), E_USER_ERROR);
255              }
256          break;
257      }
258  }
259  else
260  {
261      // Select the active module
262      $module->set_active($id, $mode);
263  }
264   
265  // Hide some of the options if we don't have the relevant information to use them
266  if (!$post_id)
267  {
268      $module->set_display('main', 'post_details', false);
269      $module->set_display('warn', 'warn_post', false);
270  }
271   
272  if ($mode == '' || $mode == 'unapproved_topics' || $mode == 'unapproved_posts' || $mode == 'deleted_topics' || $mode == 'deleted_posts')
273  {
274      $module->set_display('queue', 'approve_details', false);
275  }
276   
277  if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'pm_report_details')
278  {
279      $module->set_display('reports', 'report_details', false);
280  }
281   
282  if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'report_details')
283  {
284      $module->set_display('pm_reports', 'pm_report_details', false);
285  }
286   
287  if (!$topic_id)
288  {
289      $module->set_display('main', 'topic_view', false);
290      $module->set_display('logs', 'topic_logs', false);
291  }
292   
293  if (!$forum_id)
294  {
295      $module->set_display('main', 'forum_view', false);
296      $module->set_display('logs', 'forum_logs', false);
297  }
298   
299  if (!$user_id && $username == '')
300  {
301      $module->set_display('notes', 'user_notes', false);
302      $module->set_display('warn', 'warn_user', false);
303  }
304   
305  /**
306  * This event allows you to set display option for custom MCP modules
307  *
308  * @event core.modify_mcp_modules_display_option
309  * @var    p_master    module            Module system class
310  * @var    string        mode            MCP mode
311  * @var    int            user_id            User id
312  * @var    int            forum_id        Forum id
313  * @var    int            topic_id        Topic id
314  * @var    int            post_id            Post id
315  * @var    string        username        User name
316  * @var    int            id                Parent module id
317  * @since 3.1.0-b2
318  */
319  $vars = array(
320      'module',
321      'mode',
322      'user_id',
323      'forum_id',
324      'topic_id',
325      'post_id',
326      'username',
327      'id',
328  );
329  extract($phpbb_dispatcher->trigger_event('core.modify_mcp_modules_display_option', compact($vars)));
330   
331  $template->assign_block_vars('navlinks', array(
332      'BREADCRUMB_NAME'    => $user->lang('MCP'),
333      'U_BREADCRUMB'        => append_sid("{$phpbb_root_path}mcp.$phpEx"),
334  ));
335   
336  // Generate urls for letting the moderation control panel being accessed in different modes
337  $template->assign_vars(array(
338      'U_MCP'            => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main'),
339      'U_MCP_FORUM'    => ($forum_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=forum_view&amp;f=$forum_id") : '',
340      'U_MCP_TOPIC'    => ($forum_id && $topic_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=topic_view&amp;t=$topic_id") : '',
341      'U_MCP_POST'    => ($forum_id && $topic_id && $post_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=post_details&amp;t=$topic_id&amp;p=$post_id") : '',
342  ));
343   
344  // Load and execute the relevant module
345  $module->load_active();
346   
347  // Assign data to the template engine for the list of modules
348  $module->assign_tpl_vars(append_sid("{$phpbb_root_path}mcp.$phpEx"));
349   
350  // Generate the page, do not display/query online list
351  $module->display($module->get_page_title());
352