Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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: 09.10.2024, 12:50 - Dateigröße: 8.12 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_var('i', '');
037   
038  $mode = request_var('mode', array(''));
039  $mode = sizeof($mode) ? array_shift($mode) : request_var('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_var('action', '');
054  $action_ary = request_var('action', array('' => 0));
055   
056  $forum_action = request_var('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 (sizeof($action_ary))
063  {
064      list($action, ) = each($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_var('p', 0);
075  $topic_id = request_var('t', 0);
076  $forum_id = request_var('f', 0);
077  $report_id = request_var('r', 0);
078  $user_id = request_var('u', 0);
079  $username = utf8_normalize_nfc(request_var('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 = $post_id";
087      $result = $db->sql_query($sql);
088      $row = $db->sql_fetchrow($result);
089      $db->sql_freeresult($result);
090   
091      $topic_id = (int) $row['topic_id'];
092      $forum_id = (int) $row['forum_id'];
093  }
094  else if ($topic_id)
095  {
096      $sql = 'SELECT forum_id
097          FROM ' . TOPICS_TABLE . "
098          WHERE topic_id = $topic_id";
099      $result = $db->sql_query($sql);
100      $row = $db->sql_fetchrow($result);
101      $db->sql_freeresult($result);
102   
103      $forum_id = (int) $row['forum_id'];
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',
115          'make_normal'    => array('f_announce', '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      if (!$allow_user)
129      {
130          trigger_error('NOT_AUTHORISED');
131      }
132  }
133   
134  // if the user cannot read the forum he tries to access then we won't allow mcp access either
135  if ($forum_id && !$auth->acl_get('f_read', $forum_id))
136  {
137      trigger_error('NOT_AUTHORISED');
138  }
139   
140  if ($forum_id)
141  {
142      $module->acl_forum_id = $forum_id;
143  }
144   
145  // Instantiate module system and generate list of available modules
146  $module->list_modules('mcp');
147   
148  if ($quickmod)
149  {
150      $mode = 'quickmod';
151   
152      switch ($action)
153      {
154          case 'lock':
155          case 'unlock':
156          case 'lock_post':
157          case 'unlock_post':
158          case 'make_sticky':
159          case 'make_announce':
160          case 'make_global':
161          case 'make_normal':
162          case 'fork':
163          case 'move':
164          case 'delete_post':
165          case 'delete_topic':
166          case 'restore_topic':
167              $module->load('mcp', 'main', 'quickmod');
168              return;
169          break;
170   
171          case 'topic_logs':
172              // Reset start parameter if we jumped from the quickmod dropdown
173              if (request_var('start', 0))
174              {
175                  $request->overwrite('start', 0);
176              }
177   
178              $module->set_active('logs', 'topic_logs');
179          break;
180   
181          case 'merge_topic':
182              $module->set_active('main', 'forum_view');
183          break;
184   
185          case 'split':
186          case 'merge':
187              $module->set_active('main', 'topic_view');
188          break;
189   
190          default:
191              // If needed, the flag can be set to true within event listener
192              // to indicate that the action was handled properly
193              // and to pass by the trigger_error() call below
194              $is_valid_action = false;
195   
196              /**
197              * This event allows you to add custom quickmod options
198              *
199              * @event core.modify_quickmod_options
200              * @var    object    module            Instance of module system class
201              * @var    string    action            Quickmod option
202              * @var    bool    is_valid_action    Flag indicating if the action was handled properly
203              * @since 3.1.0-a4
204              */
205              $vars = array('module', 'action', 'is_valid_action');
206              extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_options', compact($vars)));
207   
208              if (!$is_valid_action)
209              {
210                  trigger_error($user->lang('QUICKMOD_ACTION_NOT_ALLOWED', $action), E_USER_ERROR);
211              }
212          break;
213      }
214  }
215  else
216  {
217      // Select the active module
218      $module->set_active($id, $mode);
219  }
220   
221  // Hide some of the options if we don't have the relevant information to use them
222  if (!$post_id)
223  {
224      $module->set_display('main', 'post_details', false);
225      $module->set_display('warn', 'warn_post', false);
226  }
227   
228  if ($mode == '' || $mode == 'unapproved_topics' || $mode == 'unapproved_posts' || $mode == 'deleted_topics' || $mode == 'deleted_posts')
229  {
230      $module->set_display('queue', 'approve_details', false);
231  }
232   
233  if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'pm_report_details')
234  {
235      $module->set_display('reports', 'report_details', false);
236  }
237   
238  if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'report_details')
239  {
240      $module->set_display('pm_reports', 'pm_report_details', false);
241  }
242   
243  if (!$topic_id)
244  {
245      $module->set_display('main', 'topic_view', false);
246      $module->set_display('logs', 'topic_logs', false);
247  }
248   
249  if (!$forum_id)
250  {
251      $module->set_display('main', 'forum_view', false);
252      $module->set_display('logs', 'forum_logs', false);
253  }
254   
255  if (!$user_id && $username == '')
256  {
257      $module->set_display('notes', 'user_notes', false);
258      $module->set_display('warn', 'warn_user', false);
259  }
260   
261  /**
262  * This event allows you to set display option for custom MCP modules
263  *
264  * @event core.modify_mcp_modules_display_option
265  * @var    p_master    module            Module system class
266  * @var    string        mode            MCP mode
267  * @var    int            user_id            User id
268  * @var    int            forum_id        Forum id
269  * @var    int            topic_id        Topic id
270  * @var    int            post_id            Post id
271  * @var    string        username        User name
272  * @var    int            id                Parent module id
273  * @since 3.1.0-b2
274  */
275  $vars = array(
276      'module',
277      'mode',
278      'user_id',
279      'forum_id',
280      'topic_id',
281      'post_id',
282      'username',
283      'id',
284  );
285  extract($phpbb_dispatcher->trigger_event('core.modify_mcp_modules_display_option', compact($vars)));
286   
287  // Load and execute the relevant module
288  $module->load_active();
289   
290  // Assign data to the template engine for the list of modules
291  $module->assign_tpl_vars(append_sid("{$phpbb_root_path}mcp.$phpEx"));
292   
293  // Generate urls for letting the moderation control panel being accessed in different modes
294  $template->assign_vars(array(
295      'U_MCP'            => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main'),
296      'U_MCP_FORUM'    => ($forum_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=forum_view&amp;f=$forum_id") : '',
297      'U_MCP_TOPIC'    => ($forum_id && $topic_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=topic_view&amp;t=$topic_id") : '',
298      '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") : '',
299  ));
300   
301  // Generate the page, do not display/query online list
302  $module->display($module->get_page_title());
303