diff options
author | Yuchen Pei <hi@ypei.me> | 2021-10-15 09:52:00 +1100 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2021-10-15 09:52:00 +1100 |
commit | 71b0e901f5fb1cfcd162d8acc23120d3f77a3152 (patch) | |
tree | 323c00faef1edc7dea2e88ff581cc2258b2b6432 /h-source/External/swiftmailer/lib/classes/Swift/Plugins | |
parent | 72cce24864b064b5762f4fe97fdf40d8d2ad4b51 (diff) | |
parent | 07f5140771388c9e0c8a99b0dd2e5d950bdb173b (diff) |
Merge branch 'development' into h-node
Diffstat (limited to 'h-source/External/swiftmailer/lib/classes/Swift/Plugins')
18 files changed, 0 insertions, 1717 deletions
diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php deleted file mode 100755 index 46a7f44..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Events/SendListener.php'; -//@require 'Swift/Events/SendEvent.php'; -//@require 'Swift/Plugins/Sleeper.php'; - -/** - * Reduces network flooding when sending large amounts of mail. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -class Swift_Plugins_AntiFloodPlugin - implements Swift_Events_SendListener, Swift_Plugins_Sleeper -{ - - /** - * The number of emails to send before restarting Transport. - * @var int - * @access private - */ - private $_threshold; - - /** - * The number of seconds to sleep for during a restart. - * @var int - * @access private - */ - private $_sleep; - - /** - * The internal counter. - * @var int - * @access private - */ - private $_counter = 0; - - /** - * The Sleeper instance for sleeping. - * @var Swift_Plugins_Sleeper - * @access private - */ - private $_sleeper; - - /** - * Create a new AntiFloodPlugin with $threshold and $sleep time. - * @param int $threshold - * @param int $sleep time - * @param Swift_Plugins_Sleeper $sleeper (not needed really) - */ - public function __construct($threshold = 99, $sleep = 0, - Swift_Plugins_Sleeper $sleeper = null) - { - $this->setThreshold($threshold); - $this->setSleepTime($sleep); - $this->_sleeper = $sleeper; - } - - /** - * Set the number of emails to send before restarting. - * @param int $threshold - */ - public function setThreshold($threshold) - { - $this->_threshold = $threshold; - } - - /** - * Get the number of emails to send before restarting. - * @return int - */ - public function getThreshold() - { - return $this->_threshold; - } - - /** - * Set the number of seconds to sleep for during a restart. - * @param int $sleep time - */ - public function setSleepTime($sleep) - { - $this->_sleep = $sleep; - } - - /** - * Get the number of seconds to sleep for during a restart. - * @return int - */ - public function getSleepTime() - { - return $this->_sleep; - } - - /** - * Invoked immediately before the Message is sent. - * @param Swift_Events_SendEvent $evt - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } - - /** - * Invoked immediately after the Message is sent. - * @param Swift_Events_SendEvent $evt - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - ++$this->_counter; - if ($this->_counter >= $this->_threshold) - { - $transport = $evt->getTransport(); - $transport->stop(); - if ($this->_sleep) - { - $this->sleep($this->_sleep); - } - $transport->start(); - $this->_counter = 0; - } - } - - /** - * Sleep for $seconds. - * @param int $seconds - */ - public function sleep($seconds) - { - if (isset($this->_sleeper)) - { - $this->_sleeper->sleep($seconds); - } - else - { - sleep($seconds); - } - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php deleted file mode 100755 index 501cd80..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php +++ /dev/null @@ -1,173 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Events/SendListener.php'; -//@require 'Swift/Events/SendEvent.php'; -//@require 'Swift/Events/CommandListener.php'; -//@require 'Swift/Events/CommandEvent.php'; -//@require 'Swift/Events/ResponseListener.php'; -//@require 'Swift/Events/ResponseEvent.php'; -//@require 'Swift/InputByteStream.php'; - -/** - * Reduces network flooding when sending large amounts of mail. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -class Swift_Plugins_BandwidthMonitorPlugin - implements Swift_Events_SendListener, Swift_Events_CommandListener, - Swift_Events_ResponseListener, Swift_InputByteStream -{ - - /** - * The outgoing traffic counter. - * @var int - * @access private - */ - private $_out = 0; - - /** - * The incoming traffic counter. - * @var int - * @access private - */ - private $_in = 0; - - /** Bound byte streams */ - private $_mirrors = array(); - - /** - * Not used. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } - - /** - * Invoked immediately after the Message is sent. - * @param Swift_Events_SendEvent $evt - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $message->toByteStream($this); - } - - /** - * Invoked immediately following a command being sent. - * @param Swift_Events_ResponseEvent $evt - */ - public function commandSent(Swift_Events_CommandEvent $evt) - { - $command = $evt->getCommand(); - $this->_out += strlen($command); - } - - /** - * Invoked immediately following a response coming back. - * @param Swift_Events_ResponseEvent $evt - */ - public function responseReceived(Swift_Events_ResponseEvent $evt) - { - $response = $evt->getResponse(); - $this->_in += strlen($response); - } - - /** - * Called when a message is sent so that the outgoing counter can be increased. - * @param string $bytes - */ - public function write($bytes) - { - $this->_out += strlen($bytes); - foreach ($this->_mirrors as $stream) - { - $stream->write($bytes); - } - } - - /** - * Not used. - */ - public function commit() - { - } - - /** - * Attach $is to this stream. - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @param Swift_InputByteStream $is - */ - public function bind(Swift_InputByteStream $is) - { - $this->_mirrors[] = $is; - } - - /** - * Remove an already bound stream. - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - * - * @param Swift_InputByteStream $is - */ - public function unbind(Swift_InputByteStream $is) - { - foreach ($this->_mirrors as $k => $stream) - { - if ($is === $stream) - { - unset($this->_mirrors[$k]); - } - } - } - - /** - * Not used. - */ - public function flushBuffers() - { - foreach ($this->_mirrors as $stream) - { - $stream->flushBuffers(); - } - } - - /** - * Get the total number of bytes sent to the server. - * @return int - */ - public function getBytesOut() - { - return $this->_out; - } - - /** - * Get the total number of bytes received from the server. - * @return int - */ - public function getBytesIn() - { - return $this->_in; - } - - /** - * Reset the internal counters to zero. - */ - public function reset() - { - $this->_out = 0; - $this->_in = 0; - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php deleted file mode 100755 index 9735d0a..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Allows customization of Messages on-the-fly. - * - * @package Swift - * @subpackage Plugins - * - * @author Chris Corbyn - */ -interface Swift_Plugins_Decorator_Replacements -{ - - /** - * Return the array of replacements for $address. - * - * This method is invoked once for every single recipient of a message. - * - * If no replacements can be found, an empty value (NULL) should be returned - * and no replacements will then be made on the message. - * - * @param string $address - * - * @return array - */ - public function getReplacementsFor($address); - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php deleted file mode 100755 index da1a307..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php +++ /dev/null @@ -1,201 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Events/SendListener.php'; -//@require 'Swift/Events/SendEvent.php'; -//@require 'Swift/Plugins/Decorator/Replacements.php'; - -/** - * Allows customization of Messages on-the-fly. - * - * @package Swift - * @subpackage Plugins - * - * @author Chris Corbyn - */ -class Swift_Plugins_DecoratorPlugin - implements Swift_Events_SendListener, Swift_Plugins_Decorator_Replacements -{ - - /** The replacement map */ - private $_replacements; - - /** The body as it was before replacements */ - private $_orginalBody; - - /** The original subject of the message, before replacements */ - private $_originalSubject; - - /** Bodies of children before they are replaced */ - private $_originalChildBodies = array(); - - /** The Message that was last replaced */ - private $_lastMessage; - - /** - * Create a new DecoratorPlugin with $replacements. - * - * The $replacements can either be an associative array, or an implementation - * of {@link Swift_Plugins_Decorator_Replacements}. - * - * When using an array, it should be of the form: - * <code> - * $replacements = array( - * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"), - * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y") - * ) - * </code> - * - * When using an instance of {@link Swift_Plugins_Decorator_Replacements}, - * the object should return just the array of replacements for the address - * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}. - * - * @param mixed $replacements - */ - public function __construct($replacements) - { - if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) - { - $this->_replacements = (array) $replacements; - } - else - { - $this->_replacements = $replacements; - } - } - - /** - * Invoked immediately before the Message is sent. - * - * @param Swift_Events_SendEvent $evt - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $this->_restoreMessage($message); - $to = array_keys($message->getTo()); - $address = array_shift($to); - if ($replacements = $this->getReplacementsFor($address)) - { - $body = $message->getBody(); - $search = array_keys($replacements); - $replace = array_values($replacements); - $bodyReplaced = str_replace( - $search, $replace, $body - ); - if ($body != $bodyReplaced) - { - $this->_originalBody = $body; - $message->setBody($bodyReplaced); - } - $subject = $message->getSubject(); - $subjectReplaced = str_replace( - $search, $replace, $subject - ); - if ($subject != $subjectReplaced) - { - $this->_originalSubject = $subject; - $message->setSubject($subjectReplaced); - } - $children = (array) $message->getChildren(); - foreach ($children as $child) - { - list($type, ) = sscanf($child->getContentType(), '%[^/]/%s'); - if ('text' == $type) - { - $body = $child->getBody(); - $bodyReplaced = str_replace( - $search, $replace, $body - ); - if ($body != $bodyReplaced) - { - $child->setBody($bodyReplaced); - $this->_originalChildBodies[$child->getId()] = $body; - } - } - } - $this->_lastMessage = $message; - } - } - - /** - * Find a map of replacements for the address. - * - * If this plugin was provided with a delegate instance of - * {@link Swift_Plugins_Decorator_Replacements} then the call will be - * delegated to it. Otherwise, it will attempt to find the replacements - * from the array provided in the constructor. - * - * If no replacements can be found, an empty value (NULL) is returned. - * - * @param string $address - * - * @return array - */ - public function getReplacementsFor($address) - { - if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) - { - return $this->_replacements->getReplacementsFor($address); - } - else - { - return isset($this->_replacements[$address]) - ? $this->_replacements[$address] - : null - ; - } - } - - /** - * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $this->_restoreMessage($evt->getMessage()); - } - - // -- Private methods - - /** Restore a changed message back to its original state */ - private function _restoreMessage(Swift_Mime_Message $message) - { - if ($this->_lastMessage === $message) - { - if (isset($this->_originalBody)) - { - $message->setBody($this->_originalBody); - $this->_originalBody = null; - } - if (isset($this->_originalSubject)) - { - $message->setSubject($this->_originalSubject); - $this->_originalSubject = null; - } - if (!empty($this->_originalChildBodies)) - { - $children = (array) $message->getChildren(); - foreach ($children as $child) - { - $id = $child->getId(); - if (array_key_exists($id, $this->_originalChildBodies)) - { - $child->setBody($this->_originalChildBodies[$id]); - } - } - $this->_originalChildBodies = array(); - } - $this->_lastMessage = null; - } - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Logger.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Logger.php deleted file mode 100755 index 9864da0..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Logger.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Logs events in the Transport system. - * @package Swift - * @subpackage Transport - * @author Chris Corbyn - */ -interface Swift_Plugins_Logger -{ - - /** - * Add a log entry. - * @param string $entry - */ - public function add($entry); - - /** - * Clear the log contents. - */ - public function clear(); - - /** - * Get this log as a string. - * @return string - */ - public function dump(); - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php deleted file mode 100755 index d595f26..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php +++ /dev/null @@ -1,160 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Events/CommandListener.php'; -//@require 'Swift/Events/CommandEvent.php'; -//@require 'Swift/Events/ResponseListener.php'; -//@require 'Swift/Events/ResponseEvent.php'; -//@require 'Swift/Events/TransportChangeListener.php'; -//@require 'Swift/Events/TransportChangeEvent.php'; -//@require 'Swift/Events/TransportExceptionEvent.php'; -//@require 'Swift/Events/TransportExceptionListener.php'; -//@require 'Swift/Events/TransportException.php'; -//@require 'Swift/Plugins/Logger.php'; - -/** - * Does real time logging of Transport level information. - * - * @package Swift - * @subpackage Plugins - * - * @author Chris Corbyn - */ -class Swift_Plugins_LoggerPlugin - implements Swift_Events_CommandListener, Swift_Events_ResponseListener, - Swift_Events_TransportChangeListener, Swift_Events_TransportExceptionListener, - Swift_Plugins_Logger -{ - - /** The logger which is delegated to */ - private $_logger; - - /** - * Create a new LoggerPlugin using $logger. - * - * @param Swift_Plugins_Logger $logger - */ - public function __construct(Swift_Plugins_Logger $logger) - { - $this->_logger = $logger; - } - - /** - * Add a log entry. - * - * @param string $entry - */ - public function add($entry) - { - $this->_logger->add($entry); - } - - /** - * Clear the log contents. - */ - public function clear() - { - $this->_logger->clear(); - } - - /** - * Get this log as a string. - * - * @return string - */ - public function dump() - { - return $this->_logger->dump(); - } - - /** - * Invoked immediately following a command being sent. - * - * @param Swift_Events_ResponseEvent $evt - */ - public function commandSent(Swift_Events_CommandEvent $evt) - { - $command = $evt->getCommand(); - $this->_logger->add(sprintf(">> %s", $command)); - } - - /** - * Invoked immediately following a response coming back. - * - * @param Swift_Events_ResponseEvent $evt - */ - public function responseReceived(Swift_Events_ResponseEvent $evt) - { - $response = $evt->getResponse(); - $this->_logger->add(sprintf("<< %s", $response)); - } - - /** - * Invoked just before a Transport is started. - * - * @param Swift_Events_TransportChangeEvent $evt - */ - public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) - { - $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf("++ Starting %s", $transportName)); - } - - /** - * Invoked immediately after the Transport is started. - * - * @param Swift_Events_TransportChangeEvent $evt - */ - public function transportStarted(Swift_Events_TransportChangeEvent $evt) - { - $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf("++ %s started", $transportName)); - } - - /** - * Invoked just before a Transport is stopped. - * - * @param Swift_Events_TransportChangeEvent $evt - */ - public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) - { - $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf("++ Stopping %s", $transportName)); - } - - /** - * Invoked immediately after the Transport is stopped. - * - * @param Swift_Events_TransportChangeEvent $evt - */ - public function transportStopped(Swift_Events_TransportChangeEvent $evt) - { - $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf("++ %s stopped", $transportName)); - } - - /** - * Invoked as a TransportException is thrown in the Transport system. - * - * @param Swift_Events_TransportExceptionEvent $evt - */ - public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) - { - $e = $evt->getException(); - $message = $e->getMessage(); - $this->_logger->add(sprintf("!! %s", $message)); - $message .= PHP_EOL; - $message .= 'Log data:' . PHP_EOL; - $message .= $this->_logger->dump(); - $evt->cancelBubble(); - throw new Swift_TransportException($message); - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php deleted file mode 100755 index 930eca2..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Logs to an Array backend. - * @package Swift - * @subpackage Transport - * @author Chris Corbyn - */ -class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger -{ - - /** - * The log contents. - * @var array - * @access private - */ - private $_log = array(); - - /** - * Max size of the log. - * @var int - * @access private - */ - private $_size = 0; - - /** - * Create a new ArrayLogger with a maximum of $size entries. - * @var int $size - */ - public function __construct($size = 50) - { - $this->_size = $size; - } - - /** - * Add a log entry. - * @param string $entry - */ - public function add($entry) - { - $this->_log[] = $entry; - while (count($this->_log) > $this->_size) - { - array_shift($this->_log); - } - } - - /** - * Clear the log contents. - */ - public function clear() - { - $this->_log = array(); - } - - /** - * Get this log as a string. - * @return string - */ - public function dump() - { - return implode(PHP_EOL, $this->_log); - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php deleted file mode 100755 index 83dd54b..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Prints all log messages in real time. - * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn - */ -class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger -{ - - /** Whether or not HTML should be output */ - private $_isHtml; - - /** - * Create a new EchoLogger. - * - * @param boolean $isHtml - */ - public function __construct($isHtml = true) - { - $this->_isHtml = $isHtml; - } - - /** - * Add a log entry. - * @param string $entry - */ - public function add($entry) - { - if ($this->_isHtml) - { - printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '<br />', PHP_EOL); - } - else - { - printf('%s%s', $entry, PHP_EOL); - } - } - - /** - * Not implemented. - */ - public function clear() - { - } - - /** - * Not implemented. - */ - public function dump() - { - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php deleted file mode 100755 index 1c96dcf..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Pop3Connection interface for connecting and disconnecting to a POP3 host. - * - * @package Swift - * @subpackage Plugins - * - * @author Chris Corbyn - */ -interface Swift_Plugins_Pop_Pop3Connection -{ - - /** - * Connect to the POP3 host and throw an Exception if it fails. - * - * @throws Swift_Plugins_Pop_Pop3Exception - */ - public function connect(); - - /** - * Disconnect from the POP3 host and throw an Exception if it fails. - * - * @throws Swift_Plugins_Pop_Pop3Exception - */ - public function disconnect(); - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php deleted file mode 100755 index e0205f4..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/IoException.php'; - -/** - * Pop3Exception thrown when an error occurs connecting to a POP3 host. - * - * @package Swift - * @subpackage Transport - * - * @author Chris Corbyn - */ -class Swift_Plugins_Pop_Pop3Exception extends Swift_IoException -{ - - /** - * Create a new Pop3Exception with $message. - * - * @param string $message - */ - public function __construct($message) - { - parent::__construct($message); - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php deleted file mode 100755 index fd1cf46..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php +++ /dev/null @@ -1,288 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Events/TransportChangeListener.php'; -//@require 'Swift/Events/TransportChangeEvent.php'; - -/** - * Makes sure a connection to a POP3 host has been established prior to connecting to SMTP. - * - * @package Swift - * @subpackage Plugins - * - * @author Chris Corbyn - */ -class Swift_Plugins_PopBeforeSmtpPlugin - implements Swift_Events_TransportChangeListener, Swift_Plugins_Pop_Pop3Connection -{ - - /** A delegate connection to use (mostly a test hook) */ - private $_connection; - - /** Hostname of the POP3 server */ - private $_host; - - /** Port number to connect on */ - private $_port; - - /** Encryption type to use (if any) */ - private $_crypto; - - /** Username to use (if any) */ - private $_username; - - /** Password to use (if any) */ - private $_password; - - /** Established connection via TCP socket */ - private $_socket; - - /** Connect timeout in seconds */ - private $_timeout = 10; - - /** SMTP Transport to bind to */ - private $_transport; - - /** - * Create a new PopBeforeSmtpPlugin for $host and $port. - * - * @param string $host - * @param int $port - * @param string $cypto as "tls" or "ssl" - */ - public function __construct($host, $port = 110, $crypto = null) - { - $this->_host = $host; - $this->_port = $port; - $this->_crypto = $crypto; - } - - /** - * Create a new PopBeforeSmtpPlugin for $host and $port. - * - * @param string $host - * @param int $port - * @param string $cypto as "tls" or "ssl" - * - * @return Swift_Plugins_PopBeforeSmtpPlugin - */ - public static function newInstance($host, $port = 110, $crypto = null) - { - return new self($host, $port, $crypto); - } - - /** - * Set a Pop3Connection to delegate to instead of connecting directly. - * - * @param Swift_Plugins_Pop_Pop3Connection $connection - */ - public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) - { - $this->_connection = $connection; - return $this; - } - - /** - * Bind this plugin to a specific SMTP transport instance. - * - * @param Swift_Transport - */ - public function bindSmtp(Swift_Transport $smtp) - { - $this->_transport = $smtp; - } - - /** - * Set the connection timeout in seconds (default 10). - * - * @param int $timeout - */ - public function setTimeout($timeout) - { - $this->_timeout = (int) $timeout; - return $this; - } - - /** - * Set the username to use when connecting (if needed). - * - * @param string $username - */ - public function setUsername($username) - { - $this->_username = $username; - return $this; - } - - /** - * Set the password to use when connecting (if needed). - * - * @param string $password - */ - public function setPassword($password) - { - $this->_password = $password; - return $this; - } - - /** - * Connect to the POP3 host and authenticate. - * - * @throws Swift_Plugins_Pop_Pop3Exception if connection fails - */ - public function connect() - { - if (isset($this->_connection)) - { - $this->_connection->connect(); - } - else - { - if (!isset($this->_socket)) - { - if (!$socket = fsockopen( - $this->_getHostString(), $this->_port, $errno, $errstr, $this->_timeout)) - { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to connect to POP3 host [%s]: %s', $this->_host, $errstr) - ); - } - $this->_socket = $socket; - - if (false === $greeting = fgets($this->_socket)) - { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to connect to POP3 host [%s]', trim($greeting)) - ); - } - - $this->_assertOk($greeting); - - if ($this->_username) - { - $this->_command(sprintf("USER %s\r\n", $this->_username)); - $this->_command(sprintf("PASS %s\r\n", $this->_password)); - } - } - } - } - - /** - * Disconnect from the POP3 host. - */ - public function disconnect() - { - if (isset($this->_connection)) - { - $this->_connection->disconnect(); - } - else - { - $this->_command("QUIT\r\n"); - if (!fclose($this->_socket)) - { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('POP3 host [%s] connection could not be stopped', $this->_host) - ); - } - $this->_socket = null; - } - } - - /** - * Invoked just before a Transport is started. - * - * @param Swift_Events_TransportChangeEvent $evt - */ - public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) - { - if (isset($this->_transport)) - { - if ($this->_transport !== $evt->getTransport()) - { - return; - } - } - - $this->connect(); - $this->disconnect(); - } - - /** - * Not used. - */ - public function transportStarted(Swift_Events_TransportChangeEvent $evt) - { - } - - /** - * Not used. - */ - public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) - { - } - - /** - * Not used. - */ - public function transportStopped(Swift_Events_TransportChangeEvent $evt) - { - } - - // -- Private Methods - - private function _command($command) - { - if (!fwrite($this->_socket, $command)) - { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to write command [%s] to POP3 host', trim($command)) - ); - } - - if (false === $response = fgets($this->_socket)) - { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to read from POP3 host after command [%s]', trim($command)) - ); - } - - $this->_assertOk($response); - - return $response; - } - - private function _assertOk($response) - { - if (substr($response, 0, 3) != '+OK') - { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('POP3 command failed [%s]', trim($response)) - ); - } - } - - private function _getHostString() - { - $host = $this->_host; - switch (strtolower($this->_crypto)) - { - case 'ssl': - $host = 'ssl://' . $host; - break; - - case 'tls': - $host = 'tls://' . $host; - break; - } - return $host; - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporter.php deleted file mode 100755 index 00d5765..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporter.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Mime/Message.php'; - -/** - * The Reporter plugin sends pass/fail notification to a Reporter. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -interface Swift_Plugins_Reporter -{ - - /** The recipient was accepted for delivery */ - const RESULT_PASS = 0x01; - - /** The recipient could not be accepted */ - const RESULT_FAIL = 0x10; - - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * @param Swift_Mime_Message $message - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_Message $message, $address, $result); - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php deleted file mode 100755 index 1beac5b..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Events/SendListener.php'; -//@require 'Swift/Events/SendEvent.php'; -//@require 'Swift/Plugins/Reporter.php'; - -/** - * Does real time reporting of pass/fail for each recipient. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -class Swift_Plugins_ReporterPlugin - implements Swift_Events_SendListener -{ - - /** - * The reporter backend which takes notifications. - * @var Swift_Plugin_Reporter - * @access private - */ - private $_reporter; - - /** - * Create a new ReporterPlugin using $reporter. - * @param Swift_Plugins_Reporter $reporter - */ - public function __construct(Swift_Plugins_Reporter $reporter) - { - $this->_reporter = $reporter; - } - - /** - * Not used. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } - - /** - * Invoked immediately after the Message is sent. - * @param Swift_Events_SendEvent $evt - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $failures = array_flip($evt->getFailedRecipients()); - foreach ((array) $message->getTo() as $address => $null) - { - $this->_reporter->notify( - $message, $address, (array_key_exists($address, $failures) - ? Swift_Plugins_Reporter::RESULT_FAIL - : Swift_Plugins_Reporter::RESULT_PASS) - ); - } - foreach ((array) $message->getCc() as $address => $null) - { - $this->_reporter->notify( - $message, $address, (array_key_exists($address, $failures) - ? Swift_Plugins_Reporter::RESULT_FAIL - : Swift_Plugins_Reporter::RESULT_PASS) - ); - } - foreach ((array) $message->getBcc() as $address => $null) - { - $this->_reporter->notify( - $message, $address, (array_key_exists($address, $failures) - ? Swift_Plugins_Reporter::RESULT_FAIL - : Swift_Plugins_Reporter::RESULT_PASS) - ); - } - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php deleted file mode 100755 index 0022f5e..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Plugins/Reporter.php'; -//@require 'Swift/Mime/Message.php'; - -/** - * A reporter which "collects" failures for the Reporter plugin. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter -{ - - /** - * The list of failures. - * @var array - * @access private - */ - private $_failures = array(); - private $_failures_cache = array(); - - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * @param Swift_Mime_Message $message - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_Message $message, $address, $result) - { - if (self::RESULT_FAIL == $result && !isset($this->_failures_cache[$address])) - { - $this->_failures[] = $address; - $this->_failures_cache[$address] = true; - } - } - - /** - * Get an array of addresses for which delivery failed. - * @return array - */ - public function getFailedRecipients() - { - return $this->_failures; - } - - /** - * Clear the buffer (empty the list). - */ - public function clear() - { - $this->_failures = $this->_failures_cache = array(); - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php deleted file mode 100755 index 7370078..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Plugins/Reporter.php'; -//@require 'Swift/Mime/Message.php'; - -/** - * A HTML output reporter for the Reporter plugin. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter -{ - - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * @param Swift_Mime_Message $message - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_Message $message, $address, $result) - { - if (self::RESULT_PASS == $result) - { - echo "<div style=\"color: #fff; background: #006600; padding: 2px; margin: 2px;\">" . PHP_EOL; - echo "PASS " . $address . PHP_EOL; - echo "</div>" . PHP_EOL; - flush(); - } - else - { - echo "<div style=\"color: #fff; background: #880000; padding: 2px; margin: 2px;\">" . PHP_EOL; - echo "FAIL " . $address . PHP_EOL; - echo "</div>" . PHP_EOL; - flush(); - } - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php deleted file mode 100755 index 148cbd3..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Sleeps for a duration of time. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -interface Swift_Plugins_Sleeper -{ - - /** - * Sleep for $seconds. - * @param int $seconds - */ - public function sleep($seconds); - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php deleted file mode 100755 index 43bb1f4..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php +++ /dev/null @@ -1,188 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -//@require 'Swift/Events/SendEvent.php'; -//@require 'Swift/Plugins/BandwidthMonitorPlugin.php'; -//@require 'Swift/Plugins/Sleeper.php'; -//@require 'Swift/Plugins/Timer.php'; - -/** - * Throttles the rate at which emails are sent. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -class Swift_Plugins_ThrottlerPlugin - extends Swift_Plugins_BandwidthMonitorPlugin - implements Swift_Plugins_Sleeper, Swift_Plugins_Timer -{ - - /** Flag for throttling in bytes per minute */ - const BYTES_PER_MINUTE = 0x01; - - /** Flag for throttling in emails per minute */ - const MESSAGES_PER_MINUTE = 0x10; - - /** - * The Sleeper instance for sleeping. - * @var Swift_Plugins_Sleeper - * @access private - */ - private $_sleeper; - - /** - * The Timer instance which provides the timestamp. - * @var Swift_Plugins_Timer - * @access private - */ - private $_timer; - - /** - * The time at which the first email was sent. - * @var int - * @access private - */ - private $_start; - - /** - * The rate at which messages should be sent. - * @var int - * @access private - */ - private $_rate; - - /** - * The mode for throttling. - * This is {@link BYTES_PER_MINUTE} or {@link MESSAGES_PER_MINUTE} - * @var int - * @access private - */ - private $_mode; - - /** - * An internal counter of the number of messages sent. - * @var int - * @access private - */ - private $_messages = 0; - - /** - * Create a new ThrottlerPlugin. - * @param int $rate - * @param int $mode, defaults to {@link BYTES_PER_MINUTE} - * @param Swift_Plugins_Sleeper $sleeper (only needed in testing) - * @param Swift_Plugins_Timer $timer (only needed in testing) - */ - public function __construct($rate, $mode = self::BYTES_PER_MINUTE, - Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null) - { - $this->_rate = $rate; - $this->_mode = $mode; - $this->_sleeper = $sleeper; - $this->_timer = $timer; - } - - /** - * Invoked immediately before the Message is sent. - * @param Swift_Events_SendEvent $evt - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $time = $this->getTimestamp(); - if (!isset($this->_start)) - { - $this->_start = $time; - } - $duration = $time - $this->_start; - - if (self::BYTES_PER_MINUTE == $this->_mode) - { - $sleep = $this->_throttleBytesPerMinute($duration); - } - else - { - $sleep = $this->_throttleMessagesPerMinute($duration); - } - - if ($sleep > 0) - { - $this->sleep($sleep); - } - } - - /** - * Invoked when a Message is sent. - * @param Swift_Events_SendEvent $evt - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - parent::sendPerformed($evt); - ++$this->_messages; - } - - /** - * Sleep for $seconds. - * @param int $seconds - */ - public function sleep($seconds) - { - if (isset($this->_sleeper)) - { - $this->_sleeper->sleep($seconds); - } - else - { - sleep($seconds); - } - } - - /** - * Get the current UNIX timestamp - * @return int - */ - public function getTimestamp() - { - if (isset($this->_timer)) - { - return $this->_timer->getTimestamp(); - } - else - { - return time(); - } - } - - // -- Private methods - - /** - * Get a number of seconds to sleep for. - * @param int $timePassed - * @return int - * @access private - */ - private function _throttleBytesPerMinute($timePassed) - { - $expectedDuration = $this->getBytesOut() / ($this->_rate / 60); - return (int) ceil($expectedDuration - $timePassed); - } - - /** - * Get a number of seconds to sleep for. - * @param int $timePassed - * @return int - * @access private - */ - private function _throttleMessagesPerMinute($timePassed) - { - $expectedDuration = $this->_messages / ($this->_rate / 60); - return (int) ceil($expectedDuration - $timePassed); - } - -} diff --git a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Timer.php b/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Timer.php deleted file mode 100755 index 92207bf..0000000 --- a/h-source/External/swiftmailer/lib/classes/Swift/Plugins/Timer.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -/* - * This file is part of SwiftMailer. - * (c) 2004-2009 Chris Corbyn - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Provides timestamp data. - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - */ -interface Swift_Plugins_Timer -{ - - /** - * Get the current UNIX timestamp. - * @return int - */ - public function getTimestamp(); - -} |