Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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_ban.php

Zuletzt modifiziert: 01.05.2026, 11:25 - 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  if (!defined('IN_PHPBB'))
 018  {
 019      exit;
 020  }
 021   
 022  class mcp_ban
 023  {
 024      var $u_action;
 025   
 026      function main($id, $mode)
 027      {
 028          global $db, $user, $auth, $template, $request, $phpbb_dispatcher;
 029          global $phpbb_root_path, $phpEx;
 030   
 031          if (!function_exists('user_ban'))
 032          {
 033              include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
 034          }
 035   
 036          // Include the admin banning interface...
 037          if (!class_exists('acp_ban'))
 038          {
 039              include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx);
 040          }
 041   
 042          $bansubmit        = $request->is_set_post('bansubmit');
 043          $unbansubmit    = $request->is_set_post('unbansubmit');
 044   
 045          $user->add_lang(array('acp/ban', 'acp/users'));
 046          $this->tpl_name = 'mcp_ban';
 047   
 048          /**
 049          * Use this event to pass perform actions when a ban is issued or revoked
 050          *
 051          * @event core.mcp_ban_main
 052          * @var    bool    bansubmit    True if a ban is issued
 053          * @var    bool    unbansubmit    True if a ban is removed
 054          * @var    string    mode        Mode of the ban that is being worked on
 055          * @since 3.1.0-RC5
 056          */
 057          $vars = array(
 058              'bansubmit',
 059              'unbansubmit',
 060              'mode',
 061          );
 062          extract($phpbb_dispatcher->trigger_event('core.mcp_ban_main', compact($vars)));
 063   
 064          // Ban submitted?
 065          if ($bansubmit)
 066          {
 067              // Grab the list of entries
 068              $ban                = $request->variable('ban', '', $mode === 'user');
 069              $ban_length            = $request->variable('banlength', 0);
 070              $ban_length_other    = $request->variable('banlengthother', '');
 071              $ban_exclude        = $request->variable('banexclude', 0);
 072              $ban_reason            = $request->variable('banreason', '', true);
 073              $ban_give_reason    = $request->variable('bangivereason', '', true);
 074   
 075              if ($ban)
 076              {
 077                  if (confirm_box(true))
 078                  {
 079                      $abort_ban = false;
 080                      /**
 081                      * Use this event to modify the ban details before the ban is performed
 082                      *
 083                      * @event core.mcp_ban_before
 084                      * @var    string    mode                One of the following: user, ip, email
 085                      * @var    string    ban                    Either string or array with usernames, ips or email addresses
 086                      * @var    int        ban_length            Ban length in minutes
 087                      * @var    string    ban_length_other    Ban length as a date (YYYY-MM-DD)
 088                      * @var    bool    ban_exclude            Are we banning or excluding from another ban
 089                      * @var    string    ban_reason            Ban reason displayed to moderators
 090                      * @var    string    ban_give_reason        Ban reason displayed to the banned user
 091                      * @var    mixed    abort_ban            Either false, or an error message that is displayed to the user.
 092                      *                                    If a string is given the bans are not issued.
 093                      * @since 3.1.0-RC5
 094                      */
 095                      $vars = array(
 096                          'mode',
 097                          'ban',
 098                          'ban_length',
 099                          'ban_length_other',
 100                          'ban_exclude',
 101                          'ban_reason',
 102                          'ban_give_reason',
 103                          'abort_ban',
 104                      );
 105                      extract($phpbb_dispatcher->trigger_event('core.mcp_ban_before', compact($vars)));
 106   
 107                      if ($abort_ban)
 108                      {
 109                          trigger_error($abort_ban);
 110                      }
 111                      user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason);
 112   
 113                      /**
 114                      * Use this event to perform actions after the ban has been performed
 115                      *
 116                      * @event core.mcp_ban_after
 117                      * @var    string    mode                One of the following: user, ip, email
 118                      * @var    string    ban                    Either string or array with usernames, ips or email addresses
 119                      * @var    int        ban_length            Ban length in minutes
 120                      * @var    string    ban_length_other    Ban length as a date (YYYY-MM-DD)
 121                      * @var    bool    ban_exclude            Are we banning or excluding from another ban
 122                      * @var    string    ban_reason            Ban reason displayed to moderators
 123                      * @var    string    ban_give_reason        Ban reason displayed to the banned user
 124                      * @since 3.1.0-RC5
 125                      */
 126                      $vars = array(
 127                          'mode',
 128                          'ban',
 129                          'ban_length',
 130                          'ban_length_other',
 131                          'ban_exclude',
 132                          'ban_reason',
 133                          'ban_give_reason',
 134                      );
 135                      extract($phpbb_dispatcher->trigger_event('core.mcp_ban_after', compact($vars)));
 136   
 137                      trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">&laquo; ' . $user->lang['BACK_TO_PREV'] . '</a>');
 138                  }
 139                  else
 140                  {
 141                      $hidden_fields = array(
 142                          'mode'                => $mode,
 143                          'ban'                => $ban,
 144                          'bansubmit'            => true,
 145                          'banlength'            => $ban_length,
 146                          'banlengthother'    => $ban_length_other,
 147                          'banexclude'        => $ban_exclude,
 148                          'banreason'            => $ban_reason,
 149                          'bangivereason'        => $ban_give_reason,
 150                      );
 151   
 152                      /**
 153                      * Use this event to pass data from the ban form to the confirmation screen
 154                      *
 155                      * @event core.mcp_ban_confirm
 156                      * @var    array    hidden_fields    Hidden fields that are passed through the confirm screen
 157                      * @since 3.1.0-RC5
 158                      */
 159                      $vars = array('hidden_fields');
 160                      extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars)));
 161   
 162                      confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields));
 163                  }
 164              }
 165          }
 166          else if ($unbansubmit)
 167          {
 168              $ban = $request->variable('unban', array(''));
 169   
 170              if ($ban)
 171              {
 172                  if (confirm_box(true))
 173                  {
 174                      user_unban($mode, $ban);
 175   
 176                      trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">&laquo; ' . $user->lang['BACK_TO_PREV'] . '</a>');
 177                  }
 178                  else
 179                  {
 180                      confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
 181                          'mode'            => $mode,
 182                          'unbansubmit'    => true,
 183                          'unban'            => $ban)));
 184                  }
 185              }
 186          }
 187   
 188          // Define language vars
 189          $this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
 190   
 191          $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
 192          $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
 193          $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
 194          $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
 195          $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
 196   
 197          switch ($mode)
 198          {
 199              case 'user':
 200                  $l_ban_cell = $user->lang['USERNAME'];
 201              break;
 202   
 203              case 'ip':
 204                  $l_ban_cell = $user->lang['IP_HOSTNAME'];
 205              break;
 206   
 207              case 'email':
 208                  $l_ban_cell = $user->lang['EMAIL_ADDRESS'];
 209              break;
 210          }
 211   
 212          display_ban_end_options();
 213          display_ban_options($mode);
 214   
 215          $template->assign_vars(array(
 216              'L_TITLE'                => $this->page_title,
 217              'L_EXPLAIN'                => $l_ban_explain,
 218              'L_UNBAN_TITLE'            => $l_unban_title,
 219              'L_UNBAN_EXPLAIN'        => $l_unban_explain,
 220              'L_BAN_CELL'            => $l_ban_cell,
 221              'L_BAN_EXCLUDE_EXPLAIN'    => $l_ban_exclude_explain,
 222              'L_NO_BAN_CELL'            => $l_no_ban_cell,
 223   
 224              'S_USERNAME_BAN'    => ($mode == 'user') ? true : false,
 225   
 226              'U_ACTION'            => $this->u_action,
 227              'U_FIND_USERNAME'    => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=mcp_ban&amp;field=ban'),
 228          ));
 229   
 230          if ($mode === 'email' && !$auth->acl_get('a_user'))
 231          {
 232              return;
 233          }
 234   
 235          // As a "service" we will check if any post id is specified and populate the username of the poster id if given
 236          $post_id = $request->variable('p', 0);
 237          $user_id = $request->variable('u', 0);
 238          $pre_fill = false;
 239   
 240          if ($user_id && $user_id <> ANONYMOUS)
 241          {
 242              $sql = 'SELECT username, user_email, user_ip
 243                  FROM ' . USERS_TABLE . '
 244                  WHERE user_id = ' . $user_id;
 245              $result = $db->sql_query($sql);
 246              switch ($mode)
 247              {
 248                  case 'user':
 249                      $pre_fill = (string) $db->sql_fetchfield('username');
 250                  break;
 251   
 252                  case 'ip':
 253                      $pre_fill = (string) $db->sql_fetchfield('user_ip');
 254                  break;
 255   
 256                  case 'email':
 257                      $pre_fill = (string) $db->sql_fetchfield('user_email');
 258                  break;
 259              }
 260              $db->sql_freeresult($result);
 261          }
 262          else if ($post_id)
 263          {
 264              $post_info = phpbb_get_post_data(array($post_id), 'm_ban');
 265   
 266              if (count($post_info) && !empty($post_info[$post_id]))
 267              {
 268                  switch ($mode)
 269                  {
 270                      case 'user':
 271                          $pre_fill = $post_info[$post_id]['username'];
 272                      break;
 273   
 274                      case 'ip':
 275                          $pre_fill = $post_info[$post_id]['poster_ip'];
 276                      break;
 277   
 278                      case 'email':
 279                          $pre_fill = $post_info[$post_id]['user_email'];
 280                      break;
 281                  }
 282   
 283              }
 284          }
 285   
 286          if ($pre_fill)
 287          {
 288              // left for legacy template compatibility
 289              $template->assign_var('USERNAMES', $pre_fill);
 290              $template->assign_var('BAN_QUANTIFIER', $pre_fill);
 291          }
 292      }
 293  }
 294