+ */
+
+Class Swift_CharacterStream_NgCharacterStream
+ implements Swift_CharacterStream
+{
+
+ /**
+ * The char reader (lazy-loaded) for the current charset.
+ * @var Swift_CharacterReader
+ * @access private
+ */
+ private $_charReader;
+
+ /**
+ * A factory for creatiing CharacterReader instances.
+ * @var Swift_CharacterReaderFactory
+ * @access private
+ */
+ private $_charReaderFactory;
+
+ /**
+ * The character set this stream is using.
+ * @var string
+ * @access private
+ */
+ private $_charset;
+
+ /**
+ * The datas stored as is
+ *
+ * @var string
+ */
+ private $_datas = "";
+
+ /**
+ * Number of bytes in the stream
+ *
+ * @var int
+ */
+ private $_datasSize = 0;
+
+ /**
+ * Map
+ *
+ * @var mixed
+ */
+ private $_map;
+
+ /**
+ * Map Type
+ *
+ * @var int
+ */
+ private $_mapType = 0;
+
+ /**
+ * Number of characters in the stream
+ *
+ * @var int
+ */
+ private $_charCount = 0;
+
+ /**
+ * Position in the stream
+ *
+ * @var unknown_type
+ */
+ private $_currentPos = 0;
+
+ /**
+ * The constructor
+ *
+ * @param Swift_CharacterReaderFactory $factory
+ * @param unknown_type $charset
+ */
+ public function __construct(Swift_CharacterReaderFactory $factory,
+ $charset)
+ {
+ $this->setCharacterReaderFactory($factory);
+ $this->setCharacterSet($charset);
+ }
+
+ /* -- Changing parameters of the stream -- */
+
+ /**
+ * Set the character set used in this CharacterStream.
+ * @param string $charset
+ */
+ public function setCharacterSet($charset)
+ {
+ $this->_charset = $charset;
+ $this->_charReader = null;
+ $this->_mapType = 0;
+ }
+
+ /**
+ * Set the CharacterReaderFactory for multi charset support.
+ * @param Swift_CharacterReaderFactory $factory
+ */
+ public function setCharacterReaderFactory(
+ Swift_CharacterReaderFactory $factory)
+ {
+ $this->_charReaderFactory = $factory;
+ }
+
+ /**
+ * @see Swift_CharacterStream::flushContents()
+ *
+ */
+ public function flushContents()
+ {
+ $this->_datas = null;
+ $this->_map = null;
+ $this->_charCount = 0;
+ $this->_currentPos = 0;
+ $this->_datasSize = 0;
+ }
+
+ /**
+ * @see Swift_CharacterStream::importByteStream()
+ *
+ * @param Swift_OutputByteStream $os
+ */
+ public function importByteStream(Swift_OutputByteStream $os)
+ {
+ $this->flushContents();
+ $blocks=512;
+ $os->setReadPointer(0);
+ while(false!==($read = $os->read($blocks)))
+ $this->write($read);
+ }
+
+ /**
+ * @see Swift_CharacterStream::importString()
+ *
+ * @param string $string
+ */
+ public function importString($string)
+ {
+ $this->flushContents();
+ $this->write($string);
+ }
+
+ /**
+ * @see Swift_CharacterStream::read()
+ *
+ * @param int $length
+ * @return string
+ */
+ public function read($length)
+ {
+ if ($this->_currentPos>=$this->_charCount)
+ {
+ return false;
+ }
+ $ret=false;
+ $length = ($this->_currentPos+$length > $this->_charCount)
+ ? $this->_charCount - $this->_currentPos
+ : $length;
+ switch ($this->_mapType)
+ {
+ case Swift_CharacterReader::MAP_TYPE_FIXED_LEN:
+ $len = $length*$this->_map;
+ $ret = substr($this->_datas,
+ $this->_currentPos * $this->_map,
+ $len);
+ $this->_currentPos += $length;
+ break;
+
+ case Swift_CharacterReader::MAP_TYPE_INVALID:
+ $end = $this->_currentPos + $length;
+ $end = $end > $this->_charCount
+ ?$this->_charCount
+ :$end;
+ $ret = '';
+ for (; $this->_currentPos < $length; ++$this->_currentPos)
+ {
+ if (isset ($this->_map[$this->_currentPos]))
+ {
+ $ret .= '?';
+ }
+ else
+ {
+ $ret .= $this->_datas[$this->_currentPos];
+ }
+ }
+ break;
+
+ case Swift_CharacterReader::MAP_TYPE_POSITIONS:
+ $end = $this->_currentPos + $length;
+ $end = $end > $this->_charCount
+ ?$this->_charCount
+ :$end;
+ $ret = '';
+ $start = 0;
+ if ($this->_currentPos>0)
+ {
+ $start = $this->_map['p'][$this->_currentPos-1];
+ }
+ $to = $start;
+ for (; $this->_currentPos < $end; ++$this->_currentPos)
+ {
+ if (isset($this->_map['i'][$this->_currentPos])) {
+ $ret .= substr($this->_datas, $start, $to - $start).'?';
+ $start = $this->_map['p'][$this->_currentPos];
+ } else {
+ $to = $this->_map['p'][$this->_currentPos];
+ }
+ }
+ $ret .= substr($this->_datas, $start, $to - $start);
+ break;
+ }
+ return $ret;
+ }
+
+ /**
+ * @see Swift_CharacterStream::readBytes()
+ *
+ * @param int $length
+ * @return int[]
+ */
+ public function readBytes($length)
+ {
+ $read=$this->read($length);
+ if ($read!==false)
+ {
+ $ret = array_map('ord', str_split($read, 1));
+ return $ret;
+ }
+ return false;
+ }
+
+ /**
+ * @see Swift_CharacterStream::setPointer()
+ *
+ * @param int $charOffset
+ */
+ public function setPointer($charOffset)
+ {
+ if ($this->_charCount<$charOffset){
+ $charOffset=$this->_charCount;
+ }
+ $this->_currentPos = $charOffset;
+ }
+
+ /**
+ * @see Swift_CharacterStream::write()
+ *
+ * @param string $chars
+ */
+ public function write($chars)
+ {
+ if (!isset($this->_charReader))
+ {
+ $this->_charReader = $this->_charReaderFactory->getReaderFor(
+ $this->_charset);
+ $this->_map = array();
+ $this->_mapType = $this->_charReader->getMapType();
+ }
+ $ignored='';
+ $this->_datas .= $chars;
+ $this->_charCount += $this->_charReader->getCharPositions(substr($this->_datas, $this->_datasSize), $this->_datasSize, $this->_map, $ignored);
+ if ($ignored!==false) {
+ $this->_datasSize=strlen($this->_datas)-strlen($ignored);
+ }
+ else
+ {
+ $this->_datasSize=strlen($this->_datas);
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/khemail/vendor/swift/classes/Swift/DependencyContainer.php b/modules/khemail/vendor/swift/classes/Swift/DependencyContainer.php
new file mode 100644
index 0000000..b6ba554
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/DependencyContainer.php
@@ -0,0 +1,349 @@
+_store);
+ }
+
+ /**
+ * Test if an item is registered in this container with the given name.
+ * @param string $itemName
+ * @return boolean
+ * @see register()
+ */
+ public function has($itemName)
+ {
+ return array_key_exists($itemName, $this->_store)
+ && isset($this->_store[$itemName]['lookupType']);
+ }
+
+ /**
+ * Lookup the item with the given $itemName.
+ * @param string $itemName
+ * @return mixed
+ * @throws Swift_DependencyException If the dependency is not found
+ * @see register()
+ */
+ public function lookup($itemName)
+ {
+ if (!$this->has($itemName))
+ {
+ throw new Swift_DependencyException(
+ 'Cannot lookup dependency "' . $itemName . '" since it is not registered.'
+ );
+ }
+
+ switch ($this->_store[$itemName]['lookupType'])
+ {
+ case self::TYPE_ALIAS:
+ return $this->_createAlias($itemName);
+ case self::TYPE_VALUE:
+ return $this->_getValue($itemName);
+ case self::TYPE_INSTANCE:
+ return $this->_createNewInstance($itemName);
+ case self::TYPE_SHARED:
+ return $this->_createSharedInstance($itemName);
+ }
+ }
+
+ /**
+ * Create an array of arguments passed to the constructor of $itemName.
+ * @param string $itemName
+ * @return array
+ */
+ public function createDependenciesFor($itemName)
+ {
+ $args = array();
+ if (isset($this->_store[$itemName]['args']))
+ {
+ $args = $this->_resolveArgs($this->_store[$itemName]['args']);
+ }
+ return $args;
+ }
+
+ /**
+ * Register a new dependency with $itemName.
+ * This method returns the current DependencyContainer instance because it
+ * requires the use of the fluid interface to set the specific details for the
+ * dependency.
+ *
+ * @param string $itemName
+ * @return Swift_DependencyContainer
+ * @see asNewInstanceOf(), asSharedInstanceOf(), asValue()
+ */
+ public function register($itemName)
+ {
+ $this->_store[$itemName] = array();
+ $this->_endPoint =& $this->_store[$itemName];
+ return $this;
+ }
+
+ /**
+ * Specify the previously registered item as a literal value.
+ * {@link register()} must be called before this will work.
+ *
+ * @param mixed $value
+ * @return Swift_DependencyContainer
+ */
+ public function asValue($value)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['lookupType'] = self::TYPE_VALUE;
+ $endPoint['value'] = $value;
+ return $this;
+ }
+
+ /**
+ * Specify the previously registered item as an alias of another item.
+ * @param string $lookup
+ * @return Swift_DependencyContainer
+ */
+ public function asAliasOf($lookup)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['lookupType'] = self::TYPE_ALIAS;
+ $endPoint['ref'] = $lookup;
+ return $this;
+ }
+
+ /**
+ * Specify the previously registered item as a new instance of $className.
+ * {@link register()} must be called before this will work.
+ * Any arguments can be set with {@link withDependencies()},
+ * {@link addConstructorValue()} or {@link addConstructorLookup()}.
+ *
+ * @param string $className
+ * @return Swift_DependencyContainer
+ * @see withDependencies(), addConstructorValue(), addConstructorLookup()
+ */
+ public function asNewInstanceOf($className)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['lookupType'] = self::TYPE_INSTANCE;
+ $endPoint['className'] = $className;
+ return $this;
+ }
+
+ /**
+ * Specify the previously registered item as a shared instance of $className.
+ * {@link register()} must be called before this will work.
+ * @param string $className
+ * @return Swift_DependencyContainer
+ */
+ public function asSharedInstanceOf($className)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['lookupType'] = self::TYPE_SHARED;
+ $endPoint['className'] = $className;
+ return $this;
+ }
+
+ /**
+ * Specify a list of injected dependencies for the previously registered item.
+ * This method takes an array of lookup names.
+ *
+ * @param array $lookups
+ * @return Swift_DependencyContainer
+ * @see addConstructorValue(), addConstructorLookup()
+ */
+ public function withDependencies(array $lookups)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['args'] = array();
+ foreach ($lookups as $lookup)
+ {
+ $this->addConstructorLookup($lookup);
+ }
+ return $this;
+ }
+
+ /**
+ * Specify a literal (non looked up) value for the constructor of the
+ * previously registered item.
+ *
+ * @param mixed $value
+ * @return Swift_DependencyContainer
+ * @see withDependencies(), addConstructorLookup()
+ */
+ public function addConstructorValue($value)
+ {
+ $endPoint =& $this->_getEndPoint();
+ if (!isset($endPoint['args']))
+ {
+ $endPoint['args'] = array();
+ }
+ $endPoint['args'][] = array('type' => 'value', 'item' => $value);
+ return $this;
+ }
+
+ /**
+ * Specify a dependency lookup for the constructor of the previously
+ * registered item.
+ *
+ * @param string $lookup
+ * @return Swift_DependencyContainer
+ * @see withDependencies(), addConstructorValue()
+ */
+ public function addConstructorLookup($lookup)
+ {
+ $endPoint =& $this->_getEndPoint();
+ if (!isset($this->_endPoint['args']))
+ {
+ $endPoint['args'] = array();
+ }
+ $endPoint['args'][] = array('type' => 'lookup', 'item' => $lookup);
+ return $this;
+ }
+
+ // -- Private methods
+
+ /** Get the literal value with $itemName */
+ private function _getValue($itemName)
+ {
+ return $this->_store[$itemName]['value'];
+ }
+
+ /** Resolve an alias to another item */
+ private function _createAlias($itemName)
+ {
+ return $this->lookup($this->_store[$itemName]['ref']);
+ }
+
+ /** Create a fresh instance of $itemName */
+ private function _createNewInstance($itemName)
+ {
+ $reflector = new ReflectionClass($this->_store[$itemName]['className']);
+ if ($reflector->getConstructor())
+ {
+ return $reflector->newInstanceArgs(
+ $this->createDependenciesFor($itemName)
+ );
+ }
+ else
+ {
+ return $reflector->newInstance();
+ }
+ }
+
+ /** Create and register a shared instance of $itemName */
+ private function _createSharedInstance($itemName)
+ {
+ if (!isset($this->_store[$itemName]['instance']))
+ {
+ $this->_store[$itemName]['instance'] = $this->_createNewInstance($itemName);
+ }
+ return $this->_store[$itemName]['instance'];
+ }
+
+ /** Get the current endpoint in the store */
+ private function &_getEndPoint()
+ {
+ if (!isset($this->_endPoint))
+ {
+ throw new BadMethodCallException(
+ 'Component must first be registered by calling register()'
+ );
+ }
+ return $this->_endPoint;
+ }
+
+ /** Get an argument list with dependencies resolved */
+ private function _resolveArgs(array $args)
+ {
+ $resolved = array();
+ foreach ($args as $argDefinition)
+ {
+ switch ($argDefinition['type'])
+ {
+ case 'lookup':
+ $resolved[] = $this->_lookupRecursive($argDefinition['item']);
+ break;
+ case 'value':
+ $resolved[] = $argDefinition['item'];
+ break;
+ }
+ }
+ return $resolved;
+ }
+
+ /** Resolve a single dependency with an collections */
+ private function _lookupRecursive($item)
+ {
+ if (is_array($item))
+ {
+ $collection = array();
+ foreach ($item as $k => $v)
+ {
+ $collection[$k] = $this->_lookupRecursive($v);
+ }
+ return $collection;
+ }
+ else
+ {
+ return $this->lookup($item);
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/DependencyException.php b/modules/khemail/vendor/swift/classes/Swift/DependencyException.php
new file mode 100644
index 0000000..bb1681c
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/DependencyException.php
@@ -0,0 +1,30 @@
+createDependenciesFor('mime.embeddedfile')
+ );
+
+ $this->setBody($data);
+ $this->setFilename($filename);
+ if ($contentType)
+ {
+ $this->setContentType($contentType);
+ }
+ }
+
+ /**
+ * Create a new EmbeddedFile.
+ * @param string|Swift_OutputByteStream $data
+ * @param string $filename
+ * @param string $contentType
+ * @return Swift_Mime_EmbeddedFile
+ */
+ public static function newInstance($data = null, $filename = null,
+ $contentType = null)
+ {
+ return new self($data, $filename, $contentType);
+ }
+
+ /**
+ * Create a new EmbeddedFile from a filesystem path.
+ * @param string $path
+ * @return Swift_Mime_EmbeddedFile
+ */
+ public static function fromPath($path)
+ {
+ return self::newInstance()->setFile(
+ new Swift_ByteStream_FileByteStream($path)
+ );
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Encoder.php b/modules/khemail/vendor/swift/classes/Swift/Encoder.php
new file mode 100644
index 0000000..32aa96a
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Encoder.php
@@ -0,0 +1,32 @@
+= $maxLineLength || 76 < $maxLineLength)
+ {
+ $maxLineLength = 76;
+ }
+
+ $encodedString = base64_encode($string);
+ $firstLine = '';
+
+ if (0 != $firstLineOffset)
+ {
+ $firstLine = substr(
+ $encodedString, 0, $maxLineLength - $firstLineOffset
+ ) . "\r\n";
+ $encodedString = substr(
+ $encodedString, $maxLineLength - $firstLineOffset
+ );
+ }
+
+ return $firstLine . trim(chunk_split($encodedString, $maxLineLength, "\r\n"));
+ }
+
+ /**
+ * Does nothing.
+ */
+ public function charsetChanged($charset)
+ {
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Encoder/QpEncoder.php b/modules/khemail/vendor/swift/classes/Swift/Encoder/QpEncoder.php
new file mode 100644
index 0000000..6914f6c
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Encoder/QpEncoder.php
@@ -0,0 +1,263 @@
+ '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04',
+ 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09',
+ 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E',
+ 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13',
+ 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18',
+ 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D',
+ 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22',
+ 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27',
+ 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C',
+ 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31',
+ 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36',
+ 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B',
+ 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40',
+ 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45',
+ 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A',
+ 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F',
+ 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54',
+ 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59',
+ 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E',
+ 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63',
+ 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68',
+ 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D',
+ 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72',
+ 115 => '=73', 116 => '=74', 117 => '=75', 118 => '=76', 119 => '=77',
+ 120 => '=78', 121 => '=79', 122 => '=7A', 123 => '=7B', 124 => '=7C',
+ 125 => '=7D', 126 => '=7E', 127 => '=7F', 128 => '=80', 129 => '=81',
+ 130 => '=82', 131 => '=83', 132 => '=84', 133 => '=85', 134 => '=86',
+ 135 => '=87', 136 => '=88', 137 => '=89', 138 => '=8A', 139 => '=8B',
+ 140 => '=8C', 141 => '=8D', 142 => '=8E', 143 => '=8F', 144 => '=90',
+ 145 => '=91', 146 => '=92', 147 => '=93', 148 => '=94', 149 => '=95',
+ 150 => '=96', 151 => '=97', 152 => '=98', 153 => '=99', 154 => '=9A',
+ 155 => '=9B', 156 => '=9C', 157 => '=9D', 158 => '=9E', 159 => '=9F',
+ 160 => '=A0', 161 => '=A1', 162 => '=A2', 163 => '=A3', 164 => '=A4',
+ 165 => '=A5', 166 => '=A6', 167 => '=A7', 168 => '=A8', 169 => '=A9',
+ 170 => '=AA', 171 => '=AB', 172 => '=AC', 173 => '=AD', 174 => '=AE',
+ 175 => '=AF', 176 => '=B0', 177 => '=B1', 178 => '=B2', 179 => '=B3',
+ 180 => '=B4', 181 => '=B5', 182 => '=B6', 183 => '=B7', 184 => '=B8',
+ 185 => '=B9', 186 => '=BA', 187 => '=BB', 188 => '=BC', 189 => '=BD',
+ 190 => '=BE', 191 => '=BF', 192 => '=C0', 193 => '=C1', 194 => '=C2',
+ 195 => '=C3', 196 => '=C4', 197 => '=C5', 198 => '=C6', 199 => '=C7',
+ 200 => '=C8', 201 => '=C9', 202 => '=CA', 203 => '=CB', 204 => '=CC',
+ 205 => '=CD', 206 => '=CE', 207 => '=CF', 208 => '=D0', 209 => '=D1',
+ 210 => '=D2', 211 => '=D3', 212 => '=D4', 213 => '=D5', 214 => '=D6',
+ 215 => '=D7', 216 => '=D8', 217 => '=D9', 218 => '=DA', 219 => '=DB',
+ 220 => '=DC', 221 => '=DD', 222 => '=DE', 223 => '=DF', 224 => '=E0',
+ 225 => '=E1', 226 => '=E2', 227 => '=E3', 228 => '=E4', 229 => '=E5',
+ 230 => '=E6', 231 => '=E7', 232 => '=E8', 233 => '=E9', 234 => '=EA',
+ 235 => '=EB', 236 => '=EC', 237 => '=ED', 238 => '=EE', 239 => '=EF',
+ 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4',
+ 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9',
+ 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE',
+ 255 => '=FF'
+ );
+
+ /**
+ * A map of non-encoded ascii characters.
+ * @var string[]
+ * @access protected
+ */
+ protected static $_safeMap = array();
+
+ /**
+ * Creates a new QpEncoder for the given CharacterStream.
+ * @param Swift_CharacterStream $charStream to use for reading characters
+ * @param Swift_StreamFilter $filter if input should be canonicalized
+ */
+ public function __construct(Swift_CharacterStream $charStream,
+ Swift_StreamFilter $filter = null)
+ {
+ $this->_charStream = $charStream;
+ if (empty(self::$_safeMap))
+ {
+ foreach (array_merge(
+ array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte)
+ {
+ self::$_safeMap[$byte] = chr($byte);
+ }
+ }
+ $this->_filter = $filter;
+ }
+
+ /**
+ * Takes an unencoded string and produces a QP encoded string from it.
+ * QP encoded strings have a maximum line length of 76 characters.
+ * If the first line needs to be shorter, indicate the difference with
+ * $firstLineOffset.
+ * @param string $string to encode
+ * @param int $firstLineOffset, optional
+ * @param int $maxLineLength, optional, 0 indicates the default of 76 chars
+ * @return string
+ */
+ public function encodeString($string, $firstLineOffset = 0,
+ $maxLineLength = 0)
+ {
+ if ($maxLineLength > 76 || $maxLineLength <= 0)
+ {
+ $maxLineLength = 76;
+ }
+
+ $thisLineLength = $maxLineLength - $firstLineOffset;
+
+ $lines = array();
+ $lNo = 0;
+ $lines[$lNo] = '';
+ $currentLine =& $lines[$lNo++];
+ $size=$lineLen=0;
+
+ $this->_charStream->flushContents();
+ $this->_charStream->importString($string);
+
+ //Fetching more than 4 chars at one is slower, as is fetching fewer bytes
+ // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6
+ // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes
+ while (false !== $bytes = $this->_nextSequence())
+ {
+ //If we're filtering the input
+ if (isset($this->_filter))
+ {
+ //If we can't filter because we need more bytes
+ while ($this->_filter->shouldBuffer($bytes))
+ {
+ //Then collect bytes into the buffer
+ if (false === $moreBytes = $this->_nextSequence(1))
+ {
+ break;
+ }
+
+ foreach ($moreBytes as $b)
+ {
+ $bytes[] = $b;
+ }
+ }
+ //And filter them
+ $bytes = $this->_filter->filter($bytes);
+ }
+
+ $enc = $this->_encodeByteSequence($bytes, $size);
+ if ($currentLine && $lineLen+$size >= $thisLineLength)
+ {
+ $lines[$lNo] = '';
+ $currentLine =& $lines[$lNo++];
+ $thisLineLength = $maxLineLength;
+ $lineLen=0;
+ }
+ $lineLen+=$size;
+ $currentLine .= $enc;
+ }
+
+ return $this->_standardize(implode("=\r\n", $lines));
+ }
+
+ /**
+ * Updates the charset used.
+ * @param string $charset
+ */
+ public function charsetChanged($charset)
+ {
+ $this->_charStream->setCharacterSet($charset);
+ }
+
+ // -- Protected methods
+
+ /**
+ * Encode the given byte array into a verbatim QP form.
+ * @param int[] $bytes
+ * @return string
+ * @access protected
+ */
+ protected function _encodeByteSequence(array $bytes, &$size)
+ {
+ $ret = '';
+ $size=0;
+ foreach ($bytes as $b)
+ {
+ if (isset(self::$_safeMap[$b]))
+ {
+ $ret .= self::$_safeMap[$b];
+ ++$size;
+ }
+ else
+ {
+ $ret .= self::$_qpMap[$b];
+ $size+=3;
+ }
+ }
+ return $ret;
+ }
+
+ /**
+ * Get the next sequence of bytes to read from the char stream.
+ * @param int $size number of bytes to read
+ * @return int[]
+ * @access protected
+ */
+ protected function _nextSequence($size = 4)
+ {
+ return $this->_charStream->readBytes($size);
+ }
+
+ /**
+ * Make sure CRLF is correct and HT/SPACE are in valid places.
+ * @param string $string
+ * @return string
+ * @access protected
+ */
+ protected function _standardize($string)
+ {
+ $string = str_replace(array("\t=0D=0A", " =0D=0A", "=0D=0A"),
+ array("=09\r\n", "=20\r\n", "\r\n"), $string
+ );
+ switch ($end = ord(substr($string, -1)))
+ {
+ case 0x09:
+ case 0x20:
+ $string = substr_replace($string, self::$_qpMap[$end], -1);
+ }
+ return $string;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Encoder/Rfc2231Encoder.php b/modules/khemail/vendor/swift/classes/Swift/Encoder/Rfc2231Encoder.php
new file mode 100644
index 0000000..febc6ba
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Encoder/Rfc2231Encoder.php
@@ -0,0 +1,89 @@
+_charStream = $charStream;
+ }
+
+ /**
+ * Takes an unencoded string and produces a string encoded according to
+ * RFC 2231 from it.
+ * @param string $string to encode
+ * @param int $firstLineOffset
+ * @param int $maxLineLength, optional, 0 indicates the default of 75 bytes
+ * @return string
+ */
+ public function encodeString($string, $firstLineOffset = 0,
+ $maxLineLength = 0)
+ {
+ $lines = array(); $lineCount = 0;
+ $lines[] = '';
+ $currentLine =& $lines[$lineCount++];
+
+ if (0 >= $maxLineLength)
+ {
+ $maxLineLength = 75;
+ }
+
+ $this->_charStream->flushContents();
+ $this->_charStream->importString($string);
+
+ $thisLineLength = $maxLineLength - $firstLineOffset;
+
+ while (false !== $char = $this->_charStream->read(4))
+ {
+ $encodedChar = rawurlencode($char);
+ if (0 != strlen($currentLine)
+ && strlen($currentLine . $encodedChar) > $thisLineLength)
+ {
+ $lines[] = '';
+ $currentLine =& $lines[$lineCount++];
+ $thisLineLength = $maxLineLength;
+ }
+ $currentLine .= $encodedChar;
+ }
+
+ return implode("\r\n", $lines);
+ }
+
+ /**
+ * Updates the charset used.
+ * @param string $charset
+ */
+ public function charsetChanged($charset)
+ {
+ $this->_charStream->setCharacterSet($charset);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Encoding.php b/modules/khemail/vendor/swift/classes/Swift/Encoding.php
new file mode 100644
index 0000000..1849a82
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Encoding.php
@@ -0,0 +1,70 @@
+lookup($key);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Events/CommandEvent.php b/modules/khemail/vendor/swift/classes/Swift/Events/CommandEvent.php
new file mode 100644
index 0000000..73eb585
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Events/CommandEvent.php
@@ -0,0 +1,67 @@
+_command = $command;
+ $this->_successCodes = $successCodes;
+ }
+
+ /**
+ * Get the command which was sent to the server.
+ * @return string
+ */
+ public function getCommand()
+ {
+ return $this->_command;
+ }
+
+ /**
+ * Get the numeric response codes which indicate success for this command.
+ * @return int[]
+ */
+ public function getSuccessCodes()
+ {
+ return $this->_successCodes;
+ }
+
+}
\ No newline at end of file
diff --git a/modules/khemail/vendor/swift/classes/Swift/Events/CommandListener.php b/modules/khemail/vendor/swift/classes/Swift/Events/CommandListener.php
new file mode 100644
index 0000000..2fd7117
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Events/CommandListener.php
@@ -0,0 +1,29 @@
+_source = $source;
+ }
+
+ /**
+ * Get the source object of this event.
+ * @return object
+ */
+ public function getSource()
+ {
+ return $this->_source;
+ }
+
+ /**
+ * Prevent this Event from bubbling any further up the stack.
+ * @param boolean $cancel, optional
+ */
+ public function cancelBubble($cancel = true)
+ {
+ $this->_bubbleCancelled = $cancel;
+ }
+
+ /**
+ * Returns true if this Event will not bubble any further up the stack.
+ * @return boolean
+ */
+ public function bubbleCancelled()
+ {
+ return $this->_bubbleCancelled;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Events/ResponseEvent.php b/modules/khemail/vendor/swift/classes/Swift/Events/ResponseEvent.php
new file mode 100644
index 0000000..addf9e7
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Events/ResponseEvent.php
@@ -0,0 +1,65 @@
+_response = $response;
+ $this->_valid = $valid;
+ }
+
+ /**
+ * Get the response which was received from the server.
+ * @return string
+ */
+ public function getResponse()
+ {
+ return $this->_response;
+ }
+
+ /**
+ * Get the success status of this Event.
+ * @return boolean
+ */
+ public function isValid()
+ {
+ return $this->_valid;
+ }
+
+}
\ No newline at end of file
diff --git a/modules/khemail/vendor/swift/classes/Swift/Events/ResponseListener.php b/modules/khemail/vendor/swift/classes/Swift/Events/ResponseListener.php
new file mode 100644
index 0000000..092385b
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Events/ResponseListener.php
@@ -0,0 +1,29 @@
+_message = $message;
+ $this->_result = self::RESULT_PENDING;
+ }
+
+ /**
+ * Get the Transport used to send the Message.
+ * @return Swift_Transport
+ */
+ public function getTransport()
+ {
+ return $this->getSource();
+ }
+
+ /**
+ * Get the Message being sent.
+ * @return Swift_Mime_Message
+ */
+ public function getMessage()
+ {
+ return $this->_message;
+ }
+
+ /**
+ * Set the array of addresses that failed in sending.
+ * @param array $recipients
+ */
+ public function setFailedRecipients($recipients)
+ {
+ $this->_failedRecipients = $recipients;
+ }
+
+ /**
+ * Get an recipient addresses which were not accepted for delivery.
+ * @return string[]
+ */
+ public function getFailedRecipients()
+ {
+ return $this->_failedRecipients;
+ }
+
+ /**
+ * Set the result of sending.
+ * @return int
+ */
+ public function setResult($result)
+ {
+ $this->_result = $result;
+ }
+
+ /**
+ * Get the result of this Event.
+ * The return value is a bitmask from
+ * {@link RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED}
+ * @return int
+ */
+ public function getResult()
+ {
+ return $this->_result;
+ }
+
+}
\ No newline at end of file
diff --git a/modules/khemail/vendor/swift/classes/Swift/Events/SendListener.php b/modules/khemail/vendor/swift/classes/Swift/Events/SendListener.php
new file mode 100644
index 0000000..a8f0cc3
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Events/SendListener.php
@@ -0,0 +1,35 @@
+_eventMap = array(
+ 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener',
+ 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener',
+ 'Swift_Events_SendEvent' => 'Swift_Events_SendListener',
+ 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener',
+ 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener'
+ );
+ }
+
+ /**
+ * Create a new SendEvent for $source and $message.
+ *
+ * @param Swift_Transport $source
+ * @param Swift_Mime_Message
+ * @return Swift_Events_SendEvent
+ */
+ public function createSendEvent(Swift_Transport $source,
+ Swift_Mime_Message $message)
+ {
+ return new Swift_Events_SendEvent($source, $message);
+ }
+
+ /**
+ * Create a new CommandEvent for $source and $command.
+ *
+ * @param Swift_Transport $source
+ * @param string $command That will be executed
+ * @param array $successCodes That are needed
+ * @return Swift_Events_CommandEvent
+ */
+ public function createCommandEvent(Swift_Transport $source,
+ $command, $successCodes = array())
+ {
+ return new Swift_Events_CommandEvent($source, $command, $successCodes);
+ }
+
+ /**
+ * Create a new ResponseEvent for $source and $response.
+ *
+ * @param Swift_Transport $source
+ * @param string $response
+ * @param boolean $valid If the response is valid
+ * @return Swift_Events_ResponseEvent
+ */
+ public function createResponseEvent(Swift_Transport $source,
+ $response, $valid)
+ {
+ return new Swift_Events_ResponseEvent($source, $response, $valid);
+ }
+
+ /**
+ * Create a new TransportChangeEvent for $source.
+ *
+ * @param Swift_Transport $source
+ * @return Swift_Events_TransportChangeEvent
+ */
+ public function createTransportChangeEvent(Swift_Transport $source)
+ {
+ return new Swift_Events_TransportChangeEvent($source);
+ }
+
+ /**
+ * Create a new TransportExceptionEvent for $source.
+ *
+ * @param Swift_Transport $source
+ * @param Swift_TransportException $ex
+ * @return Swift_Events_TransportExceptionEvent
+ */
+ public function createTransportExceptionEvent(Swift_Transport $source,
+ Swift_TransportException $ex)
+ {
+ return new Swift_Events_TransportExceptionEvent($source, $ex);
+ }
+
+ /**
+ * Bind an event listener to this dispatcher.
+ *
+ * @param Swift_Events_EventListener $listener
+ */
+ public function bindEventListener(Swift_Events_EventListener $listener)
+ {
+ foreach ($this->_listeners as $l)
+ {
+ //Already loaded
+ if ($l === $listener)
+ {
+ return;
+ }
+ }
+ $this->_listeners[] = $listener;
+ }
+
+ /**
+ * Dispatch the given Event to all suitable listeners.
+ *
+ * @param Swift_Events_EventObject $evt
+ * @param string $target method
+ */
+ public function dispatchEvent(Swift_Events_EventObject $evt, $target)
+ {
+ $this->_prepareBubbleQueue($evt);
+ $this->_bubble($evt, $target);
+ }
+
+ // -- Private methods
+
+ /** Queue listeners on a stack ready for $evt to be bubbled up it */
+ private function _prepareBubbleQueue(Swift_Events_EventObject $evt)
+ {
+ $this->_bubbleQueue = array();
+ $evtClass = get_class($evt);
+ foreach ($this->_listeners as $listener)
+ {
+ if (array_key_exists($evtClass, $this->_eventMap)
+ && ($listener instanceof $this->_eventMap[$evtClass]))
+ {
+ $this->_bubbleQueue[] = $listener;
+ }
+ }
+ }
+
+ /** Bubble $evt up the stack calling $target() on each listener */
+ private function _bubble(Swift_Events_EventObject $evt, $target)
+ {
+ if (!$evt->bubbleCancelled() && $listener = array_shift($this->_bubbleQueue))
+ {
+ $listener->$target($evt);
+ $this->_bubble($evt, $target);
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeEvent.php b/modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeEvent.php
new file mode 100644
index 0000000..f069a4c
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeEvent.php
@@ -0,0 +1,31 @@
+getSource();
+ }
+
+}
\ No newline at end of file
diff --git a/modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeListener.php b/modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeListener.php
new file mode 100644
index 0000000..ba729d0
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeListener.php
@@ -0,0 +1,53 @@
+_exception = $ex;
+ }
+
+ /**
+ * Get the TransportException thrown.
+ * @return Swift_TransportException
+ */
+ public function getException()
+ {
+ return $this->_exception;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Events/TransportExceptionListener.php b/modules/khemail/vendor/swift/classes/Swift/Events/TransportExceptionListener.php
new file mode 100644
index 0000000..d6dce94
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Events/TransportExceptionListener.php
@@ -0,0 +1,30 @@
+createDependenciesFor('transport.failover')
+ );
+
+ $this->setTransports($transports);
+ }
+
+ /**
+ * Create a new FailoverTransport instance.
+ * @param string $transports
+ * @return Swift_FailoverTransport
+ */
+ public static function newInstance($transports = array())
+ {
+ return new self($transports);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/FileStream.php b/modules/khemail/vendor/swift/classes/Swift/FileStream.php
new file mode 100644
index 0000000..a7f894d
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/FileStream.php
@@ -0,0 +1,28 @@
+setFile(
+ new Swift_ByteStream_FileByteStream($path)
+ );
+ return $image;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/InputByteStream.php b/modules/khemail/vendor/swift/classes/Swift/InputByteStream.php
new file mode 100644
index 0000000..e8f45f4
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/InputByteStream.php
@@ -0,0 +1,72 @@
+_stream = $stream;
+ }
+
+ /**
+ * Set a string into the cache under $itemKey for the namespace $nsKey.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @param string $string
+ * @param int $mode
+ * @see MODE_WRITE, MODE_APPEND
+ */
+ public function setString($nsKey, $itemKey, $string, $mode)
+ {
+ $this->_prepareCache($nsKey);
+ switch ($mode)
+ {
+ case self::MODE_WRITE:
+ $this->_contents[$nsKey][$itemKey] = $string;
+ break;
+ case self::MODE_APPEND:
+ if (!$this->hasKey($nsKey, $itemKey))
+ {
+ $this->_contents[$nsKey][$itemKey] = '';
+ }
+ $this->_contents[$nsKey][$itemKey] .= $string;
+ break;
+ default:
+ throw new Swift_SwiftException(
+ 'Invalid mode [' . $mode . '] used to set nsKey='.
+ $nsKey . ', itemKey=' . $itemKey
+ );
+ }
+ }
+
+ /**
+ * Set a ByteStream into the cache under $itemKey for the namespace $nsKey.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @param Swift_OutputByteStream $os
+ * @param int $mode
+ * @see MODE_WRITE, MODE_APPEND
+ */
+ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os,
+ $mode)
+ {
+ $this->_prepareCache($nsKey);
+ switch ($mode)
+ {
+ case self::MODE_WRITE:
+ $this->clearKey($nsKey, $itemKey);
+ case self::MODE_APPEND:
+ if (!$this->hasKey($nsKey, $itemKey))
+ {
+ $this->_contents[$nsKey][$itemKey] = '';
+ }
+ while (false !== $bytes = $os->read(8192))
+ {
+ $this->_contents[$nsKey][$itemKey] .= $bytes;
+ }
+ break;
+ default:
+ throw new Swift_SwiftException(
+ 'Invalid mode [' . $mode . '] used to set nsKey='.
+ $nsKey . ', itemKey=' . $itemKey
+ );
+ }
+ }
+
+ /**
+ * Provides a ByteStream which when written to, writes data to $itemKey.
+ * NOTE: The stream will always write in append mode.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @return Swift_InputByteStream
+ */
+ public function getInputByteStream($nsKey, $itemKey,
+ Swift_InputByteStream $writeThrough = null)
+ {
+ $is = clone $this->_stream;
+ $is->setKeyCache($this);
+ $is->setNsKey($nsKey);
+ $is->setItemKey($itemKey);
+ if (isset($writeThrough))
+ {
+ $is->setWriteThroughStream($writeThrough);
+ }
+ return $is;
+ }
+
+ /**
+ * Get data back out of the cache as a string.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @return string
+ */
+ public function getString($nsKey, $itemKey)
+ {
+ $this->_prepareCache($nsKey);
+ if ($this->hasKey($nsKey, $itemKey))
+ {
+ return $this->_contents[$nsKey][$itemKey];
+ }
+ }
+
+ /**
+ * Get data back out of the cache as a ByteStream.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @param Swift_InputByteStream $is to write the data to
+ */
+ public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is)
+ {
+ $this->_prepareCache($nsKey);
+ $is->write($this->getString($nsKey, $itemKey));
+ }
+
+ /**
+ * Check if the given $itemKey exists in the namespace $nsKey.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @return boolean
+ */
+ public function hasKey($nsKey, $itemKey)
+ {
+ $this->_prepareCache($nsKey);
+ return array_key_exists($itemKey, $this->_contents[$nsKey]);
+ }
+
+ /**
+ * Clear data for $itemKey in the namespace $nsKey if it exists.
+ * @param string $nsKey
+ * @param string $itemKey
+ */
+ public function clearKey($nsKey, $itemKey)
+ {
+ unset($this->_contents[$nsKey][$itemKey]);
+ }
+
+ /**
+ * Clear all data in the namespace $nsKey if it exists.
+ * @param string $nsKey
+ */
+ public function clearAll($nsKey)
+ {
+ unset($this->_contents[$nsKey]);
+ }
+
+ // -- Private methods
+
+ /**
+ * Initialize the namespace of $nsKey if needed.
+ * @param string $nsKey
+ * @access private
+ */
+ private function _prepareCache($nsKey)
+ {
+ if (!array_key_exists($nsKey, $this->_contents))
+ {
+ $this->_contents[$nsKey] = array();
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/KeyCache/DiskKeyCache.php b/modules/khemail/vendor/swift/classes/Swift/KeyCache/DiskKeyCache.php
new file mode 100644
index 0000000..599fd6c
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/KeyCache/DiskKeyCache.php
@@ -0,0 +1,316 @@
+_stream = $stream;
+ $this->_path = $path;
+ $this->_quotes = get_magic_quotes_runtime();
+ }
+
+ /**
+ * Set a string into the cache under $itemKey for the namespace $nsKey.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @param string $string
+ * @param int $mode
+ * @throws Swift_IoException
+ * @see MODE_WRITE, MODE_APPEND
+ */
+ public function setString($nsKey, $itemKey, $string, $mode)
+ {
+ $this->_prepareCache($nsKey);
+ switch ($mode)
+ {
+ case self::MODE_WRITE:
+ $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START);
+ break;
+ case self::MODE_APPEND:
+ $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END);
+ break;
+ default:
+ throw new Swift_SwiftException(
+ 'Invalid mode [' . $mode . '] used to set nsKey='.
+ $nsKey . ', itemKey=' . $itemKey
+ );
+ break;
+ }
+ fwrite($fp, $string);
+ }
+
+ /**
+ * Set a ByteStream into the cache under $itemKey for the namespace $nsKey.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @param Swift_OutputByteStream $os
+ * @param int $mode
+ * @see MODE_WRITE, MODE_APPEND
+ * @throws Swift_IoException
+ */
+ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os,
+ $mode)
+ {
+ $this->_prepareCache($nsKey);
+ switch ($mode)
+ {
+ case self::MODE_WRITE:
+ $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START);
+ break;
+ case self::MODE_APPEND:
+ $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END);
+ break;
+ default:
+ throw new Swift_SwiftException(
+ 'Invalid mode [' . $mode . '] used to set nsKey='.
+ $nsKey . ', itemKey=' . $itemKey
+ );
+ break;
+ }
+ while (false !== $bytes = $os->read(8192))
+ {
+ fwrite($fp, $bytes);
+ }
+ }
+
+ /**
+ * Provides a ByteStream which when written to, writes data to $itemKey.
+ * NOTE: The stream will always write in append mode.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @return Swift_InputByteStream
+ */
+ public function getInputByteStream($nsKey, $itemKey,
+ Swift_InputByteStream $writeThrough = null)
+ {
+ $is = clone $this->_stream;
+ $is->setKeyCache($this);
+ $is->setNsKey($nsKey);
+ $is->setItemKey($itemKey);
+ if (isset($writeThrough))
+ {
+ $is->setWriteThroughStream($writeThrough);
+ }
+ return $is;
+ }
+
+ /**
+ * Get data back out of the cache as a string.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @return string
+ * @throws Swift_IoException
+ */
+ public function getString($nsKey, $itemKey)
+ {
+ $this->_prepareCache($nsKey);
+ if ($this->hasKey($nsKey, $itemKey))
+ {
+ $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START);
+ if ($this->_quotes)
+ {
+ set_magic_quotes_runtime(0);
+ }
+ $str = '';
+ while (!feof($fp) && false !== $bytes = fread($fp, 8192))
+ {
+ $str .= $bytes;
+ }
+ if ($this->_quotes)
+ {
+ set_magic_quotes_runtime(1);
+ }
+ return $str;
+ }
+ }
+
+ /**
+ * Get data back out of the cache as a ByteStream.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @param Swift_InputByteStream $is to write the data to
+ */
+ public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is)
+ {
+ if ($this->hasKey($nsKey, $itemKey))
+ {
+ $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START);
+ if ($this->_quotes)
+ {
+ set_magic_quotes_runtime(0);
+ }
+ while (!feof($fp) && false !== $bytes = fread($fp, 8192))
+ {
+ $is->write($bytes);
+ }
+ if ($this->_quotes)
+ {
+ set_magic_quotes_runtime(1);
+ }
+ }
+ }
+
+ /**
+ * Check if the given $itemKey exists in the namespace $nsKey.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @return boolean
+ */
+ public function hasKey($nsKey, $itemKey)
+ {
+ return is_file($this->_path . '/' . $nsKey . '/' . $itemKey);
+ }
+
+ /**
+ * Clear data for $itemKey in the namespace $nsKey if it exists.
+ * @param string $nsKey
+ * @param string $itemKey
+ */
+ public function clearKey($nsKey, $itemKey)
+ {
+ if ($this->hasKey($nsKey, $itemKey))
+ {
+ $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END);
+ fclose($fp);
+ unlink($this->_path . '/' . $nsKey . '/' . $itemKey);
+ }
+ unset($this->_keys[$nsKey][$itemKey]);
+ }
+
+ /**
+ * Clear all data in the namespace $nsKey if it exists.
+ * @param string $nsKey
+ */
+ public function clearAll($nsKey)
+ {
+ if (array_key_exists($nsKey, $this->_keys))
+ {
+ foreach ($this->_keys[$nsKey] as $itemKey=>$null)
+ {
+ $this->clearKey($nsKey, $itemKey);
+ }
+ rmdir($this->_path . '/' . $nsKey);
+ unset($this->_keys[$nsKey]);
+ }
+ }
+
+ // -- Private methods
+
+ /**
+ * Initialize the namespace of $nsKey if needed.
+ * @param string $nsKey
+ * @access private
+ */
+ private function _prepareCache($nsKey)
+ {
+ $cacheDir = $this->_path . '/' . $nsKey;
+ if (!is_dir($cacheDir))
+ {
+ if (!mkdir($cacheDir))
+ {
+ throw new Swift_IoException('Failed to create cache directory ' . $cacheDir);
+ }
+ $this->_keys[$nsKey] = array();
+ }
+ }
+
+ /**
+ * Get a file handle on the cache item.
+ * @param string $nsKey
+ * @param string $itemKey
+ * @param int $position
+ * @return resource
+ * @access private
+ */
+ private function _getHandle($nsKey, $itemKey, $position)
+ {
+ if (!isset($this->_keys[$nsKey]) || !array_key_exists($itemKey, $this->_keys[$nsKey]))
+ {
+ $fp = fopen($this->_path . '/' . $nsKey . '/' . $itemKey, 'w+b');
+ $this->_keys[$nsKey][$itemKey] = $fp;
+ }
+ if (self::POSITION_START == $position)
+ {
+ fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_SET);
+ }
+ else
+ {
+ fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_END);
+ }
+ return $this->_keys[$nsKey][$itemKey];
+ }
+
+ /**
+ * Destructor.
+ */
+ public function __destruct()
+ {
+ foreach ($this->_keys as $nsKey=>$null)
+ {
+ $this->clearAll($nsKey);
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/KeyCache/KeyCacheInputStream.php b/modules/khemail/vendor/swift/classes/Swift/KeyCache/KeyCacheInputStream.php
new file mode 100644
index 0000000..a1f4440
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/KeyCache/KeyCacheInputStream.php
@@ -0,0 +1,53 @@
+_keyCache = $keyCache;
+ }
+
+ /**
+ * Specify a stream to write through for each write().
+ * @param Swift_InputByteStream $is
+ */
+ public function setWriteThroughStream(Swift_InputByteStream $is)
+ {
+ $this->_writeThrough = $is;
+ }
+
+ /**
+ * Writes $bytes to the end of the stream.
+ * @param string $bytes
+ * @param Swift_InputByteStream $is, optional
+ */
+ public function write($bytes, Swift_InputByteStream $is = null)
+ {
+ $this->_keyCache->setString(
+ $this->_nsKey, $this->_itemKey, $bytes, Swift_KeyCache::MODE_APPEND
+ );
+ if (isset($is))
+ {
+ $is->write($bytes);
+ }
+ if (isset($this->_writeThrough))
+ {
+ $this->_writeThrough->write($bytes);
+ }
+ }
+
+ /**
+ * Not used.
+ */
+ public function commit()
+ {
+ }
+
+ /**
+ * Not used.
+ */
+ public function bind(Swift_InputByteStream $is)
+ {
+ }
+
+ /**
+ * Not used.
+ */
+ public function unbind(Swift_InputByteStream $is)
+ {
+ }
+
+ /**
+ * Flush the contents of the stream (empty it) and set the internal pointer
+ * to the beginning.
+ */
+ public function flushBuffers()
+ {
+ $this->_keyCache->clearKey($this->_nsKey, $this->_itemKey);
+ }
+
+ /**
+ * Set the nsKey which will be written to.
+ * @param string $nsKey
+ */
+ public function setNsKey($nsKey)
+ {
+ $this->_nsKey = $nsKey;
+ }
+
+ /**
+ * Set the itemKey which will be written to.
+ * @param string $itemKey
+ */
+ public function setItemKey($itemKey)
+ {
+ $this->_itemKey = $itemKey;
+ }
+
+ /**
+ * Any implementation should be cloneable, allowing the clone to access a
+ * separate $nsKey and $itemKey.
+ */
+ public function __clone()
+ {
+ $this->_writeThrough = null;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/LoadBalancedTransport.php b/modules/khemail/vendor/swift/classes/Swift/LoadBalancedTransport.php
new file mode 100644
index 0000000..14ae292
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/LoadBalancedTransport.php
@@ -0,0 +1,48 @@
+createDependenciesFor('transport.loadbalanced')
+ );
+
+ $this->setTransports($transports);
+ }
+
+ /**
+ * Create a new LoadBalancedTransport instance.
+ * @param string $transports
+ * @return Swift_LoadBalancedTransport
+ */
+ public static function newInstance($transports = array())
+ {
+ return new self($transports);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/MailTransport.php b/modules/khemail/vendor/swift/classes/Swift/MailTransport.php
new file mode 100644
index 0000000..afe29c6
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/MailTransport.php
@@ -0,0 +1,48 @@
+createDependenciesFor('transport.mail')
+ );
+
+ $this->setExtraParams($extraParams);
+ }
+
+ /**
+ * Create a new MailTransport instance.
+ * @param string $extraParams To be passed to mail()
+ * @return Swift_MailTransport
+ */
+ public static function newInstance($extraParams = '-f%s')
+ {
+ return new self($extraParams);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mailer.php b/modules/khemail/vendor/swift/classes/Swift/Mailer.php
new file mode 100644
index 0000000..c92feb4
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mailer.php
@@ -0,0 +1,173 @@
+_transport = $transport;
+ }
+
+ /**
+ * Create a new Mailer instance.
+ *
+ * @param Swift_Transport $transport
+ * @return Swift_Mailer
+ */
+ public static function newInstance(Swift_Transport $transport)
+ {
+ return new self($transport);
+ }
+
+ /**
+ * Send the given Message like it would be sent in a mail client.
+ *
+ * All recipients (with the exception of Bcc) will be able to see the other
+ * recipients this message was sent to.
+ *
+ * If you need to send to each recipient without disclosing details about the
+ * other recipients see {@link batchSend()}.
+ *
+ * Recipient/sender data will be retreived from the Message object.
+ *
+ * The return value is the number of recipients who were accepted for
+ * delivery.
+ *
+ * @param Swift_Mime_Message $message
+ * @param array &$failedRecipients, optional
+ * @return int
+ * @see batchSend()
+ */
+ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ {
+ $failedRecipients = (array) $failedRecipients;
+
+ if (!$this->_transport->isStarted())
+ {
+ $this->_transport->start();
+ }
+
+ return $this->_transport->send($message, $failedRecipients);
+ }
+
+ /**
+ * Send the given Message to all recipients individually.
+ *
+ * This differs from {@link send()} in the way headers are presented to the
+ * recipient. The only recipient in the "To:" field will be the individual
+ * recipient it was sent to.
+ *
+ * If an iterator is provided, recipients will be read from the iterator
+ * one-by-one, otherwise recipient data will be retreived from the Message
+ * object.
+ *
+ * Sender information is always read from the Message object.
+ *
+ * The return value is the number of recipients who were accepted for
+ * delivery.
+ *
+ * @param Swift_Mime_Message $message
+ * @param array &$failedRecipients, optional
+ * @param Swift_Mailer_RecipientIterator $it, optional
+ * @return int
+ * @see send()
+ */
+ public function batchSend(Swift_Mime_Message $message,
+ &$failedRecipients = null,
+ Swift_Mailer_RecipientIterator $it = null)
+ {
+ $failedRecipients = (array) $failedRecipients;
+
+ $sent = 0;
+ $to = $message->getTo();
+ $cc = $message->getCc();
+ $bcc = $message->getBcc();
+
+ if (!empty($cc))
+ {
+ $message->setCc(array());
+ }
+ if (!empty($bcc))
+ {
+ $message->setBcc(array());
+ }
+
+ //Use an iterator if set
+ if (isset($it))
+ {
+ while ($it->hasNext())
+ {
+ $message->setTo($it->nextRecipient());
+ $sent += $this->send($message, $failedRecipients);
+ }
+ }
+ else
+ {
+ foreach ($to as $address => $name)
+ {
+ $message->setTo(array($address => $name));
+ $sent += $this->send($message, $failedRecipients);
+ }
+ }
+
+ $message->setTo($to);
+
+ if (!empty($cc))
+ {
+ $message->setCc($cc);
+ }
+ if (!empty($bcc))
+ {
+ $message->setBcc($bcc);
+ }
+
+ return $sent;
+ }
+
+ /**
+ * Register a plugin using a known unique key (e.g. myPlugin).
+ *
+ * @param Swift_Events_EventListener $plugin
+ * @param string $key
+ */
+ public function registerPlugin(Swift_Events_EventListener $plugin)
+ {
+ $this->_transport->registerPlugin($plugin);
+ }
+
+ /**
+ * The Transport used to send messages.
+ * @return Swift_Transport
+ */
+ public function getTransport()
+ {
+ return $this->_transport;
+ }
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mailer/ArrayRecipientIterator.php b/modules/khemail/vendor/swift/classes/Swift/Mailer/ArrayRecipientIterator.php
new file mode 100644
index 0000000..65d60c1
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mailer/ArrayRecipientIterator.php
@@ -0,0 +1,59 @@
+_recipients = $recipients;
+ }
+
+ /**
+ * Returns true only if there are more recipients to send to.
+ * @return boolean
+ */
+ public function hasNext()
+ {
+ return !empty($this->_recipients);
+ }
+
+ /**
+ * Returns an array where the keys are the addresses of recipients and the
+ * values are the names.
+ * e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL)
+ * @return array
+ */
+ public function nextRecipient()
+ {
+ return array_splice($this->_recipients, 0, 1);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mailer/RecipientIterator.php b/modules/khemail/vendor/swift/classes/Swift/Mailer/RecipientIterator.php
new file mode 100644
index 0000000..2713841
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mailer/RecipientIterator.php
@@ -0,0 +1,34 @@
+ 'Foo') or ('foo@bar' => NULL)
+ * @return array
+ */
+ public function nextRecipient();
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Message.php b/modules/khemail/vendor/swift/classes/Swift/Message.php
new file mode 100644
index 0000000..e8183ea
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Message.php
@@ -0,0 +1,82 @@
+createDependenciesFor('mime.message')
+ );
+
+ if (!isset($charset))
+ {
+ $charset = Swift_DependencyContainer::getInstance()
+ ->lookup('properties.charset');
+ }
+ $this->setSubject($subject);
+ $this->setBody($body);
+ $this->setCharset($charset);
+ if ($contentType)
+ {
+ $this->setContentType($contentType);
+ }
+ }
+
+ /**
+ * Create a new Message.
+ * @param string $subject
+ * @param string $body
+ * @param string $contentType
+ * @param string $charset
+ * @return Swift_Mime_Message
+ */
+ public static function newInstance($subject = null, $body = null,
+ $contentType = null, $charset = null)
+ {
+ return new self($subject, $body, $contentType, $charset);
+ }
+
+ /**
+ * Add a MimePart to this Message.
+ * @param string|Swift_OutputByteStream $body
+ * @param string $contentType
+ * @param string $charset
+ */
+ public function addPart($body, $contentType = null, $charset = null)
+ {
+ return $this->attach(Swift_MimePart::newInstance(
+ $body, $contentType, $charset
+ ));
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/Attachment.php b/modules/khemail/vendor/swift/classes/Swift/Mime/Attachment.php
new file mode 100644
index 0000000..25ef68b
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/Attachment.php
@@ -0,0 +1,143 @@
+setDisposition('attachment');
+ $this->setContentType('application/octet-stream');
+ $this->_mimeTypes = $mimeTypes;
+ }
+
+ /**
+ * Get the nesting level used for this attachment.
+ * Always returns {@link LEVEL_MIXED}.
+ * @return int
+ */
+ public function getNestingLevel()
+ {
+ return self::LEVEL_MIXED;
+ }
+
+ /**
+ * Get the Content-Disposition of this attachment.
+ * By default attachments have a disposition of "attachment".
+ * @return string
+ */
+ public function getDisposition()
+ {
+ return $this->_getHeaderFieldModel('Content-Disposition');
+ }
+
+ /**
+ * Set the Content-Disposition of this attachment.
+ * @param string $disposition
+ */
+ public function setDisposition($disposition)
+ {
+ if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition))
+ {
+ $this->getHeaders()->addParameterizedHeader(
+ 'Content-Disposition', $disposition
+ );
+ }
+ return $this;
+ }
+
+ /**
+ * Get the filename of this attachment when downloaded.
+ * @return string
+ */
+ public function getFilename()
+ {
+ return $this->_getHeaderParameter('Content-Disposition', 'filename');
+ }
+
+ /**
+ * Set the filename of this attachment.
+ * @param string $filename
+ */
+ public function setFilename($filename)
+ {
+ $this->_setHeaderParameter('Content-Disposition', 'filename', $filename);
+ $this->_setHeaderParameter('Content-Type', 'name', $filename);
+ return $this;
+ }
+
+ /**
+ * Get the file size of this attachment.
+ * @return int
+ */
+ public function getSize()
+ {
+ return $this->_getHeaderParameter('Content-Disposition', 'size');
+ }
+
+ /**
+ * Set the file size of this attachment.
+ * @param int $size
+ */
+ public function setSize($size)
+ {
+ $this->_setHeaderParameter('Content-Disposition', 'size', $size);
+ return $this;
+ }
+
+ /**
+ * Set the file that this attachment is for.
+ * @param Swift_FileStream $file
+ * @param string $contentType optional
+ */
+ public function setFile(Swift_FileStream $file, $contentType = null)
+ {
+ $this->setFilename(basename($file->getPath()));
+ $this->setBody($file, $contentType);
+ if (!isset($contentType))
+ {
+ $extension = strtolower(substr(
+ $file->getPath(), strrpos($file->getPath(), '.') + 1
+ ));
+
+ if (array_key_exists($extension, $this->_mimeTypes))
+ {
+ $this->setContentType($this->_mimeTypes[$extension]);
+ }
+ }
+ return $this;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/CharsetObserver.php b/modules/khemail/vendor/swift/classes/Swift/Mime/CharsetObserver.php
new file mode 100644
index 0000000..c26009f
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/CharsetObserver.php
@@ -0,0 +1,26 @@
+= $maxLineLength || 76 < $maxLineLength)
+ {
+ $maxLineLength = 76;
+ }
+
+ $remainder = 0;
+
+ while (false !== $bytes = $os->read(8190))
+ {
+ $encoded = base64_encode($bytes);
+ $encodedTransformed = '';
+ $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset;
+
+ while ($thisMaxLineLength < strlen($encoded))
+ {
+ $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength) . "\r\n";
+ $firstLineOffset = 0;
+ $encoded = substr($encoded, $thisMaxLineLength);
+ $thisMaxLineLength = $maxLineLength;
+ $remainder = 0;
+ }
+
+ if (0 < $remainingLength = strlen($encoded))
+ {
+ $remainder += $remainingLength;
+ $encodedTransformed .= $encoded;
+ $encoded = null;
+ }
+
+ $is->write($encodedTransformed);
+ }
+ }
+
+ /**
+ * Get the name of this encoding scheme.
+ * Returns the string 'base64'.
+ * @return string
+ */
+ public function getName()
+ {
+ return 'base64';
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php b/modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php
new file mode 100644
index 0000000..4a725d8
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php
@@ -0,0 +1,175 @@
+_name = $name;
+ $this->_canonical = $canonical;
+ }
+
+ /**
+ * Encode a given string to produce an encoded string.
+ * @param string $string
+ * @param int $firstLineOffset, ignored
+ * @param int $maxLineLength - 0 means no wrapping will occur
+ * @return string
+ */
+ public function encodeString($string, $firstLineOffset = 0,
+ $maxLineLength = 0)
+ {
+ if ($this->_canonical)
+ {
+ $string = $this->_canonicalize($string);
+ }
+ return $this->_safeWordWrap($string, $maxLineLength, "\r\n");
+ }
+
+ /**
+ * Encode stream $in to stream $out.
+ * @param Swift_OutputByteStream $in
+ * @param Swift_InputByteStream $out
+ * @param int $firstLineOffset, ignored
+ * @param int $maxLineLength, optional, 0 means no wrapping will occur
+ */
+ public function encodeByteStream(
+ Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0,
+ $maxLineLength = 0)
+ {
+ $leftOver = '';
+ while (false !== $bytes = $os->read(8192))
+ {
+ $toencode = $leftOver . $bytes;
+ if ($this->_canonical)
+ {
+ $toencode = $this->_canonicalize($toencode);
+ }
+ $wrapped = $this->_safeWordWrap($toencode, $maxLineLength, "\r\n");
+ $lastLinePos = strrpos($wrapped, "\r\n");
+ $leftOver = substr($wrapped, $lastLinePos);
+ $wrapped = substr($wrapped, 0, $lastLinePos);
+
+ $is->write($wrapped);
+ }
+ if (strlen($leftOver))
+ {
+ $is->write($leftOver);
+ }
+ }
+
+ /**
+ * Get the name of this encoding scheme.
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->_name;
+ }
+
+ /**
+ * Not used.
+ */
+ public function charsetChanged($charset)
+ {
+ }
+
+ // -- Private methods
+
+ /**
+ * A safer (but weaker) wordwrap for unicode.
+ * @param string $string
+ * @param int $length
+ * @param string $le
+ * @return string
+ * @access private
+ */
+ private function _safeWordwrap($string, $length = 75, $le = "\r\n")
+ {
+ if (0 >= $length)
+ {
+ return $string;
+ }
+
+ $originalLines = explode($le, $string);
+
+ $lines = array();
+ $lineCount = 0;
+
+ foreach ($originalLines as $originalLine)
+ {
+ $lines[] = '';
+ $currentLine =& $lines[$lineCount++];
+
+ //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine);
+ $chunks = preg_split('/(?<=\s)/', $originalLine);
+
+ foreach ($chunks as $chunk)
+ {
+ if (0 != strlen($currentLine)
+ && strlen($currentLine . $chunk) > $length)
+ {
+ $lines[] = '';
+ $currentLine =& $lines[$lineCount++];
+ }
+ $currentLine .= $chunk;
+ }
+ }
+
+ return implode("\r\n", $lines);
+ }
+
+ /**
+ * Canonicalize string input (fix CRLF).
+ * @param string $string
+ * @return string
+ * @access private
+ */
+ private function _canonicalize($string)
+ {
+ return str_replace(
+ array("\r\n", "\r", "\n"),
+ array("\n", "\n", "\r\n"),
+ $string
+ );
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php
new file mode 100644
index 0000000..3beeb63
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php
@@ -0,0 +1,117 @@
+ 76 || $maxLineLength <= 0)
+ {
+ $maxLineLength = 76;
+ }
+
+ $thisLineLength = $maxLineLength - $firstLineOffset;
+
+ $this->_charStream->flushContents();
+ $this->_charStream->importByteStream($os);
+
+ $currentLine = '';
+ $prepend = '';
+ $size=$lineLen=0;
+
+ while (false !== $bytes = $this->_nextSequence())
+ {
+ //If we're filtering the input
+ if (isset($this->_filter))
+ {
+ //If we can't filter because we need more bytes
+ while ($this->_filter->shouldBuffer($bytes))
+ {
+ //Then collect bytes into the buffer
+ if (false === $moreBytes = $this->_nextSequence(1))
+ {
+ break;
+ }
+
+ foreach ($moreBytes as $b)
+ {
+ $bytes[] = $b;
+ }
+ }
+ //And filter them
+ $bytes = $this->_filter->filter($bytes);
+ }
+
+ $enc = $this->_encodeByteSequence($bytes, $size);
+ if ($currentLine && $lineLen+$size >= $thisLineLength)
+ {
+ $is->write($prepend . $this->_standardize($currentLine));
+ $currentLine = '';
+ $prepend = "=\r\n";
+ $thisLineLength = $maxLineLength;
+ $lineLen=0;
+ }
+ $lineLen+=$size;
+ $currentLine .= $enc;
+ }
+ if (strlen($currentLine))
+ {
+ $is->write($prepend . $this->_standardize($currentLine));
+ }
+ }
+
+ /**
+ * Get the name of this encoding scheme.
+ * Returns the string 'quoted-printable'.
+ * @return string
+ */
+ public function getName()
+ {
+ return 'quoted-printable';
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/EmbeddedFile.php b/modules/khemail/vendor/swift/classes/Swift/Mime/EmbeddedFile.php
new file mode 100644
index 0000000..983b78d
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/EmbeddedFile.php
@@ -0,0 +1,51 @@
+setDisposition('inline');
+ $this->setId($this->getId());
+ }
+
+ /**
+ * Get the nesting level of this EmbeddedFile.
+ * Returns {@link LEVEL_RELATED}.
+ * @return int
+ */
+ public function getNestingLevel()
+ {
+ return self::LEVEL_RELATED;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/EncodingObserver.php b/modules/khemail/vendor/swift/classes/Swift/Mime/EncodingObserver.php
new file mode 100644
index 0000000..50472db
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/EncodingObserver.php
@@ -0,0 +1,28 @@
+clearCachedValueIf($charset != $this->_charset);
+ $this->_charset = $charset;
+ if (isset($this->_encoder))
+ {
+ $this->_encoder->charsetChanged($charset);
+ }
+ }
+
+ /**
+ * Get the character set used in this Header.
+ * @return string
+ */
+ public function getCharset()
+ {
+ return $this->_charset;
+ }
+
+ /**
+ * Set the language used in this Header.
+ * For example, for US English, 'en-us'.
+ * This can be unspecified.
+ * @param string $lang
+ */
+ public function setLanguage($lang)
+ {
+ $this->clearCachedValueIf($this->_lang != $lang);
+ $this->_lang = $lang;
+ }
+
+ /**
+ * Get the language used in this Header.
+ * @return string
+ */
+ public function getLanguage()
+ {
+ return $this->_lang;
+ }
+
+ /**
+ * Set the encoder used for encoding the header.
+ * @param Swift_Mime_HeaderEncoder $encoder
+ */
+ public function setEncoder(Swift_Mime_HeaderEncoder $encoder)
+ {
+ $this->_encoder = $encoder;
+ $this->setCachedValue(null);
+ }
+
+ /**
+ * Get the encoder used for encoding this Header.
+ * @return Swift_Mime_HeaderEncoder
+ */
+ public function getEncoder()
+ {
+ return $this->_encoder;
+ }
+
+ /**
+ * Get the name of this header (e.g. charset).
+ * @return string
+ */
+ public function getFieldName()
+ {
+ return $this->_name;
+ }
+
+ /**
+ * Set the maximum length of lines in the header (excluding EOL).
+ * @param int $lineLength
+ */
+ public function setMaxLineLength($lineLength)
+ {
+ $this->clearCachedValueIf($this->_lineLength != $lineLength);
+ $this->_lineLength = $lineLength;
+ }
+
+ /**
+ * Get the maximum permitted length of lines in this Header.
+ * @return int
+ */
+ public function getMaxLineLength()
+ {
+ return $this->_lineLength;
+ }
+
+ /**
+ * Get this Header rendered as a RFC 2822 compliant string.
+ * @return string
+ * @throws Swift_RfcComplianceException
+ */
+ public function toString()
+ {
+ return $this->_tokensToString($this->toTokens());
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return string
+ *
+ * @see toString()
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+
+ // -- Points of extension
+
+ /**
+ * Set the name of this Header field.
+ * @param string $name
+ * @access protected
+ */
+ protected function setFieldName($name)
+ {
+ $this->_name = $name;
+ }
+
+ /**
+ * Initialize some RFC 2822 (and friends) ABNF grammar definitions.
+ * @access protected
+ */
+ protected function initializeGrammar()
+ {
+ $this->_specials = array(
+ '(', ')', '<', '>', '[', ']',
+ ':', ';', '@', ',', '.', '"'
+ );
+
+ /*** Refer to RFC 2822 for ABNF grammar ***/
+
+ //All basic building blocks
+ $this->_grammar['NO-WS-CTL'] = '[\x01-\x08\x0B\x0C\x0E-\x19\x7F]';
+ $this->_grammar['WSP'] = '[ \t]';
+ $this->_grammar['CRLF'] = '(?:\r\n)';
+ $this->_grammar['FWS'] = '(?:(?:' . $this->_grammar['WSP'] . '*' .
+ $this->_grammar['CRLF'] . ')?' . $this->_grammar['WSP'] . ')';
+ $this->_grammar['text'] = '[\x00-\x08\x0B\x0C\x0E-\x7F]';
+ $this->_grammar['quoted-pair'] = '(?:\\\\' . $this->_grammar['text'] . ')';
+ $this->_grammar['ctext'] = '(?:' . $this->_grammar['NO-WS-CTL'] .
+ '|[\x21-\x27\x2A-\x5B\x5D-\x7E])';
+ //Uses recursive PCRE (?1) -- could be a weak point??
+ $this->_grammar['ccontent'] = '(?:' . $this->_grammar['ctext'] . '|' .
+ $this->_grammar['quoted-pair'] . '|(?1))';
+ $this->_grammar['comment'] = '(\((?:' . $this->_grammar['FWS'] . '|' .
+ $this->_grammar['ccontent']. ')*' . $this->_grammar['FWS'] . '?\))';
+ $this->_grammar['CFWS'] = '(?:(?:' . $this->_grammar['FWS'] . '?' .
+ $this->_grammar['comment'] . ')*(?:(?:' . $this->_grammar['FWS'] . '?' .
+ $this->_grammar['comment'] . ')|' . $this->_grammar['FWS'] . '))';
+ $this->_grammar['qtext'] = '(?:' . $this->_grammar['NO-WS-CTL'] .
+ '|[\x21\x23-\x5B\x5D-\x7E])';
+ $this->_grammar['qcontent'] = '(?:' . $this->_grammar['qtext'] . '|' .
+ $this->_grammar['quoted-pair'] . ')';
+ $this->_grammar['quoted-string'] = '(?:' . $this->_grammar['CFWS'] . '?"' .
+ '(' . $this->_grammar['FWS'] . '?' . $this->_grammar['qcontent'] . ')*' .
+ $this->_grammar['FWS'] . '?"' . $this->_grammar['CFWS'] . '?)';
+ $this->_grammar['atext'] = '[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]';
+ $this->_grammar['atom'] = '(?:' . $this->_grammar['CFWS'] . '?' .
+ $this->_grammar['atext'] . '+' . $this->_grammar['CFWS'] . '?)';
+ $this->_grammar['dot-atom-text'] = '(?:' . $this->_grammar['atext'] . '+' .
+ '(\.' . $this->_grammar['atext'] . '+)*)';
+ $this->_grammar['dot-atom'] = '(?:' . $this->_grammar['CFWS'] . '?' .
+ $this->_grammar['dot-atom-text'] . '+' . $this->_grammar['CFWS'] . '?)';
+ $this->_grammar['word'] = '(?:' . $this->_grammar['atom'] . '|' .
+ $this->_grammar['quoted-string'] . ')';
+ $this->_grammar['phrase'] = '(?:' . $this->_grammar['word'] . '+?)';
+ $this->_grammar['no-fold-quote'] = '(?:"(?:' . $this->_grammar['qtext'] .
+ '|' . $this->_grammar['quoted-pair'] . ')*")';
+ $this->_grammar['dtext'] = '(?:' . $this->_grammar['NO-WS-CTL'] .
+ '|[\x21-\x5A\x5E-\x7E])';
+ $this->_grammar['no-fold-literal'] = '(?:\[(?:' . $this->_grammar['dtext'] .
+ '|' . $this->_grammar['quoted-pair'] . ')*\])';
+
+ //Message IDs
+ $this->_grammar['id-left'] = '(?:' . $this->_grammar['dot-atom-text'] . '|' .
+ $this->_grammar['no-fold-quote'] . ')';
+ $this->_grammar['id-right'] = '(?:' . $this->_grammar['dot-atom-text'] . '|' .
+ $this->_grammar['no-fold-literal'] . ')';
+
+ //Addresses, mailboxes and paths
+ $this->_grammar['local-part'] = '(?:' . $this->_grammar['dot-atom'] . '|' .
+ $this->_grammar['quoted-string'] . ')';
+ $this->_grammar['dcontent'] = '(?:' . $this->_grammar['dtext'] . '|' .
+ $this->_grammar['quoted-pair'] . ')';
+ $this->_grammar['domain-literal'] = '(?:' . $this->_grammar['CFWS'] . '?\[(' .
+ $this->_grammar['FWS'] . '?' . $this->_grammar['dcontent'] . ')*?' .
+ $this->_grammar['FWS'] . '?\]' . $this->_grammar['CFWS'] . '?)';
+ $this->_grammar['domain'] = '(?:' . $this->_grammar['dot-atom'] . '|' .
+ $this->_grammar['domain-literal'] . ')';
+ $this->_grammar['addr-spec'] = '(?:' . $this->_grammar['local-part'] . '@' .
+ $this->_grammar['domain'] . ')';
+ }
+
+ /**
+ * Get the grammar defined for $name token.
+ * @param string $name execatly as written in the RFC
+ * @return string
+ */
+ protected function getGrammar($name)
+ {
+ if (array_key_exists($name, $this->_grammar))
+ {
+ return $this->_grammar[$name];
+ }
+ else
+ {
+ throw new Swift_RfcComplianceException(
+ "No such grammar '" . $name . "' defined."
+ );
+ }
+ }
+
+ /**
+ * Escape special characters in a string (convert to quoted-pairs).
+ * @param string $token
+ * @param string[] $include additonal chars to escape
+ * @param string[] $exclude chars from escaping
+ * @return string
+ */
+ protected function escapeSpecials($token, $include = array(),
+ $exclude = array())
+ {
+ foreach (
+ array_merge(array('\\'), array_diff($this->_specials, $exclude), $include) as $char)
+ {
+ $token = str_replace($char, '\\' . $char, $token);
+ }
+ return $token;
+ }
+
+ /**
+ * Produces a compliant, formatted RFC 2822 'phrase' based on the string given.
+ * @param Swift_Mime_Header $header
+ * @param string $string as displayed
+ * @param string $charset of the text
+ * @param Swift_Mime_HeaderEncoder $encoder
+ * @param boolean $shorten the first line to make remove for header name
+ * @return string
+ */
+ protected function createPhrase(Swift_Mime_Header $header, $string, $charset,
+ Swift_Mime_HeaderEncoder $encoder = null, $shorten = false)
+ {
+ //Treat token as exactly what was given
+ $phraseStr = $string;
+ //If it's not valid
+ if (!preg_match('/^' . $this->_grammar['phrase'] . '$/D', $phraseStr))
+ {
+ // .. but it is just ascii text, try escaping some characters
+ // and make it a quoted-string
+ if (preg_match('/^' . $this->_grammar['text'] . '*$/D', $phraseStr))
+ {
+ $phraseStr = $this->escapeSpecials(
+ $phraseStr, array('"'), $this->_specials
+ );
+ $phraseStr = '"' . $phraseStr . '"';
+ }
+ else // ... otherwise it needs encoding
+ {
+ //Determine space remaining on line if first line
+ if ($shorten)
+ {
+ $usedLength = strlen($header->getFieldName() . ': ');
+ }
+ else
+ {
+ $usedLength = 0;
+ }
+ $phraseStr = $this->encodeWords($header, $string, $usedLength);
+ }
+ }
+
+ return $phraseStr;
+ }
+
+ /**
+ * Encode needed word tokens within a string of input.
+ * @param string $input
+ * @param string $usedLength, optional
+ * @return string
+ */
+ protected function encodeWords(Swift_Mime_Header $header, $input,
+ $usedLength = -1)
+ {
+ $value = '';
+
+ $tokens = $this->getEncodableWordTokens($input);
+
+ foreach ($tokens as $token)
+ {
+ //See RFC 2822, Sect 2.2 (really 2.2 ??)
+ if ($this->tokenNeedsEncoding($token))
+ {
+ //Don't encode starting WSP
+ $firstChar = substr($token, 0, 1);
+ switch($firstChar)
+ {
+ case ' ':
+ case "\t":
+ $value .= $firstChar;
+ $token = substr($token, 1);
+ }
+
+ if (-1 == $usedLength)
+ {
+ $usedLength = strlen($header->getFieldName() . ': ') + strlen($value);
+ }
+ $value .= $this->getTokenAsEncodedWord($token, $usedLength);
+
+ $header->setMaxLineLength(76); //Forefully override
+ }
+ else
+ {
+ $value .= $token;
+ }
+ }
+
+ return $value;
+ }
+
+ /**
+ * Test if a token needs to be encoded or not.
+ * @param string $token
+ * @return boolean
+ */
+ protected function tokenNeedsEncoding($token)
+ {
+ return preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $token);
+ }
+
+ /**
+ * Splits a string into tokens in blocks of words which can be encoded quickly.
+ * @param string $string
+ * @return string[]
+ */
+ protected function getEncodableWordTokens($string)
+ {
+ $tokens = array();
+
+ $encodedToken = '';
+ //Split at all whitespace boundaries
+ foreach (preg_split('~(?=[\t ])~', $string) as $token)
+ {
+ if ($this->tokenNeedsEncoding($token))
+ {
+ $encodedToken .= $token;
+ }
+ else
+ {
+ if (strlen($encodedToken) > 0)
+ {
+ $tokens[] = $encodedToken;
+ $encodedToken = '';
+ }
+ $tokens[] = $token;
+ }
+ }
+ if (strlen($encodedToken))
+ {
+ $tokens[] = $encodedToken;
+ }
+
+ return $tokens;
+ }
+
+ /**
+ * Get a token as an encoded word for safe insertion into headers.
+ * @param string $token to encode
+ * @param int $firstLineOffset, optional
+ * @return string
+ */
+ protected function getTokenAsEncodedWord($token, $firstLineOffset = 0)
+ {
+ //Adjust $firstLineOffset to account for space needed for syntax
+ $charsetDecl = $this->_charset;
+ if (isset($this->_lang))
+ {
+ $charsetDecl .= '*' . $this->_lang;
+ }
+ $encodingWrapperLength = strlen(
+ '=?' . $charsetDecl . '?' . $this->_encoder->getName() . '??='
+ );
+
+ if ($firstLineOffset >= 75) //Does this logic need to be here?
+ {
+ $firstLineOffset = 0;
+ }
+
+ $encodedTextLines = explode("\r\n",
+ $this->_encoder->encodeString(
+ $token, $firstLineOffset, 75 - $encodingWrapperLength
+ )
+ );
+
+ foreach ($encodedTextLines as $lineNum => $line)
+ {
+ $encodedTextLines[$lineNum] = '=?' . $charsetDecl .
+ '?' . $this->_encoder->getName() .
+ '?' . $line . '?=';
+ }
+
+ return implode("\r\n ", $encodedTextLines);
+ }
+
+ /**
+ * Generates tokens from the given string which include CRLF as individual tokens.
+ * @param string $token
+ * @return string[]
+ * @access protected
+ */
+ protected function generateTokenLines($token)
+ {
+ return preg_split('~(\r\n)~', $token, -1, PREG_SPLIT_DELIM_CAPTURE);
+ }
+
+ /**
+ * Set a value into the cache.
+ * @param string $value
+ * @access protected
+ */
+ protected function setCachedValue($value)
+ {
+ $this->_cachedValue = $value;
+ }
+
+ /**
+ * Get the value in the cache.
+ * @return string
+ * @access protected
+ */
+ protected function getCachedValue()
+ {
+ return $this->_cachedValue;
+ }
+
+ /**
+ * Clear the cached value if $condition is met.
+ * @param boolean $condition
+ * @access protected
+ */
+ protected function clearCachedValueIf($condition)
+ {
+ if ($condition)
+ {
+ $this->setCachedValue(null);
+ }
+ }
+
+ // -- Private methods
+
+ /**
+ * Generate a list of all tokens in the final header.
+ * @param string $string input, optional
+ * @return string[]
+ * @access private
+ */
+ protected function toTokens($string = null)
+ {
+ if (is_null($string))
+ {
+ $string = $this->getFieldBody();
+ }
+
+ $tokens = array();
+
+ //Generate atoms; split at all invisible boundaries followed by WSP
+ foreach (preg_split('~(?=[ \t])~', $string) as $token)
+ {
+ $tokens = array_merge($tokens, $this->generateTokenLines($token));
+ }
+
+ return $tokens;
+ }
+
+ /**
+ * Takes an array of tokens which appear in the header and turns them into
+ * an RFC 2822 compliant string, adding FWSP where needed.
+ * @param string[] $tokens
+ * @return string
+ * @access private
+ */
+ private function _tokensToString(array $tokens)
+ {
+ $lineCount = 0;
+ $headerLines = array();
+ $headerLines[] = $this->_name . ': ';
+ $currentLine =& $headerLines[$lineCount++];
+
+ //Build all tokens back into compliant header
+ foreach ($tokens as $i => $token)
+ {
+ //Line longer than specified maximum or token was just a new line
+ if (("\r\n" == $token) ||
+ ($i > 0 && strlen($currentLine . $token) > $this->_lineLength)
+ && 0 < strlen($currentLine))
+ {
+ $headerLines[] = '';
+ $currentLine =& $headerLines[$lineCount++];
+ }
+
+ //Append token to the line
+ if ("\r\n" != $token)
+ {
+ $currentLine .= $token;
+ }
+ }
+
+ //Implode with FWS (RFC 2822, 2.2.3)
+ return implode("\r\n", $headerLines) . "\r\n";
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/DateHeader.php b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/DateHeader.php
new file mode 100644
index 0000000..598c0c5
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/DateHeader.php
@@ -0,0 +1,118 @@
+
+ *
+ *
+ * @param string $name of Header
+ */
+ public function __construct($name)
+ {
+ $this->setFieldName($name);
+ }
+
+ /**
+ * Get the type of Header that this instance represents.
+ * @return int
+ * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
+ * @see TYPE_DATE, TYPE_ID, TYPE_PATH
+ */
+ public function getFieldType()
+ {
+ return self::TYPE_DATE;
+ }
+
+ /**
+ * Set the model for the field body.
+ * This method takes a UNIX timestamp.
+ * @param int $model
+ */
+ public function setFieldBodyModel($model)
+ {
+ $this->setTimestamp($model);
+ }
+
+ /**
+ * Get the model for the field body.
+ * This method returns a UNIX timestamp.
+ * @return mixed
+ */
+ public function getFieldBodyModel()
+ {
+ return $this->getTimestamp();
+ }
+
+ /**
+ * Get the UNIX timestamp of the Date in this Header.
+ * @return int
+ */
+ public function getTimestamp()
+ {
+ return $this->_timestamp;
+ }
+
+ /**
+ * Set the UNIX timestamp of the Date in this Header.
+ * @param int $timestamp
+ */
+ public function setTimestamp($timestamp)
+ {
+ if (!is_null($timestamp))
+ {
+ $timestamp = (int) $timestamp;
+ }
+ $this->clearCachedValueIf($this->_timestamp != $timestamp);
+ $this->_timestamp = $timestamp;
+ }
+
+ /**
+ * Get the string value of the body in this Header.
+ * This is not necessarily RFC 2822 compliant since folding white space will
+ * not be added at this stage (see {@link toString()} for that).
+ * @return string
+ * @see toString()
+ */
+ public function getFieldBody()
+ {
+ if (!$this->getCachedValue())
+ {
+ if (isset($this->_timestamp))
+ {
+ $this->setCachedValue(date('r', $this->_timestamp));
+ }
+ }
+ return $this->getCachedValue();
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/IdentificationHeader.php b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/IdentificationHeader.php
new file mode 100644
index 0000000..55ff737
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/IdentificationHeader.php
@@ -0,0 +1,161 @@
+setFieldName($name);
+ $this->initializeGrammar();
+ }
+
+ /**
+ * Get the type of Header that this instance represents.
+ * @return int
+ * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
+ * @see TYPE_DATE, TYPE_ID, TYPE_PATH
+ */
+ public function getFieldType()
+ {
+ return self::TYPE_ID;
+ }
+
+ /**
+ * Set the model for the field body.
+ * This method takes a string ID, or an array of IDs
+ * @param mixed $model
+ * @throws Swift_RfcComplianceException
+ */
+ public function setFieldBodyModel($model)
+ {
+ $this->setId($model);
+ }
+
+ /**
+ * Get the model for the field body.
+ * This method returns an array of IDs
+ * @return array
+ */
+ public function getFieldBodyModel()
+ {
+ return $this->getIds();
+ }
+
+ /**
+ * Set the ID used in the value of this header.
+ * @param string $id
+ * @throws Swift_RfcComplianceException
+ */
+ public function setId($id)
+ {
+ return $this->setIds(array($id));
+ }
+
+ /**
+ * Get the ID used in the value of this Header.
+ * If multiple IDs are set only the first is returned.
+ * @return string
+ */
+ public function getId()
+ {
+ if (count($this->_ids) > 0)
+ {
+ return $this->_ids[0];
+ }
+ }
+
+ /**
+ * Set a collection of IDs to use in the value of this Header.
+ * @param string[] $ids
+ * @throws Swift_RfcComplianceException
+ */
+ public function setIds(array $ids)
+ {
+ $actualIds = array();
+
+ foreach ($ids as $k => $id)
+ {
+ if (preg_match(
+ '/^' . $this->getGrammar('id-left') . '@' .
+ $this->getGrammar('id-right') . '$/D',
+ $id
+ ))
+ {
+ $actualIds[] = $id;
+ }
+ else
+ {
+ throw new Swift_RfcComplianceException(
+ 'Invalid ID given <' . $id . '>'
+ );
+ }
+ }
+
+ $this->clearCachedValueIf($this->_ids != $actualIds);
+ $this->_ids = $actualIds;
+ }
+
+ /**
+ * Get the list of IDs used in this Header.
+ * @return string[]
+ */
+ public function getIds()
+ {
+ return $this->_ids;
+ }
+
+ /**
+ * Get the string value of the body in this Header.
+ * This is not necessarily RFC 2822 compliant since folding white space will
+ * not be added at this stage (see {@link toString()} for that).
+ * @return string
+ * @see toString()
+ * @throws Swift_RfcComplianceException
+ */
+ public function getFieldBody()
+ {
+ if (!$this->getCachedValue())
+ {
+ $angleAddrs = array();
+
+ foreach ($this->_ids as $id)
+ {
+ $angleAddrs[] = '<' . $id . '>';
+ }
+
+ $this->setCachedValue(implode(' ', $angleAddrs));
+ }
+ return $this->getCachedValue();
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/MailboxHeader.php b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/MailboxHeader.php
new file mode 100644
index 0000000..77d3bba
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/MailboxHeader.php
@@ -0,0 +1,316 @@
+setFieldName($name);
+ $this->setEncoder($encoder);
+ $this->initializeGrammar();
+ }
+
+ /**
+ * Get the type of Header that this instance represents.
+ * @return int
+ * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
+ * @see TYPE_DATE, TYPE_ID, TYPE_PATH
+ */
+ public function getFieldType()
+ {
+ return self::TYPE_MAILBOX;
+ }
+
+ /**
+ * Set the model for the field body.
+ * This method takes a string, or an array of addresses.
+ * @param mixed $model
+ * @throws Swift_RfcComplianceException
+ */
+ public function setFieldBodyModel($model)
+ {
+ $this->setNameAddresses($model);
+ }
+
+ /**
+ * Get the model for the field body.
+ * This method returns an associative array like {@link getNameAddresses()}
+ * @return array
+ * @throws Swift_RfcComplianceException
+ */
+ public function getFieldBodyModel()
+ {
+ return $this->getNameAddresses();
+ }
+
+ /**
+ * Set a list of mailboxes to be shown in this Header.
+ * The mailboxes can be a simple array of addresses, or an array of
+ * key=>value pairs where (email => personalName).
+ * Example:
+ *
+ * setNameAddresses(array(
+ * 'chris@swiftmailer.org' => 'Chris Corbyn',
+ * 'mark@swiftmailer.org' //No associated personal name
+ * ));
+ * ?>
+ *
+ * @param string|string[] $mailboxes
+ * @throws Swift_RfcComplianceException
+ * @see __construct()
+ * @see setAddresses()
+ * @see setValue()
+ */
+ public function setNameAddresses($mailboxes)
+ {
+ $this->_mailboxes = $this->normalizeMailboxes((array) $mailboxes);
+ $this->setCachedValue(null); //Clear any cached value
+ }
+
+ /**
+ * Get the full mailbox list of this Header as an array of valid RFC 2822 strings.
+ * Example:
+ *
+ * 'Chris Corbyn',
+ * 'mark@swiftmailer.org' => 'Mark Corbyn')
+ * );
+ * print_r($header->getNameAddressStrings());
+ * // array (
+ * // 0 => Chris Corbyn ,
+ * // 1 => Mark Corbyn
+ * // )
+ * ?>
+ *
+ * @return string[]
+ * @throws Swift_RfcComplianceException
+ * @see getNameAddresses()
+ * @see toString()
+ */
+ public function getNameAddressStrings()
+ {
+ return $this->_createNameAddressStrings($this->getNameAddresses());
+ }
+
+ /**
+ * Get all mailboxes in this Header as key=>value pairs.
+ * The key is the address and the value is the name (or null if none set).
+ * Example:
+ *
+ * 'Chris Corbyn',
+ * 'mark@swiftmailer.org' => 'Mark Corbyn')
+ * );
+ * print_r($header->getNameAddresses());
+ * // array (
+ * // chris@swiftmailer.org => Chris Corbyn,
+ * // mark@swiftmailer.org => Mark Corbyn
+ * // )
+ * ?>
+ *
+ * @return string[]
+ * @see getAddresses()
+ * @see getNameAddressStrings()
+ */
+ public function getNameAddresses()
+ {
+ return $this->_mailboxes;
+ }
+
+ /**
+ * Makes this Header represent a list of plain email addresses with no names.
+ * Example:
+ *
+ * setAddresses(
+ * array('one@domain.tld', 'two@domain.tld', 'three@domain.tld')
+ * );
+ * ?>
+ *
+ * @param string[] $addresses
+ * @throws Swift_RfcComplianceException
+ * @see setNameAddresses()
+ * @see setValue()
+ */
+ public function setAddresses($addresses)
+ {
+ return $this->setNameAddresses(array_values((array) $addresses));
+ }
+
+ /**
+ * Get all email addresses in this Header.
+ * @return string[]
+ * @see getNameAddresses()
+ */
+ public function getAddresses()
+ {
+ return array_keys($this->_mailboxes);
+ }
+
+ /**
+ * Remove one or more addresses from this Header.
+ * @param string|string[] $addresses
+ */
+ public function removeAddresses($addresses)
+ {
+ $this->setCachedValue(null);
+ foreach ((array) $addresses as $address)
+ {
+ unset($this->_mailboxes[$address]);
+ }
+ }
+
+ /**
+ * Get the string value of the body in this Header.
+ * This is not necessarily RFC 2822 compliant since folding white space will
+ * not be added at this stage (see {@link toString()} for that).
+ * @return string
+ * @throws Swift_RfcComplianceException
+ * @see toString()
+ */
+ public function getFieldBody()
+ {
+ //Compute the string value of the header only if needed
+ if (is_null($this->getCachedValue()))
+ {
+ $this->setCachedValue($this->createMailboxListString($this->_mailboxes));
+ }
+ return $this->getCachedValue();
+ }
+
+ // -- Points of extension
+
+ /**
+ * Normalizes a user-input list of mailboxes into consistent key=>value pairs.
+ * @param string[] $mailboxes
+ * @return string[]
+ * @access protected
+ */
+ protected function normalizeMailboxes(array $mailboxes)
+ {
+ $actualMailboxes = array();
+
+ foreach ($mailboxes as $key => $value)
+ {
+ if (is_string($key)) //key is email addr
+ {
+ $address = $key;
+ $name = $value;
+ }
+ else
+ {
+ $address = $value;
+ $name = null;
+ }
+ $this->_assertValidAddress($address);
+ $actualMailboxes[$address] = $name;
+ }
+
+ return $actualMailboxes;
+ }
+
+ /**
+ * Produces a compliant, formatted display-name based on the string given.
+ * @param string $displayName as displayed
+ * @param boolean $shorten the first line to make remove for header name
+ * @return string
+ * @access protected
+ */
+ protected function createDisplayNameString($displayName, $shorten = false)
+ {
+ return $this->createPhrase($this, $displayName,
+ $this->getCharset(), $this->getEncoder(), $shorten
+ );
+ }
+
+ /**
+ * Creates a string form of all the mailboxes in the passed array.
+ * @param string[] $mailboxes
+ * @return string
+ * @throws Swift_RfcComplianceException
+ * @access protected
+ */
+ protected function createMailboxListString(array $mailboxes)
+ {
+ return implode(', ', $this->_createNameAddressStrings($mailboxes));
+ }
+
+ // -- Private methods
+
+ /**
+ * Return an array of strings conforming the the name-addr spec of RFC 2822.
+ * @param string[] $mailboxes
+ * @return string[]
+ * @access private
+ */
+ private function _createNameAddressStrings(array $mailboxes)
+ {
+ $strings = array();
+
+ foreach ($mailboxes as $email => $name)
+ {
+ $mailboxStr = $email;
+ if (!is_null($name))
+ {
+ $nameStr = $this->createDisplayNameString($name, empty($strings));
+ $mailboxStr = $nameStr . ' <' . $mailboxStr . '>';
+ }
+ $strings[] = $mailboxStr;
+ }
+
+ return $strings;
+ }
+
+ /**
+ * Throws an Exception if the address passed does not comply with RFC 2822.
+ * @param string $address
+ * @throws Exception If invalid.
+ * @access protected
+ */
+ private function _assertValidAddress($address)
+ {
+ if (!preg_match('/^' . $this->getGrammar('addr-spec') . '$/D',
+ $address))
+ {
+ throw new Swift_RfcComplianceException(
+ 'Address in mailbox given [' . $address .
+ '] does not comply with RFC 2822, 3.6.2.'
+ );
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/ParameterizedHeader.php b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/ParameterizedHeader.php
new file mode 100644
index 0000000..974b44e
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/ParameterizedHeader.php
@@ -0,0 +1,274 @@
+setFieldName($name);
+ $this->setEncoder($encoder);
+ $this->_paramEncoder = $paramEncoder;
+ $this->initializeGrammar();
+ $this->_tokenRe = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)';
+ }
+
+ /**
+ * Get the type of Header that this instance represents.
+ * @return int
+ * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
+ * @see TYPE_DATE, TYPE_ID, TYPE_PATH
+ */
+ public function getFieldType()
+ {
+ return self::TYPE_PARAMETERIZED;
+ }
+
+ /**
+ * Set the character set used in this Header.
+ * @param string $charset
+ */
+ public function setCharset($charset)
+ {
+ parent::setCharset($charset);
+ if (isset($this->_paramEncoder))
+ {
+ $this->_paramEncoder->charsetChanged($charset);
+ }
+ }
+
+ /**
+ * Set the value of $parameter.
+ * @param string $parameter
+ * @param string $value
+ */
+ public function setParameter($parameter, $value)
+ {
+ $this->setParameters(array_merge($this->getParameters(), array($parameter => $value)));
+ }
+
+ /**
+ * Get the value of $parameter.
+ * @return string
+ */
+ public function getParameter($parameter)
+ {
+ $params = $this->getParameters();
+ return array_key_exists($parameter, $params)
+ ? $params[$parameter]
+ : null;
+ }
+
+ /**
+ * Set an associative array of parameter names mapped to values.
+ * @param string[]
+ */
+ public function setParameters(array $parameters)
+ {
+ $this->clearCachedValueIf($this->_params != $parameters);
+ $this->_params = $parameters;
+ }
+
+ /**
+ * Returns an associative array of parameter names mapped to values.
+ * @return string[]
+ */
+ public function getParameters()
+ {
+ return $this->_params;
+ }
+
+ /**
+ * Get the value of this header prepared for rendering.
+ * @return string
+ */
+ public function getFieldBody() //TODO: Check caching here
+ {
+ $body = parent::getFieldBody();
+ foreach ($this->_params as $name => $value)
+ {
+ if (!is_null($value))
+ {
+ //Add the parameter
+ $body .= '; ' . $this->_createParameter($name, $value);
+ }
+ }
+ return $body;
+ }
+
+ // -- Protected methods
+
+ /**
+ * Generate a list of all tokens in the final header.
+ * This doesn't need to be overridden in theory, but it is for implementation
+ * reasons to prevent potential breakage of attributes.
+ * @return string[]
+ * @access protected
+ */
+ protected function toTokens($string = null)
+ {
+ $tokens = parent::toTokens(parent::getFieldBody());
+
+ //Try creating any parameters
+ foreach ($this->_params as $name => $value)
+ {
+ if (!is_null($value))
+ {
+ //Add the semi-colon separator
+ $tokens[count($tokens)-1] .= ';';
+ $tokens = array_merge($tokens, $this->generateTokenLines(
+ ' ' . $this->_createParameter($name, $value)
+ ));
+ }
+ }
+
+ return $tokens;
+ }
+
+ // -- Private methods
+
+ /**
+ * Render a RFC 2047 compliant header parameter from the $name and $value.
+ * @param string $name
+ * @param string $value
+ * @return string
+ * @access private
+ */
+ private function _createParameter($name, $value)
+ {
+ $origValue = $value;
+
+ $encoded = false;
+ //Allow room for parameter name, indices, "=" and DQUOTEs
+ $maxValueLength = $this->getMaxLineLength() - strlen($name . '=*N"";') - 1;
+ $firstLineOffset = 0;
+
+ //If it's not already a valid parameter value...
+ if (!preg_match('/^' . $this->_tokenRe . '$/D', $value))
+ {
+ //TODO: text, or something else??
+ //... and it's not ascii
+ if (!preg_match('/^' . $this->getGrammar('text') . '*$/D', $value))
+ {
+ $encoded = true;
+ //Allow space for the indices, charset and language
+ $maxValueLength = $this->getMaxLineLength() - strlen($name . '*N*="";') - 1;
+ $firstLineOffset = strlen(
+ $this->getCharset() . "'" . $this->getLanguage() . "'"
+ );
+ }
+ }
+
+ //Encode if we need to
+ if ($encoded || strlen($value) > $maxValueLength)
+ {
+ if (isset($this->_paramEncoder))
+ {
+ $value = $this->_paramEncoder->encodeString(
+ $origValue, $firstLineOffset, $maxValueLength
+ );
+ }
+ else //We have to go against RFC 2183/2231 in some areas for interoperability
+ {
+ $value = $this->getTokenAsEncodedWord($origValue);
+ $encoded = false;
+ }
+ }
+
+ $valueLines = isset($this->_paramEncoder) ? explode("\r\n", $value) : array($value);
+
+ //Need to add indices
+ if (count($valueLines) > 1)
+ {
+ $paramLines = array();
+ foreach ($valueLines as $i => $line)
+ {
+ $paramLines[] = $name . '*' . $i .
+ $this->_getEndOfParameterValue($line, $encoded, $i == 0);
+ }
+ return implode(";\r\n ", $paramLines);
+ }
+ else
+ {
+ return $name . $this->_getEndOfParameterValue(
+ $valueLines[0], $encoded, true
+ );
+ }
+ }
+
+ /**
+ * Returns the parameter value from the "=" and beyond.
+ * @param string $value to append
+ * @param boolean $encoded
+ * @param boolean $firstLine
+ * @return string
+ * @access private
+ */
+ private function _getEndOfParameterValue($value, $encoded = false, $firstLine = false)
+ {
+ if (!preg_match('/^' . $this->_tokenRe . '$/D', $value))
+ {
+ $value = '"' . $value . '"';
+ }
+ $prepend = '=';
+ if ($encoded)
+ {
+ $prepend = '*=';
+ if ($firstLine)
+ {
+ $prepend = '*=' . $this->getCharset() . "'" . $this->getLanguage() .
+ "'";
+ }
+ }
+ return $prepend . $value;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/PathHeader.php b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/PathHeader.php
new file mode 100644
index 0000000..0a8a100
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/PathHeader.php
@@ -0,0 +1,126 @@
+setFieldName($name);
+ $this->initializeGrammar();
+ }
+
+ /**
+ * Get the type of Header that this instance represents.
+ * @return int
+ * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
+ * @see TYPE_DATE, TYPE_ID, TYPE_PATH
+ */
+ public function getFieldType()
+ {
+ return self::TYPE_PATH;
+ }
+
+ /**
+ * Set the model for the field body.
+ * This method takes a string for an address.
+ * @param string $model
+ * @throws Swift_RfcComplianceException
+ */
+ public function setFieldBodyModel($model)
+ {
+ $this->setAddress($model);
+ }
+
+ /**
+ * Get the model for the field body.
+ * This method returns a string email address.
+ * @return mixed
+ */
+ public function getFieldBodyModel()
+ {
+ return $this->getAddress();
+ }
+
+ /**
+ * Set the Address which should appear in this Header.
+ * @param string $address
+ * @throws Swift_RfcComplianceException
+ */
+ public function setAddress($address)
+ {
+ if (is_null($address))
+ {
+ $this->_address = null;
+ }
+ elseif ('' == $address
+ || preg_match('/^' . $this->getGrammar('addr-spec') . '$/D', $address))
+ {
+ $this->_address = $address;
+ }
+ else
+ {
+ throw new Swift_RfcComplianceException(
+ 'Address set in PathHeader does not comply with addr-spec of RFC 2822.'
+ );
+ }
+ $this->setCachedValue(null);
+ }
+
+ /**
+ * Get the address which is used in this Header (if any).
+ * Null is returned if no address is set.
+ * @return string
+ */
+ public function getAddress()
+ {
+ return $this->_address;
+ }
+
+ /**
+ * Get the string value of the body in this Header.
+ * This is not necessarily RFC 2822 compliant since folding white space will
+ * not be added at this stage (see {@link toString()} for that).
+ * @return string
+ * @see toString()
+ */
+ public function getFieldBody()
+ {
+ if (!$this->getCachedValue())
+ {
+ if (isset($this->_address))
+ {
+ $this->setCachedValue('<' . $this->_address . '>');
+ }
+ }
+ return $this->getCachedValue();
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/UnstructuredHeader.php b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/UnstructuredHeader.php
new file mode 100644
index 0000000..fdcc21e
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/Headers/UnstructuredHeader.php
@@ -0,0 +1,108 @@
+setFieldName($name);
+ $this->setEncoder($encoder);
+ }
+ /**
+ * Get the type of Header that this instance represents.
+ * @return int
+ * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
+ * @see TYPE_DATE, TYPE_ID, TYPE_PATH
+ */
+ public function getFieldType()
+ {
+ return self::TYPE_TEXT;
+ }
+
+ /**
+ * Set the model for the field body.
+ * This method takes a string for the field value.
+ * @param string $model
+ */
+ public function setFieldBodyModel($model)
+ {
+ $this->setValue($model);
+ }
+
+ /**
+ * Get the model for the field body.
+ * This method returns a string.
+ * @return string
+ */
+ public function getFieldBodyModel()
+ {
+ return $this->getValue();
+ }
+
+ /**
+ * Get the (unencoded) value of this header.
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->_value;
+ }
+
+ /**
+ * Set the (unencoded) value of this header.
+ * @param string $value
+ */
+ public function setValue($value)
+ {
+ $this->clearCachedValueIf($this->_value != $value);
+ $this->_value = $value;
+ }
+
+ /**
+ * Get the value of this header prepared for rendering.
+ * @return string
+ */
+ public function getFieldBody()
+ {
+ if (!$this->getCachedValue())
+ {
+ $this->setCachedValue(
+ str_replace('\\', '\\\\', $this->encodeWords(
+ $this, $this->_value, -1, $this->getCharset(), $this->getEncoder()
+ ))
+ );
+ }
+ return $this->getCachedValue();
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/Message.php b/modules/khemail/vendor/swift/classes/Swift/Mime/Message.php
new file mode 100644
index 0000000..0496c08
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/Message.php
@@ -0,0 +1,230 @@
+ 'Real Name').
+ *
+ * If the second parameter is provided and the first is a string, then $name
+ * is associated with the address.
+ *
+ * @param mixed $address
+ * @param string $name optional
+ */
+ public function setSender($address, $name = null);
+
+ /**
+ * Get the sender address for this message.
+ *
+ * This has a higher significance than the From address.
+ *
+ * @return string
+ */
+ public function getSender();
+
+ /**
+ * Set the From address of this message.
+ *
+ * It is permissible for multiple From addresses to be set using an array.
+ *
+ * If multiple From addresses are used, you SHOULD set the Sender address and
+ * according to RFC 2822, MUST set the sender address.
+ *
+ * An array can be used if display names are to be provided: i.e.
+ * array('email@address.com' => 'Real Name').
+ *
+ * If the second parameter is provided and the first is a string, then $name
+ * is associated with the address.
+ *
+ * @param mixed $addresses
+ * @param string $name optional
+ */
+ public function setFrom($addresses, $name = null);
+
+ /**
+ * Get the From address(es) of this message.
+ *
+ * This method always returns an associative array where the keys are the
+ * addresses.
+ *
+ * @return string[]
+ */
+ public function getFrom();
+
+ /**
+ * Set the Reply-To address(es).
+ *
+ * Any replies from the receiver will be sent to this address.
+ *
+ * It is permissible for multiple reply-to addresses to be set using an array.
+ *
+ * This method has the same synopsis as {@link setFrom()} and {@link setTo()}.
+ *
+ * If the second parameter is provided and the first is a string, then $name
+ * is associated with the address.
+ *
+ * @param mixed $addresses
+ * @param string $name optional
+ */
+ public function setReplyTo($addresses, $name = null);
+
+ /**
+ * Get the Reply-To addresses for this message.
+ *
+ * This method always returns an associative array where the keys provide the
+ * email addresses.
+ *
+ * @return string[]
+ */
+ public function getReplyTo();
+
+ /**
+ * Set the To address(es).
+ *
+ * Recipients set in this field will receive a copy of this message.
+ *
+ * This method has the same synopsis as {@link setFrom()} and {@link setCc()}.
+ *
+ * If the second parameter is provided and the first is a string, then $name
+ * is associated with the address.
+ *
+ * @param mixed $addresses
+ * @param string $name optional
+ */
+ public function setTo($addresses, $name = null);
+
+ /**
+ * Get the To addresses for this message.
+ *
+ * This method always returns an associative array, whereby the keys provide
+ * the actual email addresses.
+ *
+ * @return string[]
+ */
+ public function getTo();
+
+ /**
+ * Set the Cc address(es).
+ *
+ * Recipients set in this field will receive a 'carbon-copy' of this message.
+ *
+ * This method has the same synopsis as {@link setFrom()} and {@link setTo()}.
+ *
+ * @param mixed $addresses
+ * @param string $name optional
+ */
+ public function setCc($addresses, $name = null);
+
+ /**
+ * Get the Cc addresses for this message.
+ *
+ * This method always returns an associative array, whereby the keys provide
+ * the actual email addresses.
+ *
+ * @return string[]
+ */
+ public function getCc();
+
+ /**
+ * Set the Bcc address(es).
+ *
+ * Recipients set in this field will receive a 'blind-carbon-copy' of this
+ * message.
+ *
+ * In other words, they will get the message, but any other recipients of the
+ * message will have no such knowledge of their receipt of it.
+ *
+ * This method has the same synopsis as {@link setFrom()} and {@link setTo()}.
+ *
+ * @param mixed $addresses
+ * @param string $name optional
+ */
+ public function setBcc($addresses, $name = null);
+
+ /**
+ * Get the Bcc addresses for this message.
+ *
+ * This method always returns an associative array, whereby the keys provide
+ * the actual email addresses.
+ *
+ * @return string[]
+ */
+ public function getBcc();
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/MimeEntity.php b/modules/khemail/vendor/swift/classes/Swift/Mime/MimeEntity.php
new file mode 100644
index 0000000..2b08009
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/MimeEntity.php
@@ -0,0 +1,108 @@
+setContentType('text/plain');
+ if (!is_null($charset))
+ {
+ $this->setCharset($charset);
+ }
+ }
+
+ /**
+ * Set the body of this entity, either as a string, or as an instance of
+ * {@link Swift_OutputByteStream}.
+ *
+ * @param mixed $body
+ * @param string $contentType optional
+ * @param string $charset optional
+ */
+ public function setBody($body, $contentType = null, $charset = null)
+ {
+ parent::setBody($body, $contentType);
+ if (isset($charset))
+ {
+ $this->setCharset($charset);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the character set of this entity.
+ *
+ * @return string
+ */
+ public function getCharset()
+ {
+ return $this->_getHeaderParameter('Content-Type', 'charset');
+ }
+
+ /**
+ * Set the character set of this entity.
+ *
+ * @param string $charset
+ */
+ public function setCharset($charset)
+ {
+ $this->_setHeaderParameter('Content-Type', 'charset', $charset);
+ if ($charset !== $this->_userCharset)
+ {
+ $this->_clearCache();
+ }
+ $this->_userCharset = $charset;
+ parent::charsetChanged($charset);
+ return $this;
+ }
+
+ /**
+ * Get the format of this entity (i.e. flowed or fixed).
+ *
+ * @return string
+ */
+ public function getFormat()
+ {
+ return $this->_getHeaderParameter('Content-Type', 'format');
+ }
+
+ /**
+ * Set the format of this entity (flowed or fixed).
+ *
+ * @param string $format
+ */
+ public function setFormat($format)
+ {
+ $this->_setHeaderParameter('Content-Type', 'format', $format);
+ $this->_userFormat = $format;
+ return $this;
+ }
+
+ /**
+ * Test if delsp is being used for this entity.
+ *
+ * @return boolean
+ */
+ public function getDelSp()
+ {
+ return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes')
+ ? true
+ : false;
+ }
+
+ /**
+ * Turn delsp on or off for this entity.
+ *
+ * @param boolean $delsp
+ */
+ public function setDelSp($delsp = true)
+ {
+ $this->_setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null);
+ $this->_userDelSp = $delsp;
+ return $this;
+ }
+
+ /**
+ * Get the nesting level of this entity.
+ *
+ * @return int
+ * @see LEVEL_TOP, LEVEL_ALTERNATIVE, LEVEL_MIXED, LEVEL_RELATED
+ */
+ public function getNestingLevel()
+ {
+ return $this->_nestingLevel;
+ }
+
+ /**
+ * Receive notification that the charset has changed on this document, or a
+ * parent document.
+ *
+ * @param string $charset
+ */
+ public function charsetChanged($charset)
+ {
+ $this->setCharset($charset);
+ }
+
+ // -- Protected methods
+
+ /** Fix the content-type and encoding of this entity */
+ protected function _fixHeaders()
+ {
+ parent::_fixHeaders();
+ if (count($this->getChildren()))
+ {
+ $this->_setHeaderParameter('Content-Type', 'charset', null);
+ $this->_setHeaderParameter('Content-Type', 'format', null);
+ $this->_setHeaderParameter('Content-Type', 'delsp', null);
+ }
+ else
+ {
+ $this->setCharset($this->_userCharset);
+ $this->setFormat($this->_userFormat);
+ $this->setDelSp($this->_userDelSp);
+ }
+ }
+
+ /** Set the nesting level of this entity */
+ protected function _setNestingLevel($level)
+ {
+ $this->_nestingLevel = $level;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/ParameterizedHeader.php b/modules/khemail/vendor/swift/classes/Swift/Mime/ParameterizedHeader.php
new file mode 100644
index 0000000..da65ca9
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/ParameterizedHeader.php
@@ -0,0 +1,35 @@
+_encoder = $encoder;
+ $this->_paramEncoder = $paramEncoder;
+ $this->_charset = $charset;
+ }
+
+ /**
+ * Create a new Mailbox Header with a list of $addresses.
+ * @param string $name
+ * @param array|string $addresses
+ * @return Swift_Mime_Header
+ */
+ public function createMailboxHeader($name, $addresses = null)
+ {
+ $header = new Swift_Mime_Headers_MailboxHeader($name, $this->_encoder);
+ if (isset($addresses))
+ {
+ $header->setFieldBodyModel($addresses);
+ }
+ $this->_setHeaderCharset($header);
+ return $header;
+ }
+
+ /**
+ * Create a new Date header using $timestamp (UNIX time).
+ * @param string $name
+ * @param int $timestamp
+ * @return Swift_Mime_Header
+ */
+ public function createDateHeader($name, $timestamp = null)
+ {
+ $header = new Swift_Mime_Headers_DateHeader($name);
+ if (isset($timestamp))
+ {
+ $header->setFieldBodyModel($timestamp);
+ }
+ $this->_setHeaderCharset($header);
+ return $header;
+ }
+
+ /**
+ * Create a new basic text header with $name and $value.
+ * @param string $name
+ * @param string $value
+ * @return Swift_Mime_Header
+ */
+ public function createTextHeader($name, $value = null)
+ {
+ $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->_encoder);
+ if (isset($value))
+ {
+ $header->setFieldBodyModel($value);
+ }
+ $this->_setHeaderCharset($header);
+ return $header;
+ }
+
+ /**
+ * Create a new ParameterizedHeader with $name, $value and $params.
+ * @param string $name
+ * @param string $value
+ * @param array $params
+ * @return Swift_Mime_ParameterizedHeader
+ */
+ public function createParameterizedHeader($name, $value = null,
+ $params = array())
+ {
+ $header = new Swift_Mime_Headers_ParameterizedHeader($name,
+ $this->_encoder, (strtolower($name) == 'content-disposition')
+ ? $this->_paramEncoder
+ : null
+ );
+ if (isset($value))
+ {
+ $header->setFieldBodyModel($value);
+ }
+ foreach ($params as $k => $v)
+ {
+ $header->setParameter($k, $v);
+ }
+ $this->_setHeaderCharset($header);
+ return $header;
+ }
+
+ /**
+ * Create a new ID header for Message-ID or Content-ID.
+ * @param string $name
+ * @param string|array $ids
+ * @return Swift_Mime_Header
+ */
+ public function createIdHeader($name, $ids = null)
+ {
+ $header = new Swift_Mime_Headers_IdentificationHeader($name);
+ if (isset($ids))
+ {
+ $header->setFieldBodyModel($ids);
+ }
+ $this->_setHeaderCharset($header);
+ return $header;
+ }
+
+ /**
+ * Create a new Path header with an address (path) in it.
+ * @param string $name
+ * @param string $path
+ * @return Swift_Mime_Header
+ */
+ public function createPathHeader($name, $path = null)
+ {
+ $header = new Swift_Mime_Headers_PathHeader($name);
+ if (isset($path))
+ {
+ $header->setFieldBodyModel($path);
+ }
+ $this->_setHeaderCharset($header);
+ return $header;
+ }
+
+ /**
+ * Notify this observer that the entity's charset has changed.
+ * @param string $charset
+ */
+ public function charsetChanged($charset)
+ {
+ $this->_charset = $charset;
+ $this->_encoder->charsetChanged($charset);
+ $this->_paramEncoder->charsetChanged($charset);
+ }
+
+ // -- Private methods
+
+ /** Apply the charset to the Header */
+ private function _setHeaderCharset(Swift_Mime_Header $header)
+ {
+ if (isset($this->_charset))
+ {
+ $header->setCharset($this->_charset);
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleHeaderSet.php b/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleHeaderSet.php
new file mode 100644
index 0000000..eeb0221
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleHeaderSet.php
@@ -0,0 +1,396 @@
+_factory = $factory;
+ if (isset($charset))
+ {
+ $this->setCharset($charset);
+ }
+ }
+
+ /**
+ * Set the charset used by these headers.
+ *
+ * @param string $charset
+ */
+ public function setCharset($charset)
+ {
+ $this->_charset = $charset;
+ $this->_factory->charsetChanged($charset);
+ $this->_notifyHeadersOfCharset($charset);
+ }
+
+ /**
+ * Add a new Mailbox Header with a list of $addresses.
+ *
+ * @param string $name
+ * @param array|string $addresses
+ */
+ public function addMailboxHeader($name, $addresses = null)
+ {
+ $this->_storeHeader($name,
+ $this->_factory->createMailboxHeader($name, $addresses));
+ }
+
+ /**
+ * Add a new Date header using $timestamp (UNIX time).
+ *
+ * @param string $name
+ * @param int $timestamp
+ */
+ public function addDateHeader($name, $timestamp = null)
+ {
+ $this->_storeHeader($name,
+ $this->_factory->createDateHeader($name, $timestamp));
+ }
+
+ /**
+ * Add a new basic text header with $name and $value.
+ *
+ * @param string $name
+ * @param string $value
+ */
+ public function addTextHeader($name, $value = null)
+ {
+ $this->_storeHeader($name,
+ $this->_factory->createTextHeader($name, $value));
+ }
+
+ /**
+ * Add a new ParameterizedHeader with $name, $value and $params.
+ *
+ * @param string $name
+ * @param string $value
+ * @param array $params
+ */
+ public function addParameterizedHeader($name, $value = null,
+ $params = array())
+ {
+ $this->_storeHeader($name,
+ $this->_factory->createParameterizedHeader($name, $value,
+ $params));
+ }
+
+ /**
+ * Add a new ID header for Message-ID or Content-ID.
+ *
+ * @param string $name
+ * @param string|array $ids
+ */
+ public function addIdHeader($name, $ids = null)
+ {
+ $this->_storeHeader($name, $this->_factory->createIdHeader($name, $ids));
+ }
+
+ /**
+ * Add a new Path header with an address (path) in it.
+ *
+ * @param string $name
+ * @param string $path
+ */
+ public function addPathHeader($name, $path = null)
+ {
+ $this->_storeHeader($name, $this->_factory->createPathHeader($name, $path));
+ }
+
+ /**
+ * Returns true if at least one header with the given $name exists.
+ *
+ * If multiple headers match, the actual one may be specified by $index.
+ *
+ * @param string $name
+ * @param int $index
+ *
+ * @return boolean
+ */
+ public function has($name, $index = 0)
+ {
+ $lowerName = strtolower($name);
+ return array_key_exists($lowerName, $this->_headers)
+ && array_key_exists($index, $this->_headers[$lowerName]);
+ }
+
+ /**
+ * Set a header in the HeaderSet.
+ *
+ * The header may be a previously fetched header via {@link get()} or it may
+ * be one that has been created separately.
+ *
+ * If $index is specified, the header will be inserted into the set at this
+ * offset.
+ *
+ * @param Swift_Mime_Header $header
+ * @param int $index
+ */
+ public function set(Swift_Mime_Header $header, $index = 0)
+ {
+ $this->_storeHeader($header->getFieldName(), $header, $index);
+ }
+
+ /**
+ * Get the header with the given $name.
+ *
+ * If multiple headers match, the actual one may be specified by $index.
+ * Returns NULL if none present.
+ *
+ * @param string $name
+ * @param int $index
+ *
+ * @return Swift_Mime_Header
+ */
+ public function get($name, $index = 0)
+ {
+ if ($this->has($name, $index))
+ {
+ $lowerName = strtolower($name);
+ return $this->_headers[$lowerName][$index];
+ }
+ }
+
+ /**
+ * Get all headers with the given $name.
+ *
+ * @param string $name
+ *
+ * @return array
+ */
+ public function getAll($name = null)
+ {
+ if (!isset($name))
+ {
+ $headers = array();
+ foreach ($this->_headers as $collection)
+ {
+ $headers = array_merge($headers, $collection);
+ }
+ return $headers;
+ }
+
+ $lowerName = strtolower($name);
+ if (!array_key_exists($lowerName, $this->_headers))
+ {
+ return array();
+ }
+ return $this->_headers[$lowerName];
+ }
+
+ /**
+ * Remove the header with the given $name if it's set.
+ *
+ * If multiple headers match, the actual one may be specified by $index.
+ *
+ * @param string $name
+ * @param int $index
+ */
+ public function remove($name, $index = 0)
+ {
+ $lowerName = strtolower($name);
+ unset($this->_headers[$lowerName][$index]);
+ }
+
+ /**
+ * Remove all headers with the given $name.
+ *
+ * @param string $name
+ */
+ public function removeAll($name)
+ {
+ $lowerName = strtolower($name);
+ unset($this->_headers[$lowerName]);
+ }
+
+ /**
+ * Create a new instance of this HeaderSet.
+ *
+ * @return Swift_Mime_HeaderSet
+ */
+ public function newInstance()
+ {
+ return new self($this->_factory);
+ }
+
+ /**
+ * Define a list of Header names as an array in the correct order.
+ *
+ * These Headers will be output in the given order where present.
+ *
+ * @param array $sequence
+ */
+ public function defineOrdering(array $sequence)
+ {
+ $this->_order = array_flip(array_map('strtolower', $sequence));
+ }
+
+ /**
+ * Set a list of header names which must always be displayed when set.
+ *
+ * Usually headers without a field value won't be output unless set here.
+ *
+ * @param array $names
+ */
+ public function setAlwaysDisplayed(array $names)
+ {
+ $this->_required = array_flip(array_map('strtolower', $names));
+ }
+
+ /**
+ * Notify this observer that the entity's charset has changed.
+ *
+ * @param string $charset
+ */
+ public function charsetChanged($charset)
+ {
+ $this->setCharset($charset);
+ }
+
+ /**
+ * Returns a string with a representation of all headers.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ $string = '';
+ $headers = $this->_headers;
+ if ($this->_canSort())
+ {
+ uksort($headers, array($this, '_sortHeaders'));
+ }
+ foreach ($headers as $collection)
+ {
+ foreach ($collection as $header)
+ {
+ if ($this->_isDisplayed($header) || $header->getFieldBody() != '')
+ {
+ $string .= $header->toString();
+ }
+ }
+ }
+ return $string;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return string
+ *
+ * @see toString()
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+
+ // -- Private methods
+
+ /** Save a Header to the internal collection */
+ private function _storeHeader($name, Swift_Mime_Header $header, $offset = null)
+ {
+ if (!isset($this->_headers[strtolower($name)]))
+ {
+ $this->_headers[strtolower($name)] = array();
+ }
+ if (!isset($offset))
+ {
+ $this->_headers[strtolower($name)][] = $header;
+ }
+ else
+ {
+ $this->_headers[strtolower($name)][$offset] = $header;
+ }
+ }
+
+ /** Test if the headers can be sorted */
+ private function _canSort()
+ {
+ return count($this->_order) > 0;
+ }
+
+ /** uksort() algorithm for Header ordering */
+ private function _sortHeaders($a, $b)
+ {
+ $lowerA = strtolower($a);
+ $lowerB = strtolower($b);
+ $aPos = array_key_exists($lowerA, $this->_order)
+ ? $this->_order[$lowerA]
+ : -1;
+ $bPos = array_key_exists($lowerB, $this->_order)
+ ? $this->_order[$lowerB]
+ : -1;
+
+ if ($aPos == -1)
+ {
+ return 1;
+ }
+ elseif ($bPos == -1)
+ {
+ return -1;
+ }
+
+ return ($aPos < $bPos) ? -1 : 1;
+ }
+
+ /** Test if the given Header is always displayed */
+ private function _isDisplayed(Swift_Mime_Header $header)
+ {
+ return array_key_exists(strtolower($header->getFieldName()), $this->_required);
+ }
+
+ /** Notify all Headers of the new charset */
+ private function _notifyHeadersOfCharset($charset)
+ {
+ foreach ($this->_headers as $headerGroup)
+ {
+ foreach ($headerGroup as $header)
+ {
+ $header->setCharset($charset);
+ }
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleMessage.php b/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleMessage.php
new file mode 100644
index 0000000..bbe1e8f
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleMessage.php
@@ -0,0 +1,609 @@
+getHeaders()->defineOrdering(array(
+ 'Return-Path',
+ 'Sender',
+ 'Message-ID',
+ 'Date',
+ 'Subject',
+ 'From',
+ 'Reply-To',
+ 'To',
+ 'Cc',
+ 'Bcc',
+ 'MIME-Version',
+ 'Content-Type',
+ 'Content-Transfer-Encoding'
+ ));
+ $this->getHeaders()->setAlwaysDisplayed(
+ array('Date', 'Message-ID', 'From')
+ );
+ $this->getHeaders()->addTextHeader('MIME-Version', '1.0');
+ $this->setDate(time());
+ $this->setId($this->getId());
+ $this->getHeaders()->addMailboxHeader('From');
+ }
+
+ /**
+ * Always returns {@link LEVEL_TOP} for a message instance.
+ * @return int
+ */
+ public function getNestingLevel()
+ {
+ return self::LEVEL_TOP;
+ }
+
+ /**
+ * Set the subject of this message.
+ * @param string $subject
+ */
+ public function setSubject($subject)
+ {
+ if (!$this->_setHeaderFieldModel('Subject', $subject))
+ {
+ $this->getHeaders()->addTextHeader('Subject', $subject);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the subject of this message.
+ * @return string
+ */
+ public function getSubject()
+ {
+ return $this->_getHeaderFieldModel('Subject');
+ }
+
+ /**
+ * Set the date at which this message was created.
+ * @param int $date
+ */
+ public function setDate($date)
+ {
+ if (!$this->_setHeaderFieldModel('Date', $date))
+ {
+ $this->getHeaders()->addDateHeader('Date', $date);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the date at which this message was created.
+ * @return int
+ */
+ public function getDate()
+ {
+ return $this->_getHeaderFieldModel('Date');
+ }
+
+ /**
+ * Set the return-path (the bounce address) of this message.
+ * @param string $address
+ */
+ public function setReturnPath($address)
+ {
+ if (!$this->_setHeaderFieldModel('Return-Path', $address))
+ {
+ $this->getHeaders()->addPathHeader('Return-Path', $address);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the return-path (bounce address) of this message.
+ * @return string
+ */
+ public function getReturnPath()
+ {
+ return $this->_getHeaderFieldModel('Return-Path');
+ }
+
+ /**
+ * Set the sender of this message.
+ * This does not override the From field, but it has a higher significance.
+ * @param string $sender
+ * @param string $name optional
+ */
+ public function setSender($address, $name = null)
+ {
+ if (!is_array($address) && isset($name))
+ {
+ $address = array($address => $name);
+ }
+
+ if (!$this->_setHeaderFieldModel('Sender', (array) $address))
+ {
+ $this->getHeaders()->addMailboxHeader('Sender', (array) $address);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the sender of this message.
+ * @return string
+ */
+ public function getSender()
+ {
+ return $this->_getHeaderFieldModel('Sender');
+ }
+
+ /**
+ * Add a From: address to this message.
+ *
+ * If $name is passed this name will be associated with the address.
+ *
+ * @param string $address
+ * @param string $name optional
+ */
+ public function addFrom($address, $name = null)
+ {
+ $current = $this->getFrom();
+ $current[$address] = $name;
+ return $this->setFrom($current);
+ }
+
+ /**
+ * Set the from address of this message.
+ *
+ * You may pass an array of addresses if this message is from multiple people.
+ *
+ * If $name is passed and the first parameter is a string, this name will be
+ * associated with the address.
+ *
+ * @param string $addresses
+ * @param string $name optional
+ */
+ public function setFrom($addresses, $name = null)
+ {
+ if (!is_array($addresses) && isset($name))
+ {
+ $addresses = array($addresses => $name);
+ }
+
+ if (!$this->_setHeaderFieldModel('From', (array) $addresses))
+ {
+ $this->getHeaders()->addMailboxHeader('From', (array) $addresses);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the from address of this message.
+ *
+ * @return string
+ */
+ public function getFrom()
+ {
+ return $this->_getHeaderFieldModel('From');
+ }
+
+ /**
+ * Add a Reply-To: address to this message.
+ *
+ * If $name is passed this name will be associated with the address.
+ *
+ * @param string $address
+ * @param string $name optional
+ */
+ public function addReplyTo($address, $name = null)
+ {
+ $current = $this->getReplyTo();
+ $current[$address] = $name;
+ return $this->setReplyTo($current);
+ }
+
+ /**
+ * Set the reply-to address of this message.
+ *
+ * You may pass an array of addresses if replies will go to multiple people.
+ *
+ * If $name is passed and the first parameter is a string, this name will be
+ * associated with the address.
+ *
+ * @param string $addresses
+ * @param string $name optional
+ */
+ public function setReplyTo($addresses, $name = null)
+ {
+ if (!is_array($addresses) && isset($name))
+ {
+ $addresses = array($addresses => $name);
+ }
+
+ if (!$this->_setHeaderFieldModel('Reply-To', (array) $addresses))
+ {
+ $this->getHeaders()->addMailboxHeader('Reply-To', (array) $addresses);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the reply-to address of this message.
+ *
+ * @return string
+ */
+ public function getReplyTo()
+ {
+ return $this->_getHeaderFieldModel('Reply-To');
+ }
+
+ /**
+ * Add a To: address to this message.
+ *
+ * If $name is passed this name will be associated with the address.
+ *
+ * @param string $address
+ * @param string $name optional
+ */
+ public function addTo($address, $name = null)
+ {
+ $current = $this->getTo();
+ $current[$address] = $name;
+ return $this->setTo($current);
+ }
+
+ /**
+ * Set the to addresses of this message.
+ *
+ * If multiple recipients will receive the message and array should be used.
+ *
+ * If $name is passed and the first parameter is a string, this name will be
+ * associated with the address.
+ *
+ * @param array $addresses
+ * @param string $name optional
+ */
+ public function setTo($addresses, $name = null)
+ {
+ if (!is_array($addresses) && isset($name))
+ {
+ $addresses = array($addresses => $name);
+ }
+
+ if (!$this->_setHeaderFieldModel('To', (array) $addresses))
+ {
+ $this->getHeaders()->addMailboxHeader('To', (array) $addresses);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the To addresses of this message.
+ *
+ * @return array
+ */
+ public function getTo()
+ {
+ return $this->_getHeaderFieldModel('To');
+ }
+
+ /**
+ * Add a Cc: address to this message.
+ *
+ * If $name is passed this name will be associated with the address.
+ *
+ * @param string $address
+ * @param string $name optional
+ */
+ public function addCc($address, $name = null)
+ {
+ $current = $this->getCc();
+ $current[$address] = $name;
+ return $this->setCc($current);
+ }
+
+ /**
+ * Set the Cc addresses of this message.
+ *
+ * If $name is passed and the first parameter is a string, this name will be
+ * associated with the address.
+ *
+ * @param array $addresses
+ * @param string $name optional
+ */
+ public function setCc($addresses, $name = null)
+ {
+ if (!is_array($addresses) && isset($name))
+ {
+ $addresses = array($addresses => $name);
+ }
+
+ if (!$this->_setHeaderFieldModel('Cc', (array) $addresses))
+ {
+ $this->getHeaders()->addMailboxHeader('Cc', (array) $addresses);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the Cc address of this message.
+ *
+ * @return array
+ */
+ public function getCc()
+ {
+ return $this->_getHeaderFieldModel('Cc');
+ }
+
+ /**
+ * Add a Bcc: address to this message.
+ *
+ * If $name is passed this name will be associated with the address.
+ *
+ * @param string $address
+ * @param string $name optional
+ */
+ public function addBcc($address, $name = null)
+ {
+ $current = $this->getBcc();
+ $current[$address] = $name;
+ return $this->setBcc($current);
+ }
+
+ /**
+ * Set the Bcc addresses of this message.
+ *
+ * If $name is passed and the first parameter is a string, this name will be
+ * associated with the address.
+ *
+ * @param array $addresses
+ * @param string $name optional
+ */
+ public function setBcc($addresses, $name = null)
+ {
+ if (!is_array($addresses) && isset($name))
+ {
+ $addresses = array($addresses => $name);
+ }
+
+ if (!$this->_setHeaderFieldModel('Bcc', (array) $addresses))
+ {
+ $this->getHeaders()->addMailboxHeader('Bcc', (array) $addresses);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the Bcc addresses of this message.
+ *
+ * @return array
+ */
+ public function getBcc()
+ {
+ return $this->_getHeaderFieldModel('Bcc');
+ }
+
+ /**
+ * Set the priority of this message.
+ * The value is an integer where 1 is the highest priority and 5 is the lowest.
+ * @param int $priority
+ */
+ public function setPriority($priority)
+ {
+ $priorityMap = array(
+ 1 => 'Highest',
+ 2 => 'High',
+ 3 => 'Normal',
+ 4 => 'Low',
+ 5 => 'Lowest'
+ );
+ $pMapKeys = array_keys($priorityMap);
+ if ($priority > max($pMapKeys))
+ {
+ $priority = max($pMapKeys);
+ }
+ elseif ($priority < min($pMapKeys))
+ {
+ $priority = min($pMapKeys);
+ }
+ if (!$this->_setHeaderFieldModel('X-Priority',
+ sprintf('%d (%s)', $priority, $priorityMap[$priority])))
+ {
+ $this->getHeaders()->addTextHeader('X-Priority',
+ sprintf('%d (%s)', $priority, $priorityMap[$priority]));
+ }
+ return $this;
+ }
+
+ /**
+ * Get the priority of this message.
+ * The returned value is an integer where 1 is the highest priority and 5
+ * is the lowest.
+ * @return int
+ */
+ public function getPriority()
+ {
+ list($priority) = sscanf($this->_getHeaderFieldModel('X-Priority'),
+ '%[1-5]'
+ );
+ return isset($priority) ? $priority : 3;
+ }
+
+ /**
+ * Ask for a delivery receipt from the recipient to be sent to $addresses
+ * @param array $addresses
+ */
+ public function setReadReceiptTo($addresses)
+ {
+ if (!$this->_setHeaderFieldModel('Disposition-Notification-To', $addresses))
+ {
+ $this->getHeaders()
+ ->addMailboxHeader('Disposition-Notification-To', $addresses);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the addresses to which a read-receipt will be sent.
+ * @return string
+ */
+ public function getReadReceiptTo()
+ {
+ return $this->_getHeaderFieldModel('Disposition-Notification-To');
+ }
+
+ /**
+ * Attach a {@link Swift_Mime_MimeEntity} such as an Attachment or MimePart.
+ * @param Swift_Mime_MimeEntity $entity
+ */
+ public function attach(Swift_Mime_MimeEntity $entity)
+ {
+ $this->setChildren(array_merge($this->getChildren(), array($entity)));
+ return $this;
+ }
+
+ /**
+ * Remove an already attached entity.
+ * @param Swift_Mime_MimeEntity $entity
+ */
+ public function detach(Swift_Mime_MimeEntity $entity)
+ {
+ $newChildren = array();
+ foreach ($this->getChildren() as $child)
+ {
+ if ($entity !== $child)
+ {
+ $newChildren[] = $child;
+ }
+ }
+ $this->setChildren($newChildren);
+ return $this;
+ }
+
+ /**
+ * Attach a {@link Swift_Mime_MimeEntity} and return it's CID source.
+ * This method should be used when embedding images or other data in a message.
+ * @param Swift_Mime_MimeEntity $entity
+ * @return string
+ */
+ public function embed(Swift_Mime_MimeEntity $entity)
+ {
+ $this->attach($entity);
+ return 'cid:' . $entity->getId();
+ }
+
+ /**
+ * Get this message as a complete string.
+ * @return string
+ */
+ public function toString()
+ {
+ if (count($children = $this->getChildren()) > 0 && $this->getBody() != '')
+ {
+ $this->setChildren(array_merge(array($this->_becomeMimePart()), $children));
+ $string = parent::toString();
+ $this->setChildren($children);
+ }
+ else
+ {
+ $string = parent::toString();
+ }
+ return $string;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return string
+ *
+ * @see toString()
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * Write this message to a {@link Swift_InputByteStream}.
+ * @param Swift_InputByteStream $is
+ */
+ public function toByteStream(Swift_InputByteStream $is)
+ {
+ if (count($children = $this->getChildren()) > 0 && $this->getBody() != '')
+ {
+ $this->setChildren(array_merge(array($this->_becomeMimePart()), $children));
+ parent::toByteStream($is);
+ $this->setChildren($children);
+ }
+ else
+ {
+ parent::toByteStream($is);
+ }
+ }
+
+ // -- Protected methods
+
+ /** @see Swift_Mime_SimpleMimeEntity::_getIdField() */
+ protected function _getIdField()
+ {
+ return 'Message-ID';
+ }
+
+ // -- Private methods
+
+ /** Turn the body of this message into a child of itself if needed */
+ private function _becomeMimePart()
+ {
+ $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(),
+ $this->_getCache(), $this->_userCharset
+ );
+ $part->setContentType($this->_userContentType);
+ $part->setBody($this->getBody());
+ $part->setFormat($this->_userFormat);
+ $part->setDelSp($this->_userDelSp);
+ $part->_setNestingLevel($this->_getTopNestingLevel());
+ return $part;
+ }
+
+ /** Get the highest nesting level nested inside this message */
+ private function _getTopNestingLevel()
+ {
+ $highestLevel = $this->getNestingLevel();
+ foreach ($this->getChildren() as $child)
+ {
+ $childLevel = $child->getNestingLevel();
+ if ($highestLevel < $childLevel)
+ {
+ $highestLevel = $childLevel;
+ }
+ }
+ return $highestLevel;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleMimeEntity.php b/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleMimeEntity.php
new file mode 100644
index 0000000..1615822
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Mime/SimpleMimeEntity.php
@@ -0,0 +1,803 @@
+ array(self::LEVEL_TOP, self::LEVEL_MIXED),
+ 'multipart/alternative' => array(self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE),
+ 'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED)
+ );
+
+ /** A set of filter rules to define what level an entity should be nested at */
+ private $_compoundLevelFilters = array();
+
+ /** The nesting level of this entity */
+ private $_nestingLevel = self::LEVEL_ALTERNATIVE;
+
+ /** A KeyCache instance used during encoding and streaming */
+ private $_cache;
+
+ /** Direct descendants of this entity */
+ private $_immediateChildren = array();
+
+ /** All descendants of this entity */
+ private $_children = array();
+
+ /** The maximum line length of the body of this entity */
+ private $_maxLineLength = 78;
+
+ /** The order in which alternative mime types should appear */
+ private $_alternativePartOrder = array(
+ 'text/plain' => 1,
+ 'text/html' => 2,
+ 'multipart/related' => 3
+ );
+
+ /** The CID of this entity */
+ private $_id;
+
+ /** The key used for accessing the cache */
+ private $_cacheKey;
+
+ protected $_userContentType;
+
+ /**
+ * Create a new SimpleMimeEntity with $headers, $encoder and $cache.
+ * @param Swift_Mime_HeaderSet $headers
+ * @param Swift_Mime_ContentEncoder $encoder
+ * @param Swift_KeyCache $cache
+ */
+ public function __construct(Swift_Mime_HeaderSet $headers,
+ Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache)
+ {
+ $this->_cacheKey = uniqid();
+ $this->_cache = $cache;
+ $this->_headers = $headers;
+ $this->setEncoder($encoder);
+ $this->_headers->defineOrdering(
+ array('Content-Type', 'Content-Transfer-Encoding')
+ );
+
+ // This array specifies that, when the entire MIME document contains
+ // $compoundLevel, then for each child within $level, if its Content-Type
+ // is $contentType then it should be treated as if it's level is
+ // $neededLevel instead. I tried to write that unambiguously! :-\
+ // Data Structure:
+ // array (
+ // $compoundLevel => array(
+ // $level => array(
+ // $contentType => $neededLevel
+ // )
+ // )
+ // )
+
+ $this->_compoundLevelFilters = array(
+ (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => array(
+ self::LEVEL_ALTERNATIVE => array(
+ 'text/plain' => self::LEVEL_ALTERNATIVE,
+ 'text/html' => self::LEVEL_RELATED
+ )
+ )
+ );
+
+ $this->_id = $this->getRandomId();
+ }
+
+ /**
+ * Generate a new Content-ID or Message-ID for this MIME entity.
+ * @return string
+ */
+ public function generateId()
+ {
+ $this->setId($this->getRandomId());
+ return $this->_id;
+ }
+
+ /**
+ * Get the {@link Swift_Mime_HeaderSet} for this entity.
+ * @return Swift_Mime_HeaderSet
+ */
+ public function getHeaders()
+ {
+ return $this->_headers;
+ }
+
+ /**
+ * Get the nesting level of this entity.
+ * @return int
+ * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE
+ */
+ public function getNestingLevel()
+ {
+ return $this->_nestingLevel;
+ }
+
+ /**
+ * Get the Content-type of this entity.
+ * @return string
+ */
+ public function getContentType()
+ {
+ return $this->_getHeaderFieldModel('Content-Type');
+ }
+
+ /**
+ * Set the Content-type of this entity.
+ * @param string $type
+ */
+ public function setContentType($type)
+ {
+ $this->_setContentTypeInHeaders($type);
+ // Keep track of the value so that if the content-type changes automatically
+ // due to added child entities, it can be restored if they are later removed
+ $this->_userContentType = $type;
+ return $this;
+ }
+
+ /**
+ * Get the CID of this entity.
+ * The CID will only be present in headers if a Content-ID header is present.
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->_headers->has($this->_getIdField())
+ ? current((array) $this->_getHeaderFieldModel($this->_getIdField()))
+ : $this->_id;
+ }
+
+ /**
+ * Set the CID of this entity.
+ * @param string $id
+ */
+ public function setId($id)
+ {
+ if (!$this->_setHeaderFieldModel($this->_getIdField(), $id))
+ {
+ $this->_headers->addIdHeader($this->_getIdField(), $id);
+ }
+ $this->_id = $id;
+ return $this;
+ }
+
+ /**
+ * Get the description of this entity.
+ * This value comes from the Content-Description header if set.
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->_getHeaderFieldModel('Content-Description');
+ }
+
+ /**
+ * Set the description of this entity.
+ * This method sets a value in the Content-ID header.
+ * @param string $description
+ */
+ public function setDescription($description)
+ {
+ if (!$this->_setHeaderFieldModel('Content-Description', $description))
+ {
+ $this->_headers->addTextHeader('Content-Description', $description);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the maximum line length of the body of this entity.
+ * @return int
+ */
+ public function getMaxLineLength()
+ {
+ return $this->_maxLineLength;
+ }
+
+ /**
+ * Set the maximum line length of lines in this body.
+ * Though not enforced by the library, lines should not exceed 1000 chars.
+ * @param int $length
+ */
+ public function setMaxLineLength($length)
+ {
+ $this->_maxLineLength = $length;
+ return $this;
+ }
+
+ /**
+ * Get all children added to this entity.
+ * @return array of Swift_Mime_Entity
+ */
+ public function getChildren()
+ {
+ return $this->_children;
+ }
+
+ /**
+ * Set all children of this entity.
+ * @param array $children Swiift_Mime_Entity instances
+ * @param int $compoundLevel For internal use only
+ */
+ public function setChildren(array $children, $compoundLevel = null)
+ {
+ //TODO: Try to refactor this logic
+
+ $compoundLevel = isset($compoundLevel)
+ ? $compoundLevel
+ : $this->_getCompoundLevel($children)
+ ;
+
+ $immediateChildren = array();
+ $grandchildren = array();
+ $newContentType = $this->_userContentType;
+
+ foreach ($children as $child)
+ {
+ $level = $this->_getNeededChildLevel($child, $compoundLevel);
+ if (empty($immediateChildren)) //first iteration
+ {
+ $immediateChildren = array($child);
+ }
+ else
+ {
+ $nextLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel);
+ if ($nextLevel == $level)
+ {
+ $immediateChildren[] = $child;
+ }
+ elseif ($level < $nextLevel)
+ {
+ //Re-assign immediateChildren to grandchilden
+ $grandchildren = array_merge($grandchildren, $immediateChildren);
+ //Set new children
+ $immediateChildren = array($child);
+ }
+ else
+ {
+ $grandchildren[] = $child;
+ }
+ }
+ }
+
+ if (!empty($immediateChildren))
+ {
+ $lowestLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel);
+
+ //Determine which composite media type is needed to accomodate the
+ // immediate children
+ foreach ($this->_compositeRanges as $mediaType => $range)
+ {
+ if ($lowestLevel > $range[0]
+ && $lowestLevel <= $range[1])
+ {
+ $newContentType = $mediaType;
+ break;
+ }
+ }
+
+ //Put any grandchildren in a subpart
+ if (!empty($grandchildren))
+ {
+ $subentity = $this->_createChild();
+ $subentity->_setNestingLevel($lowestLevel);
+ $subentity->setChildren($grandchildren, $compoundLevel);
+ array_unshift($immediateChildren, $subentity);
+ }
+ }
+
+ $this->_immediateChildren = $immediateChildren;
+ $this->_children = $children;
+ $this->_setContentTypeInHeaders($newContentType);
+ $this->_fixHeaders();
+ $this->_sortChildren();
+
+ return $this;
+ }
+
+ /**
+ * Get the body of this entity as a string.
+ * @return string
+ */
+ public function getBody()
+ {
+ return ($this->_body instanceof Swift_OutputByteStream)
+ ? $this->_readStream($this->_body)
+ : $this->_body;
+ }
+
+ /**
+ * Set the body of this entity, either as a string, or as an instance of
+ * {@link Swift_OutputByteStream}.
+ * @param mixed $body
+ * @param string $contentType optional
+ */
+ public function setBody($body, $contentType = null)
+ {
+ if ($body !== $this->_body)
+ {
+ $this->_clearCache();
+ }
+
+ $this->_body = $body;
+ if (isset($contentType))
+ {
+ $this->setContentType($contentType);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the encoder used for the body of this entity.
+ * @return Swift_Mime_ContentEncoder
+ */
+ public function getEncoder()
+ {
+ return $this->_encoder;
+ }
+
+ /**
+ * Set the encoder used for the body of this entity.
+ * @param Swift_Mime_ContentEncoder $encoder
+ */
+ public function setEncoder(Swift_Mime_ContentEncoder $encoder)
+ {
+ if ($encoder !== $this->_encoder)
+ {
+ $this->_clearCache();
+ }
+
+ $this->_encoder = $encoder;
+ $this->_setEncoding($encoder->getName());
+ $this->_notifyEncoderChanged($encoder);
+ return $this;
+ }
+
+ /**
+ * Get the boundary used to separate children in this entity.
+ * @return string
+ */
+ public function getBoundary()
+ {
+ if (!isset($this->_boundary))
+ {
+ $this->_boundary = '_=_swift_v4_' . time() . uniqid() . '_=_';
+ }
+ return $this->_boundary;
+ }
+
+ /**
+ * Set the boundary used to separate children in this entity.
+ * @param string $boundary
+ * @throws Swift_RfcComplianceException
+ */
+ public function setBoundary($boundary)
+ {
+ $this->_assertValidBoundary($boundary);
+ $this->_boundary = $boundary;
+ return $this;
+ }
+
+ /**
+ * Receive notification that the charset of this entity, or a parent entity
+ * has changed.
+ * @param string $charset
+ */
+ public function charsetChanged($charset)
+ {
+ $this->_notifyCharsetChanged($charset);
+ }
+
+ /**
+ * Receive notification that the encoder of this entity or a parent entity
+ * has changed.
+ * @param Swift_Mime_ContentEncoder $encoder
+ */
+ public function encoderChanged(Swift_Mime_ContentEncoder $encoder)
+ {
+ $this->_notifyEncoderChanged($encoder);
+ }
+
+ /**
+ * Get this entire entity as a string.
+ * @return string
+ */
+ public function toString()
+ {
+ $string = $this->_headers->toString();
+ if (isset($this->_body) && empty($this->_immediateChildren))
+ {
+ if ($this->_cache->hasKey($this->_cacheKey, 'body'))
+ {
+ $body = $this->_cache->getString($this->_cacheKey, 'body');
+ }
+ else
+ {
+ $body = "\r\n" . $this->_encoder->encodeString($this->getBody(), 0,
+ $this->getMaxLineLength()
+ );
+ $this->_cache->setString($this->_cacheKey, 'body', $body,
+ Swift_KeyCache::MODE_WRITE
+ );
+ }
+ $string .= $body;
+ }
+
+ if (!empty($this->_immediateChildren))
+ {
+ foreach ($this->_immediateChildren as $child)
+ {
+ $string .= "\r\n\r\n--" . $this->getBoundary() . "\r\n";
+ $string .= $child->toString();
+ }
+ $string .= "\r\n\r\n--" . $this->getBoundary() . "--\r\n";
+ }
+
+ return $string;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return string
+ *
+ * @see toString()
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * Write this entire entity to a {@link Swift_InputByteStream}.
+ * @param Swift_InputByteStream
+ */
+ public function toByteStream(Swift_InputByteStream $is)
+ {
+ $is->write($this->_headers->toString());
+ $is->commit();
+
+ if (empty($this->_immediateChildren))
+ {
+ if (isset($this->_body))
+ {
+ if ($this->_cache->hasKey($this->_cacheKey, 'body'))
+ {
+ $this->_cache->exportToByteStream($this->_cacheKey, 'body', $is);
+ }
+ else
+ {
+ $cacheIs = $this->_cache->getInputByteStream($this->_cacheKey, 'body');
+ if ($cacheIs)
+ {
+ $is->bind($cacheIs);
+ }
+
+ $is->write("\r\n");
+
+ if ($this->_body instanceof Swift_OutputByteStream)
+ {
+ $this->_body->setReadPointer(0);
+
+ $this->_encoder->encodeByteStream($this->_body, $is, 0,
+ $this->getMaxLineLength()
+ );
+ }
+ else
+ {
+ $is->write($this->_encoder->encodeString(
+ $this->getBody(), 0, $this->getMaxLineLength()
+ ));
+ }
+
+ if ($cacheIs)
+ {
+ $is->unbind($cacheIs);
+ }
+ }
+ }
+ }
+
+ if (!empty($this->_immediateChildren))
+ {
+ foreach ($this->_immediateChildren as $child)
+ {
+ $is->write("\r\n\r\n--" . $this->getBoundary() . "\r\n");
+ $child->toByteStream($is);
+ }
+ $is->write("\r\n\r\n--" . $this->getBoundary() . "--\r\n");
+ }
+ }
+
+ // -- Protected methods
+
+ /**
+ * Get the name of the header that provides the ID of this entity */
+ protected function _getIdField()
+ {
+ return 'Content-ID';
+ }
+
+ /**
+ * Get the model data (usually an array or a string) for $field.
+ */
+ protected function _getHeaderFieldModel($field)
+ {
+ if ($this->_headers->has($field))
+ {
+ return $this->_headers->get($field)->getFieldBodyModel();
+ }
+ }
+
+ /**
+ * Set the model data for $field.
+ */
+ protected function _setHeaderFieldModel($field, $model)
+ {
+ if ($this->_headers->has($field))
+ {
+ $this->_headers->get($field)->setFieldBodyModel($model);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Get the parameter value of $parameter on $field header.
+ */
+ protected function _getHeaderParameter($field, $parameter)
+ {
+ if ($this->_headers->has($field))
+ {
+ return $this->_headers->get($field)->getParameter($parameter);
+ }
+ }
+
+ /**
+ * Set the parameter value of $parameter on $field header.
+ */
+ protected function _setHeaderParameter($field, $parameter, $value)
+ {
+ if ($this->_headers->has($field))
+ {
+ $this->_headers->get($field)->setParameter($parameter, $value);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Re-evaluate what content type and encoding should be used on this entity.
+ */
+ protected function _fixHeaders()
+ {
+ if (count($this->_immediateChildren))
+ {
+ $this->_setHeaderParameter('Content-Type', 'boundary',
+ $this->getBoundary()
+ );
+ $this->_headers->remove('Content-Transfer-Encoding');
+ }
+ else
+ {
+ $this->_setHeaderParameter('Content-Type', 'boundary', null);
+ $this->_setEncoding($this->_encoder->getName());
+ }
+ }
+
+ /**
+ * Get the KeyCache used in this entity.
+ */
+ protected function _getCache()
+ {
+ return $this->_cache;
+ }
+
+ /**
+ * Empty the KeyCache for this entity.
+ */
+ protected function _clearCache()
+ {
+ $this->_cache->clearKey($this->_cacheKey, 'body');
+ }
+
+ /**
+ * Returns a random Content-ID or Message-ID.
+ * @return string
+ */
+ protected function getRandomId()
+ {
+ $idLeft = time() . '.' . uniqid();
+ $idRight = !empty($_SERVER['SERVER_NAME'])
+ ? $_SERVER['SERVER_NAME']
+ : 'swift.generated';
+ return $idLeft . '@' . $idRight;
+ }
+
+ // -- Private methods
+
+ private function _readStream(Swift_OutputByteStream $os)
+ {
+ $string = '';
+ while (false !== $bytes = $os->read(8192))
+ {
+ $string .= $bytes;
+ }
+ return $string;
+ }
+
+ private function _setEncoding($encoding)
+ {
+ if (!$this->_setHeaderFieldModel('Content-Transfer-Encoding', $encoding))
+ {
+ $this->_headers->addTextHeader('Content-Transfer-Encoding', $encoding);
+ }
+ }
+
+ private function _assertValidBoundary($boundary)
+ {
+ if (!preg_match(
+ '/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di',
+ $boundary))
+ {
+ throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.');
+ }
+ }
+
+ private function _setContentTypeInHeaders($type)
+ {
+ if (!$this->_setHeaderFieldModel('Content-Type', $type))
+ {
+ $this->_headers->addParameterizedHeader('Content-Type', $type);
+ }
+ }
+
+ private function _setNestingLevel($level)
+ {
+ $this->_nestingLevel = $level;
+ }
+
+ private function _getCompoundLevel($children)
+ {
+ $level = 0;
+ foreach ($children as $child)
+ {
+ $level |= $child->getNestingLevel();
+ }
+ return $level;
+ }
+
+ private function _getNeededChildLevel($child, $compoundLevel)
+ {
+ $filter = array();
+ foreach ($this->_compoundLevelFilters as $bitmask => $rules)
+ {
+ if (($compoundLevel & $bitmask) === $bitmask)
+ {
+ $filter = $rules + $filter;
+ }
+ }
+
+ $realLevel = $child->getNestingLevel();
+ $lowercaseType = strtolower($child->getContentType());
+
+ if (isset($filter[$realLevel])
+ && isset($filter[$realLevel][$lowercaseType]))
+ {
+ return $filter[$realLevel][$lowercaseType];
+ }
+ else
+ {
+ return $realLevel;
+ }
+ }
+
+ private function _createChild()
+ {
+ return new self($this->_headers->newInstance(),
+ $this->_encoder, $this->_cache);
+ }
+
+ private function _notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder)
+ {
+ foreach ($this->_immediateChildren as $child)
+ {
+ $child->encoderChanged($encoder);
+ }
+ }
+
+ private function _notifyCharsetChanged($charset)
+ {
+ $this->_encoder->charsetChanged($charset);
+ $this->_headers->charsetChanged($charset);
+ foreach ($this->_immediateChildren as $child)
+ {
+ $child->charsetChanged($charset);
+ }
+ }
+
+ private function _sortChildren()
+ {
+ $shouldSort = false;
+ foreach ($this->_immediateChildren as $child)
+ {
+ //NOTE: This include alternative parts moved into a related part
+ if ($child->getNestingLevel() == self::LEVEL_ALTERNATIVE)
+ {
+ $shouldSort = true;
+ break;
+ }
+ }
+
+ //Sort in order of preference, if there is one
+ if ($shouldSort)
+ {
+ usort($this->_immediateChildren, array($this, '_childSortAlgorithm'));
+ }
+ }
+
+ private function _childSortAlgorithm($a, $b)
+ {
+ $typePrefs = array();
+ $types = array(
+ strtolower($a->getContentType()),
+ strtolower($b->getContentType())
+ );
+ foreach ($types as $type)
+ {
+ $typePrefs[] = (array_key_exists($type, $this->_alternativePartOrder))
+ ? $this->_alternativePartOrder[$type]
+ : (max($this->_alternativePartOrder) + 1);
+ }
+ return ($typePrefs[0] >= $typePrefs[1]) ? 1 : -1;
+ }
+
+ // -- Destructor
+
+ /**
+ * Empties it's own contents from the cache.
+ */
+ public function __destruct()
+ {
+ $this->_cache->clearAll($this->_cacheKey);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/MimePart.php b/modules/khemail/vendor/swift/classes/Swift/MimePart.php
new file mode 100644
index 0000000..60b6d56
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/MimePart.php
@@ -0,0 +1,65 @@
+createDependenciesFor('mime.part')
+ );
+
+ if (!isset($charset))
+ {
+ $charset = Swift_DependencyContainer::getInstance()
+ ->lookup('properties.charset');
+ }
+ $this->setBody($body);
+ $this->setCharset($charset);
+ if ($contentType)
+ {
+ $this->setContentType($contentType);
+ }
+ }
+
+ /**
+ * Create a new MimePart.
+ * @param string $body
+ * @param string $contentType
+ * @param string $charset
+ * @return Swift_Mime_MimePart
+ */
+ public static function newInstance($body = null, $contentType = null,
+ $charset = null)
+ {
+ return new self($body, $contentType, $charset);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/OutputByteStream.php b/modules/khemail/vendor/swift/classes/Swift/OutputByteStream.php
new file mode 100644
index 0000000..951b838
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/OutputByteStream.php
@@ -0,0 +1,41 @@
+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/modules/khemail/vendor/swift/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/BandwidthMonitorPlugin.php
new file mode 100644
index 0000000..501cd80
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/BandwidthMonitorPlugin.php
@@ -0,0 +1,173 @@
+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/modules/khemail/vendor/swift/classes/Swift/Plugins/Decorator/Replacements.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Decorator/Replacements.php
new file mode 100644
index 0000000..9735d0a
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Decorator/Replacements.php
@@ -0,0 +1,36 @@
+
+ * $replacements = array(
+ * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"),
+ * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y")
+ * )
+ *
+ *
+ * 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/modules/khemail/vendor/swift/classes/Swift/Plugins/Logger.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Logger.php
new file mode 100644
index 0000000..9864da0
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Logger.php
@@ -0,0 +1,37 @@
+_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/modules/khemail/vendor/swift/classes/Swift/Plugins/Loggers/ArrayLogger.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Loggers/ArrayLogger.php
new file mode 100644
index 0000000..930eca2
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Loggers/ArrayLogger.php
@@ -0,0 +1,73 @@
+_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/modules/khemail/vendor/swift/classes/Swift/Plugins/Loggers/EchoLogger.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Loggers/EchoLogger.php
new file mode 100644
index 0000000..83dd54b
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Loggers/EchoLogger.php
@@ -0,0 +1,64 @@
+_isHtml = $isHtml;
+ }
+
+ /**
+ * Add a log entry.
+ * @param string $entry
+ */
+ public function add($entry)
+ {
+ if ($this->_isHtml)
+ {
+ printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '
', PHP_EOL);
+ }
+ else
+ {
+ printf('%s%s', $entry, PHP_EOL);
+ }
+ }
+
+ /**
+ * Not implemented.
+ */
+ public function clear()
+ {
+ }
+
+ /**
+ * Not implemented.
+ */
+ public function dump()
+ {
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Plugins/Pop/Pop3Connection.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Pop/Pop3Connection.php
new file mode 100644
index 0000000..1c96dcf
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Pop/Pop3Connection.php
@@ -0,0 +1,36 @@
+_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/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporter.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporter.php
new file mode 100644
index 0000000..00d5765
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporter.php
@@ -0,0 +1,36 @@
+_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/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporters/HitReporter.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporters/HitReporter.php
new file mode 100644
index 0000000..0022f5e
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporters/HitReporter.php
@@ -0,0 +1,63 @@
+_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/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporters/HtmlReporter.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporters/HtmlReporter.php
new file mode 100644
index 0000000..7370078
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Reporters/HtmlReporter.php
@@ -0,0 +1,47 @@
+" . PHP_EOL;
+ echo "PASS " . $address . PHP_EOL;
+ echo "" . PHP_EOL;
+ flush();
+ }
+ else
+ {
+ echo "" . PHP_EOL;
+ echo "FAIL " . $address . PHP_EOL;
+ echo "
" . PHP_EOL;
+ flush();
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Plugins/Sleeper.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Sleeper.php
new file mode 100644
index 0000000..148cbd3
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Sleeper.php
@@ -0,0 +1,26 @@
+_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/modules/khemail/vendor/swift/classes/Swift/Plugins/Timer.php b/modules/khemail/vendor/swift/classes/Swift/Plugins/Timer.php
new file mode 100644
index 0000000..92207bf
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Plugins/Timer.php
@@ -0,0 +1,26 @@
+register('properties.charset')->asValue($charset);
+ return $this;
+ }
+
+ /**
+ * Set the directory where temporary files can be saved.
+ * @param string $dir
+ * @return Swift_Preferences
+ */
+ public function setTempDir($dir)
+ {
+ Swift_DependencyContainer::getInstance()
+ ->register('tempdir')->asValue($dir);
+ return $this;
+ }
+
+ /**
+ * Set the type of cache to use (i.e. "disk" or "array").
+ * @param string $type
+ * @return Swift_Preferences
+ */
+ public function setCacheType($type)
+ {
+ Swift_DependencyContainer::getInstance()
+ ->register('cache')->asAliasOf(sprintf('cache.%s', $type));
+ return $this;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/ReplacementFilterFactory.php b/modules/khemail/vendor/swift/classes/Swift/ReplacementFilterFactory.php
new file mode 100644
index 0000000..db29e6d
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/ReplacementFilterFactory.php
@@ -0,0 +1,27 @@
+createDependenciesFor('transport.sendmail')
+ );
+
+ $this->setCommand($command);
+ }
+
+ /**
+ * Create a new SendmailTransport instance.
+ * @param string $command
+ * @return Swift_SendmailTransport
+ */
+ public static function newInstance($command = '/usr/sbin/sendmail -bs')
+ {
+ return new self($command);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/SmtpTransport.php b/modules/khemail/vendor/swift/classes/Swift/SmtpTransport.php
new file mode 100644
index 0000000..65180d5
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/SmtpTransport.php
@@ -0,0 +1,56 @@
+createDependenciesFor('transport.smtp')
+ );
+
+ $this->setHost($host);
+ $this->setPort($port);
+ $this->setEncryption($security);
+ }
+
+ /**
+ * Create a new SmtpTransport instance.
+ * @param string $host
+ * @param int $port
+ * @param int $security
+ * @return Swift_SmtpTransport
+ */
+ public static function newInstance($host = 'localhost', $port = 25,
+ $security = null)
+ {
+ return new self($host, $port, $security);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/StreamFilter.php b/modules/khemail/vendor/swift/classes/Swift/StreamFilter.php
new file mode 100644
index 0000000..6c262ce
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/StreamFilter.php
@@ -0,0 +1,33 @@
+_search = $search;
+ $this->_index = array();
+ $this->_tree = array();
+ $this->_replace = array();
+ $this->_repSize = array();
+
+ $tree = null;
+ $i = null;
+ $last_size = $size = 0;
+ foreach ($search as $i => $search_element)
+ {
+ if ($tree !== null)
+ {
+ $tree[-1] = min (count($replace) - 1, $i - 1);
+ $tree[-2] = $last_size;
+ }
+ $tree = &$this->_tree;
+ if (is_array ($search_element))
+ {
+ foreach ($search_element as $k => $char)
+ {
+ $this->_index[$char] = true;
+ if (!isset($tree[$char]))
+ {
+ $tree[$char] = array();
+ }
+ $tree = &$tree[$char];
+ }
+ $last_size = $k+1;
+ $size = max($size, $last_size);
+ }
+ else
+ {
+ $last_size = 1;
+ if (!isset($tree[$search_element]))
+ {
+ $tree[$search_element] = array();
+ }
+ $tree = &$tree[$search_element];
+ $size = max($last_size, $size);
+ $this->_index[$search_element] = true;
+ }
+ }
+ if ($i !== null)
+ {
+ $tree[-1] = min (count ($replace) - 1, $i);
+ $tree[-2] = $last_size;
+ $this->_treeMaxLen = $size;
+ }
+ foreach ($replace as $rep)
+ {
+ if (!is_array($rep))
+ {
+ $rep = array ($rep);
+ }
+ $this->_replace[] = $rep;
+ }
+ for ($i = count($this->_replace) - 1; $i >= 0; --$i)
+ {
+ $this->_replace[$i] = $rep = $this->filter($this->_replace[$i], $i);
+ $this->_repSize[$i] = count($rep);
+ }
+ }
+
+ /**
+ * Returns true if based on the buffer passed more bytes should be buffered.
+ * @param array $buffer
+ * @return boolean
+ */
+ public function shouldBuffer($buffer)
+ {
+ $endOfBuffer = end($buffer);
+ return isset ($this->_index[$endOfBuffer]);
+ }
+
+ /**
+ * Perform the actual replacements on $buffer and return the result.
+ * @param array $buffer
+ * @return array
+ */
+ public function filter($buffer, $_minReplaces = -1)
+ {
+ if ($this->_treeMaxLen == 0)
+ {
+ return $buffer;
+ }
+
+ $newBuffer = array();
+ $buf_size = count($buffer);
+ for ($i = 0; $i < $buf_size; ++$i)
+ {
+ $search_pos = $this->_tree;
+ $last_found = PHP_INT_MAX;
+ // We try to find if the next byte is part of a search pattern
+ for ($j = 0; $j <= $this->_treeMaxLen; ++$j)
+ {
+ // We have a new byte for a search pattern
+ if (isset ($buffer [$p = $i + $j]) && isset($search_pos[$buffer[$p]]))
+ {
+ $search_pos = $search_pos[$buffer[$p]];
+ // We have a complete pattern, save, in case we don't find a better match later
+ if (isset($search_pos[- 1]) && $search_pos[-1] < $last_found
+ && $search_pos[-1] > $_minReplaces)
+ {
+ $last_found = $search_pos[-1];
+ $last_size = $search_pos[-2];
+ }
+ }
+ // We got a complete pattern
+ elseif ($last_found !== PHP_INT_MAX)
+ {
+ // Adding replacement datas to output buffer
+ $rep_size = $this->_repSize[$last_found];
+ for ($j = 0; $j < $rep_size; ++$j)
+ {
+ $newBuffer[] = $this->_replace[$last_found][$j];
+ }
+ // We Move cursor forward
+ $i += $last_size - 1;
+ // Edge Case, last position in buffer
+ if ($i >= $buf_size)
+ {
+ $newBuffer[] = $buffer[$i];
+ }
+
+ // We start the next loop
+ continue 2;
+ }
+ else
+ {
+ // this byte is not in a pattern and we haven't found another pattern
+ break;
+ }
+ }
+ // Normal byte, move it to output buffer
+ $newBuffer[] = $buffer[$i];
+ }
+
+ return $newBuffer;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/StreamFilters/StringReplacementFilter.php b/modules/khemail/vendor/swift/classes/Swift/StreamFilters/StringReplacementFilter.php
new file mode 100644
index 0000000..9ab6c30
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/StreamFilters/StringReplacementFilter.php
@@ -0,0 +1,66 @@
+_search = $search;
+ $this->_replace = $replace;
+ }
+
+ /**
+ * Returns true if based on the buffer passed more bytes should be buffered.
+ * @param string $buffer
+ * @return boolean
+ */
+ public function shouldBuffer($buffer)
+ {
+ $endOfBuffer = substr($buffer, -1);
+ foreach ((array) $this->_search as $needle)
+ {
+ if (false !== strpos($needle, $endOfBuffer))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Perform the actual replacements on $buffer and return the result.
+ * @param string $buffer
+ * @return string
+ */
+ public function filter($buffer)
+ {
+ return str_replace($this->_search, $this->_replace, $buffer);
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/modules/khemail/vendor/swift/classes/Swift/StreamFilters/StringReplacementFilterFactory.php
new file mode 100644
index 0000000..fcd4b83
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/StreamFilters/StringReplacementFilterFactory.php
@@ -0,0 +1,53 @@
+_filters[$search][$replace]))
+ {
+ if (!isset($this->_filters[$search]))
+ {
+ $this->_filters[$search] = array();
+ }
+
+ if (!isset($this->_filters[$search][$replace]))
+ {
+ $this->_filters[$search][$replace] = array();
+ }
+
+ $this->_filters[$search][$replace]
+ = new Swift_StreamFilters_StringReplacementFilter($search, $replace);
+ }
+
+ return $this->_filters[$search][$replace];
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/SwiftException.php b/modules/khemail/vendor/swift/classes/Swift/SwiftException.php
new file mode 100644
index 0000000..bd3b656
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/SwiftException.php
@@ -0,0 +1,28 @@
+_eventDispatcher = $dispatcher;
+ $this->_buffer = $buf;
+ $this->_lookupHostname();
+ }
+
+ /**
+ * Set the name of the local domain which Swift will identify itself as.
+ * This should be a fully-qualified domain name and should be truly the domain
+ * you're using. If your server doesn't have a domain name, use the IP in square
+ * brackets (i.e. [127.0.0.1]).
+ *
+ * @param string $domain
+ */
+ public function setLocalDomain($domain)
+ {
+ $this->_domain = $domain;
+ return $this;
+ }
+
+ /**
+ * Get the name of the domain Swift will identify as.
+ *
+ * @return string
+ */
+ public function getLocalDomain()
+ {
+ return $this->_domain;
+ }
+
+ /**
+ * Start the SMTP connection.
+ */
+ public function start()
+ {
+ if (!$this->_started)
+ {
+ if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this))
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted');
+ if ($evt->bubbleCancelled())
+ {
+ return;
+ }
+ }
+
+ try
+ {
+ $this->_buffer->initialize($this->_getBufferParams());
+ }
+ catch (Swift_TransportException $e)
+ {
+ $this->_throwException($e);
+ }
+ $this->_readGreeting();
+ $this->_doHeloCommand();
+
+ if ($evt)
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'transportStarted');
+ }
+
+ $this->_started = true;
+ }
+ }
+
+ /**
+ * Test if an SMTP connection has been established.
+ *
+ * @return boolean
+ */
+ public function isStarted()
+ {
+ return $this->_started;
+ }
+
+ /**
+ * Send the given Message.
+ *
+ * Recipient/sender data will be retreived from the Message API.
+ * The return value is the number of recipients who were accepted for delivery.
+ *
+ * @param Swift_Mime_Message $message
+ * @param string[] &$failedRecipients to collect failures by-reference
+ * @return int
+ */
+ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ {
+ $sent = 0;
+ $failedRecipients = (array) $failedRecipients;
+
+ if (!$reversePath = $this->_getReversePath($message))
+ {
+ throw new Swift_TransportException(
+ 'Cannot send message without a sender address'
+ );
+ }
+
+ if ($evt = $this->_eventDispatcher->createSendEvent($this, $message))
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
+ if ($evt->bubbleCancelled())
+ {
+ return 0;
+ }
+ }
+
+ $to = (array) $message->getTo();
+ $cc = (array) $message->getCc();
+ $bcc = (array) $message->getBcc();
+
+ $message->setBcc(array());
+
+ try
+ {
+ $sent += $this->_sendTo($message, $reversePath, $to, $failedRecipients);
+ $sent += $this->_sendCc($message, $reversePath, $cc, $failedRecipients);
+ $sent += $this->_sendBcc($message, $reversePath, $bcc, $failedRecipients);
+ }
+ catch (Exception $e)
+ {
+ $message->setBcc($bcc);
+ throw $e;
+ }
+
+ $message->setBcc($bcc);
+
+ if ($evt)
+ {
+ if ($sent == count($to) + count($cc) + count($bcc))
+ {
+ $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
+ }
+ elseif ($sent > 0)
+ {
+ $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE);
+ }
+ else
+ {
+ $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED);
+ }
+ $evt->setFailedRecipients($failedRecipients);
+ $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
+ }
+
+ $message->generateId(); //Make sure a new Message ID is used
+
+ return $sent;
+ }
+
+ /**
+ * Stop the SMTP connection.
+ */
+ public function stop()
+ {
+ if ($this->_started)
+ {
+ if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this))
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped');
+ if ($evt->bubbleCancelled())
+ {
+ return;
+ }
+ }
+
+ try
+ {
+ $this->executeCommand("QUIT\r\n", array(221));
+ }
+ catch (Swift_TransportException $e) {}
+
+ try
+ {
+ $this->_buffer->terminate();
+
+ if ($evt)
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'transportStopped');
+ }
+ }
+ catch (Swift_TransportException $e)
+ {
+ $this->_throwException($e);
+ }
+ }
+ $this->_started = false;
+ }
+
+ /**
+ * Register a plugin.
+ *
+ * @param Swift_Events_EventListener $plugin
+ */
+ public function registerPlugin(Swift_Events_EventListener $plugin)
+ {
+ $this->_eventDispatcher->bindEventListener($plugin);
+ }
+
+ /**
+ * Reset the current mail transaction.
+ */
+ public function reset()
+ {
+ $this->executeCommand("RSET\r\n", array(250));
+ }
+
+ /**
+ * Get the IoBuffer where read/writes are occurring.
+ *
+ * @return Swift_Transport_IoBuffer
+ */
+ public function getBuffer()
+ {
+ return $this->_buffer;
+ }
+
+ /**
+ * Run a command against the buffer, expecting the given response codes.
+ *
+ * If no response codes are given, the response will not be validated.
+ * If codes are given, an exception will be thrown on an invalid response.
+ *
+ * @param string $command
+ * @param int[] $codes
+ * @param string[] &$failures
+ * @return string
+ */
+ public function executeCommand($command, $codes = array(), &$failures = null)
+ {
+ $failures = (array) $failures;
+ $seq = $this->_buffer->write($command);
+ $response = $this->_getFullResponse($seq);
+ if ($evt = $this->_eventDispatcher->createCommandEvent($this, $command, $codes))
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'commandSent');
+ }
+ $this->_assertResponseCode($response, $codes);
+ return $response;
+ }
+
+ // -- Protected methods
+
+ /** Read the opening SMTP greeting */
+ protected function _readGreeting()
+ {
+ $this->_assertResponseCode($this->_getFullResponse(0), array(220));
+ }
+
+ /** Send the HELO welcome */
+ protected function _doHeloCommand()
+ {
+ $this->executeCommand(
+ sprintf("HELO %s\r\n", $this->_domain), array(250)
+ );
+ }
+
+ /** Send the MAIL FROM command */
+ protected function _doMailFromCommand($address)
+ {
+ $this->executeCommand(
+ sprintf("MAIL FROM: <%s>\r\n", $address), array(250)
+ );
+ }
+
+ /** Send the RCPT TO command */
+ protected function _doRcptToCommand($address)
+ {
+ $this->executeCommand(
+ sprintf("RCPT TO: <%s>\r\n", $address), array(250, 251, 252)
+ );
+ }
+
+ /** Send the DATA command */
+ protected function _doDataCommand()
+ {
+ $this->executeCommand("DATA\r\n", array(354));
+ }
+
+ /** Stream the contents of the message over the buffer */
+ protected function _streamMessage(Swift_Mime_Message $message)
+ {
+ $this->_buffer->setWriteTranslations(array("\r\n." => "\r\n.."));
+ try
+ {
+ $message->toByteStream($this->_buffer);
+ $this->_buffer->flushBuffers();
+ }
+ catch (Swift_TransportException $e)
+ {
+ $this->_throwException($e);
+ }
+ $this->_buffer->setWriteTranslations(array());
+ $this->executeCommand("\r\n.\r\n", array(250));
+ }
+
+ /** Determine the best-use reverse path for this message */
+ protected function _getReversePath(Swift_Mime_Message $message)
+ {
+ $return = $message->getReturnPath();
+ $sender = $message->getSender();
+ $from = $message->getFrom();
+ $path = null;
+ if (!empty($return))
+ {
+ $path = $return;
+ }
+ elseif (!empty($sender))
+ {
+ // Don't use array_keys
+ reset($sender); // Reset Pointer to first pos
+ $path = key($sender); // Get key
+ }
+ elseif (!empty($from))
+ {
+ reset($from); // Reset Pointer to first pos
+ $path = key($from); // Get key
+ }
+ return $path;
+ }
+
+ /** Throw a TransportException, first sending it to any listeners */
+ protected function _throwException(Swift_TransportException $e)
+ {
+ if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e))
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown');
+ if (!$evt->bubbleCancelled())
+ {
+ throw $e;
+ }
+ }
+ else
+ {
+ throw $e;
+ }
+ }
+
+ /** Throws an Exception if a response code is incorrect */
+ protected function _assertResponseCode($response, $wanted)
+ {
+ list($code, $separator, $text) = sscanf($response, '%3d%[ -]%s');
+ $valid = (empty($wanted) || in_array($code, $wanted));
+
+ if ($evt = $this->_eventDispatcher->createResponseEvent($this, $response,
+ $valid))
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'responseReceived');
+ }
+
+ if (!$valid)
+ {
+ $this->_throwException(
+ new Swift_TransportException(
+ 'Expected response code ' . implode('/', $wanted) . ' but got code ' .
+ '"' . $code . '", with message "' . $response . '"'
+ )
+ );
+ }
+ }
+
+ /** Get an entire multi-line response using its sequence number */
+ protected function _getFullResponse($seq)
+ {
+ $response = '';
+ try
+ {
+ do
+ {
+ $line = $this->_buffer->readLine($seq);
+ $response .= $line;
+ }
+ while (null !== $line && false !== $line && ' ' != $line{3});
+ }
+ catch (Swift_TransportException $e)
+ {
+ $this->_throwException($e);
+ }
+ return $response;
+ }
+
+ // -- Private methods
+
+ /** Send an email to the given recipients from the given reverse path */
+ private function _doMailTransaction($message, $reversePath,
+ array $recipients, array &$failedRecipients)
+ {
+ $sent = 0;
+ $this->_doMailFromCommand($reversePath);
+ foreach ($recipients as $forwardPath)
+ {
+ try
+ {
+ $this->_doRcptToCommand($forwardPath);
+ $sent++;
+ }
+ catch (Swift_TransportException $e)
+ {
+ $failedRecipients[] = $forwardPath;
+ }
+ }
+
+ if ($sent != 0)
+ {
+ $this->_doDataCommand();
+ $this->_streamMessage($message);
+ }
+ else
+ {
+ $this->reset();
+ }
+
+ return $sent;
+ }
+
+ /** Send a message to the given To: recipients */
+ private function _sendTo(Swift_Mime_Message $message, $reversePath,
+ array $to, array &$failedRecipients)
+ {
+ if (empty($to))
+ {
+ return 0;
+ }
+ return $this->_doMailTransaction($message, $reversePath, array_keys($to),
+ $failedRecipients);
+ }
+
+ /** Send a message to the given Cc: recipients */
+ private function _sendCc(Swift_Mime_Message $message, $reversePath,
+ array $cc, array &$failedRecipients)
+ {
+ if (empty($cc))
+ {
+ return 0;
+ }
+ return $this->_doMailTransaction($message, $reversePath, array_keys($cc),
+ $failedRecipients);
+ }
+
+ /** Send a message to all Bcc: recipients */
+ private function _sendBcc(Swift_Mime_Message $message, $reversePath,
+ array $bcc, array &$failedRecipients)
+ {
+ $sent = 0;
+ foreach ($bcc as $forwardPath => $name)
+ {
+ $message->setBcc(array($forwardPath => $name));
+ $sent += $this->_doMailTransaction(
+ $message, $reversePath, array($forwardPath), $failedRecipients
+ );
+ }
+ return $sent;
+ }
+
+ /** Try to determine the hostname of the server this is run on */
+ private function _lookupHostname()
+ {
+ if (!empty($_SERVER['SERVER_NAME'])
+ && $this->_isFqdn($_SERVER['SERVER_NAME']))
+ {
+ $this->_domain = $_SERVER['SERVER_NAME'];
+ }
+ elseif (!empty($_SERVER['SERVER_ADDR']))
+ {
+ $this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']);
+ }
+ }
+
+ /** Determine is the $hostname is a fully-qualified name */
+ private function _isFqdn($hostname)
+ {
+ //We could do a really thorough check, but there's really no point
+ if (false !== $dotPos = strpos($hostname, '.'))
+ {
+ return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Destructor.
+ */
+ public function __destruct()
+ {
+ $this->stop();
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php
new file mode 100644
index 0000000..4c7e0f2
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php
@@ -0,0 +1,88 @@
+executeCommand("AUTH CRAM-MD5\r\n", array(334));
+ $challenge = base64_decode(substr($challenge, 4));
+ $message = base64_encode(
+ $username . ' ' . $this->_getResponse($password, $challenge)
+ );
+ $agent->executeCommand(sprintf("%s\r\n", $message), array(235));
+ return true;
+ }
+ catch (Swift_TransportException $e)
+ {
+ $agent->executeCommand("RSET\r\n", array(250));
+ return false;
+ }
+ }
+
+ /**
+ * Generate a CRAM-MD5 response from a server challenge.
+ * @param string $secret
+ * @param string $challenge
+ * @return string
+ */
+ private function _getResponse($secret, $challenge)
+ {
+ if (strlen($secret) > 64)
+ {
+ $secret = pack('H32', md5($secret));
+ }
+
+ if (strlen($secret) < 64)
+ {
+ $secret = str_pad($secret, 64, chr(0));
+ }
+
+ $k_ipad = substr($secret, 0, 64) ^ str_repeat(chr(0x36), 64);
+ $k_opad = substr($secret, 0, 64) ^ str_repeat(chr(0x5C), 64);
+
+ $inner = pack('H32', md5($k_ipad . $challenge));
+ $digest = md5($k_opad . $inner);
+
+ return $digest;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php
new file mode 100644
index 0000000..bd22617
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php
@@ -0,0 +1,58 @@
+executeCommand("AUTH LOGIN\r\n", array(334));
+ $agent->executeCommand(sprintf("%s\r\n", base64_encode($username)), array(334));
+ $agent->executeCommand(sprintf("%s\r\n", base64_encode($password)), array(235));
+ return true;
+ }
+ catch (Swift_TransportException $e)
+ {
+ $agent->executeCommand("RSET\r\n", array(250));
+ return false;
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php
new file mode 100644
index 0000000..ddd8094
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php
@@ -0,0 +1,57 @@
+executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), array(235));
+ return true;
+ }
+ catch (Swift_TransportException $e)
+ {
+ $agent->executeCommand("RSET\r\n", array(250));
+ return false;
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/AuthHandler.php b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/AuthHandler.php
new file mode 100644
index 0000000..a223169
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/AuthHandler.php
@@ -0,0 +1,262 @@
+setAuthenticators($authenticators);
+ }
+
+ /**
+ * Set the Authenticators which can process a login request.
+ * @param Swift_Transport_Esmtp_Authenticator[] $authenticators
+ */
+ public function setAuthenticators(array $authenticators)
+ {
+ $this->_authenticators = $authenticators;
+ }
+
+ /**
+ * Get the Authenticators which can process a login request.
+ * @return Swift_Transport_Esmtp_Authenticator[]
+ */
+ public function getAuthenticators()
+ {
+ return $this->_authenticators;
+ }
+
+ /**
+ * Set the username to authenticate with.
+ * @param string $username
+ */
+ public function setUsername($username)
+ {
+ $this->_username = $username;
+ }
+
+ /**
+ * Get the username to authenticate with.
+ * @return string
+ */
+ public function getUsername()
+ {
+ return $this->_username;
+ }
+
+ /**
+ * Set the password to authenticate with.
+ * @param string $password
+ */
+ public function setPassword($password)
+ {
+ $this->_password = $password;
+ }
+
+ /**
+ * Get the password to authenticate with.
+ * @return string
+ */
+ public function getPassword()
+ {
+ return $this->_password;
+ }
+
+ /**
+ * Set the auth mode to use to authenticate.
+ * @param string $mode
+ */
+ public function setAuthMode($mode)
+ {
+ $this->_auth_mode = $mode;
+ }
+
+ /**
+ * Get the auth mode to use to authenticate.
+ * @return string
+ */
+ public function getAuthMode()
+ {
+ return $this->_auth_mode;
+ }
+
+ /**
+ * Get the name of the ESMTP extension this handles.
+ * @return boolean
+ */
+ public function getHandledKeyword()
+ {
+ return 'AUTH';
+ }
+
+ /**
+ * Set the parameters which the EHLO greeting indicated.
+ * @param string[] $parameters
+ */
+ public function setKeywordParams(array $parameters)
+ {
+ $this->_esmtpParams = $parameters;
+ }
+
+ /**
+ * Runs immediately after a EHLO has been issued.
+ * @param Swift_Transport_SmtpAgent $agent to read/write
+ */
+ public function afterEhlo(Swift_Transport_SmtpAgent $agent)
+ {
+ if ($this->_username)
+ {
+ $count = 0;
+ foreach ($this->_getAuthenticatorsForAgent() as $authenticator)
+ {
+ if (in_array(strtolower($authenticator->getAuthKeyword()),
+ array_map('strtolower', $this->_esmtpParams)))
+ {
+ $count++;
+ if ($authenticator->authenticate($agent, $this->_username, $this->_password))
+ {
+ return;
+ }
+ }
+ }
+ throw new Swift_TransportException(
+ 'Failed to authenticate on SMTP server with username "' .
+ $this->_username . '" using ' . $count . ' possible authenticators'
+ );
+ }
+ }
+
+ /**
+ * Not used.
+ */
+ public function getMailParams()
+ {
+ return array();
+ }
+
+ /**
+ * Not used.
+ */
+ public function getRcptParams()
+ {
+ return array();
+ }
+
+ /**
+ * Not used.
+ */
+ public function onCommand(Swift_Transport_SmtpAgent $agent,
+ $command, $codes = array(), &$failedRecipients = null, &$stop = false)
+ {
+ }
+
+ /**
+ * Returns +1, -1 or 0 according to the rules for usort().
+ * This method is called to ensure extensions can be execute in an appropriate order.
+ * @param string $esmtpKeyword to compare with
+ * @return int
+ */
+ public function getPriorityOver($esmtpKeyword)
+ {
+ return 0;
+ }
+
+ /**
+ * Returns an array of method names which are exposed to the Esmtp class.
+ * @return string[]
+ */
+ public function exposeMixinMethods()
+ {
+ return array('setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode');
+ }
+
+ /**
+ * Not used.
+ */
+ public function resetState()
+ {
+ }
+
+ // -- Protected methods
+
+ /**
+ * Returns the authenticator list for the given agent.
+ * @param Swift_Transport_SmtpAgent $agent
+ * @return array
+ * @access protected
+ */
+ protected function _getAuthenticatorsForAgent()
+ {
+ if (!$mode = strtolower($this->_auth_mode))
+ {
+ return $this->_authenticators;
+ }
+
+ foreach ($this->_authenticators as $authenticator)
+ {
+ if (strtolower($authenticator->getAuthKeyword()) == $mode)
+ {
+ return array($authenticator);
+ }
+ }
+
+ throw new Swift_TransportException('Auth mode '.$mode.' is invalid');
+ }
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Authenticator.php b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Authenticator.php
new file mode 100644
index 0000000..bf166d3
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/Esmtp/Authenticator.php
@@ -0,0 +1,38 @@
+.
+ * @return string[]
+ */
+ public function getMailParams();
+
+ /**
+ * Get params which are appended to RCPT TO:<>.
+ * @return string[]
+ */
+ public function getRcptParams();
+
+ /**
+ * Runs when a command is due to be sent.
+ * @param Swift_Transport_SmtpAgent $agent to read/write
+ * @param string $command to send
+ * @param int[] $codes expected in response
+ * @param string[] &$failedRecipients
+ * @param boolean &$stop to be set true if the command is now sent
+ */
+ public function onCommand(Swift_Transport_SmtpAgent $agent,
+ $command, $codes = array(), &$failedRecipients = null, &$stop = false);
+
+ /**
+ * Returns +1, -1 or 0 according to the rules for usort().
+ * This method is called to ensure extensions can be execute in an appropriate order.
+ * @param string $esmtpKeyword to compare with
+ * @return int
+ */
+ public function getPriorityOver($esmtpKeyword);
+
+ /**
+ * Returns an array of method names which are exposed to the Esmtp class.
+ * @return string[]
+ */
+ public function exposeMixinMethods();
+
+ /**
+ * Tells this handler to clear any buffers and reset its state.
+ */
+ public function resetState();
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/EsmtpTransport.php b/modules/khemail/vendor/swift/classes/Swift/Transport/EsmtpTransport.php
new file mode 100644
index 0000000..c7833c3
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/EsmtpTransport.php
@@ -0,0 +1,340 @@
+ 'tcp',
+ 'host' => 'localhost',
+ 'port' => 25,
+ 'timeout' => 30,
+ 'blocking' => 1,
+ 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET
+ );
+
+ /**
+ * Creates a new EsmtpTransport using the given I/O buffer.
+ * @param Swift_Transport_IoBuffer $buf
+ * @param Swift_Transport_EsmtpHandler[] $extensionHandlers
+ * @param Swift_Events_EventDispatcher $dispatcher
+ */
+ public function __construct(Swift_Transport_IoBuffer $buf,
+ array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher)
+ {
+ parent::__construct($buf, $dispatcher);
+ $this->setExtensionHandlers($extensionHandlers);
+ }
+
+ /**
+ * Set the host to connect to.
+ * @param string $host
+ */
+ public function setHost($host)
+ {
+ $this->_params['host'] = $host;
+ return $this;
+ }
+
+ /**
+ * Get the host to connect to.
+ * @return string
+ */
+ public function getHost()
+ {
+ return $this->_params['host'];
+ }
+
+ /**
+ * Set the port to connect to.
+ * @param int $port
+ */
+ public function setPort($port)
+ {
+ $this->_params['port'] = (int) $port;
+ return $this;
+ }
+
+ /**
+ * Get the port to connect to.
+ * @return int
+ */
+ public function getPort()
+ {
+ return $this->_params['port'];
+ }
+
+ /**
+ * Set the connection timeout.
+ * @param int $timeout seconds
+ */
+ public function setTimeout($timeout)
+ {
+ $this->_params['timeout'] = (int) $timeout;
+ return $this;
+ }
+
+ /**
+ * Get the connection timeout.
+ * @return int
+ */
+ public function getTimeout()
+ {
+ return $this->_params['timeout'];
+ }
+
+ /**
+ * Set the encryption type (tls or ssl)
+ * @param string $encryption
+ */
+ public function setEncryption($enc)
+ {
+ $this->_params['protocol'] = $enc;
+ return $this;
+ }
+
+ /**
+ * Get the encryption type.
+ * @return string
+ */
+ public function getEncryption()
+ {
+ return $this->_params['protocol'];
+ }
+
+ /**
+ * Set ESMTP extension handlers.
+ * @param Swift_Transport_EsmtpHandler[] $handlers
+ */
+ public function setExtensionHandlers(array $handlers)
+ {
+ $assoc = array();
+ foreach ($handlers as $handler)
+ {
+ $assoc[$handler->getHandledKeyword()] = $handler;
+ }
+ uasort($assoc, array($this, '_sortHandlers'));
+ $this->_handlers = $assoc;
+ $this->_setHandlerParams();
+ return $this;
+ }
+
+ /**
+ * Get ESMTP extension handlers.
+ * @return Swift_Transport_EsmtpHandler[]
+ */
+ public function getExtensionHandlers()
+ {
+ return array_values($this->_handlers);
+ }
+
+ /**
+ * Run a command against the buffer, expecting the given response codes.
+ * If no response codes are given, the response will not be validated.
+ * If codes are given, an exception will be thrown on an invalid response.
+ * @param string $command
+ * @param int[] $codes
+ * @param string[] &$failures
+ * @return string
+ */
+ public function executeCommand($command, $codes = array(), &$failures = null)
+ {
+ $failures = (array) $failures;
+ $stopSignal = false;
+ $response = null;
+ foreach ($this->_getActiveHandlers() as $handler)
+ {
+ $response = $handler->onCommand(
+ $this, $command, $codes, $failures, $stopSignal
+ );
+ if ($stopSignal)
+ {
+ return $response;
+ }
+ }
+ return parent::executeCommand($command, $codes, $failures);
+ }
+
+ // -- Mixin invocation code
+
+ /** Mixin handling method for ESMTP handlers */
+ public function __call($method, $args)
+ {
+ foreach ($this->_handlers as $handler)
+ {
+ if (in_array(strtolower($method),
+ array_map('strtolower', (array) $handler->exposeMixinMethods())
+ ))
+ {
+ $return = call_user_func_array(array($handler, $method), $args);
+ //Allow fluid method calls
+ if (is_null($return) && substr($method, 0, 3) == 'set')
+ {
+ return $this;
+ }
+ else
+ {
+ return $return;
+ }
+ }
+ }
+ trigger_error('Call to undefined method ' . $method, E_USER_ERROR);
+ }
+
+ // -- Protected methods
+
+ /** Get the params to initialize the buffer */
+ protected function _getBufferParams()
+ {
+ return $this->_params;
+ }
+
+ /** Overridden to perform EHLO instead */
+ protected function _doHeloCommand()
+ {
+ try
+ {
+ $response = $this->executeCommand(
+ sprintf("EHLO %s\r\n", $this->_domain), array(250)
+ );
+ }
+ catch (Swift_TransportException $e)
+ {
+ return parent::_doHeloCommand();
+ }
+
+ $this->_capabilities = $this->_getCapabilities($response);
+ $this->_setHandlerParams();
+ foreach ($this->_getActiveHandlers() as $handler)
+ {
+ $handler->afterEhlo($this);
+ }
+ }
+
+ /** Overridden to add Extension support */
+ protected function _doMailFromCommand($address)
+ {
+ $handlers = $this->_getActiveHandlers();
+ $params = array();
+ foreach ($handlers as $handler)
+ {
+ $params = array_merge($params, (array) $handler->getMailParams());
+ }
+ $paramStr = !empty($params) ? ' ' . implode(' ', $params) : '';
+ $this->executeCommand(
+ sprintf("MAIL FROM: <%s>%s\r\n", $address, $paramStr), array(250)
+ );
+ }
+
+ /** Overridden to add Extension support */
+ protected function _doRcptToCommand($address)
+ {
+ $handlers = $this->_getActiveHandlers();
+ $params = array();
+ foreach ($handlers as $handler)
+ {
+ $params = array_merge($params, (array) $handler->getRcptParams());
+ }
+ $paramStr = !empty($params) ? ' ' . implode(' ', $params) : '';
+ $this->executeCommand(
+ sprintf("RCPT TO: <%s>%s\r\n", $address, $paramStr), array(250, 251, 252)
+ );
+ }
+
+ // -- Private methods
+
+ /** Determine ESMTP capabilities by function group */
+ private function _getCapabilities($ehloResponse)
+ {
+ $capabilities = array();
+ $ehloResponse = trim($ehloResponse);
+ $lines = explode("\r\n", $ehloResponse);
+ array_shift($lines);
+ foreach ($lines as $line)
+ {
+ if (preg_match('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches))
+ {
+ $keyword = strtoupper($matches[1]);
+ $paramStr = strtoupper(ltrim($matches[2], ' ='));
+ $params = !empty($paramStr) ? explode(' ', $paramStr) : array();
+ $capabilities[$keyword] = $params;
+ }
+ }
+ return $capabilities;
+ }
+
+ /** Set parameters which are used by each extension handler */
+ private function _setHandlerParams()
+ {
+ foreach ($this->_handlers as $keyword => $handler)
+ {
+ if (array_key_exists($keyword, $this->_capabilities))
+ {
+ $handler->setKeywordParams($this->_capabilities[$keyword]);
+ }
+ }
+ }
+
+ /** Get ESMTP handlers which are currently ok to use */
+ private function _getActiveHandlers()
+ {
+ $handlers = array();
+ foreach ($this->_handlers as $keyword => $handler)
+ {
+ if (array_key_exists($keyword, $this->_capabilities))
+ {
+ $handlers[] = $handler;
+ }
+ }
+ return $handlers;
+ }
+
+ /** Custom sort for extension handler ordering */
+ private function _sortHandlers($a, $b)
+ {
+ return $a->getPriorityOver($b->getHandledKeyword());
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/FailoverTransport.php b/modules/khemail/vendor/swift/classes/Swift/Transport/FailoverTransport.php
new file mode 100644
index 0000000..e62491c
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/FailoverTransport.php
@@ -0,0 +1,97 @@
+_transports);
+ $sent = 0;
+
+ for ($i = 0; $i < $maxTransports
+ && $transport = $this->_getNextTransport(); ++$i)
+ {
+ try
+ {
+ if (!$transport->isStarted())
+ {
+ $transport->start();
+ }
+
+ return $transport->send($message, $failedRecipients);
+ }
+ catch (Swift_TransportException $e)
+ {
+ $this->_killCurrentTransport();
+ }
+ }
+
+ if (count($this->_transports) == 0)
+ {
+ throw new Swift_TransportException(
+ 'All Transports in FailoverTransport failed, or no Transports available'
+ );
+ }
+
+ return $sent;
+ }
+
+ // -- Protected methods
+
+ protected function _getNextTransport()
+ {
+ if (!isset($this->_currentTransport))
+ {
+ $this->_currentTransport = parent::_getNextTransport();
+ }
+ return $this->_currentTransport;
+ }
+
+ protected function _killCurrentTransport()
+ {
+ $this->_currentTransport = null;
+ parent::_killCurrentTransport();
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/IoBuffer.php b/modules/khemail/vendor/swift/classes/Swift/Transport/IoBuffer.php
new file mode 100644
index 0000000..ac66ef0
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/IoBuffer.php
@@ -0,0 +1,65 @@
+_transports = $transports;
+ $this->_deadTransports = array();
+ }
+
+ /**
+ * Get $transports to delegate to.
+ *
+ * @return array Swift_Transport
+ */
+ public function getTransports(array $transports)
+ {
+ return array_merge($this->_transports, $this->_deadTransports);
+ }
+
+ /**
+ * Test if this Transport mechanism has started.
+ *
+ * @return boolean
+ */
+ public function isStarted()
+ {
+ return count($this->_transports) > 0;
+ }
+
+ /**
+ * Start this Transport mechanism.
+ */
+ public function start()
+ {
+ $this->_transports = array_merge($this->_transports, $this->_deadTransports);
+ }
+
+ /**
+ * Stop this Transport mechanism.
+ */
+ public function stop()
+ {
+ foreach ($this->_transports as $transport)
+ {
+ $transport->stop();
+ }
+ }
+
+ /**
+ * Send the given Message.
+ *
+ * Recipient/sender data will be retreived from the Message API.
+ * The return value is the number of recipients who were accepted for delivery.
+ *
+ * @param Swift_Mime_Message $message
+ * @param string[] &$failedRecipients to collect failures by-reference
+ * @return int
+ */
+ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ {
+ $maxTransports = count($this->_transports);
+ $sent = 0;
+
+ for ($i = 0; $i < $maxTransports
+ && $transport = $this->_getNextTransport(); ++$i)
+ {
+ try
+ {
+ if (!$transport->isStarted())
+ {
+ $transport->start();
+ }
+ if ($sent = $transport->send($message, $failedRecipients))
+ {
+ break;
+ }
+ }
+ catch (Swift_TransportException $e)
+ {
+ $this->_killCurrentTransport();
+ }
+ }
+
+ if (count($this->_transports) == 0)
+ {
+ throw new Swift_TransportException(
+ 'All Transports in LoadBalancedTransport failed, or no Transports available'
+ );
+ }
+
+ return $sent;
+ }
+
+ /**
+ * Register a plugin.
+ *
+ * @param Swift_Events_EventListener $plugin
+ */
+ public function registerPlugin(Swift_Events_EventListener $plugin)
+ {
+ foreach ($this->_transports as $transport)
+ {
+ $transport->registerPlugin($plugin);
+ }
+ }
+
+ // -- Protected methods
+
+ /**
+ * Rotates the transport list around and returns the first instance.
+ *
+ * @return Swift_Transport
+ * @access protected
+ */
+ protected function _getNextTransport()
+ {
+ if ($next = array_shift($this->_transports))
+ {
+ $this->_transports[] = $next;
+ }
+ return $next;
+ }
+
+ /**
+ * Tag the currently used (top of stack) transport as dead/useless.
+ *
+ * @access protected
+ */
+ protected function _killCurrentTransport()
+ {
+ if ($transport = array_pop($this->_transports))
+ {
+ try
+ {
+ $transport->stop();
+ }
+ catch (Exception $e)
+ {
+ }
+ $this->_deadTransports[] = $transport;
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/MailInvoker.php b/modules/khemail/vendor/swift/classes/Swift/Transport/MailInvoker.php
new file mode 100644
index 0000000..dda882f
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/MailInvoker.php
@@ -0,0 +1,36 @@
+_invoker = $invoker;
+ $this->_eventDispatcher = $eventDispatcher;
+ }
+
+ /**
+ * Not used.
+ */
+ public function isStarted()
+ {
+ return false;
+ }
+
+ /**
+ * Not used.
+ */
+ public function start()
+ {
+ }
+
+ /**
+ * Not used.
+ */
+ public function stop()
+ {
+ }
+
+ /**
+ * Set the additional parameters used on the mail() function.
+ *
+ * This string is formatted for sprintf() where %s is the sender address.
+ *
+ * @param string $params
+ */
+ public function setExtraParams($params)
+ {
+ $this->_extraParams = $params;
+ return $this;
+ }
+
+ /**
+ * Get the additional parameters used on the mail() function.
+ *
+ * This string is formatted for sprintf() where %s is the sender address.
+ *
+ * @return string
+ */
+ public function getExtraParams()
+ {
+ return $this->_extraParams;
+ }
+
+ /**
+ * Send the given Message.
+ *
+ * Recipient/sender data will be retreived from the Message API.
+ * The return value is the number of recipients who were accepted for delivery.
+ *
+ * @param Swift_Mime_Message $message
+ * @param string[] &$failedRecipients to collect failures by-reference
+ * @return int
+ */
+ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ {
+ $failedRecipients = (array) $failedRecipients;
+
+ if ($evt = $this->_eventDispatcher->createSendEvent($this, $message))
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
+ if ($evt->bubbleCancelled())
+ {
+ return 0;
+ }
+ }
+
+ $count = (
+ count((array) $message->getTo())
+ + count((array) $message->getCc())
+ + count((array) $message->getBcc())
+ );
+
+ $toHeader = $message->getHeaders()->get('To');
+ $subjectHeader = $message->getHeaders()->get('Subject');
+
+ $to = $toHeader->getFieldBody();
+ $subject = $subjectHeader->getFieldBody();
+
+ $reversePath = $this->_getReversePath($message);
+
+ //Remove headers that would otherwise be duplicated
+ $message->getHeaders()->remove('To');
+ $message->getHeaders()->remove('Subject');
+
+ $messageStr = $message->toString();
+
+ $message->getHeaders()->set($toHeader);
+ $message->getHeaders()->set($subjectHeader);
+
+ //Separate headers from body
+ if (false !== $endHeaders = strpos($messageStr, "\r\n\r\n"))
+ {
+ $headers = substr($messageStr, 0, $endHeaders) . "\r\n"; //Keep last EOL
+ $body = substr($messageStr, $endHeaders + 4);
+ }
+ else
+ {
+ $headers = $messageStr . "\r\n";
+ $body = '';
+ }
+
+ unset($messageStr);
+
+ if ("\r\n" != PHP_EOL) //Non-windows (not using SMTP)
+ {
+ $headers = str_replace("\r\n", PHP_EOL, $headers);
+ $body = str_replace("\r\n", PHP_EOL, $body);
+ }
+ else //Windows, using SMTP
+ {
+ $headers = str_replace("\r\n.", "\r\n..", $headers);
+ $body = str_replace("\r\n.", "\r\n..", $body);
+ }
+
+ if ($this->_invoker->mail($to, $subject, $body, $headers,
+ sprintf($this->_extraParams, $reversePath)))
+ {
+ if ($evt)
+ {
+ $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
+ $evt->setFailedRecipients($failedRecipients);
+ $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
+ }
+ }
+ else
+ {
+ $failedRecipients = array_merge(
+ $failedRecipients,
+ array_keys((array) $message->getTo()),
+ array_keys((array) $message->getCc()),
+ array_keys((array) $message->getBcc())
+ );
+
+ if ($evt)
+ {
+ $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED);
+ $evt->setFailedRecipients($failedRecipients);
+ $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
+ }
+
+ $message->generateId();
+
+ $count = 0;
+ }
+
+ return $count;
+ }
+
+ /**
+ * Register a plugin.
+ *
+ * @param Swift_Events_EventListener $plugin
+ */
+ public function registerPlugin(Swift_Events_EventListener $plugin)
+ {
+ $this->_eventDispatcher->bindEventListener($plugin);
+ }
+
+ // -- Private methods
+
+ /** Determine the best-use reverse path for this message */
+ private function _getReversePath(Swift_Mime_Message $message)
+ {
+ $return = $message->getReturnPath();
+ $sender = $message->getSender();
+ $from = $message->getFrom();
+ $path = null;
+ if (!empty($return))
+ {
+ $path = $return;
+ }
+ elseif (!empty($sender))
+ {
+ $keys = array_keys($sender);
+ $path = array_shift($keys);
+ }
+ elseif (!empty($from))
+ {
+ $keys = array_keys($from);
+ $path = array_shift($keys);
+ }
+ return $path;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/SendmailTransport.php b/modules/khemail/vendor/swift/classes/Swift/Transport/SendmailTransport.php
new file mode 100644
index 0000000..aae8bde
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/SendmailTransport.php
@@ -0,0 +1,173 @@
+ 30,
+ 'blocking' => 1,
+ 'command' => '/usr/sbin/sendmail -bs',
+ 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS
+ );
+
+ /**
+ * Create a new SendmailTransport with $buf for I/O.
+ * @param Swift_Transport_IoBuffer $buf
+ * @param Swift_Events_EventDispatcher $dispatcher
+ */
+ public function __construct(Swift_Transport_IoBuffer $buf,
+ Swift_Events_EventDispatcher $dispatcher)
+ {
+ parent::__construct($buf, $dispatcher);
+ }
+
+ /**
+ * Start the standalone SMTP session if running in -bs mode.
+ */
+ public function start()
+ {
+ if (false !== strpos($this->getCommand(), ' -bs'))
+ {
+ parent::start();
+ }
+ }
+
+ /**
+ * Set the command to invoke.
+ * If using -t mode you are strongly advised to include -oi or -i in the
+ * flags. For example: /usr/sbin/sendmail -oi -t
+ * Swift will append a -f flag if one is not present.
+ * The recommended mode is "-bs" since it is interactive and failure notifications
+ * are hence possible.
+ * @param string $command
+ */
+ public function setCommand($command)
+ {
+ $this->_params['command'] = $command;
+ return $this;
+ }
+
+ /**
+ * Get the sendmail command which will be invoked.
+ * @return string
+ */
+ public function getCommand()
+ {
+ return $this->_params['command'];
+ }
+
+ /**
+ * Send the given Message.
+ * Recipient/sender data will be retreived from the Message API.
+ * The return value is the number of recipients who were accepted for delivery.
+ * NOTE: If using 'sendmail -t' you will not be aware of any failures until
+ * they bounce (i.e. send() will always return 100% success).
+ * @param Swift_Mime_Message $message
+ * @param string[] &$failedRecipients to collect failures by-reference
+ * @return int
+ */
+ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ {
+ $failedRecipients = (array) $failedRecipients;
+ $command = $this->getCommand();
+ $buffer = $this->getBuffer();
+
+ if (false !== strpos($command, ' -t'))
+ {
+ if ($evt = $this->_eventDispatcher->createSendEvent($this, $message))
+ {
+ $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
+ if ($evt->bubbleCancelled())
+ {
+ return 0;
+ }
+ }
+
+ if (false === strpos($command, ' -f'))
+ {
+ $command .= ' -f' . $this->_getReversePath($message);
+ }
+
+ $buffer->initialize(array_merge($this->_params, array('command' => $command)));
+
+ if (false === strpos($command, ' -i') && false === strpos($command, ' -oi'))
+ {
+ $buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n.."));
+ }
+ else
+ {
+ $buffer->setWriteTranslations(array("\r\n"=>"\n"));
+ }
+
+ $count = count((array) $message->getTo())
+ + count((array) $message->getCc())
+ + count((array) $message->getBcc())
+ ;
+ $message->toByteStream($buffer);
+ $buffer->flushBuffers();
+ $buffer->setWriteTranslations(array());
+ $buffer->terminate();
+
+ if ($evt)
+ {
+ $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
+ $evt->setFailedRecipients($failedRecipients);
+ $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
+ }
+
+ $message->generateId();
+ }
+ elseif (false !== strpos($command, ' -bs'))
+ {
+ $count = parent::send($message, $failedRecipients);
+ }
+ else
+ {
+ $this->_throwException(new Swift_TransportException(
+ 'Unsupported sendmail command flags [' . $command . ']. ' .
+ 'Must be one of "-bs" or "-t" but can include additional flags.'
+ ));
+ }
+
+ return $count;
+ }
+
+ // -- Protected methods
+
+ /** Get the params to initialize the buffer */
+ protected function _getBufferParams()
+ {
+ return $this->_params;
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/SimpleMailInvoker.php b/modules/khemail/vendor/swift/classes/Swift/Transport/SimpleMailInvoker.php
new file mode 100644
index 0000000..271ba84
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/SimpleMailInvoker.php
@@ -0,0 +1,58 @@
+.
+
+ */
+
+//@require 'Swift/Transport/MailInvoker.php';
+
+/**
+ * This is the implementation class for {@link Swift_Transport_MailInvoker}.
+ *
+ * @package Swift
+ * @subpackage Transport
+ * @author Chris Corbyn
+ */
+class Swift_Transport_SimpleMailInvoker implements Swift_Transport_MailInvoker
+{
+
+ /**
+ * Send mail via the mail() function.
+ *
+ * This method takes the same arguments as PHP mail().
+ *
+ * @param string $to
+ * @param string $subject
+ * @param string $body
+ * @param string $headers
+ * @param string $extraParams
+ *
+ * @return boolean
+ */
+ public function mail($to, $subject, $body, $headers = null, $extraParams = null)
+ {
+ if (!ini_get('safe_mode'))
+ {
+ return mail($to, $subject, $body, $headers, $extraParams);
+ }
+ else
+ {
+ return mail($to, $subject, $body, $headers);
+ }
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/Transport/SmtpAgent.php b/modules/khemail/vendor/swift/classes/Swift/Transport/SmtpAgent.php
new file mode 100644
index 0000000..ee9b8ed
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/Transport/SmtpAgent.php
@@ -0,0 +1,36 @@
+_replacementFactory = $replacementFactory;
+ }
+
+ /**
+ * Perform any initialization needed, using the given $params.
+ * Parameters will vary depending upon the type of IoBuffer used.
+ * @param array $params
+ */
+ public function initialize(array $params)
+ {
+ $this->_params = $params;
+ switch ($params['type'])
+ {
+ case self::TYPE_PROCESS:
+ $this->_establishProcessConnection();
+ break;
+ case self::TYPE_SOCKET:
+ default:
+ $this->_establishSocketConnection();
+ break;
+ }
+ }
+
+ /**
+ * Set an individual param on the buffer (e.g. switching to SSL).
+ * @param string $param
+ * @param mixed $value
+ */
+ public function setParam($param, $value)
+ {
+ if (isset($this->_stream))
+ {
+ switch ($param)
+ {
+ case 'protocol':
+ if (!array_key_exists('protocol', $this->_params)
+ || $value != $this->_params['protocol'])
+ {
+ if ('tls' == $value)
+ {
+ stream_socket_enable_crypto(
+ $this->_stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT
+ );
+ }
+ }
+ break;
+ }
+ }
+ $this->_params[$param] = $value;
+ }
+
+ /**
+ * Perform any shutdown logic needed.
+ */
+ public function terminate()
+ {
+ if (isset($this->_stream))
+ {
+ switch ($this->_params['type'])
+ {
+ case self::TYPE_PROCESS:
+ fclose($this->_in);
+ fclose($this->_out);
+ proc_close($this->_stream);
+ break;
+ case self::TYPE_SOCKET:
+ default:
+ fclose($this->_stream);
+ break;
+ }
+ }
+ $this->_stream = null;
+ $this->_out = null;
+ $this->_in = null;
+ }
+
+ /**
+ * Set an array of string replacements which should be made on data written
+ * to the buffer. This could replace LF with CRLF for example.
+ * @param string[] $replacements
+ */
+ public function setWriteTranslations(array $replacements)
+ {
+ foreach ($this->_translations as $search => $replace)
+ {
+ if (!isset($replacements[$search]))
+ {
+ $this->removeFilter($search);
+ unset($this->_translations[$search]);
+ }
+ }
+
+ foreach ($replacements as $search => $replace)
+ {
+ if (!isset($this->_translations[$search]))
+ {
+ $this->addFilter(
+ $this->_replacementFactory->createFilter($search, $replace), $search
+ );
+ $this->_translations[$search] = true;
+ }
+ }
+ }
+
+ /**
+ * Get a line of output (including any CRLF).
+ * The $sequence number comes from any writes and may or may not be used
+ * depending upon the implementation.
+ * @param int $sequence of last write to scan from
+ * @return string
+ */
+ public function readLine($sequence)
+ {
+ if (isset($this->_out) && !feof($this->_out))
+ {
+ $line = fgets($this->_out);
+ return $line;
+ }
+ }
+
+ /**
+ * Reads $length bytes from the stream into a string and moves the pointer
+ * through the stream by $length. If less bytes exist than are requested the
+ * remaining bytes are given instead. If no bytes are remaining at all, boolean
+ * false is returned.
+ * @param int $length
+ * @return string
+ */
+ public function read($length)
+ {
+ if (isset($this->_out) && !feof($this->_out))
+ {
+ $ret = fread($this->_out, $length);
+ return $ret;
+ }
+ }
+
+ /** Not implemented */
+ public function setReadPointer($byteOffset)
+ {
+ }
+
+ // -- Protected methods
+
+ /** Flush the stream contents */
+ protected function _flush()
+ {
+ if (isset($this->_in))
+ {
+ fflush($this->_in);
+ }
+ }
+
+ /** Write this bytes to the stream */
+ protected function _commit($bytes)
+ {
+ if (isset($this->_in)
+ && fwrite($this->_in, $bytes))
+ {
+ return ++$this->_sequence;
+ }
+ }
+
+ // -- Private methods
+
+ /**
+ * Establishes a connection to a remote server.
+ * @access private
+ */
+ private function _establishSocketConnection()
+ {
+ $host = $this->_params['host'];
+ if (!empty($this->_params['protocol']))
+ {
+ $host = $this->_params['protocol'] . '://' . $host;
+ }
+ $timeout = 15;
+ if (!empty($this->_params['timeout']))
+ {
+ $timeout = $this->_params['timeout'];
+ }
+ if (!$this->_stream = fsockopen($host, $this->_params['port'], $errno, $errstr, $timeout))
+ {
+ throw new Swift_TransportException(
+ 'Connection could not be established with host ' . $this->_params['host'] .
+ ' [' . $errstr . ' #' . $errno . ']'
+ );
+ }
+ if (!empty($this->_params['blocking']))
+ {
+ stream_set_blocking($this->_stream, 1);
+ }
+ else
+ {
+ stream_set_blocking($this->_stream, 0);
+ }
+ $this->_in =& $this->_stream;
+ $this->_out =& $this->_stream;
+ }
+
+ /**
+ * Opens a process for input/output.
+ * @access private
+ */
+ private function _establishProcessConnection()
+ {
+ $command = $this->_params['command'];
+ $descriptorSpec = array(
+ 0 => array('pipe', 'r'),
+ 1 => array('pipe', 'w'),
+ 2 => array('pipe', 'w')
+ );
+ $this->_stream = proc_open($command, $descriptorSpec, $pipes);
+ stream_set_blocking($pipes[2], 0);
+ if ($err = stream_get_contents($pipes[2]))
+ {
+ throw new Swift_TransportException(
+ 'Process could not be started [' . $err . ']'
+ );
+ }
+ $this->_in =& $pipes[0];
+ $this->_out =& $pipes[1];
+ }
+
+}
diff --git a/modules/khemail/vendor/swift/classes/Swift/TransportException.php b/modules/khemail/vendor/swift/classes/Swift/TransportException.php
new file mode 100644
index 0000000..b7cd658
--- /dev/null
+++ b/modules/khemail/vendor/swift/classes/Swift/TransportException.php
@@ -0,0 +1,31 @@
+ register('cache')
+ -> asAliasOf('cache.array')
+
+ -> register('tempdir')
+ -> asValue('/tmp')
+
+ -> register('cache.null')
+ -> asSharedInstanceOf('Swift_KeyCache_NullKeyCache')
+
+ -> register('cache.array')
+ -> asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache')
+ -> withDependencies(array('cache.inputstream'))
+
+ -> register('cache.disk')
+ -> asSharedInstanceOf('Swift_KeyCache_DiskKeyCache')
+ -> withDependencies(array('cache.inputstream', 'tempdir'))
+
+ -> register('cache.inputstream')
+ -> asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream')
+
+ ;
diff --git a/modules/khemail/vendor/swift/dependency_maps/mime_deps.php b/modules/khemail/vendor/swift/dependency_maps/mime_deps.php
new file mode 100644
index 0000000..e03927a
--- /dev/null
+++ b/modules/khemail/vendor/swift/dependency_maps/mime_deps.php
@@ -0,0 +1,97 @@
+ register('properties.charset')
+ -> asValue('utf-8')
+
+ -> register('mime.message')
+ -> asNewInstanceOf('Swift_Mime_SimpleMessage')
+ -> withDependencies(array(
+ 'mime.headerset',
+ 'mime.qpcontentencoder',
+ 'cache',
+ 'properties.charset'
+ ))
+
+ -> register('mime.part')
+ -> asNewInstanceOf('Swift_Mime_MimePart')
+ -> withDependencies(array(
+ 'mime.headerset',
+ 'mime.qpcontentencoder',
+ 'cache',
+ 'properties.charset'
+ ))
+
+ -> register('mime.attachment')
+ -> asNewInstanceOf('Swift_Mime_Attachment')
+ -> withDependencies(array(
+ 'mime.headerset',
+ 'mime.base64contentencoder',
+ 'cache'
+ ))
+ -> addConstructorValue($swift_mime_types)
+
+ -> register('mime.embeddedfile')
+ -> asNewInstanceOf('Swift_Mime_EmbeddedFile')
+ -> withDependencies(array(
+ 'mime.headerset',
+ 'mime.base64contentencoder',
+ 'cache'
+ ))
+ -> addConstructorValue($swift_mime_types)
+
+ -> register('mime.headerfactory')
+ -> asNewInstanceOf('Swift_Mime_SimpleHeaderFactory')
+ -> withDependencies(array(
+ 'mime.qpheaderencoder',
+ 'mime.rfc2231encoder',
+ 'properties.charset'
+ ))
+
+ -> register('mime.headerset')
+ -> asNewInstanceOf('Swift_Mime_SimpleHeaderSet')
+ -> withDependencies(array('mime.headerfactory', 'properties.charset'))
+
+ -> register('mime.qpheaderencoder')
+ -> asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder')
+ -> withDependencies(array('mime.charstream'))
+
+ -> register('mime.charstream')
+ -> asNewInstanceOf('Swift_CharacterStream_NgCharacterStream')
+ -> withDependencies(array('mime.characterreaderfactory', 'properties.charset'))
+
+ -> register('mime.bytecanonicalizer')
+ -> asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter')
+ -> addConstructorValue(array(array(0x0D, 0x0A), array(0x0D), array(0x0A)))
+ -> addConstructorValue(array(array(0x0A), array(0x0A), array(0x0D, 0x0A)))
+
+ -> register('mime.characterreaderfactory')
+ -> asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory')
+
+ -> register('mime.qpcontentencoder')
+ -> asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
+ -> withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
+
+ -> register('mime.7bitcontentencoder')
+ -> asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')
+ -> addConstructorValue('7bit')
+ -> addConstructorValue(true)
+
+ -> register('mime.8bitcontentencoder')
+ -> asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')
+ -> addConstructorValue('8bit')
+ -> addConstructorValue(true)
+
+ -> register('mime.base64contentencoder')
+ -> asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder')
+
+ -> register('mime.rfc2231encoder')
+ -> asNewInstanceOf('Swift_Encoder_Rfc2231Encoder')
+ -> withDependencies(array('mime.charstream'))
+
+ ;
+
+unset($swift_mime_types);
diff --git a/modules/khemail/vendor/swift/dependency_maps/transport_deps.php b/modules/khemail/vendor/swift/dependency_maps/transport_deps.php
new file mode 100644
index 0000000..32881d6
--- /dev/null
+++ b/modules/khemail/vendor/swift/dependency_maps/transport_deps.php
@@ -0,0 +1,62 @@
+ register('transport.smtp')
+ -> asNewInstanceOf('Swift_Transport_EsmtpTransport')
+ -> withDependencies(array(
+ 'transport.buffer',
+ array('transport.authhandler'),
+ 'transport.eventdispatcher'
+ ))
+
+ -> register('transport.sendmail')
+ -> asNewInstanceOf('Swift_Transport_SendmailTransport')
+ -> withDependencies(array(
+ 'transport.buffer',
+ 'transport.eventdispatcher'
+ ))
+
+ -> register('transport.mail')
+ -> asNewInstanceOf('Swift_Transport_MailTransport')
+ -> withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher'))
+
+ -> register('transport.loadbalanced')
+ -> asNewInstanceOf('Swift_Transport_LoadBalancedTransport')
+
+ -> register('transport.failover')
+ -> asNewInstanceOf('Swift_Transport_FailoverTransport')
+
+ -> register('transport.mailinvoker')
+ -> asSharedInstanceOf('Swift_Transport_SimpleMailInvoker')
+
+ -> register('transport.buffer')
+ -> asNewInstanceOf('Swift_Transport_StreamBuffer')
+ -> withDependencies(array('transport.replacementfactory'))
+
+ -> register('transport.authhandler')
+ -> asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler')
+ -> withDependencies(array(
+ array(
+ 'transport.crammd5auth',
+ 'transport.loginauth',
+ 'transport.plainauth'
+ )
+ ))
+
+ -> register('transport.crammd5auth')
+ -> asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator')
+
+ -> register('transport.loginauth')
+ -> asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator')
+
+ -> register('transport.plainauth')
+ -> asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator')
+
+ -> register('transport.eventdispatcher')
+ -> asNewInstanceOf('Swift_Events_SimpleEventDispatcher')
+
+ -> register('transport.replacementfactory')
+ -> asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory')
+
+ ;
diff --git a/modules/khemail/vendor/swift/mime_types.php b/modules/khemail/vendor/swift/mime_types.php
new file mode 100644
index 0000000..65c9aa0
--- /dev/null
+++ b/modules/khemail/vendor/swift/mime_types.php
@@ -0,0 +1,76 @@
+ 'audio/x-aiff',
+ 'aiff' => 'audio/x-aiff',
+ 'avi' => 'video/avi',
+ 'bmp' => 'image/bmp',
+ 'bz2' => 'application/x-bz2',
+ 'csv' => 'text/csv',
+ 'dmg' => 'application/x-apple-diskimage',
+ 'doc' => 'application/msword',
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'eml' => 'message/rfc822',
+ 'aps' => 'application/postscript',
+ 'exe' => 'application/x-ms-dos-executable',
+ 'flv' => 'video/x-flv',
+ 'gif' => 'image/gif',
+ 'gz' => 'application/x-gzip',
+ 'hqx' => 'application/stuffit',
+ 'htm' => 'text/html',
+ 'html' => 'text/html',
+ 'jar' => 'application/x-java-archive',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'm3u' => 'audio/x-mpegurl',
+ 'm4a' => 'audio/mp4',
+ 'mdb' => 'application/x-msaccess',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mov' => 'video/quicktime',
+ 'mp3' => 'audio/mpeg',
+ 'mp4' => 'video/mp4',
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'odg' => 'vnd.oasis.opendocument.graphics',
+ 'odp' => 'vnd.oasis.opendocument.presentation',
+ 'odt' => 'vnd.oasis.opendocument.text',
+ 'ods' => 'vnd.oasis.opendocument.spreadsheet',
+ 'ogg' => 'audio/ogg',
+ 'pdf' => 'application/pdf',
+ 'png' => 'image/png',
+ 'ppt' => 'application/vnd.ms-powerpoint',
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'ps' => 'application/postscript',
+ 'rar' => 'application/x-rar-compressed',
+ 'rtf' => 'application/rtf',
+ 'tar' => 'application/x-tar',
+ 'sit' => 'application/x-stuffit',
+ 'svg' => 'image/svg+xml',
+ 'tif' => 'image/tiff',
+ 'tiff' => 'image/tiff',
+ 'ttf' => 'application/x-font-truetype',
+ 'txt' => 'text/plain',
+ 'vcf' => 'text/x-vcard',
+ 'wav' => 'audio/wav',
+ 'wma' => 'audio/x-ms-wma',
+ 'wmv' => 'audio/x-ms-wmv',
+ 'xls' => 'application/excel',
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'xml' => 'application/xml',
+ 'zip' => 'application/zip'
+);
diff --git a/modules/khemail/vendor/swift/preferences.php b/modules/khemail/vendor/swift/preferences.php
new file mode 100644
index 0000000..0b9e4b1
--- /dev/null
+++ b/modules/khemail/vendor/swift/preferences.php
@@ -0,0 +1,20 @@
+setCharset('utf-8');
+
+// Without these lines the default caching mechanism is "array" but this uses
+// a lot of memory.
+// If possible, use a disk cache to enable attaching large attachments etc
+if (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()))
+{
+ Swift_Preferences::getInstance()
+ -> setTempDir(sys_get_temp_dir())
+ -> setCacheType('disk');
+}
diff --git a/modules/khemail/vendor/swift/swift_init.php b/modules/khemail/vendor/swift/swift_init.php
new file mode 100644
index 0000000..fe624a9
--- /dev/null
+++ b/modules/khemail/vendor/swift/swift_init.php
@@ -0,0 +1,21 @@
+ array('source' => 'query_string', 'key' => 'page'),
+ 'total_items' => 0,
+ 'items_per_page' => 10,
+ 'view' => 'pagination/basic',
+ 'auto_hide' => TRUE,
+ 'first_page_in_url' => FALSE,
+ );
+
+ /**
+ * @var array Members that have access methods
+ */
+ protected $_properties = array(
+ 'current_page', 'total_items', 'items_per_page', 'total_pages', 'current_first_item', 'current_last_item',
+ 'previous_page', 'next_page', 'first_page', 'last_page', 'offset',
+ );
+
+ // Current page number
+ protected $_current_page;
+
+ // Total item count
+ protected $_total_items;
+
+ // How many items to show per page
+ protected $_items_per_page;
+
+ // Total page count
+ protected $_total_pages;
+
+ // Item offset for the first item displayed on the current page
+ protected $_current_first_item;
+
+ // Item offset for the last item displayed on the current page
+ protected $_current_last_item;
+
+ // Previous page number; FALSE if the current page is the first one
+ protected $_previous_page;
+
+ // Next page number; FALSE if the current page is the last one
+ protected $_next_page;
+
+ // First page number; FALSE if the current page is the first one
+ protected $_first_page;
+
+ // Last page number; FALSE if the current page is the last one
+ protected $_last_page;
+
+ // Query offset
+ protected $_offset;
+
+ /**
+ * Creates a new Pagination object.
+ *
+ * @param array configuration
+ * @return Pagination
+ */
+ public static function factory(array $config = array())
+ {
+ return new Pagination($config);
+ }
+
+ /**
+ * Creates a new Pagination object.
+ *
+ * @param array configuration
+ * @return void
+ */
+ public function __construct(array $config = array())
+ {
+ // Overwrite system defaults with application defaults
+ $this->config = $this->config_group() + $this->config;
+
+ // Pagination setup
+ $this->setup($config);
+ }
+
+ /**
+ * Retrieves a pagination config group from the config file. One config group can
+ * refer to another as its parent, which will be recursively loaded.
+ *
+ * @param string pagination config group; "default" if none given
+ * @return array config settings
+ */
+ public function config_group($group = 'default')
+ {
+ // Load the pagination config file
+ $config_file = Kohana::$config->load('pagination');
+
+ // Initialize the $config array
+ $config['group'] = (string) $group;
+
+ // Recursively load requested config groups
+ while (isset($config['group']) AND isset($config_file->$config['group']))
+ {
+ // Temporarily store config group name
+ $group = $config['group'];
+ unset($config['group']);
+
+ // Add config group values, not overwriting existing keys
+ $config += $config_file->$group;
+ }
+
+ // Get rid of possible stray config group names
+ unset($config['group']);
+
+ // Return the merged config group settings
+ return $config;
+ }
+
+ /**
+ * Loads configuration settings into the object and (re)calculates pagination if needed.
+ * Allows you to update config settings after a Pagination object has been constructed.
+ *
+ * @param array configuration
+ * @return object Pagination
+ */
+ public function setup(array $config = array())
+ {
+ if (isset($config['group']))
+ {
+ // Recursively load requested config groups
+ $config += $this->config_group($config['group']);
+ }
+
+ // Overwrite the current config settings
+ $this->config = $config + $this->config;
+
+ // Only (re)calculate pagination when needed
+ if ($this->_current_page === NULL
+ OR isset($config['current_page'])
+ OR isset($config['total_items'])
+ OR isset($config['items_per_page']))
+ {
+ // Retrieve the current page number
+ if ( ! empty($this->config['current_page']['page']))
+ {
+ // The current page number has been set manually
+ $this->_current_page = (int) $this->config['current_page']['page'];
+ }
+ else
+ {
+ switch ($this->config['current_page']['source'])
+ {
+ case 'query_string':
+ $this->_current_page = isset($_GET[$this->config['current_page']['key']])
+ ? (int) $_GET[$this->config['current_page']['key']]
+ : 1;
+ break;
+
+ case 'route':
+ $this->_current_page = (int) Request::current()->param($this->config['current_page']['key'], 1);
+ break;
+ }
+ }
+
+ // Calculate and clean all pagination variables
+ $this->_total_items = (int) max(0, $this->config['total_items']);
+ $this->_items_per_page = (int) max(1, $this->config['items_per_page']);
+ $this->_total_pages = (int) ceil($this->_total_items / $this->_items_per_page);
+ $this->_current_page = (int) min(max(1, $this->_current_page), max(1, $this->_total_pages));
+ $this->_current_first_item = (int) min((($this->_current_page - 1) * $this->_items_per_page) + 1, $this->_total_items);
+ $this->_current_last_item = (int) min($this->_current_first_item + $this->_items_per_page - 1, $this->_total_items);
+ $this->_previous_page = ($this->_current_page > 1) ? $this->_current_page - 1 : FALSE;
+ $this->_next_page = ($this->_current_page < $this->_total_pages) ? $this->_current_page + 1 : FALSE;
+ $this->_first_page = ($this->_current_page === 1) ? FALSE : 1;
+ $this->_last_page = ($this->_current_page >= $this->_total_pages) ? FALSE : $this->_total_pages;
+ $this->_offset = (int) (($this->_current_page - 1) * $this->_items_per_page);
+ }
+
+ // Chainable method
+ return $this;
+ }
+
+ /**
+ * Generates the full URL for a certain page.
+ *
+ * @param integer page number
+ * @return string page URL
+ */
+ public function url($page = 1)
+ {
+ // Clean the page number
+ $page = max(1, (int) $page);
+
+ // No page number in URLs to first page
+ if ($page === 1 AND ! $this->config['first_page_in_url'])
+ {
+ $page = NULL;
+ }
+
+ switch ($this->config['current_page']['source'])
+ {
+ case 'query_string':
+ return URL::site(Request::current()->uri()).URL::query(array($this->config['current_page']['key'] => $page));
+
+ case 'route':
+ return URL::site(Request::current()->uri(array($this->config['current_page']['key'] => $page))).URL::query();
+ }
+
+ return '#';
+ }
+
+ /**
+ * Checks whether the given page number exists.
+ *
+ * @param integer page number
+ * @return boolean
+ * @since 3.0.7
+ */
+ public function valid_page($page)
+ {
+ // Page number has to be a clean integer
+ if ( ! Valid::digit($page))
+ return FALSE;
+
+ return $page > 0 AND $page <= $this->_total_pages;
+ }
+
+ /**
+ * Renders the pagination links.
+ *
+ * @param mixed string of the view to use, or a Kohana_View object
+ * @return string pagination output (HTML)
+ */
+ public function render($view = NULL)
+ {
+ // Automatically hide pagination whenever it is superfluous
+ if ($this->config['auto_hide'] === TRUE AND $this->_total_pages <= 1)
+ return '';
+
+ if ($view === NULL)
+ {
+ // Use the view from config
+ $view = $this->config['view'];
+ }
+
+ if ( ! $view instanceof View)
+ {
+ // Load the view file
+ $view = View::factory($view);
+ }
+
+ // Pass on the whole Pagination object
+ return $view->set(get_object_vars($this))->set('page', $this)->render();
+ }
+
+ /**
+ * Renders the pagination links.
+ *
+ * @return string pagination output (HTML)
+ */
+ public function __toString()
+ {
+ try
+ {
+ return $this->render();
+ }
+ catch(Exception $e)
+ {
+ Kohana_Exception::handler($e);
+ return '';
+ }
+ }
+
+ /**
+ * Handles loading and setting properties.
+ *
+ * @param string $method Method name
+ * @param array $args Method arguments
+ * @return mixed
+ */
+ public function __call($method, array $args)
+ {
+ if (in_array($method, $this->_properties))
+ {
+ if (!count($args))
+ {
+ return $this->{'_'.$method};
+ }
+ }
+ else
+ {
+ throw new Kohana_Exception('Invalid method :method called in :class',
+ array(':method' => $method, ':class' => get_class($this)));
+ }
+ }
+
+ /**
+ * Handles setting of property
+ *
+ * @param string $key Property name
+ * @param mixed $value Property value
+ * @return void
+ */
+ public function __set($key, $value)
+ {
+ if (isset($this->{'_'.$key}))
+ {
+ $this->setup(array($key => $value));
+ }
+ else
+ {
+ throw new Kohana_Exception('The :property: property does not exist in the :class: class',
+ array(':property:' => $key, ':class:' => get_class($this)));
+ }
+ }
+
+} // End Pagination
diff --git a/modules/pagination/classes/Pagination.php b/modules/pagination/classes/Pagination.php
new file mode 100644
index 0000000..6be4b15
--- /dev/null
+++ b/modules/pagination/classes/Pagination.php
@@ -0,0 +1,3 @@
+ array(
+ 'current_page' => array('source' => 'query_string', 'key' => 'page'), // source: "query_string" or "route"
+ 'total_items' => 0,
+ 'items_per_page' => 10,
+ 'view' => 'pagination/basic',
+ 'auto_hide' => TRUE,
+ 'first_page_in_url' => FALSE,
+ ),
+
+);
diff --git a/modules/pagination/config/userguide.php b/modules/pagination/config/userguide.php
new file mode 100644
index 0000000..936b209
--- /dev/null
+++ b/modules/pagination/config/userguide.php
@@ -0,0 +1,23 @@
+ array(
+
+ // This should be the path to this modules userguide pages, without the 'guide/'. Ex: '/guide/modulename/' would be 'modulename'
+ 'pagination' => array(
+
+ // Whether this modules userguide pages should be shown
+ 'enabled' => TRUE,
+
+ // The name that should show up on the userguide index page
+ 'name' => 'Pagination',
+
+ // A short description of this module, shown on the index page
+ 'description' => 'Tool for creating paginated links and viewing pages of results.',
+
+ // Copyright message, shown in the footer for this module
+ 'copyright' => '© 2008–2010 Kohana Team',
+ )
+ )
+);
\ No newline at end of file
diff --git a/modules/pagination/guide/pagination/config.md b/modules/pagination/guide/pagination/config.md
new file mode 100644
index 0000000..4a5713b
--- /dev/null
+++ b/modules/pagination/guide/pagination/config.md
@@ -0,0 +1,94 @@
+# Pagination Configuration
+
+[Pagination] uses 6 settings: `current_page`, `total_items`, `items_per_page`, `view`, `auto_hide` and `first_page_in_url`.
+
+## Configuration Examples
+
+This example shows the default configuration:
+
+ return array(
+
+ // Application defaults
+ 'default' => array(
+ 'current_page' => array('source' => 'query_string', 'key' => 'page'), // source: "query_string" or "route"
+ 'total_items' => 0,
+ 'items_per_page' => 10,
+ 'view' => 'pagination/basic',
+ 'auto_hide' => TRUE,
+ 'first_page_in_url' => FALSE,
+ ),
+ );
+
+This is an example with multiple configurations:
+
+ return array(
+
+ // Application defaults
+ 'default' => array(
+ 'current_page' => array('source' => 'query_string', 'key' => 'page'),
+ 'total_items' => 0,
+ 'items_per_page' => 10,
+ 'view' => 'pagination/basic',
+ 'auto_hide' => TRUE,
+ 'first_page_in_url' => FALSE,
+ ),
+
+ // Second configuration
+ 'pretty' => array(
+ 'current_page' => array('source' => 'route', 'key' => 'page'),
+ 'total_items' => 0,
+ 'items_per_page' => 20,
+ 'view' => 'pagination/pretty',
+ 'auto_hide' => TRUE,
+ 'first_page_in_url' => FALSE,
+ ),
+ );
+
+
+
+## Settings
+
+### current_page
+
+The `current_page` setting tells Pagination where to look to find the current page number.
+There are two options for the `source` of the page number: `query_string` and `route`.
+The `key` index in the configuration array tells Pagination what name to look for when it's searching in the query string or route.
+
+This configuration informs Pagination to look in the query string for a value named `page`:
+
+ 'current_page' => array('source' => 'query_string', 'key' => 'page'),
+
+If you have a route setup with the page number in the actual URL like this:
+
+ Route::set('city_listings', 'listings(/)', array('page_num' => '[0-9]+'))
+ ->defaults(array(
+ 'controller' => 'city',
+ 'action' => 'listings'
+ ));
+
+then you would use a setting like this:
+
+ 'current_page' => array('source' => 'route', 'key' => 'page_num'),
+
+
+### total_items
+
+`total_items` is a setting you will most likely pass in during runtime after figuring out exactly how many items you have. It can be set to zero in the configuration for now.
+
+### items_per_page
+
+Self explanatory. This is the maximum items to show on each page. Pagination determines the total number of pages based off of this number.
+
+### view
+
+The `view` setting should be a path to a Pagination view file.
+
+### auto_hide
+
+If `auto_hide` is set to `TRUE` then Pagination will automatically hide whenever there's only one page of items.
+
+### first_page_in_url
+
+If you want Pagination to add the page number to the first page's link then set this setting to `TRUE` otherwise leave it as `FALSE`.
+
+
diff --git a/modules/pagination/guide/pagination/examples.md b/modules/pagination/guide/pagination/examples.md
new file mode 100644
index 0000000..e69de29
diff --git a/modules/pagination/guide/pagination/index.md b/modules/pagination/guide/pagination/index.md
new file mode 100644
index 0000000..e69de29
diff --git a/modules/pagination/guide/pagination/menu.md b/modules/pagination/guide/pagination/menu.md
new file mode 100644
index 0000000..08c39c8
--- /dev/null
+++ b/modules/pagination/guide/pagination/menu.md
@@ -0,0 +1,4 @@
+## [Pagination]()
+- [Config](config)
+- [Usage](usage)
+- [Examples](examples)
\ No newline at end of file
diff --git a/modules/pagination/guide/pagination/usage.md b/modules/pagination/guide/pagination/usage.md
new file mode 100644
index 0000000..e69de29
diff --git a/modules/pagination/views/pagination/basic.php b/modules/pagination/views/pagination/basic.php
new file mode 100644
index 0000000..f0d414d
--- /dev/null
+++ b/modules/pagination/views/pagination/basic.php
@@ -0,0 +1,37 @@
+
diff --git a/modules/pagination/views/pagination/floating.php b/modules/pagination/views/pagination/floating.php
new file mode 100644
index 0000000..52e3fc2
--- /dev/null
+++ b/modules/pagination/views/pagination/floating.php
@@ -0,0 +1,94 @@
+total_pages());
+
+// Ending group of pages: $n7...$n8
+$n7 = max(1, $page->total_pages() - $count_out + 1);
+$n8 = $page->total_pages();
+
+// Middle group of pages: $n4...$n5
+$n4 = max($n2 + 1, $page->current_page() - $count_in);
+$n5 = min($n7 - 1, $page->current_page() + $count_in);
+$use_middle = ($n5 >= $n4);
+
+// Point $n3 between $n2 and $n4
+$n3 = (int) (($n2 + $n4) / 2);
+$use_n3 = ($use_middle && (($n4 - $n2) > 1));
+
+// Point $n6 between $n5 and $n7
+$n6 = (int) (($n5 + $n7) / 2);
+$use_n6 = ($use_middle && (($n7 - $n5) > 1));
+
+// Links to display as array(page => content)
+$links = array();
+
+// Generate links data in accordance with calculated numbers
+for ($i = $n1; $i <= $n2; $i++)
+{
+ $links[$i] = $i;
+}
+if ($use_n3)
+{
+ $links[$n3] = '…';
+}
+for ($i = $n4; $i <= $n5; $i++)
+{
+ $links[$i] = $i;
+}
+if ($use_n6)
+{
+ $links[$n6] = '…';
+}
+for ($i = $n7; $i <= $n8; $i++)
+{
+ $links[$i] = $i;
+}
+
+?>
+
diff --git a/modules/simplehtmldom/classes/simple_html_dom.php b/modules/simplehtmldom/classes/simple_html_dom.php
new file mode 100644
index 0000000..67c7c9d
--- /dev/null
+++ b/modules/simplehtmldom/classes/simple_html_dom.php
@@ -0,0 +1,1742 @@
+size is the "real" number of bytes the dom was created from.
+ * but for most purposes, it's a really good estimation.
+ * Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags closed is great for malformed html, but it CAN lead to parsing errors.
+ * Allow the user to tell us how much they trust the html.
+ * Paperg add the text and plaintext to the selectors for the find syntax. plaintext implies text in the innertext of a node. text implies that the tag is a text node.
+ * This allows for us to find tags based on the text they contain.
+ * Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag.
+ * Paperg: added parse_charset so that we know about the character set of the source document.
+ * NOTE: If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the
+ * last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection.
+ *
+ * Found infinite loop in the case of broken html in restore_noise. Rewrote to protect from that.
+ * PaperG (John Schlick) Added get_display_size for "IMG" tags.
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @author S.C. Chen
+ * @author John Schlick
+ * @author Rus Carroll
+ * @version 1.5 ($Rev: 210 $)
+ * @package PlaceLocalInclude
+ * @subpackage simple_html_dom
+ */
+
+/**
+ * All of the Defines for the classes below.
+ * @author S.C. Chen
+ */
+define('HDOM_TYPE_ELEMENT', 1);
+define('HDOM_TYPE_COMMENT', 2);
+define('HDOM_TYPE_TEXT', 3);
+define('HDOM_TYPE_ENDTAG', 4);
+define('HDOM_TYPE_ROOT', 5);
+define('HDOM_TYPE_UNKNOWN', 6);
+define('HDOM_QUOTE_DOUBLE', 0);
+define('HDOM_QUOTE_SINGLE', 1);
+define('HDOM_QUOTE_NO', 3);
+define('HDOM_INFO_BEGIN', 0);
+define('HDOM_INFO_END', 1);
+define('HDOM_INFO_QUOTE', 2);
+define('HDOM_INFO_SPACE', 3);
+define('HDOM_INFO_TEXT', 4);
+define('HDOM_INFO_INNER', 5);
+define('HDOM_INFO_OUTER', 6);
+define('HDOM_INFO_ENDSPACE',7);
+define('DEFAULT_TARGET_CHARSET', 'UTF-8');
+define('DEFAULT_BR_TEXT', "\r\n");
+define('DEFAULT_SPAN_TEXT', " ");
+define('MAX_FILE_SIZE', 600000);
+// helper functions
+// -----------------------------------------------------------------------------
+// get html dom from file
+// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
+function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+{
+ // We DO force the tags to be terminated.
+ $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
+ // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
+ $contents = file_get_contents($url, $use_include_path, $context, $offset);
+ // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
+ //$contents = retrieve_url_contents($url);
+ if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
+ {
+ return false;
+ }
+ // The second parameter can force the selectors to all be lowercase.
+ $dom->load($contents, $lowercase, $stripRN);
+ return $dom;
+}
+
+// get html dom from string
+function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+{
+ $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
+ if (empty($str) || strlen($str) > MAX_FILE_SIZE)
+ {
+ $dom->clear();
+ return false;
+ }
+ $dom->load($str, $lowercase, $stripRN);
+ return $dom;
+}
+
+// dump html dom tree
+function dump_html_tree($node, $show_attr=true, $deep=0)
+{
+ $node->dump($node);
+}
+
+
+/**
+ * simple html dom node
+ * PaperG - added ability for "find" routine to lowercase the value of the selector.
+ * PaperG - added $tag_start to track the start position of the tag in the total byte index
+ *
+ * @package PlaceLocalInclude
+ */
+class simple_html_dom_node
+{
+ public $nodetype = HDOM_TYPE_TEXT;
+ public $tag = 'text';
+ public $attr = array();
+ public $children = array();
+ public $nodes = array();
+ public $parent = null;
+ // The "info" array - see HDOM_INFO_... for what each element contains.
+ public $_ = array();
+ public $tag_start = 0;
+ private $dom = null;
+
+ function __construct($dom)
+ {
+ $this->dom = $dom;
+ $dom->nodes[] = $this;
+ }
+
+ function __destruct()
+ {
+ $this->clear();
+ }
+
+ function __toString()
+ {
+ return $this->outertext();
+ }
+
+ // clean up memory due to php5 circular references memory leak...
+ function clear()
+ {
+ $this->dom = null;
+ $this->nodes = null;
+ $this->parent = null;
+ $this->children = null;
+ }
+
+ // dump node's tree
+ function dump($show_attr=true, $deep=0)
+ {
+ $lead = str_repeat(' ', $deep);
+
+ echo $lead.$this->tag;
+ if ($show_attr && count($this->attr)>0)
+ {
+ echo '(';
+ foreach ($this->attr as $k=>$v)
+ echo "[$k]=>\"".$this->$k.'", ';
+ echo ')';
+ }
+ echo "\n";
+
+ if ($this->nodes)
+ {
+ foreach ($this->nodes as $c)
+ {
+ $c->dump($show_attr, $deep+1);
+ }
+ }
+ }
+
+
+ // Debugging function to dump a single dom node with a bunch of information about it.
+ function dump_node($echo=true)
+ {
+
+ $string = $this->tag;
+ if (count($this->attr)>0)
+ {
+ $string .= '(';
+ foreach ($this->attr as $k=>$v)
+ {
+ $string .= "[$k]=>\"".$this->$k.'", ';
+ }
+ $string .= ')';
+ }
+ if (count($this->_)>0)
+ {
+ $string .= ' $_ (';
+ foreach ($this->_ as $k=>$v)
+ {
+ if (is_array($v))
+ {
+ $string .= "[$k]=>(";
+ foreach ($v as $k2=>$v2)
+ {
+ $string .= "[$k2]=>\"".$v2.'", ';
+ }
+ $string .= ")";
+ } else {
+ $string .= "[$k]=>\"".$v.'", ';
+ }
+ }
+ $string .= ")";
+ }
+
+ if (isset($this->text))
+ {
+ $string .= " text: (" . $this->text . ")";
+ }
+
+ $string .= " HDOM_INNER_INFO: '";
+ if (isset($node->_[HDOM_INFO_INNER]))
+ {
+ $string .= $node->_[HDOM_INFO_INNER] . "'";
+ }
+ else
+ {
+ $string .= ' NULL ';
+ }
+
+ $string .= " children: " . count($this->children);
+ $string .= " nodes: " . count($this->nodes);
+ $string .= " tag_start: " . $this->tag_start;
+ $string .= "\n";
+
+ if ($echo)
+ {
+ echo $string;
+ return;
+ }
+ else
+ {
+ return $string;
+ }
+ }
+
+ // returns the parent of node
+ // If a node is passed in, it will reset the parent of the current node to that one.
+ function parent($parent=null)
+ {
+ // I am SURE that this doesn't work properly.
+ // It fails to unset the current node from it's current parents nodes or children list first.
+ if ($parent !== null)
+ {
+ $this->parent = $parent;
+ $this->parent->nodes[] = $this;
+ $this->parent->children[] = $this;
+ }
+
+ return $this->parent;
+ }
+
+ // verify that node has children
+ function has_child()
+ {
+ return !empty($this->children);
+ }
+
+ // returns children of node
+ function children($idx=-1)
+ {
+ if ($idx===-1)
+ {
+ return $this->children;
+ }
+ if (isset($this->children[$idx]))
+ {
+ return $this->children[$idx];
+ }
+ return null;
+ }
+
+ // returns the first child of node
+ function first_child()
+ {
+ if (count($this->children)>0)
+ {
+ return $this->children[0];
+ }
+ return null;
+ }
+
+ // returns the last child of node
+ function last_child()
+ {
+ if (($count=count($this->children))>0)
+ {
+ return $this->children[$count-1];
+ }
+ return null;
+ }
+
+ // returns the next sibling of node
+ function next_sibling()
+ {
+ if ($this->parent===null)
+ {
+ return null;
+ }
+
+ $idx = 0;
+ $count = count($this->parent->children);
+ while ($idx<$count && $this!==$this->parent->children[$idx])
+ {
+ ++$idx;
+ }
+ if (++$idx>=$count)
+ {
+ return null;
+ }
+ return $this->parent->children[$idx];
+ }
+
+ // returns the previous sibling of node
+ function prev_sibling()
+ {
+ if ($this->parent===null) return null;
+ $idx = 0;
+ $count = count($this->parent->children);
+ while ($idx<$count && $this!==$this->parent->children[$idx])
+ ++$idx;
+ if (--$idx<0) return null;
+ return $this->parent->children[$idx];
+ }
+
+ // function to locate a specific ancestor tag in the path to the root.
+ function find_ancestor_tag($tag)
+ {
+ global $debug_object;
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
+
+ // Start by including ourselves in the comparison.
+ $returnDom = $this;
+
+ while (!is_null($returnDom))
+ {
+ if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: " . $returnDom->tag); }
+
+ if ($returnDom->tag == $tag)
+ {
+ break;
+ }
+ $returnDom = $returnDom->parent;
+ }
+ return $returnDom;
+ }
+
+ // get dom node's inner html
+ function innertext()
+ {
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
+
+ $ret = '';
+ foreach ($this->nodes as $n)
+ $ret .= $n->outertext();
+ return $ret;
+ }
+
+ // get dom node's outer text (with tag)
+ function outertext()
+ {
+ global $debug_object;
+ if (is_object($debug_object))
+ {
+ $text = '';
+ if ($this->tag == 'text')
+ {
+ if (!empty($this->text))
+ {
+ $text = " with text: " . $this->text;
+ }
+ }
+ $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text);
+ }
+
+ if ($this->tag==='root') return $this->innertext();
+
+ // trigger callback
+ if ($this->dom && $this->dom->callback!==null)
+ {
+ call_user_func_array($this->dom->callback, array($this));
+ }
+
+ if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER];
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
+
+ // render begin tag
+ if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]])
+ {
+ $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
+ } else {
+ $ret = "";
+ }
+
+ // render inner text
+ if (isset($this->_[HDOM_INFO_INNER]))
+ {
+ // If it's a br tag... don't return the HDOM_INNER_INFO that we may or may not have added.
+ if ($this->tag != "br")
+ {
+ $ret .= $this->_[HDOM_INFO_INNER];
+ }
+ } else {
+ if ($this->nodes)
+ {
+ foreach ($this->nodes as $n)
+ {
+ $ret .= $this->convert_text($n->outertext());
+ }
+ }
+ }
+
+ // render end tag
+ if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
+ $ret .= ''.$this->tag.'>';
+ return $ret;
+ }
+
+ // get dom node's plain text
+ function text()
+ {
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
+ switch ($this->nodetype)
+ {
+ case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
+ case HDOM_TYPE_COMMENT: return '';
+ case HDOM_TYPE_UNKNOWN: return '';
+ }
+ if (strcasecmp($this->tag, 'script')===0) return '';
+ if (strcasecmp($this->tag, 'style')===0) return '';
+
+ $ret = '';
+ // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
+ // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening.
+ // WHY is this happening?
+ if (!is_null($this->nodes))
+ {
+ foreach ($this->nodes as $n)
+ {
+ $ret .= $this->convert_text($n->text());
+ }
+
+ // If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all.
+ if ($this->tag == "span")
+ {
+ $ret .= $this->dom->default_span_text;
+ }
+
+
+ }
+ return $ret;
+ }
+
+ function xmltext()
+ {
+ $ret = $this->innertext();
+ $ret = str_ireplace('', '', $ret);
+ return $ret;
+ }
+
+ // build node's text with tag
+ function makeup()
+ {
+ // text, comment, unknown
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
+
+ $ret = '<'.$this->tag;
+ $i = -1;
+
+ foreach ($this->attr as $key=>$val)
+ {
+ ++$i;
+
+ // skip removed attribute
+ if ($val===null || $val===false)
+ continue;
+
+ $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
+ //no value attr: nowrap, checked selected...
+ if ($val===true)
+ $ret .= $key;
+ else {
+ switch ($this->_[HDOM_INFO_QUOTE][$i])
+ {
+ case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
+ case HDOM_QUOTE_SINGLE: $quote = '\''; break;
+ default: $quote = '';
+ }
+ $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
+ }
+ }
+ $ret = $this->dom->restore_noise($ret);
+ return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
+ }
+
+ // find elements by css selector
+ //PaperG - added ability for find to lowercase the value of the selector.
+ function find($selector, $idx=null, $lowercase=false)
+ {
+ $selectors = $this->parse_selector($selector);
+ if (($count=count($selectors))===0) return array();
+ $found_keys = array();
+
+ // find each selector
+ for ($c=0; $c<$count; ++$c)
+ {
+ // The change on the below line was documented on the sourceforge code tracker id 2788009
+ // used to be: if (($levle=count($selectors[0]))===0) return array();
+ if (($levle=count($selectors[$c]))===0) return array();
+ if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
+
+ $head = array($this->_[HDOM_INFO_BEGIN]=>1);
+
+ // handle descendant selectors, no recursive!
+ for ($l=0; $l<$levle; ++$l)
+ {
+ $ret = array();
+ foreach ($head as $k=>$v)
+ {
+ $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
+ //PaperG - Pass this optional parameter on to the seek function.
+ $n->seek($selectors[$c][$l], $ret, $lowercase);
+ }
+ $head = $ret;
+ }
+
+ foreach ($head as $k=>$v)
+ {
+ if (!isset($found_keys[$k]))
+ {
+ $found_keys[$k] = 1;
+ }
+ }
+ }
+
+ // sort keys
+ ksort($found_keys);
+
+ $found = array();
+ foreach ($found_keys as $k=>$v)
+ $found[] = $this->dom->nodes[$k];
+
+ // return nth-element or array
+ if (is_null($idx)) return $found;
+ else if ($idx<0) $idx = count($found) + $idx;
+ return (isset($found[$idx])) ? $found[$idx] : null;
+ }
+
+ // seek for given conditions
+ // PaperG - added parameter to allow for case insensitive testing of the value of a selector.
+ protected function seek($selector, &$ret, $lowercase=false)
+ {
+ global $debug_object;
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
+
+ list($tag, $key, $val, $exp, $no_key) = $selector;
+
+ // xpath index
+ if ($tag && $key && is_numeric($key))
+ {
+ $count = 0;
+ foreach ($this->children as $c)
+ {
+ if ($tag==='*' || $tag===$c->tag) {
+ if (++$count==$key) {
+ $ret[$c->_[HDOM_INFO_BEGIN]] = 1;
+ return;
+ }
+ }
+ }
+ return;
+ }
+
+ $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
+ if ($end==0) {
+ $parent = $this->parent;
+ while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
+ $end -= 1;
+ $parent = $parent->parent;
+ }
+ $end += $parent->_[HDOM_INFO_END];
+ }
+
+ for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
+ $node = $this->dom->nodes[$i];
+
+ $pass = true;
+
+ if ($tag==='*' && !$key) {
+ if (in_array($node, $this->children, true))
+ $ret[$i] = 1;
+ continue;
+ }
+
+ // compare tag
+ if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
+ // compare key
+ if ($pass && $key) {
+ if ($no_key) {
+ if (isset($node->attr[$key])) $pass=false;
+ } else {
+ if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false;
+ }
+ }
+ // compare value
+ if ($pass && $key && $val && $val!=='*') {
+ // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right?
+ if ($key == "plaintext") {
+ // $node->plaintext actually returns $node->text();
+ $nodeKeyValue = $node->text();
+ } else {
+ // this is a normal search, we want the value of that attribute of the tag.
+ $nodeKeyValue = $node->attr[$key];
+ }
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);}
+
+ //PaperG - If lowercase is set, do a case insensitive test of the value of the selector.
+ if ($lowercase) {
+ $check = $this->match($exp, strtolower($val), strtolower($nodeKeyValue));
+ } else {
+ $check = $this->match($exp, $val, $nodeKeyValue);
+ }
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: " . ($check ? "true" : "false"));}
+
+ // handle multiple class
+ if (!$check && strcasecmp($key, 'class')===0) {
+ foreach (explode(' ',$node->attr[$key]) as $k) {
+ // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form.
+ if (!empty($k)) {
+ if ($lowercase) {
+ $check = $this->match($exp, strtolower($val), strtolower($k));
+ } else {
+ $check = $this->match($exp, $val, $k);
+ }
+ if ($check) break;
+ }
+ }
+ }
+ if (!$check) $pass = false;
+ }
+ if ($pass) $ret[$i] = 1;
+ unset($node);
+ }
+ // It's passed by reference so this is actually what this function returns.
+ if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret);}
+ }
+
+ protected function match($exp, $pattern, $value) {
+ global $debug_object;
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
+
+ switch ($exp) {
+ case '=':
+ return ($value===$pattern);
+ case '!=':
+ return ($value!==$pattern);
+ case '^=':
+ return preg_match("/^".preg_quote($pattern,'/')."/", $value);
+ case '$=':
+ return preg_match("/".preg_quote($pattern,'/')."$/", $value);
+ case '*=':
+ if ($pattern[0]=='/') {
+ return preg_match($pattern, $value);
+ }
+ return preg_match("/".$pattern."/i", $value);
+ }
+ return false;
+ }
+
+ protected function parse_selector($selector_string) {
+ global $debug_object;
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
+
+ // pattern of CSS selectors, modified from mootools
+ // Paperg: Add the colon to the attrbute, so that it properly finds like google does.
+ // Note: if you try to look at this attribute, yo MUST use getAttribute since $dom->x:y will fail the php syntax check.
+// Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured.
+// This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
+// farther study is required to determine of this should be documented or removed.
+// $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
+ $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
+ preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches);}
+
+ $selectors = array();
+ $result = array();
+ //print_r($matches);
+
+ foreach ($matches as $m) {
+ $m[0] = trim($m[0]);
+ if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
+ // for browser generated xpath
+ if ($m[1]==='tbody') continue;
+
+ list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
+ if (!empty($m[2])) {$key='id'; $val=$m[2];}
+ if (!empty($m[3])) {$key='class'; $val=$m[3];}
+ if (!empty($m[4])) {$key=$m[4];}
+ if (!empty($m[5])) {$exp=$m[5];}
+ if (!empty($m[6])) {$val=$m[6];}
+
+ // convert to lowercase
+ if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
+ //elements that do NOT have the specified attribute
+ if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
+
+ $result[] = array($tag, $key, $val, $exp, $no_key);
+ if (trim($m[7])===',') {
+ $selectors[] = $result;
+ $result = array();
+ }
+ }
+ if (count($result)>0)
+ $selectors[] = $result;
+ return $selectors;
+ }
+
+ function __get($name)
+ {
+ if (isset($this->attr[$name]))
+ {
+ return $this->convert_text($this->attr[$name]);
+ }
+ switch ($name)
+ {
+ case 'outertext': return $this->outertext();
+ case 'innertext': return $this->innertext();
+ case 'plaintext': return $this->text();
+ case 'xmltext': return $this->xmltext();
+ default: return array_key_exists($name, $this->attr);
+ }
+ }
+
+ function __set($name, $value)
+ {
+ global $debug_object;
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
+
+ switch ($name)
+ {
+ case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
+ case 'innertext':
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value;
+ return $this->_[HDOM_INFO_INNER] = $value;
+ }
+ if (!isset($this->attr[$name]))
+ {
+ $this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
+ $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
+ }
+ $this->attr[$name] = $value;
+ }
+
+ function __isset($name)
+ {
+ switch ($name)
+ {
+ case 'outertext': return true;
+ case 'innertext': return true;
+ case 'plaintext': return true;
+ }
+ //no value attr: nowrap, checked selected...
+ return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
+ }
+
+ function __unset($name) {
+ if (isset($this->attr[$name]))
+ unset($this->attr[$name]);
+ }
+
+ // PaperG - Function to convert the text from one character set to another if the two sets are not the same.
+ function convert_text($text)
+ {
+ global $debug_object;
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
+
+ $converted_text = $text;
+
+ $sourceCharset = "";
+ $targetCharset = "";
+
+ if ($this->dom)
+ {
+ $sourceCharset = strtoupper($this->dom->_charset);
+ $targetCharset = strtoupper($this->dom->_target_charset);
+ }
+ if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);}
+
+ if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0))
+ {
+ // Check if the reported encoding could have been incorrect and the text is actually already UTF-8
+ if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text)))
+ {
+ $converted_text = $text;
+ }
+ else
+ {
+ $converted_text = iconv($sourceCharset, $targetCharset, $text);
+ }
+ }
+
+ // Lets make sure that we don't have that silly BOM issue with any of the utf-8 text we output.
+ if ($targetCharset == 'UTF-8')
+ {
+ if (substr($converted_text, 0, 3) == "\xef\xbb\xbf")
+ {
+ $converted_text = substr($converted_text, 3);
+ }
+ if (substr($converted_text, -3) == "\xef\xbb\xbf")
+ {
+ $converted_text = substr($converted_text, 0, -3);
+ }
+ }
+
+ return $converted_text;
+ }
+
+ /**
+ * Returns true if $string is valid UTF-8 and false otherwise.
+ *
+ * @param mixed $str String to be tested
+ * @return boolean
+ */
+ static function is_utf8($str)
+ {
+ $c=0; $b=0;
+ $bits=0;
+ $len=strlen($str);
+ for($i=0; $i<$len; $i++)
+ {
+ $c=ord($str[$i]);
+ if($c > 128)
+ {
+ if(($c >= 254)) return false;
+ elseif($c >= 252) $bits=6;
+ elseif($c >= 248) $bits=5;
+ elseif($c >= 240) $bits=4;
+ elseif($c >= 224) $bits=3;
+ elseif($c >= 192) $bits=2;
+ else return false;
+ if(($i+$bits) > $len) return false;
+ while($bits > 1)
+ {
+ $i++;
+ $b=ord($str[$i]);
+ if($b < 128 || $b > 191) return false;
+ $bits--;
+ }
+ }
+ }
+ return true;
+ }
+ /*
+ function is_utf8($string)
+ {
+ //this is buggy
+ return (utf8_encode(utf8_decode($string)) == $string);
+ }
+ */
+
+ /**
+ * Function to try a few tricks to determine the displayed size of an img on the page.
+ * NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types.
+ *
+ * @author John Schlick
+ * @version April 19 2012
+ * @return array an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out.
+ */
+ function get_display_size()
+ {
+ global $debug_object;
+
+ $width = -1;
+ $height = -1;
+
+ if ($this->tag !== 'img')
+ {
+ return false;
+ }
+
+ // See if there is aheight or width attribute in the tag itself.
+ if (isset($this->attr['width']))
+ {
+ $width = $this->attr['width'];
+ }
+
+ if (isset($this->attr['height']))
+ {
+ $height = $this->attr['height'];
+ }
+
+ // Now look for an inline style.
+ if (isset($this->attr['style']))
+ {
+ // Thanks to user gnarf from stackoverflow for this regular expression.
+ $attributes = array();
+ preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
+ foreach ($matches as $match) {
+ $attributes[$match[1]] = $match[2];
+ }
+
+ // If there is a width in the style attributes:
+ if (isset($attributes['width']) && $width == -1)
+ {
+ // check that the last two characters are px (pixels)
+ if (strtolower(substr($attributes['width'], -2)) == 'px')
+ {
+ $proposed_width = substr($attributes['width'], 0, -2);
+ // Now make sure that it's an integer and not something stupid.
+ if (filter_var($proposed_width, FILTER_VALIDATE_INT))
+ {
+ $width = $proposed_width;
+ }
+ }
+ }
+
+ // If there is a width in the style attributes:
+ if (isset($attributes['height']) && $height == -1)
+ {
+ // check that the last two characters are px (pixels)
+ if (strtolower(substr($attributes['height'], -2)) == 'px')
+ {
+ $proposed_height = substr($attributes['height'], 0, -2);
+ // Now make sure that it's an integer and not something stupid.
+ if (filter_var($proposed_height, FILTER_VALIDATE_INT))
+ {
+ $height = $proposed_height;
+ }
+ }
+ }
+
+ }
+
+ // Future enhancement:
+ // Look in the tag to see if there is a class or id specified that has a height or width attribute to it.
+
+ // Far future enhancement
+ // Look at all the parent tags of this image to see if they specify a class or id that has an img selector that specifies a height or width
+ // Note that in this case, the class or id will have the img subselector for it to apply to the image.
+
+ // ridiculously far future development
+ // If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page.
+
+ $result = array('height' => $height,
+ 'width' => $width);
+ return $result;
+ }
+
+ // camel naming conventions
+ function getAllAttributes() {return $this->attr;}
+ function getAttribute($name) {return $this->__get($name);}
+ function setAttribute($name, $value) {$this->__set($name, $value);}
+ function hasAttribute($name) {return $this->__isset($name);}
+ function removeAttribute($name) {$this->__set($name, null);}
+ function getElementById($id) {return $this->find("#$id", 0);}
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
+ function getElementByTagName($name) {return $this->find($name, 0);}
+ function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);}
+ function parentNode() {return $this->parent();}
+ function childNodes($idx=-1) {return $this->children($idx);}
+ function firstChild() {return $this->first_child();}
+ function lastChild() {return $this->last_child();}
+ function nextSibling() {return $this->next_sibling();}
+ function previousSibling() {return $this->prev_sibling();}
+ function hasChildNodes() {return $this->has_child();}
+ function nodeName() {return $this->tag;}
+ function appendChild($node) {$node->parent($this); return $node;}
+
+}
+
+/**
+ * simple html dom parser
+ * Paperg - in the find routine: allow us to specify that we want case insensitive testing of the value of the selector.
+ * Paperg - change $size from protected to public so we can easily access it
+ * Paperg - added ForceTagsClosed in the constructor which tells us whether we trust the html or not. Default is to NOT trust it.
+ *
+ * @package PlaceLocalInclude
+ */
+class simple_html_dom
+{
+ public $root = null;
+ public $nodes = array();
+ public $callback = null;
+ public $lowercase = false;
+ // Used to keep track of how large the text was when we started.
+ public $original_size;
+ public $size;
+ protected $pos;
+ protected $doc;
+ protected $char;
+ protected $cursor;
+ protected $parent;
+ protected $noise = array();
+ protected $token_blank = " \t\r\n";
+ protected $token_equal = ' =/>';
+ protected $token_slash = " />\r\n\t";
+ protected $token_attr = ' >';
+ // Note that this is referenced by a child node, and so it needs to be public for that node to see this information.
+ public $_charset = '';
+ public $_target_charset = '';
+ protected $default_br_text = "";
+ public $default_span_text = "";
+
+ // use isset instead of in_array, performance boost about 30%...
+ protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
+ protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
+ // Known sourceforge issue #2977341
+ // B tags that are not closed cause us to return everything to the end of the document.
+ protected $optional_closing_tags = array(
+ 'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
+ 'th'=>array('th'=>1),
+ 'td'=>array('td'=>1),
+ 'li'=>array('li'=>1),
+ 'dt'=>array('dt'=>1, 'dd'=>1),
+ 'dd'=>array('dd'=>1, 'dt'=>1),
+ 'dl'=>array('dd'=>1, 'dt'=>1),
+ 'p'=>array('p'=>1),
+ 'nobr'=>array('nobr'=>1),
+ 'b'=>array('b'=>1),
+ 'option'=>array('option'=>1),
+ );
+
+ function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+ {
+ if ($str)
+ {
+ if (preg_match("/^http:\/\//i",$str) || is_file($str))
+ {
+ $this->load_file($str);
+ }
+ else
+ {
+ $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
+ }
+ }
+ // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html.
+ if (!$forceTagsClosed) {
+ $this->optional_closing_array=array();
+ }
+ $this->_target_charset = $target_charset;
+ }
+
+ function __destruct()
+ {
+ $this->clear();
+ }
+
+ // load html from string
+ function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+ {
+ global $debug_object;
+
+ // prepare
+ $this->prepare($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
+ // strip out cdata
+ $this->remove_noise("''is", true);
+ // strip out comments
+ $this->remove_noise("''is");
+ // Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037
+ // Script tags removal now preceeds style tag removal.
+ // strip out