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

message.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 6.47 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  namespace phpbb\message;
 015   
 016  /**
 017  * Class message
 018  * Holds all information for an email and sends it in the end
 019  */
 020  class message
 021  {
 022      /** @var string */
 023      protected $server_name;
 024   
 025      /** @var string */
 026      protected $subject = '';
 027      /** @var string */
 028      protected $body = '';
 029      /** @var string */
 030      protected $template = '';
 031      /** @var array */
 032      protected $template_vars = array();
 033   
 034      /** @var string */
 035      protected $sender_ip = '';
 036      /** @var string */
 037      protected $sender_name = '';
 038      /** @var string */
 039      protected $sender_address = '';
 040      /** @var string */
 041      protected $sender_lang = '';
 042      /** @var string */
 043      protected $sender_id = '';
 044      /** @var string */
 045      protected $sender_username = '';
 046      /** @var string */
 047      protected $sender_jabber = '';
 048      /** @var int */
 049      protected $sender_notify_type = NOTIFY_EMAIL;
 050   
 051      /** @var array */
 052      protected $recipients;
 053   
 054      /**
 055      * Construct
 056      *
 057      * @param string $server_name    Used for AntiAbuse header
 058      */
 059      public function __construct($server_name)
 060      {
 061          $this->server_name = $server_name;
 062      }
 063   
 064      /**
 065      * Set the subject of the email
 066      *
 067      * @param string $subject
 068      * @return null
 069      */
 070      public function set_subject($subject)
 071      {
 072          $this->subject = $subject;
 073      }
 074   
 075      /**
 076      * Set the body of the email text
 077      *
 078      * @param string $body
 079      * @return null
 080      */
 081      public function set_body($body)
 082      {
 083          $this->body = $body;
 084      }
 085   
 086      /**
 087      * Set the name of the email template to use
 088      *
 089      * @param string $template
 090      * @return null
 091      */
 092      public function set_template($template)
 093      {
 094          $this->template = $template;
 095      }
 096   
 097      /**
 098      * Set the array with the "template" data for the email
 099      *
 100      * @param array $template_vars
 101      * @return null
 102      */
 103      public function set_template_vars($template_vars)
 104      {
 105          $this->template_vars = $template_vars;
 106      }
 107   
 108      /**
 109      * Add a recipient from \phpbb\user
 110      *
 111      * @param array $user
 112      * @return null
 113      */
 114      public function add_recipient_from_user_row(array $user)
 115      {
 116          $this->add_recipient(
 117              $user['username'],
 118              $user['user_email'],
 119              $user['user_lang'],
 120              $user['user_notify_type'],
 121              $user['username'],
 122              $user['user_jabber']
 123          );
 124      }
 125   
 126      /**
 127      * Add a recipient
 128      *
 129      * @param string $recipient_name        Displayed sender name
 130      * @param string $recipient_address    Email address
 131      * @param string $recipient_lang
 132      * @param int $recipient_notify_type    Used notification methods (Jabber, Email, ...)
 133      * @param string $recipient_username    User Name (used for AntiAbuse header)
 134      * @param string $recipient_jabber
 135      * @return null
 136      */
 137      public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '')
 138      {
 139          $this->recipients[] = array(
 140              'name'            => $recipient_name,
 141              'address'        => $recipient_address,
 142              'lang'            => $recipient_lang,
 143              'username'        => $recipient_username,
 144              'jabber'        => $recipient_jabber,
 145              'notify_type'    => $recipient_notify_type,
 146              'to_name'        => $recipient_name,
 147          );
 148      }
 149   
 150      /**
 151      * Set the senders data from \phpbb\user object
 152      *
 153      * @param \phpbb\user $user
 154      * @return null
 155      */
 156      public function set_sender_from_user($user)
 157      {
 158          $this->set_sender(
 159              $user->ip,
 160              $user->data['username'],
 161              $user->data['user_email'],
 162              $user->lang_name,
 163              $user->data['user_id'],
 164              $user->data['username'],
 165              $user->data['user_jabber']
 166          );
 167   
 168          $this->set_sender_notify_type($user->data['user_notify_type']);
 169      }
 170   
 171      /**
 172      * Set the senders data
 173      *
 174      * @param string $sender_ip
 175      * @param string $sender_name        Displayed sender name
 176      * @param string $sender_address        Email address
 177      * @param string $sender_lang
 178      * @param int $sender_id                User ID
 179      * @param string $sender_username    User Name (used for AntiAbuse header)
 180      * @param string $sender_jabber
 181      * @return null
 182      */
 183      public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '')
 184      {
 185          $this->sender_ip = $sender_ip;
 186          $this->sender_name = $sender_name;
 187          $this->sender_address = $sender_address;
 188          $this->sender_lang = $sender_lang;
 189          $this->sender_id = $sender_id;
 190          $this->sender_username = $sender_username;
 191          $this->sender_jabber = $sender_jabber;
 192      }
 193   
 194      /**
 195      * Which notification type should be used? Jabber, Email, ...?
 196      *
 197      * @param int $sender_notify_type
 198      * @return null
 199      */
 200      public function set_sender_notify_type($sender_notify_type)
 201      {
 202          $this->sender_notify_type = $sender_notify_type;
 203      }
 204   
 205      /**
 206      * Ok, now the same email if CC specified, but without exposing the user's email address
 207      *
 208      * @return null
 209      */
 210      public function cc_sender()
 211      {
 212          if (!sizeof($this->recipients))
 213          {
 214              trigger_error('No email recipients specified');
 215          }
 216          if (!$this->sender_address)
 217          {
 218              trigger_error('No email sender specified');
 219          }
 220   
 221          $this->recipients[] = array(
 222              'lang'            => $this->sender_lang,
 223              'address'        => $this->sender_address,
 224              'name'            => $this->sender_name,
 225              'username'        => $this->sender_username,
 226              'jabber'        => $this->sender_jabber,
 227              'notify_type'    => $this->sender_notify_type,
 228              'to_name'        => $this->recipients[0]['to_name'],
 229          );
 230      }
 231   
 232      /**
 233      * Send the email
 234      *
 235      * @param \messenger $messenger
 236      * @param string $contact
 237      * @return null
 238      */
 239      public function send(\messenger $messenger, $contact)
 240      {
 241          if (!sizeof($this->recipients))
 242          {
 243              return;
 244          }
 245   
 246          foreach ($this->recipients as $recipient)
 247          {
 248              $messenger->template($this->template, $recipient['lang']);
 249              $messenger->replyto($this->sender_address);
 250              $messenger->to($recipient['address'], $recipient['name']);
 251              $messenger->im($recipient['jabber'], $recipient['username']);
 252   
 253              $messenger->headers('X-AntiAbuse: Board servername - ' . $this->server_name);
 254              $messenger->headers('X-AntiAbuse: User IP - ' . $this->sender_ip);
 255   
 256              if ($this->sender_id)
 257              {
 258                  $messenger->headers('X-AntiAbuse: User_id - ' . $this->sender_id);
 259              }
 260              if ($this->sender_username)
 261              {
 262                  $messenger->headers('X-AntiAbuse: Username - ' . $this->sender_username);
 263              }
 264   
 265              $messenger->subject(htmlspecialchars_decode($this->subject));
 266   
 267              $messenger->assign_vars(array(
 268                  'BOARD_CONTACT'    => $contact,
 269                  'TO_USERNAME'    => htmlspecialchars_decode($recipient['to_name']),
 270                  'FROM_USERNAME'    => htmlspecialchars_decode($this->sender_name),
 271                  'MESSAGE'        => htmlspecialchars_decode($this->body))
 272              );
 273   
 274              if (sizeof($this->template_vars))
 275              {
 276                  $messenger->assign_vars($this->template_vars);
 277              }
 278   
 279              $messenger->send($recipient['notify_type']);
 280          }
 281      }
 282  }
 283