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

acp_email.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 8.32 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, $auth, $template, $cache;
 029          global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
 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_var('usernames', '', true);
 043          $group_id    = request_var('g', 0);
 044          $subject    = utf8_normalize_nfc(request_var('subject', '', true));
 045          $message    = utf8_normalize_nfc(request_var('message', '', true));
 046   
 047          // Do the job ...
 048          if ($submit)
 049          {
 050              // Error checking needs to go here ... if no subject and/or no message then skip
 051              // over the send and return to the form
 052              $use_queue        = (isset($_POST['send_immediately'])) ? false : true;
 053              $priority        = request_var('mail_priority_flag', MAIL_NORMAL_PRIORITY);
 054   
 055              if (!check_form_key($form_key))
 056              {
 057                  $error[] = $user->lang['FORM_INVALID'];
 058              }
 059   
 060              if (!$subject)
 061              {
 062                  $error[] = $user->lang['NO_EMAIL_SUBJECT'];
 063              }
 064   
 065              if (!$message)
 066              {
 067                  $error[] = $user->lang['NO_EMAIL_MESSAGE'];
 068              }
 069   
 070              if (!sizeof($error))
 071              {
 072                  if ($usernames)
 073                  {
 074                      // If giving usernames the admin is able to email inactive users too...
 075                      $sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang
 076                          FROM ' . USERS_TABLE . '
 077                          WHERE ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', explode("\n", $usernames))) . '
 078                              AND user_allow_massemail = 1
 079                          ORDER BY user_lang, user_notify_type'; // , SUBSTRING(user_email FROM INSTR(user_email, '@'))
 080                  }
 081                  else
 082                  {
 083                      if ($group_id)
 084                      {
 085                          $sql_ary = array(
 086                              'SELECT'    => 'u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type',
 087                              'FROM'        => array(
 088                                  USERS_TABLE            => 'u',
 089                                  USER_GROUP_TABLE    => 'ug',
 090                              ),
 091                              'WHERE'        => 'ug.group_id = ' . $group_id . '
 092                                  AND ug.user_pending = 0
 093                                  AND u.user_id = ug.user_id
 094                                  AND u.user_allow_massemail = 1
 095                                  AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')',
 096                              'ORDER_BY'    => 'u.user_lang, u.user_notify_type',
 097                          );
 098                      }
 099                      else
 100                      {
 101                          $sql_ary = array(
 102                              'SELECT'    => 'u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type',
 103                              'FROM'        => array(
 104                                  USERS_TABLE    => 'u',
 105                              ),
 106                              'WHERE'        => 'u.user_allow_massemail = 1
 107                                  AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')',
 108                              'ORDER_BY'    => 'u.user_lang, u.user_notify_type',
 109                          );
 110                      }
 111   
 112                      // Mail banned or not
 113                      if (!isset($_REQUEST['mail_banned_flag']))
 114                      {
 115                          $sql_ary['WHERE'] .= ' AND (b.ban_id IS NULL
 116                                  OR b.ban_exclude = 1)';
 117                          $sql_ary['LEFT_JOIN'] = array(
 118                              array(
 119                                  'FROM'    => array(
 120                                      BANLIST_TABLE    => 'b',
 121                                  ),
 122                                  'ON'    => 'u.user_id = b.ban_userid',
 123                              ),
 124                          );
 125                      }
 126                      $sql = $db->sql_build_query('SELECT', $sql_ary);
 127                  }
 128                  $result = $db->sql_query($sql);
 129                  $row = $db->sql_fetchrow($result);
 130   
 131                  if (!$row)
 132                  {
 133                      $db->sql_freeresult($result);
 134                      trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
 135                  }
 136   
 137                  $i = $j = 0;
 138   
 139                  // Send with BCC
 140                  // Maximum number of bcc recipients
 141                  $max_chunk_size = (int) $config['email_max_chunk_size'];
 142                  $email_list = array();
 143                  $old_lang = $row['user_lang'];
 144                  $old_notify_type = $row['user_notify_type'];
 145   
 146                  do
 147                  {
 148                      if (($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email']) ||
 149                          ($row['user_notify_type'] == NOTIFY_IM && $row['user_jabber']) ||
 150                          ($row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])))
 151                      {
 152                          if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type)
 153                          {
 154                              $i = 0;
 155   
 156                              if (sizeof($email_list))
 157                              {
 158                                  $j++;
 159                              }
 160   
 161                              $old_lang = $row['user_lang'];
 162                              $old_notify_type = $row['user_notify_type'];
 163                          }
 164   
 165                          $email_list[$j][$i]['lang']        = $row['user_lang'];
 166                          $email_list[$j][$i]['method']    = $row['user_notify_type'];
 167                          $email_list[$j][$i]['email']    = $row['user_email'];
 168                          $email_list[$j][$i]['name']        = $row['username'];
 169                          $email_list[$j][$i]['jabber']    = $row['user_jabber'];
 170                          $i++;
 171                      }
 172                  }
 173                  while ($row = $db->sql_fetchrow($result));
 174                  $db->sql_freeresult($result);
 175   
 176                  // Send the messages
 177                  include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 178                  include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
 179                  $messenger = new messenger($use_queue);
 180   
 181                  $errored = false;
 182   
 183                  for ($i = 0, $size = sizeof($email_list); $i < $size; $i++)
 184                  {
 185                      $used_lang = $email_list[$i][0]['lang'];
 186                      $used_method = $email_list[$i][0]['method'];
 187   
 188                      for ($j = 0, $list_size = sizeof($email_list[$i]); $j < $list_size; $j++)
 189                      {
 190                          $email_row = $email_list[$i][$j];
 191   
 192                          $messenger->{((sizeof($email_list[$i]) == 1) ? 'to' : 'bcc')}($email_row['email'], $email_row['name']);
 193                          $messenger->im($email_row['jabber'], $email_row['name']);
 194                      }
 195   
 196                      $messenger->template('admin_send_email', $used_lang);
 197   
 198                      $messenger->anti_abuse_headers($config, $user);
 199   
 200                      $messenger->subject(htmlspecialchars_decode($subject));
 201                      $messenger->set_mail_priority($priority);
 202   
 203                      $messenger->assign_vars(array(
 204                          'CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx),
 205                          'MESSAGE'        => htmlspecialchars_decode($message))
 206                      );
 207   
 208                      if (!($messenger->send($used_method)))
 209                      {
 210                          $errored = true;
 211                      }
 212                  }
 213                  unset($email_list);
 214   
 215                  $messenger->save_queue();
 216   
 217                  if ($usernames)
 218                  {
 219                      $usernames = explode("\n", $usernames);
 220                      add_log('admin', 'LOG_MASS_EMAIL', implode(', ', utf8_normalize_nfc($usernames)));
 221                  }
 222                  else
 223                  {
 224                      if ($group_id)
 225                      {
 226                          $group_name = get_group_name($group_id);
 227                      }
 228                      else
 229                      {
 230                          // Not great but the logging routine doesn't cope well with localising on the fly
 231                          $group_name = $user->lang['ALL_USERS'];
 232                      }
 233   
 234                      add_log('admin', 'LOG_MASS_EMAIL', $group_name);
 235                  }
 236   
 237                  if (!$errored)
 238                  {
 239                      $message = ($use_queue) ? $user->lang['EMAIL_SENT_QUEUE'] : $user->lang['EMAIL_SENT'];
 240                      trigger_error($message . adm_back_link($this->u_action));
 241                  }
 242                  else
 243                  {
 244                      $message = sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&amp;mode=critical') . '">', '</a>');
 245                      trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING);
 246                  }
 247              }
 248          }
 249   
 250          // Exclude bots and guests...
 251          $sql = 'SELECT group_id
 252              FROM ' . GROUPS_TABLE . "
 253              WHERE group_name IN ('BOTS', 'GUESTS')";
 254          $result = $db->sql_query($sql);
 255   
 256          $exclude = array();
 257          while ($row = $db->sql_fetchrow($result))
 258          {
 259              $exclude[] = $row['group_id'];
 260          }
 261          $db->sql_freeresult($result);
 262   
 263          $select_list = '<option value="0"' . ((!$group_id) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
 264          $select_list .= group_select_options($group_id, $exclude);
 265   
 266          $s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
 267          $s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
 268          $s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
 269   
 270          $template->assign_vars(array(
 271              'S_WARNING'                => (sizeof($error)) ? true : false,
 272              'WARNING_MSG'            => (sizeof($error)) ? implode('<br />', $error) : '',
 273              'U_ACTION'                => $this->u_action,
 274              'S_GROUP_OPTIONS'        => $select_list,
 275              'USERNAMES'                => $usernames,
 276              'U_FIND_USERNAME'        => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=acp_email&amp;field=usernames'),
 277              'SUBJECT'                => $subject,
 278              'MESSAGE'                => $message,
 279              'S_PRIORITY_OPTIONS'    => $s_priority_options)
 280          );
 281   
 282      }
 283  }
 284