Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

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:51 - Dateigröße: 7.87 KiB


 001  <?php
 002  /**
 003  *
 004  * @package acp
 005  * @version $Id$
 006  * @copyright (c) 2005 phpBB Group
 007  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 008  *
 009  */
 010   
 011  /**
 012  * @ignore
 013  */
 014  if (!defined('IN_PHPBB'))
 015  {
 016      exit;
 017  }
 018   
 019  /**
 020  * @package acp
 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 = 'SELECT u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type
 086                              FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
 087                              WHERE ug.group_id = ' . $group_id . '
 088                                  AND ug.user_pending = 0
 089                                  AND u.user_id = ug.user_id
 090                                  AND u.user_allow_massemail = 1
 091                                  AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
 092                              ORDER BY u.user_lang, u.user_notify_type';
 093                      }
 094                      else
 095                      {
 096                          $sql = 'SELECT username, username_clean, user_email, user_jabber, user_notify_type, user_lang
 097                              FROM ' . USERS_TABLE . '
 098                              WHERE user_allow_massemail = 1
 099                                  AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
 100                              ORDER BY user_lang, user_notify_type';
 101                      }
 102                  }
 103                  $result = $db->sql_query($sql);
 104                  $row = $db->sql_fetchrow($result);
 105   
 106                  if (!$row)
 107                  {
 108                      $db->sql_freeresult($result);
 109                      trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
 110                  }
 111      
 112                  $i = $j = 0;
 113   
 114                  // Send with BCC, no more than 50 recipients for one mail (to not exceed the limit)
 115                  $max_chunk_size = 50;
 116                  $email_list = array();
 117                  $old_lang = $row['user_lang'];
 118                  $old_notify_type = $row['user_notify_type'];
 119   
 120                  do
 121                  {
 122                      if (($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email']) ||
 123                          ($row['user_notify_type'] == NOTIFY_IM && $row['user_jabber']) ||
 124                          ($row['user_notify_type'] == NOTIFY_BOTH && $row['user_email'] && $row['user_jabber']))
 125                      {
 126                          if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type)
 127                          {
 128                              $i = 0;
 129   
 130                              if (sizeof($email_list))
 131                              {
 132                                  $j++;
 133                              }
 134   
 135                              $old_lang = $row['user_lang'];
 136                              $old_notify_type = $row['user_notify_type'];
 137                          }
 138   
 139                          $email_list[$j][$i]['lang']        = $row['user_lang'];
 140                          $email_list[$j][$i]['method']    = $row['user_notify_type'];
 141                          $email_list[$j][$i]['email']    = $row['user_email'];
 142                          $email_list[$j][$i]['name']        = $row['username'];
 143                          $email_list[$j][$i]['jabber']    = $row['user_jabber'];
 144                          $i++;
 145                      }
 146                  }
 147                  while ($row = $db->sql_fetchrow($result));
 148                  $db->sql_freeresult($result);
 149   
 150                  // Send the messages
 151                  include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 152                  include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
 153                  $messenger = new messenger($use_queue);
 154   
 155                  $errored = false;
 156   
 157                  for ($i = 0, $size = sizeof($email_list); $i < $size; $i++)
 158                  {
 159                      $used_lang = $email_list[$i][0]['lang'];
 160                      $used_method = $email_list[$i][0]['method'];
 161   
 162                      for ($j = 0, $list_size = sizeof($email_list[$i]); $j < $list_size; $j++)
 163                      {
 164                          $email_row = $email_list[$i][$j];
 165   
 166                          $messenger->{((sizeof($email_list[$i]) == 1) ? 'to' : 'bcc')}($email_row['email'], $email_row['name']);
 167                          $messenger->im($email_row['jabber'], $email_row['name']);
 168                      }
 169   
 170                      $messenger->template('admin_send_email', $used_lang);
 171   
 172                      $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
 173                      $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
 174                      $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
 175                      $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
 176              
 177                      $messenger->subject(htmlspecialchars_decode($subject));
 178                      $messenger->set_mail_priority($priority);
 179   
 180                      $messenger->assign_vars(array(
 181                          'CONTACT_EMAIL' => $config['board_contact'],
 182                          'MESSAGE'        => htmlspecialchars_decode($message))
 183                      );
 184      
 185                      if (!($messenger->send($used_method)))
 186                      {
 187                          $errored = true;
 188                      }
 189                  }
 190                  unset($email_list);
 191   
 192                  $messenger->save_queue();
 193   
 194                  if ($usernames)
 195                  {
 196                      $usernames = explode("\n", $usernames);
 197                      add_log('admin', 'LOG_MASS_EMAIL', implode(', ', utf8_normalize_nfc($usernames)));
 198                  }
 199                  else
 200                  {
 201                      if ($group_id)
 202                      {
 203                          $group_name = get_group_name($group_id);
 204                      }
 205                      else
 206                      {
 207                          // Not great but the logging routine doesn't cope well with localising on the fly
 208                          $group_name = $user->lang['ALL_USERS'];
 209                      }
 210   
 211                      add_log('admin', 'LOG_MASS_EMAIL', $group_name);
 212                  }
 213   
 214                  if (!$errored)
 215                  {
 216                      $message = ($use_queue) ? $user->lang['EMAIL_SENT_QUEUE'] : $user->lang['EMAIL_SENT'];
 217                      trigger_error($message . adm_back_link($this->u_action));
 218                  }
 219                  else
 220                  {
 221                      $message = sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&amp;mode=critical') . '">', '</a>');
 222                      trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING);
 223                  }
 224              }
 225          }
 226   
 227          // Exclude bots and guests...
 228          $sql = 'SELECT group_id
 229              FROM ' . GROUPS_TABLE . "
 230              WHERE group_name IN ('BOTS', 'GUESTS')";
 231          $result = $db->sql_query($sql);
 232   
 233          $exclude = array();
 234          while ($row = $db->sql_fetchrow($result))
 235          {
 236              $exclude[] = $row['group_id'];
 237          }
 238          $db->sql_freeresult($result);
 239   
 240          $select_list = '<option value="0"' . ((!$group_id) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
 241          $select_list .= group_select_options($group_id, $exclude);
 242          
 243          $s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
 244          $s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
 245          $s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
 246   
 247          $template->assign_vars(array(
 248              'S_WARNING'                => (sizeof($error)) ? true : false,
 249              'WARNING_MSG'            => (sizeof($error)) ? implode('<br />', $error) : '',
 250              'U_ACTION'                => $this->u_action,
 251              'S_GROUP_OPTIONS'        => $select_list,
 252              'USERNAMES'                => $usernames,
 253              'U_FIND_USERNAME'        => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=acp_email&amp;field=usernames'),
 254              'SUBJECT'                => $subject,
 255              'MESSAGE'                => $message,
 256              'S_PRIORITY_OPTIONS'    => $s_priority_options)
 257          );
 258   
 259      }
 260  }
 261   
 262  ?>