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

acp_email.php

Zuletzt modifiziert: 01.05.2026, 11:25 - Dateigröße: 10.62 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 acp_email
 023  {
 024      var $u_action;
 025   
 026      function main($id, $mode)
 027      {
 028          global $config, $db, $user, $template, $phpbb_log, $request;
 029          global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_dispatcher;
 030   
 031          $user->add_lang('acp/email');
 032          $this->tpl_name = 'acp_email';
 033          $this->page_title = 'ACP_MASS_EMAIL';
 034   
 035          $form_key = 'acp_email';
 036          add_form_key($form_key);
 037   
 038          // Set some vars
 039          $submit = (isset($_POST['submit'])) ? true : false;
 040          $error = array();
 041   
 042          $usernames    = $request->variable('usernames', '', true);
 043          $usernames    = (!empty($usernames)) ? explode("\n", $usernames) : array();
 044          $group_id    = $request->variable('g', 0);
 045          $subject    = $request->variable('subject', '', true);
 046          $message    = $request->variable('message', '', true);
 047   
 048          // Do the job ...
 049          if ($submit)
 050          {
 051              // Error checking needs to go here ... if no subject and/or no message then skip
 052              // over the send and return to the form
 053              $use_queue        = (isset($_POST['send_immediately'])) ? false : true;
 054              $priority        = $request->variable('mail_priority_flag', MAIL_NORMAL_PRIORITY);
 055   
 056              if (!check_form_key($form_key))
 057              {
 058                  $error[] = $user->lang['FORM_INVALID'];
 059              }
 060   
 061              if (!$subject)
 062              {
 063                  $error[] = $user->lang['NO_EMAIL_SUBJECT'];
 064              }
 065   
 066              if (!$message)
 067              {
 068                  $error[] = $user->lang['NO_EMAIL_MESSAGE'];
 069              }
 070   
 071              if (!count($error))
 072              {
 073                  if (!empty($usernames))
 074                  {
 075                      // If giving usernames the admin is able to email inactive users too...
 076                      $sql_ary = array(
 077                          'SELECT'    => 'username, user_email, user_jabber, user_notify_type, user_lang',
 078                          'FROM'        => array(
 079                              USERS_TABLE        => '',
 080                          ),
 081                          'WHERE'        => $db->sql_in_set('username_clean', array_map('utf8_clean_string', $usernames)) . '
 082                              AND user_allow_massemail = 1',
 083                          'ORDER_BY'    => 'user_lang, user_notify_type',
 084                      );
 085                  }
 086                  else
 087                  {
 088                      if ($group_id)
 089                      {
 090                          $sql_ary = array(
 091                              'SELECT'    => 'u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type',
 092                              'FROM'        => array(
 093                                  USERS_TABLE            => 'u',
 094                                  USER_GROUP_TABLE    => 'ug',
 095                              ),
 096                              'WHERE'        => 'ug.group_id = ' . $group_id . '
 097                                  AND ug.user_pending = 0
 098                                  AND u.user_id = ug.user_id
 099                                  AND u.user_allow_massemail = 1
 100                                  AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')',
 101                              'ORDER_BY'    => 'u.user_lang, u.user_notify_type',
 102                          );
 103                      }
 104                      else
 105                      {
 106                          $sql_ary = array(
 107                              'SELECT'    => 'u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type',
 108                              'FROM'        => array(
 109                                  USERS_TABLE    => 'u',
 110                              ),
 111                              'WHERE'        => 'u.user_allow_massemail = 1
 112                                  AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')',
 113                              'ORDER_BY'    => 'u.user_lang, u.user_notify_type',
 114                          );
 115                      }
 116   
 117                      // Mail banned or not
 118                      if (!isset($_REQUEST['mail_banned_flag']))
 119                      {
 120                          $sql_ary['WHERE'] .= ' AND (b.ban_id IS NULL
 121                                  OR b.ban_exclude = 1)';
 122                          $sql_ary['LEFT_JOIN'] = array(
 123                              array(
 124                                  'FROM'    => array(
 125                                      BANLIST_TABLE    => 'b',
 126                                  ),
 127                                  'ON'    => 'u.user_id = b.ban_userid',
 128                              ),
 129                          );
 130                      }
 131                  }
 132                  /**
 133                  * Modify sql query to change the list of users the email is sent to
 134                  *
 135                  * @event core.acp_email_modify_sql
 136                  * @var    array    sql_ary        Array which is used to build the sql query
 137                  * @since 3.1.2-RC1
 138                  */
 139                  $vars = array('sql_ary');
 140                  extract($phpbb_dispatcher->trigger_event('core.acp_email_modify_sql', compact($vars)));
 141   
 142                  $sql = $db->sql_build_query('SELECT', $sql_ary);
 143                  $result = $db->sql_query($sql);
 144                  $row = $db->sql_fetchrow($result);
 145   
 146                  if (!$row)
 147                  {
 148                      $db->sql_freeresult($result);
 149                      trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
 150                  }
 151   
 152                  $i = $j = 0;
 153   
 154                  // Send with BCC
 155                  // Maximum number of bcc recipients
 156                  $max_chunk_size = (int) $config['email_max_chunk_size'];
 157                  $email_list = array();
 158                  $old_lang = $row['user_lang'];
 159                  $old_notify_type = $row['user_notify_type'];
 160   
 161                  do
 162                  {
 163                      if (($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email']) ||
 164                          ($row['user_notify_type'] == NOTIFY_IM && $row['user_jabber']) ||
 165                          ($row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])))
 166                      {
 167                          if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type)
 168                          {
 169                              $i = 0;
 170   
 171                              if (count($email_list))
 172                              {
 173                                  $j++;
 174                              }
 175   
 176                              $old_lang = $row['user_lang'];
 177                              $old_notify_type = $row['user_notify_type'];
 178                          }
 179   
 180                          $email_list[$j][$i]['lang']        = $row['user_lang'];
 181                          $email_list[$j][$i]['method']    = $row['user_notify_type'];
 182                          $email_list[$j][$i]['email']    = $row['user_email'];
 183                          $email_list[$j][$i]['name']        = $row['username'];
 184                          $email_list[$j][$i]['jabber']    = $row['user_jabber'];
 185                          $i++;
 186                      }
 187                  }
 188                  while ($row = $db->sql_fetchrow($result));
 189                  $db->sql_freeresult($result);
 190   
 191                  // Send the messages
 192                  if (!class_exists('messenger'))
 193                  {
 194                      include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 195                  }
 196   
 197                  if (!function_exists('get_group_name'))
 198                  {
 199                      include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
 200                  }
 201                  $messenger = new messenger($use_queue);
 202   
 203                  $errored = false;
 204   
 205                  $email_template = 'admin_send_email';
 206                  $template_data = array(
 207                      'CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx),
 208                      'MESSAGE'        => html_entity_decode($message, ENT_COMPAT),
 209                  );
 210                  $generate_log_entry = true;
 211   
 212                  /**
 213                  * Modify email template data before the emails are sent
 214                  *
 215                  * @event core.acp_email_send_before
 216                  * @var    string    email_template        The template to be used for sending the email
 217                  * @var    string    subject                The subject of the email
 218                  * @var    array    template_data        Array with template data assigned to email template
 219                  * @var    bool    generate_log_entry    If false, no log entry will be created
 220                  * @var    array    usernames            Usernames which will be displayed in log entry, if it will be created
 221                  * @var    int        group_id            The group this email will be sent to
 222                  * @var    bool    use_queue            If true, email queue will be used for sending
 223                  * @var    int        priority            Priority of sent emails
 224                  * @since 3.1.3-RC1
 225                  */
 226                  $vars = array(
 227                      'email_template',
 228                      'subject',
 229                      'template_data',
 230                      'generate_log_entry',
 231                      'usernames',
 232                      'group_id',
 233                      'use_queue',
 234                      'priority',
 235                  );
 236                  extract($phpbb_dispatcher->trigger_event('core.acp_email_send_before', compact($vars)));
 237   
 238                  for ($i = 0, $size = count($email_list); $i < $size; $i++)
 239                  {
 240                      $used_lang = $email_list[$i][0]['lang'];
 241                      $used_method = $email_list[$i][0]['method'];
 242   
 243                      for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
 244                      {
 245                          $email_row = $email_list[$i][$j];
 246   
 247                          $messenger->{((count($email_list[$i]) == 1) ? 'to' : 'bcc')}($email_row['email'], $email_row['name']);
 248                          $messenger->im($email_row['jabber'], $email_row['name']);
 249                      }
 250   
 251                      $messenger->template($email_template, $used_lang);
 252   
 253                      $messenger->anti_abuse_headers($config, $user);
 254   
 255                      $messenger->subject(html_entity_decode($subject, ENT_COMPAT));
 256                      $messenger->set_mail_priority($priority);
 257   
 258                      $messenger->assign_vars($template_data);
 259   
 260                      if (!($messenger->send($used_method)))
 261                      {
 262                          $errored = true;
 263                      }
 264                  }
 265                  unset($email_list);
 266   
 267                  $messenger->save_queue();
 268   
 269                  if ($generate_log_entry)
 270                  {
 271                      if (!empty($usernames))
 272                      {
 273                          $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MASS_EMAIL', false, array(implode(', ', utf8_normalize_nfc($usernames))));
 274                      }
 275                      else
 276                      {
 277                          if ($group_id)
 278                          {
 279                              $group_name = get_group_name($group_id);
 280                          }
 281                          else
 282                          {
 283                              // Not great but the logging routine doesn't cope well with localising on the fly
 284                              $group_name = $user->lang['ALL_USERS'];
 285                          }
 286   
 287                          $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MASS_EMAIL', false, array($group_name));
 288                      }
 289                  }
 290   
 291                  if (!$errored)
 292                  {
 293                      $message = ($use_queue) ? $user->lang['EMAIL_SENT_QUEUE'] : $user->lang['EMAIL_SENT'];
 294                      trigger_error($message . adm_back_link($this->u_action));
 295                  }
 296                  else
 297                  {
 298                      $message = sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&amp;mode=critical') . '">', '</a>');
 299                      trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING);
 300                  }
 301              }
 302          }
 303   
 304          // Exclude bots and guests...
 305          $sql = 'SELECT group_id
 306              FROM ' . GROUPS_TABLE . "
 307              WHERE group_name IN ('BOTS', 'GUESTS')";
 308          $result = $db->sql_query($sql);
 309   
 310          $exclude = array();
 311          while ($row = $db->sql_fetchrow($result))
 312          {
 313              $exclude[] = $row['group_id'];
 314          }
 315          $db->sql_freeresult($result);
 316   
 317          $select_list = '<option value="0"' . ((!$group_id) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
 318          $select_list .= group_select_options($group_id, $exclude);
 319   
 320          $s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
 321          $s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
 322          $s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
 323   
 324          $template_data = array(
 325              'S_WARNING'                => (count($error)) ? true : false,
 326              'WARNING_MSG'            => (count($error)) ? implode('<br />', $error) : '',
 327              'U_ACTION'                => $this->u_action,
 328              'S_GROUP_OPTIONS'        => $select_list,
 329              'USERNAMES'                => implode("\n", $usernames),
 330              'U_FIND_USERNAME'        => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=acp_email&amp;field=usernames'),
 331              'SUBJECT'                => $subject,
 332              'MESSAGE'                => $message,
 333              'S_PRIORITY_OPTIONS'    => $s_priority_options,
 334          );
 335   
 336          /**
 337          * Modify custom email template data before we display the form
 338          *
 339          * @event core.acp_email_display
 340          * @var    array    template_data        Array with template data assigned to email template
 341          * @var    array    exclude                Array with groups which are excluded from group selection
 342          * @var    array    usernames            Usernames which will be displayed in form
 343          *
 344          * @since 3.1.4-RC1
 345          */
 346          $vars = array('template_data', 'exclude', 'usernames');
 347          extract($phpbb_dispatcher->trigger_event('core.acp_email_display', compact($vars)));
 348   
 349          $template->assign_vars($template_data);
 350      }
 351  }
 352