Compare commits
7 Commits
master
...
leenooks-3
Author | SHA1 | Date | |
---|---|---|---|
|
c8517e61da | ||
|
e29c626899 | ||
|
5ffa395307 | ||
|
4cabe0db4f | ||
|
a835c25dcc | ||
|
78f0e6db06 | ||
|
a20cb078a8 |
@ -1,129 +0,0 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct script access.');
|
|
||||||
|
|
||||||
// -- Environment setup --------------------------------------------------------
|
|
||||||
|
|
||||||
// Load the core Kohana class
|
|
||||||
require SYSPATH.'classes/Kohana/Core'.EXT;
|
|
||||||
|
|
||||||
if (is_file(APPPATH.'classes/Kohana'.EXT))
|
|
||||||
{
|
|
||||||
// Application extends the core
|
|
||||||
require APPPATH.'classes/Kohana'.EXT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Load empty core extension
|
|
||||||
require SYSPATH.'classes/Kohana'.EXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default time zone.
|
|
||||||
*
|
|
||||||
* @link http://kohanaframework.org/guide/using.configuration
|
|
||||||
* @link http://www.php.net/manual/timezones
|
|
||||||
*/
|
|
||||||
date_default_timezone_set('America/Chicago');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default locale.
|
|
||||||
*
|
|
||||||
* @link http://kohanaframework.org/guide/using.configuration
|
|
||||||
* @link http://www.php.net/manual/function.setlocale
|
|
||||||
*/
|
|
||||||
setlocale(LC_ALL, 'en_US.utf-8');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable the Kohana auto-loader.
|
|
||||||
*
|
|
||||||
* @link http://kohanaframework.org/guide/using.autoloading
|
|
||||||
* @link http://www.php.net/manual/function.spl-autoload-register
|
|
||||||
*/
|
|
||||||
spl_autoload_register(array('Kohana', 'auto_load'));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionally, you can enable a compatibility auto-loader for use with
|
|
||||||
* older modules that have not been updated for PSR-0.
|
|
||||||
*
|
|
||||||
* It is recommended to not enable this unless absolutely necessary.
|
|
||||||
*/
|
|
||||||
//spl_autoload_register(array('Kohana', 'auto_load_lowercase'));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable the Kohana auto-loader for unserialization.
|
|
||||||
*
|
|
||||||
* @link http://www.php.net/manual/function.spl-autoload-call
|
|
||||||
* @link http://www.php.net/manual/var.configuration#unserialize-callback-func
|
|
||||||
*/
|
|
||||||
ini_set('unserialize_callback_func', 'spl_autoload_call');
|
|
||||||
|
|
||||||
// -- Configuration and initialization -----------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default language
|
|
||||||
*/
|
|
||||||
I18n::lang('en-us');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
|
|
||||||
*
|
|
||||||
* Note: If you supply an invalid environment name, a PHP warning will be thrown
|
|
||||||
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
|
|
||||||
*/
|
|
||||||
if (isset($_SERVER['KOHANA_ENV']))
|
|
||||||
{
|
|
||||||
Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize Kohana, setting the default options.
|
|
||||||
*
|
|
||||||
* The following options are available:
|
|
||||||
*
|
|
||||||
* - string base_url path, and optionally domain, of your application NULL
|
|
||||||
* - string index_file name of your index file, usually "index.php" index.php
|
|
||||||
* - string charset internal character set used for input and output utf-8
|
|
||||||
* - string cache_dir set the internal cache directory APPPATH/cache
|
|
||||||
* - integer cache_life lifetime, in seconds, of items cached 60
|
|
||||||
* - boolean errors enable or disable error handling TRUE
|
|
||||||
* - boolean profile enable or disable internal profiling TRUE
|
|
||||||
* - boolean caching enable or disable internal caching FALSE
|
|
||||||
* - boolean expose set the X-Powered-By header FALSE
|
|
||||||
*/
|
|
||||||
Kohana::init(array(
|
|
||||||
'base_url' => '/kohana/',
|
|
||||||
));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attach the file write to logging. Multiple writers are supported.
|
|
||||||
*/
|
|
||||||
Kohana::$log->attach(new Log_File(APPPATH.'logs'));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attach a file reader to config. Multiple readers are supported.
|
|
||||||
*/
|
|
||||||
Kohana::$config->attach(new Config_File);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable modules. Modules are referenced by a relative or absolute path.
|
|
||||||
*/
|
|
||||||
Kohana::modules(array(
|
|
||||||
// 'auth' => MODPATH.'auth', // Basic authentication
|
|
||||||
// 'cache' => MODPATH.'cache', // Caching with multiple backends
|
|
||||||
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
|
|
||||||
// 'database' => MODPATH.'database', // Database access
|
|
||||||
// 'image' => MODPATH.'image', // Image manipulation
|
|
||||||
// 'minion' => MODPATH.'minion', // CLI Tasks
|
|
||||||
// 'orm' => MODPATH.'orm', // Object Relationship Mapping
|
|
||||||
// 'unittest' => MODPATH.'unittest', // Unit testing
|
|
||||||
// 'userguide' => MODPATH.'userguide', // User guide and API documentation
|
|
||||||
));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the routes. Each route must have a minimum of a name, a URI and a set of
|
|
||||||
* defaults for the URI.
|
|
||||||
*/
|
|
||||||
Route::set('default', '(<controller>(/<action>(/<id>)))')
|
|
||||||
->defaults(array(
|
|
||||||
'controller' => 'welcome',
|
|
||||||
'action' => 'index',
|
|
||||||
));
|
|
@ -1,10 +0,0 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct script access.');
|
|
||||||
|
|
||||||
class Controller_Welcome extends Controller {
|
|
||||||
|
|
||||||
public function action_index()
|
|
||||||
{
|
|
||||||
$this->response->body('hello, world!');
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End Welcome
|
|
@ -1,21 +0,0 @@
|
|||||||
# Turn on URL rewriting
|
|
||||||
RewriteEngine On
|
|
||||||
|
|
||||||
# Installation directory
|
|
||||||
RewriteBase /
|
|
||||||
|
|
||||||
# Protect hidden files from being viewed
|
|
||||||
<Files .*>
|
|
||||||
Order Deny,Allow
|
|
||||||
Deny From All
|
|
||||||
</Files>
|
|
||||||
|
|
||||||
# Protect application and system files from being viewed
|
|
||||||
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
|
|
||||||
|
|
||||||
# Allow any files or directories that exist to be displayed directly
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
|
||||||
|
|
||||||
# Rewrite all other URLs to index.php/URL
|
|
||||||
RewriteRule .* index.php/$0 [PT]
|
|
121
index.php
121
index.php
@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The directory in which your application specific resources are located.
|
|
||||||
* The application directory must contain the bootstrap.php file.
|
|
||||||
*
|
|
||||||
* @link http://kohanaframework.org/guide/about.install#application
|
|
||||||
*/
|
|
||||||
$application = 'application';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The directory in which your modules are located.
|
|
||||||
*
|
|
||||||
* @link http://kohanaframework.org/guide/about.install#modules
|
|
||||||
*/
|
|
||||||
$modules = 'modules';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The directory in which the Kohana resources are located. The system
|
|
||||||
* directory must contain the classes/kohana.php file.
|
|
||||||
*
|
|
||||||
* @link http://kohanaframework.org/guide/about.install#system
|
|
||||||
*/
|
|
||||||
$system = 'system';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default extension of resource files. If you change this, all resources
|
|
||||||
* must be renamed to use the new extension.
|
|
||||||
*
|
|
||||||
* @link http://kohanaframework.org/guide/about.install#ext
|
|
||||||
*/
|
|
||||||
define('EXT', '.php');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the PHP error reporting level. If you set this in php.ini, you remove this.
|
|
||||||
* @link http://www.php.net/manual/errorfunc.configuration#ini.error-reporting
|
|
||||||
*
|
|
||||||
* When developing your application, it is highly recommended to enable notices
|
|
||||||
* and strict warnings. Enable them by using: E_ALL | E_STRICT
|
|
||||||
*
|
|
||||||
* In a production environment, it is safe to ignore notices and strict warnings.
|
|
||||||
* Disable them by using: E_ALL ^ E_NOTICE
|
|
||||||
*
|
|
||||||
* When using a legacy application with PHP >= 5.3, it is recommended to disable
|
|
||||||
* deprecated notices. Disable with: E_ALL & ~E_DEPRECATED
|
|
||||||
*/
|
|
||||||
error_reporting(E_ALL | E_STRICT);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* End of standard configuration! Changing any of the code below should only be
|
|
||||||
* attempted by those with a working knowledge of Kohana internals.
|
|
||||||
*
|
|
||||||
* @link http://kohanaframework.org/guide/using.configuration
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Set the full path to the docroot
|
|
||||||
define('DOCROOT', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);
|
|
||||||
|
|
||||||
// Make the application relative to the docroot, for symlink'd index.php
|
|
||||||
if ( ! is_dir($application) AND is_dir(DOCROOT.$application))
|
|
||||||
$application = DOCROOT.$application;
|
|
||||||
|
|
||||||
// Make the modules relative to the docroot, for symlink'd index.php
|
|
||||||
if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules))
|
|
||||||
$modules = DOCROOT.$modules;
|
|
||||||
|
|
||||||
// Make the system relative to the docroot, for symlink'd index.php
|
|
||||||
if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
|
|
||||||
$system = DOCROOT.$system;
|
|
||||||
|
|
||||||
// Define the absolute paths for configured directories
|
|
||||||
define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
|
|
||||||
define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
|
|
||||||
define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
|
|
||||||
|
|
||||||
// Clean up the configuration vars
|
|
||||||
unset($application, $modules, $system);
|
|
||||||
|
|
||||||
if (file_exists('install'.EXT))
|
|
||||||
{
|
|
||||||
// Load the installation check
|
|
||||||
return include 'install'.EXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the start time of the application, used for profiling.
|
|
||||||
*/
|
|
||||||
if ( ! defined('KOHANA_START_TIME'))
|
|
||||||
{
|
|
||||||
define('KOHANA_START_TIME', microtime(TRUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the memory usage at the start of the application, used for profiling.
|
|
||||||
*/
|
|
||||||
if ( ! defined('KOHANA_START_MEMORY'))
|
|
||||||
{
|
|
||||||
define('KOHANA_START_MEMORY', memory_get_usage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bootstrap the application
|
|
||||||
require APPPATH.'bootstrap'.EXT;
|
|
||||||
|
|
||||||
if (PHP_SAPI == 'cli') // Try and load minion
|
|
||||||
{
|
|
||||||
class_exists('Minion_Task') OR die('Please enable the Minion module for CLI support.');
|
|
||||||
set_exception_handler(array('Minion_Exception', 'handler'));
|
|
||||||
|
|
||||||
Minion_Task::factory(Minion_CLI::options())->execute();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
|
|
||||||
* If no source is specified, the URI will be automatically detected.
|
|
||||||
*/
|
|
||||||
echo Request::factory(TRUE, array(), FALSE)
|
|
||||||
->execute()
|
|
||||||
->send_headers(TRUE)
|
|
||||||
->body();
|
|
||||||
}
|
|
86
modules/cron/README.markdown
Normal file
86
modules/cron/README.markdown
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
# Kohana-Cron
|
||||||
|
|
||||||
|
This module provides a way to schedule tasks (jobs) within your Kohana application.
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Step 1: Download the module into your modules subdirectory.
|
||||||
|
|
||||||
|
Step 2: Enable the module in your bootstrap file:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable modules. Modules are referenced by a relative or absolute path.
|
||||||
|
*/
|
||||||
|
Kohana::modules(array(
|
||||||
|
'cron' => MODPATH.'cron',
|
||||||
|
// 'auth' => MODPATH.'auth', // Basic authentication
|
||||||
|
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
|
||||||
|
// 'database' => MODPATH.'database', // Database access
|
||||||
|
// 'image' => MODPATH.'image', // Image manipulation
|
||||||
|
// 'orm' => MODPATH.'orm', // Object Relationship Mapping
|
||||||
|
// 'pagination' => MODPATH.'pagination', // Paging of results
|
||||||
|
// 'userguide' => MODPATH.'userguide', // User guide and API documentation
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
Step 3: Make sure the settings in `config/cron.php` are correct for your environment.
|
||||||
|
If not, copy the file to `application/config/cron.php` and change the values accordingly.
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
In its simplest form, a task is a [PHP callback][1] and times at which it should run.
|
||||||
|
To configure a task call `Cron::set($name, array($frequency, $callback))` where
|
||||||
|
`$frequency` is a string of date and time fields identical to those found in [crontab][2].
|
||||||
|
For example,
|
||||||
|
|
||||||
|
Cron::set('reindex_catalog', array('@daily', 'Catalog::regenerate_index'));
|
||||||
|
Cron::set('calendar_notifications', array('*/5 * * * *', 'Calendar::send_emails'));
|
||||||
|
|
||||||
|
Configured tasks are run with their appropriate frequency by calling `Cron::run()`. Call
|
||||||
|
this method in your bootstrap file, and you're done!
|
||||||
|
|
||||||
|
|
||||||
|
## Advanced Usage
|
||||||
|
|
||||||
|
A task can also be an instance of `Cron` that extends `next()` and/or `execute()` as
|
||||||
|
needed. Such a task is configured by calling `Cron::set($name, $instance)`.
|
||||||
|
|
||||||
|
If you have access to the system crontab, you can run Cron less (or more) than once
|
||||||
|
every request. You will need to modify the lines where the request is handled in your
|
||||||
|
bootstrap file to prevent extraneous output. The default is:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
|
||||||
|
* If no source is specified, the URI will be automatically detected.
|
||||||
|
*/
|
||||||
|
echo Request::instance()
|
||||||
|
->execute()
|
||||||
|
->send_headers()
|
||||||
|
->response;
|
||||||
|
|
||||||
|
Change it to:
|
||||||
|
|
||||||
|
if ( ! defined('SUPPRESS_REQUEST'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
|
||||||
|
* If no source is specified, the URI will be automatically detected.
|
||||||
|
*/
|
||||||
|
echo Request::instance()
|
||||||
|
->execute()
|
||||||
|
->send_headers()
|
||||||
|
->response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Then set up a system cron job to run your application's Cron once a minute:
|
||||||
|
|
||||||
|
* * * * * /usr/bin/php -f /path/to/kohana/modules/cron/run.php
|
||||||
|
|
||||||
|
The included `run.php` should work for most cases, but you are free to call `Cron::run()`
|
||||||
|
in any way you see fit.
|
||||||
|
|
||||||
|
|
||||||
|
[1]: http://php.net/manual/language.pseudo-types.php#language.types.callback
|
||||||
|
[2]: http://linux.die.net/man/5/crontab
|
10
modules/cron/classes/Cron.php
Normal file
10
modules/cron/classes/Cron.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct script access.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Cron
|
||||||
|
*
|
||||||
|
* @author Chris Bandy
|
||||||
|
* @copyright (c) 2010 Chris Bandy
|
||||||
|
* @license http://www.opensource.org/licenses/isc-license.txt
|
||||||
|
*/
|
||||||
|
class Cron extends Kohana_Cron {}
|
621
modules/cron/classes/Kohana/Cron.php
Normal file
621
modules/cron/classes/Kohana/Cron.php
Normal file
@ -0,0 +1,621 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct script access.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Cron
|
||||||
|
*
|
||||||
|
* @author Chris Bandy
|
||||||
|
* @copyright (c) 2010 Chris Bandy
|
||||||
|
* @license http://www.opensource.org/licenses/isc-license.txt
|
||||||
|
*/
|
||||||
|
class Kohana_Cron
|
||||||
|
{
|
||||||
|
protected static $_jobs = array();
|
||||||
|
protected static $_times = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a job to be run
|
||||||
|
*
|
||||||
|
* @param string Unique name
|
||||||
|
* @param array|Cron Job to run
|
||||||
|
*/
|
||||||
|
public static function set($name, $job)
|
||||||
|
{
|
||||||
|
if (is_array($job))
|
||||||
|
{
|
||||||
|
$job = new Cron(reset($job), next($job));
|
||||||
|
}
|
||||||
|
|
||||||
|
Cron::$_jobs[$name] = $job;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the timestamps of when jobs should run
|
||||||
|
*/
|
||||||
|
protected static function _load()
|
||||||
|
{
|
||||||
|
Cron::$_times = Kohana::cache("Cron::run()");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acquire the Cron mutex
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
protected static function _lock()
|
||||||
|
{
|
||||||
|
$config = Kohana::$config->load('cron');
|
||||||
|
$result = FALSE;
|
||||||
|
|
||||||
|
if (file_exists($config->lock) AND ($stat = @stat($config->lock)) AND time() - $config->window < $stat['mtime'])
|
||||||
|
{
|
||||||
|
// Lock exists and has not expired
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fh = fopen($config->lock, 'a');
|
||||||
|
|
||||||
|
if (flock($fh, LOCK_EX))
|
||||||
|
{
|
||||||
|
fseek($fh, 0, SEEK_END);
|
||||||
|
|
||||||
|
if (ftell($fh) === (empty($stat) ? 0 : $stat['size']))
|
||||||
|
{
|
||||||
|
// Current size matches expected size
|
||||||
|
// Claim the file by changing the size
|
||||||
|
fwrite($fh, '.');
|
||||||
|
|
||||||
|
$result = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// else, Another process acquired during flock()
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($fh);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the timestamps of when jobs should run next
|
||||||
|
*/
|
||||||
|
protected static function _save()
|
||||||
|
{
|
||||||
|
Kohana::cache("Cron::run()", Cron::$_times, Kohana::$config->load('cron')->window * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release the Cron mutex
|
||||||
|
*/
|
||||||
|
protected static function _unlock()
|
||||||
|
{
|
||||||
|
return @unlink(Kohana::$config->load('cron')->lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean FALSE when another instance is running
|
||||||
|
*/
|
||||||
|
public static function run()
|
||||||
|
{
|
||||||
|
if (empty(Cron::$_jobs))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if ( ! Cron::_lock())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Cron::_load();
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$threshold = $now - Kohana::$config->load('cron')->window;
|
||||||
|
|
||||||
|
foreach (Cron::$_jobs as $name => $job)
|
||||||
|
{
|
||||||
|
if (empty(Cron::$_times[$name]) OR Cron::$_times[$name] < $threshold)
|
||||||
|
{
|
||||||
|
// Expired
|
||||||
|
|
||||||
|
Cron::$_times[$name] = $job->next($now);
|
||||||
|
|
||||||
|
if ($job->next($threshold) < $now)
|
||||||
|
{
|
||||||
|
// Within the window
|
||||||
|
|
||||||
|
$job->execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (Cron::$_times[$name] < $now)
|
||||||
|
{
|
||||||
|
// Within the window
|
||||||
|
|
||||||
|
Cron::$_times[$name] = $job->next($now);
|
||||||
|
|
||||||
|
$job->execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e) {}
|
||||||
|
|
||||||
|
Cron::_save();
|
||||||
|
Cron::_unlock();
|
||||||
|
|
||||||
|
if (isset($e))
|
||||||
|
throw $e;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $_callback;
|
||||||
|
protected $_period;
|
||||||
|
|
||||||
|
public function __construct($period, $callback)
|
||||||
|
{
|
||||||
|
$this->_period = $period;
|
||||||
|
$this->_callback = $callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute this job
|
||||||
|
*/
|
||||||
|
public function execute()
|
||||||
|
{
|
||||||
|
call_user_func($this->_callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the next timestamp in this period
|
||||||
|
*
|
||||||
|
* @param integer Timestamp from which to calculate
|
||||||
|
* @return integer Next timestamp in this period
|
||||||
|
*/
|
||||||
|
public function next($from)
|
||||||
|
{
|
||||||
|
// PHP >= 5.3.0
|
||||||
|
//if ($this->_period instanceof DatePeriod) { return; }
|
||||||
|
//if (is_string($this->_period) AND preg_match('/^P[\dDHMSTWY]+$/', $period)) { $this->_period = new DateInterval($this->_period); }
|
||||||
|
//if ($this->_period instanceof DateInterval) { return; }
|
||||||
|
|
||||||
|
return $this->_next_crontab($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the next timestamp of this crontab period
|
||||||
|
*
|
||||||
|
* @param integer Timestamp from which to calculate
|
||||||
|
* @return integer Next timestamp in this period
|
||||||
|
*/
|
||||||
|
protected function _next_crontab($from)
|
||||||
|
{
|
||||||
|
if (is_string($this->_period))
|
||||||
|
{
|
||||||
|
// Convert string to lists of valid values
|
||||||
|
|
||||||
|
if ($this->_period[0] === '@')
|
||||||
|
{
|
||||||
|
switch (substr($this->_period, 1))
|
||||||
|
{
|
||||||
|
case 'annually':
|
||||||
|
case 'yearly':
|
||||||
|
// '0 0 1 1 *'
|
||||||
|
$this->_period = array('minutes' => array(0), 'hours' => array(0), 'monthdays' => array(1), 'months' => array(1), 'weekdays' => range(0,6));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'daily':
|
||||||
|
case 'midnight':
|
||||||
|
// '0 0 * * *'
|
||||||
|
$this->_period = array('minutes' => array(0), 'hours' => array(0), 'monthdays' => range(1,31), 'months' => range(1,12), 'weekdays' => range(0,6));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'hourly':
|
||||||
|
// '0 * * * *'
|
||||||
|
$this->_period = array('minutes' => array(0), 'hours' => range(0,23), 'monthdays' => range(1,31), 'months' => range(1,12), 'weekdays' => range(0,6));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'monthly':
|
||||||
|
// '0 0 1 * *'
|
||||||
|
$this->_period = array('minutes' => array(0), 'hours' => array(0), 'monthdays' => array(1), 'months' => range(1,12), 'weekdays' => range(0,6));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'weekly':
|
||||||
|
// '0 0 * * 0'
|
||||||
|
$this->_period = array('minutes' => array(0), 'hours' => array(0), 'monthdays' => range(1,31), 'months' => range(1,12), 'weekdays' => array(0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list($minutes, $hours, $monthdays, $months, $weekdays) = explode(' ', $this->_period);
|
||||||
|
|
||||||
|
$months = strtr(strtolower($months), array(
|
||||||
|
'jan' => 1,
|
||||||
|
'feb' => 2,
|
||||||
|
'mar' => 3,
|
||||||
|
'apr' => 4,
|
||||||
|
'may' => 5,
|
||||||
|
'jun' => 6,
|
||||||
|
'jul' => 7,
|
||||||
|
'aug' => 8,
|
||||||
|
'sep' => 9,
|
||||||
|
'oct' => 10,
|
||||||
|
'nov' => 11,
|
||||||
|
'dec' => 12,
|
||||||
|
));
|
||||||
|
|
||||||
|
$weekdays = strtr(strtolower($weekdays), array(
|
||||||
|
'sun' => 0,
|
||||||
|
'mon' => 1,
|
||||||
|
'tue' => 2,
|
||||||
|
'wed' => 3,
|
||||||
|
'thu' => 4,
|
||||||
|
'fri' => 5,
|
||||||
|
'sat' => 6,
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->_period = array(
|
||||||
|
'minutes' => $this->_parse_crontab_field($minutes, 0, 59),
|
||||||
|
'hours' => $this->_parse_crontab_field($hours, 0, 23),
|
||||||
|
'monthdays' => $this->_parse_crontab_field($monthdays, 1, 31),
|
||||||
|
'months' => $this->_parse_crontab_field($months, 1, 12),
|
||||||
|
'weekdays' => $this->_parse_crontab_field($weekdays, 0, 7)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Ensure Sunday is zero
|
||||||
|
if (end($this->_period['weekdays']) === 7)
|
||||||
|
{
|
||||||
|
array_pop($this->_period['weekdays']);
|
||||||
|
|
||||||
|
if (reset($this->_period['weekdays']) !== 0)
|
||||||
|
{
|
||||||
|
array_unshift($this->_period['weekdays'], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$from = getdate($from);
|
||||||
|
|
||||||
|
if ( ! in_array($from['mon'], $this->_period['months']))
|
||||||
|
return $this->_next_crontab_month($from);
|
||||||
|
|
||||||
|
if (count($this->_period['weekdays']) === 7)
|
||||||
|
{
|
||||||
|
// Day of Week is unrestricted, defer to Day of Month
|
||||||
|
if ( ! in_array($from['mday'], $this->_period['monthdays']))
|
||||||
|
return $this->_next_crontab_monthday($from);
|
||||||
|
}
|
||||||
|
elseif (count($this->_period['monthdays']) === 31)
|
||||||
|
{
|
||||||
|
// Day of Month is unrestricted, use Day of Week
|
||||||
|
if ( ! in_array($from['wday'], $this->_period['weekdays']))
|
||||||
|
return $this->_next_crontab_weekday($from);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Both Day of Week and Day of Month are restricted
|
||||||
|
if ( ! in_array($from['mday'], $this->_period['monthdays']) AND ! in_array($from['wday'], $this->_period['weekdays']))
|
||||||
|
return $this->_next_crontab_day($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! in_array($from['hours'], $this->_period['hours']))
|
||||||
|
return $this->_next_crontab_hour($from);
|
||||||
|
|
||||||
|
return $this->_next_crontab_minute($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the first timestamp in the next day of this period when both
|
||||||
|
* Day of Week and Day of Month are restricted
|
||||||
|
*
|
||||||
|
* @uses _next_crontab_month()
|
||||||
|
*
|
||||||
|
* @param array Date array from getdate()
|
||||||
|
* @return integer Timestamp of next restricted Day
|
||||||
|
*/
|
||||||
|
protected function _next_crontab_day(array $from)
|
||||||
|
{
|
||||||
|
// Calculate effective Day of Month for next Day of Week
|
||||||
|
|
||||||
|
if ($from['wday'] >= end($this->_period['weekdays']))
|
||||||
|
{
|
||||||
|
$next = reset($this->_period['weekdays']) + 7;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach ($this->_period['weekdays'] as $next)
|
||||||
|
{
|
||||||
|
if ($from['wday'] < $next)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$monthday = $from['mday'] + $next - $from['wday'];
|
||||||
|
|
||||||
|
if ($monthday <= (int) date('t', mktime(0, 0, 0, $from['mon'], 1, $from['year'])))
|
||||||
|
{
|
||||||
|
// Next Day of Week is in this Month
|
||||||
|
|
||||||
|
if ($from['mday'] >= end($this->_period['monthdays']))
|
||||||
|
{
|
||||||
|
// No next Day of Month, use next Day of Week
|
||||||
|
$from['mday'] = $monthday;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Calculate next Day of Month
|
||||||
|
foreach ($this->_period['monthdays'] as $next)
|
||||||
|
{
|
||||||
|
if ($from['mday'] < $next)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use earliest day
|
||||||
|
$from['mday'] = min($monthday, $next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($from['mday'] >= end($this->_period['monthdays']))
|
||||||
|
{
|
||||||
|
// No next Day of Month, use next Month
|
||||||
|
return $this->_next_crontab_month($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate next Day of Month
|
||||||
|
foreach ($this->_period['monthdays'] as $next)
|
||||||
|
{
|
||||||
|
if ($from['mday'] < $next)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use next Day of Month
|
||||||
|
$from['mday'] = $next;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use first Hour and first Minute
|
||||||
|
return mktime(reset($this->_period['hours']), reset($this->_period['minutes']), 0, $from['mon'], $from['mday'], $from['year']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the first timestamp in the next hour of this period
|
||||||
|
*
|
||||||
|
* @uses _next_crontab_day()
|
||||||
|
* @uses _next_crontab_monthday()
|
||||||
|
* @uses _next_crontab_weekday()
|
||||||
|
*
|
||||||
|
* @param array Date array from getdate()
|
||||||
|
* @return integer Timestamp of next Hour
|
||||||
|
*/
|
||||||
|
protected function _next_crontab_hour(array $from)
|
||||||
|
{
|
||||||
|
if ($from['hours'] >= end($this->_period['hours']))
|
||||||
|
{
|
||||||
|
// No next Hour
|
||||||
|
|
||||||
|
if (count($this->_period['weekdays']) === 7)
|
||||||
|
{
|
||||||
|
// Day of Week is unrestricted, defer to Day of Month
|
||||||
|
return $this->_next_crontab_monthday($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->_period['monthdays']) === 31)
|
||||||
|
{
|
||||||
|
// Day of Month is unrestricted, use Day of Week
|
||||||
|
return $this->_next_crontab_weekday($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Both Day of Week and Day of Month are restricted
|
||||||
|
return $this->_next_crontab_day($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate next Hour
|
||||||
|
foreach ($this->_period['hours'] as $next)
|
||||||
|
{
|
||||||
|
if ($from['hours'] < $next)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use next Hour and first Minute
|
||||||
|
return mktime($next, reset($this->_period['minutes']), 0, $from['mon'], $from['mday'], $from['year']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the timestamp of the next minute in this period
|
||||||
|
*
|
||||||
|
* @uses _next_crontab_hour()
|
||||||
|
*
|
||||||
|
* @param array Date array from getdate()
|
||||||
|
* @return integer Timestamp of next Minute
|
||||||
|
*/
|
||||||
|
protected function _next_crontab_minute(array $from)
|
||||||
|
{
|
||||||
|
if ($from['minutes'] >= end($this->_period['minutes']))
|
||||||
|
{
|
||||||
|
// No next Minute, use next Hour
|
||||||
|
return $this->_next_crontab_hour($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate next Minute
|
||||||
|
foreach ($this->_period['minutes'] as $next)
|
||||||
|
{
|
||||||
|
if ($from['minutes'] < $next)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use next Minute
|
||||||
|
return mktime($from['hours'], $next, 0, $from['mon'], $from['mday'], $from['year']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the first timestamp in the next month of this period
|
||||||
|
*
|
||||||
|
* @param array Date array from getdate()
|
||||||
|
* @return integer Timestamp of next Month
|
||||||
|
*/
|
||||||
|
protected function _next_crontab_month(array $from)
|
||||||
|
{
|
||||||
|
if ($from['mon'] >= end($this->_period['months']))
|
||||||
|
{
|
||||||
|
// No next Month, increment Year and use first Month
|
||||||
|
++$from['year'];
|
||||||
|
$from['mon'] = reset($this->_period['months']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Calculate next Month
|
||||||
|
foreach ($this->_period['months'] as $next)
|
||||||
|
{
|
||||||
|
if ($from['mon'] < $next)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use next Month
|
||||||
|
$from['mon'] = $next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->_period['weekdays']) === 7)
|
||||||
|
{
|
||||||
|
// Day of Week is unrestricted, use first Day of Month
|
||||||
|
$from['mday'] = reset($this->_period['monthdays']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Calculate Day of Month for the first Day of Week
|
||||||
|
$indices = array_flip($this->_period['weekdays']);
|
||||||
|
|
||||||
|
$monthday = 1;
|
||||||
|
$weekday = (int) date('w', mktime(0, 0, 0, $from['mon'], 1, $from['year']));
|
||||||
|
|
||||||
|
while ( ! isset($indices[$weekday % 7]) AND $monthday < 7)
|
||||||
|
{
|
||||||
|
++$monthday;
|
||||||
|
++$weekday;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->_period['monthdays']) === 31)
|
||||||
|
{
|
||||||
|
// Day of Month is unrestricted, use first Day of Week
|
||||||
|
$from['mday'] = $monthday;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Both Day of Month and Day of Week are restricted, use earliest one
|
||||||
|
$from['mday'] = min($monthday, reset($this->_period['monthdays']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use first Hour and first Minute
|
||||||
|
return mktime(reset($this->_period['hours']), reset($this->_period['minutes']), 0, $from['mon'], $from['mday'], $from['year']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the first timestamp in the next day of this period when only
|
||||||
|
* Day of Month is restricted
|
||||||
|
*
|
||||||
|
* @uses _next_crontab_month()
|
||||||
|
*
|
||||||
|
* @param array Date array from getdate()
|
||||||
|
* @return integer Timestamp of next Day of Month
|
||||||
|
*/
|
||||||
|
protected function _next_crontab_monthday(array $from)
|
||||||
|
{
|
||||||
|
if ($from['mday'] >= end($this->_period['monthdays']))
|
||||||
|
{
|
||||||
|
// No next Day of Month, use next Month
|
||||||
|
return $this->_next_crontab_month($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate next Day of Month
|
||||||
|
foreach ($this->_period['monthdays'] as $next)
|
||||||
|
{
|
||||||
|
if ($from['mday'] < $next)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use next Day of Month, first Hour, and first Minute
|
||||||
|
return mktime(reset($this->_period['hours']), reset($this->_period['minutes']), 0, $from['mon'], $next, $from['year']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the first timestamp in the next day of this period when only
|
||||||
|
* Day of Week is restricted
|
||||||
|
*
|
||||||
|
* @uses _next_crontab_month()
|
||||||
|
*
|
||||||
|
* @param array Date array from getdate()
|
||||||
|
* @return integer Timestamp of next Day of Week
|
||||||
|
*/
|
||||||
|
protected function _next_crontab_weekday(array $from)
|
||||||
|
{
|
||||||
|
// Calculate effective Day of Month for next Day of Week
|
||||||
|
|
||||||
|
if ($from['wday'] >= end($this->_period['weekdays']))
|
||||||
|
{
|
||||||
|
$next = reset($this->_period['weekdays']) + 7;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach ($this->_period['weekdays'] as $next)
|
||||||
|
{
|
||||||
|
if ($from['wday'] < $next)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$monthday = $from['mday'] + $next - $from['wday'];
|
||||||
|
|
||||||
|
if ($monthday > (int) date('t', mktime(0, 0, 0, $from['mon'], 1, $from['year'])))
|
||||||
|
{
|
||||||
|
// Next Day of Week is not in this Month, use next Month
|
||||||
|
return $this->_next_crontab_month($from);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use next Day of Week, first Hour, and first Minute
|
||||||
|
return mktime(reset($this->_period['hours']), reset($this->_period['minutes']), 0, $from['mon'], $monthday, $from['year']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a sorted array of all the values indicated in a Crontab field
|
||||||
|
* @link http://linux.die.net/man/5/crontab
|
||||||
|
*
|
||||||
|
* @param string Crontab field
|
||||||
|
* @param integer Minimum value for this field
|
||||||
|
* @param integer Maximum value for this field
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _parse_crontab_field($value, $min, $max)
|
||||||
|
{
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
foreach (explode(',', $value) as $value)
|
||||||
|
{
|
||||||
|
if ($slash = strrpos($value, '/'))
|
||||||
|
{
|
||||||
|
$step = (int) substr($value, $slash + 1);
|
||||||
|
$value = substr($value, 0, $slash);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($value === '*')
|
||||||
|
{
|
||||||
|
$result = array_merge($result, range($min, $max, $slash ? $step : 1));
|
||||||
|
}
|
||||||
|
elseif ($dash = strpos($value, '-'))
|
||||||
|
{
|
||||||
|
$result = array_merge($result, range(max($min, (int) substr($value, 0, $dash)), min($max, (int) substr($value, $dash + 1)), $slash ? $step : 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value = (int) $value;
|
||||||
|
|
||||||
|
if ($min <= $value AND $value <= $max)
|
||||||
|
{
|
||||||
|
$result[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort($result);
|
||||||
|
|
||||||
|
return array_unique($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
modules/cron/config/cron.php
Normal file
28
modules/cron/config/cron.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Cron
|
||||||
|
*
|
||||||
|
* @author Chris Bandy
|
||||||
|
* @copyright (c) 2010 Chris Bandy
|
||||||
|
* @license http://www.opensource.org/licenses/isc-license.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
return array
|
||||||
|
(
|
||||||
|
// Path to a writable directory and lock file
|
||||||
|
'lock' => Kohana::$cache_dir.DIRECTORY_SEPARATOR.'cron.lck',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cron does not run EXACTLY when tasks are scheduled.
|
||||||
|
* A task can be executed up to this many seconds AFTER its scheduled time.
|
||||||
|
*
|
||||||
|
* For example, Cron is run at 10:48 and a task was scheduled to execute at
|
||||||
|
* 10:45, 180 seconds ago. If window is greater than 180, the task will be
|
||||||
|
* executed.
|
||||||
|
*
|
||||||
|
* This value should always be larger than the time it takes to run all
|
||||||
|
* your tasks.
|
||||||
|
*/
|
||||||
|
'window' => 300,
|
||||||
|
);
|
22
modules/cron/run.php
Normal file
22
modules/cron/run.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Cron
|
||||||
|
*
|
||||||
|
* @author Chris Bandy
|
||||||
|
* @copyright (c) 2010 Chris Bandy
|
||||||
|
* @license http://www.opensource.org/licenses/isc-license.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Path to Kohana's index.php
|
||||||
|
$system = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'index.php';
|
||||||
|
|
||||||
|
if (file_exists($system))
|
||||||
|
{
|
||||||
|
defined('SUPPRESS_REQUEST') or define('SUPPRESS_REQUEST', TRUE);
|
||||||
|
|
||||||
|
include $system;
|
||||||
|
|
||||||
|
// If Cron has been run in APPPATH/bootstrap.php, this second call is harmless
|
||||||
|
Cron::run();
|
||||||
|
}
|
85
modules/cron/tests/kohana/cron.php
Normal file
85
modules/cron/tests/kohana/cron.php
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Cron
|
||||||
|
* @group kohana
|
||||||
|
* @group kohana.cron
|
||||||
|
*
|
||||||
|
* @author Chris Bandy
|
||||||
|
* @copyright (c) 2010 Chris Bandy
|
||||||
|
* @license http://www.opensource.org/licenses/isc-license.txt
|
||||||
|
*/
|
||||||
|
class Kohana_Cron_Test extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @dataProvider provider_next
|
||||||
|
*
|
||||||
|
* @param string Period
|
||||||
|
* @param integer Timestamp from which to calculate
|
||||||
|
* @param integer Next timestamp in period
|
||||||
|
*/
|
||||||
|
public function test_next($period, $from, $expected_result)
|
||||||
|
{
|
||||||
|
$cron = new Cron($period, NULL);
|
||||||
|
$result = $cron->next($from);
|
||||||
|
|
||||||
|
$this->assertSame($expected_result, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provider_next()
|
||||||
|
{
|
||||||
|
return array
|
||||||
|
(
|
||||||
|
array('@annually', mktime(8, 45, 0, 11, 19, 2009), mktime(0, 0, 0, 1, 1, 2010)),
|
||||||
|
array('@monthly', mktime(8, 45, 0, 11, 19, 2009), mktime(0, 0, 0, 12, 1, 2009)),
|
||||||
|
array('@weekly', mktime(8, 45, 0, 11, 19, 2009), mktime(0, 0, 0, 11, 22, 2009)),
|
||||||
|
array('@daily', mktime(8, 45, 0, 11, 19, 2009), mktime(0, 0, 0, 11, 20, 2009)),
|
||||||
|
array('@hourly', mktime(8, 45, 0, 11, 19, 2009), mktime(9, 0, 0, 11, 19, 2009)),
|
||||||
|
|
||||||
|
array('* * * * *', mktime(8, 45, 0, 11, 19, 2009), mktime(8, 46, 0, 11, 19, 2009)),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'* * * * 0', // Sundays
|
||||||
|
mktime(0, 0, 0, 11, 30, 2009), // Monday, Nov 30, 2009
|
||||||
|
mktime(0, 0, 0, 12, 6, 2009) // Sunday, Dec 6, 2009
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'* * 15 * 6', // 15th and Saturdays
|
||||||
|
mktime(0, 0, 0, 11, 29, 2009), // Sunday, Nov 29, 2009
|
||||||
|
mktime(0, 0, 0, 12, 5, 2009) // Saturday, Dec 5, 2009
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'* * * * 1,5', // Mondays and Fridays
|
||||||
|
mktime(0, 0, 0, 11, 24, 2009), // Tuesday, Nov 24, 2009
|
||||||
|
mktime(0, 0, 0, 11, 27, 2009) // Friday, Nov 27, 2009
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'* * 15 * 6-7', // 15th, Saturdays, and Sundays
|
||||||
|
mktime(0, 0, 0, 11, 23, 2009), // Monday, Nov 23, 2009
|
||||||
|
mktime(0, 0, 0, 11, 28, 2009) // Saturday, Nov 28, 2009
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'* * 15,30 * 2', // 15th, 30th, and Tuesdays
|
||||||
|
mktime(0, 0, 0, 11, 29, 2009), // Sunday, Nov 29, 2009
|
||||||
|
mktime(0, 0, 0, 11, 30, 2009) // Monday, Nov 30, 2009
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'0 0 * * 4', // Midnight on Thursdays
|
||||||
|
mktime(1, 0, 0, 11, 19, 2009), // 01:00 Thursday, Nov 19, 2009
|
||||||
|
mktime(0, 0, 0, 11, 26, 2009) // 00:00 Thursday, Nov 26, 2009
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'0 0 */2 * 4', // Midnight on odd days and Thursdays
|
||||||
|
mktime(1, 0, 0, 11, 19, 2009), // 01:00 Thursday, Nov 19, 2009
|
||||||
|
mktime(0, 0, 0, 11, 21, 2009) // 00:00 Saturday, Nov 21, 2009
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -127,8 +127,21 @@ class Kohana_Database_Query_Builder_Join extends Database_Query_Builder {
|
|||||||
$op = ' '.strtoupper($op);
|
$op = ' '.strtoupper($op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In case C2 is prefixed with table
|
||||||
|
$c2table = FALSE;
|
||||||
|
$parts = explode('.', $c2);
|
||||||
|
|
||||||
|
// If there are parts, we'll check that first one is the table name.
|
||||||
|
if (count($parts) == 2)
|
||||||
|
{
|
||||||
|
if ($db->list_columns($parts[0],$parts[1]))
|
||||||
|
{
|
||||||
|
$c2table = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Quote each of the columns used for the condition
|
// Quote each of the columns used for the condition
|
||||||
$conditions[] = $db->quote_column($c1).$op.' '.$db->quote_column($c2);
|
$conditions[] = $db->quote_column($c1).$op.' '.($c2table ? $db->quote_column($c2) : $db->quote($c2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Concat the conditions "... AND ..."
|
// Concat the conditions "... AND ..."
|
||||||
|
39
modules/khemail/README.markdown
Normal file
39
modules/khemail/README.markdown
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
Email Module For Kohana 3.0
|
||||||
|
=================================
|
||||||
|
|
||||||
|
This is a direct port of the email helper from Kohana 2.3.3 source code.
|
||||||
|
|
||||||
|
It has been updated to work with SwiftMailer 4 and includes the libs dir from the 4.0.4 distribution.
|
||||||
|
|
||||||
|
Usage should be exactly as with old helper.
|
||||||
|
|
||||||
|
Methods defined:
|
||||||
|
|
||||||
|
### Email::connect($config = NULL)
|
||||||
|
|
||||||
|
Creates SwiftMailer object. $config is an array of configuration values and defaults to using the config file 'email'.
|
||||||
|
|
||||||
|
Note: PopBeforeSmtp is not supported in this release as I didn't know what was required to set it up.
|
||||||
|
It IS supported in Swiftmailer through the Swift_Plugins_PopBeforeSmtpPlugin plugin class. This can be used manually if required.
|
||||||
|
If anyone can modify and test the connect() methd with this functionality I'll add it but I can't find documentation about how it used to work (i.e. is expected to work) so I have left it out for now.
|
||||||
|
|
||||||
|
### Email::send($to, $from, $subject, $message, $html = false)
|
||||||
|
|
||||||
|
$to can be any of the following:
|
||||||
|
|
||||||
|
* a single string email address e.g. "test@example.com"
|
||||||
|
* an array specifying an email address and a name e.g. array('test@example.com', 'John Doe')
|
||||||
|
* an array of recipients in either above format, keyed by type e.g. array('to' => 'test@example.com', 'cc' => array('test2@example.com', 'Jane Doe'), 'bcc' => 'another@example.com')
|
||||||
|
|
||||||
|
$from can be either a string email or array of email and name as above
|
||||||
|
|
||||||
|
More complex email (multipart, attachments, batch mailing etc.) must be done using the native Swift_Mailer classes. The Swift Mailer autoloader is included by connect() so you can use and class in the Swift library without worrying about including files.
|
||||||
|
|
||||||
|
The Swift_Mailer object setup by connect is returned by it so if you need to access it manually use:
|
||||||
|
|
||||||
|
$mailer = Email::connect();
|
||||||
|
|
||||||
|
// Create complex Swift_Message object stored in $message
|
||||||
|
|
||||||
|
$mailer->send($message);
|
||||||
|
|
145
modules/khemail/classes/Email.php
Normal file
145
modules/khemail/classes/Email.php
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||||
|
/**
|
||||||
|
* Email module
|
||||||
|
*
|
||||||
|
* Ported from Kohana 2.2.3 Core to Kohana 3.0 module
|
||||||
|
*
|
||||||
|
* Updated to use Swiftmailer 4.0.4
|
||||||
|
*
|
||||||
|
* @package Core
|
||||||
|
* @author Kohana Team
|
||||||
|
* @copyright (c) 2007-2008 Kohana Team
|
||||||
|
* @license http://kohanaphp.com/license.html
|
||||||
|
*/
|
||||||
|
class Email {
|
||||||
|
|
||||||
|
// SwiftMailer instance
|
||||||
|
protected static $mail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SwiftMailer instance.
|
||||||
|
*
|
||||||
|
* @param string DSN connection string
|
||||||
|
* @return object Swift object
|
||||||
|
*/
|
||||||
|
public static function connect($config = NULL)
|
||||||
|
{
|
||||||
|
if ( ! class_exists('Swift_Mailer', FALSE))
|
||||||
|
{
|
||||||
|
// Load SwiftMailer
|
||||||
|
require Kohana::find_file('vendor', 'swift/swift_required');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load default configuration
|
||||||
|
($config === NULL) and $config = Kohana::$config->load('email');
|
||||||
|
|
||||||
|
switch ($config['driver'])
|
||||||
|
{
|
||||||
|
case 'smtp':
|
||||||
|
// Set port
|
||||||
|
$port = empty($config['options']['port']) ? 25 : (int) $config['options']['port'];
|
||||||
|
|
||||||
|
// Create SMTP Transport
|
||||||
|
$transport = Swift_SmtpTransport::newInstance($config['options']['hostname'], $port);
|
||||||
|
|
||||||
|
if ( ! empty($config['options']['encryption']))
|
||||||
|
{
|
||||||
|
// Set encryption
|
||||||
|
$transport->setEncryption($config['options']['encryption']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do authentication, if part of the DSN
|
||||||
|
empty($config['options']['username']) or $transport->setUsername($config['options']['username']);
|
||||||
|
empty($config['options']['password']) or $transport->setPassword($config['options']['password']);
|
||||||
|
|
||||||
|
// Set the timeout to 5 seconds
|
||||||
|
$transport->setTimeout(empty($config['options']['timeout']) ? 5 : (int) $config['options']['timeout']);
|
||||||
|
break;
|
||||||
|
case 'sendmail':
|
||||||
|
// Create a sendmail connection
|
||||||
|
$transport = Swift_SendmailTransport::newInstance(empty($config['options']) ? "/usr/sbin/sendmail -bs" : $config['options']);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Use the native connection
|
||||||
|
$transport = Swift_MailTransport::newInstance($config['options']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the SwiftMailer instance
|
||||||
|
return Email::$mail = Swift_Mailer::newInstance($transport);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email message.
|
||||||
|
*
|
||||||
|
* @param string|array recipient email (and name), or an array of To, Cc, Bcc names
|
||||||
|
* @param string|array sender email (and name)
|
||||||
|
* @param string message subject
|
||||||
|
* @param string message body
|
||||||
|
* @param boolean send email as HTML
|
||||||
|
* @return integer number of emails sent
|
||||||
|
*/
|
||||||
|
public static function send($to, $from, $subject, $message, $html = FALSE)
|
||||||
|
{
|
||||||
|
// Connect to SwiftMailer
|
||||||
|
(Email::$mail === NULL) and email::connect();
|
||||||
|
|
||||||
|
// Determine the message type
|
||||||
|
$html = ($html === TRUE) ? 'text/html' : 'text/plain';
|
||||||
|
|
||||||
|
// Create the message
|
||||||
|
$message = Swift_Message::newInstance($subject, $message, $html, 'utf-8');
|
||||||
|
|
||||||
|
if (is_string($to))
|
||||||
|
{
|
||||||
|
// Single recipient
|
||||||
|
$message->setTo($to);
|
||||||
|
}
|
||||||
|
elseif (is_array($to))
|
||||||
|
{
|
||||||
|
if (isset($to[0]) AND isset($to[1]))
|
||||||
|
{
|
||||||
|
// Create To: address set
|
||||||
|
$to = array('to' => $to);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($to as $method => $set)
|
||||||
|
{
|
||||||
|
if ( ! in_array($method, array('to', 'cc', 'bcc')))
|
||||||
|
{
|
||||||
|
// Use To: by default
|
||||||
|
$method = 'to';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create method name
|
||||||
|
$method = 'add'.ucfirst($method);
|
||||||
|
|
||||||
|
if (is_array($set))
|
||||||
|
{
|
||||||
|
// Add a recipient with name
|
||||||
|
$message->$method($set[0], $set[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add a recipient without name
|
||||||
|
$message->$method($set);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string($from))
|
||||||
|
{
|
||||||
|
// From without a name
|
||||||
|
$message->setFrom($from);
|
||||||
|
}
|
||||||
|
elseif (is_array($from))
|
||||||
|
{
|
||||||
|
// From with a name
|
||||||
|
$message->setFrom($from[0], $from[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Email::$mail->send($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End email
|
29
modules/khemail/config/email.php
Normal file
29
modules/khemail/config/email.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||||
|
return array(
|
||||||
|
/**
|
||||||
|
* SwiftMailer driver, used with the email module.
|
||||||
|
*
|
||||||
|
* Valid drivers are: native, sendmail, smtp
|
||||||
|
*/
|
||||||
|
'driver' => 'native',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To use secure connections with SMTP, set "port" to 465 instead of 25.
|
||||||
|
* To enable TLS, set "encryption" to "tls".
|
||||||
|
*
|
||||||
|
* Note for SMTP, 'auth' key no longer exists as it did in 2.3.x helper
|
||||||
|
* Simply specifying a username and password is enough for all normal auth methods
|
||||||
|
* as they are autodeteccted in Swiftmailer 4
|
||||||
|
*
|
||||||
|
* PopB4Smtp is not supported in this module as I had no way to test it but
|
||||||
|
* SwiftMailer 4 does have a PopBeforeSMTP plugin so it shouldn't be hard to implement
|
||||||
|
*
|
||||||
|
* Encryption can be one of 'ssl' or 'tls' (both require non-default PHP extensions
|
||||||
|
*
|
||||||
|
* Driver options:
|
||||||
|
* @param null native: no options
|
||||||
|
* @param string sendmail: executable path, with -bs or equivalent attached
|
||||||
|
* @param array smtp: hostname, (username), (password), (port), (encryption)
|
||||||
|
*/
|
||||||
|
'options' => NULL
|
||||||
|
);
|
61
modules/khemail/vendor/swift/CHANGES
vendored
Normal file
61
modules/khemail/vendor/swift/CHANGES
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
Changelog for Swift Mailer, since Version 4.x
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
09 March 2009: 4.0.0
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* Complete rewrite of Version 3.x with lots of breaking changes at the interface
|
||||||
|
level, but for the best in the long run.
|
||||||
|
* Changed Connections to Transports
|
||||||
|
* Made sending more robust (less error prone)
|
||||||
|
* Simplified Swift_Message interface (removed need for separate RecipientList)
|
||||||
|
* Improved Plugin API (better event management)
|
||||||
|
* Changed all MIME generated content to be full RFC 2822 (and friends) compliant
|
||||||
|
|
||||||
|
11 March 2009: 4.0.1
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* Fixed regression with cache clearing logic in setBody(), setEncoder() and
|
||||||
|
setCharset()
|
||||||
|
|
||||||
|
13 March 2009: 4.0.2
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* Added addTo(), addCc() etc methods.
|
||||||
|
* Allowed setTo(), setCc() etc to accept a $name parameters.
|
||||||
|
* Patched a bug in MailTransport where failed recipients were not being merged.
|
||||||
|
* Added Swift::VERSION constant
|
||||||
|
* Allowed custom autoloaders to be used
|
||||||
|
|
||||||
|
20 March 2009: 4.0.3
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* Fixed Bug where base64 encoded content could exceed 76 chars per line
|
||||||
|
* Allowed Decorator plugin to accept a custom Replacements object
|
||||||
|
|
||||||
|
12 August 2009: 4.0.4
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* Bugfixes for operating under safe mode and using the MailTransport
|
||||||
|
* Compatibility for PHP 5.3
|
||||||
|
* Optimizations for addTo(), addCc() etc operations
|
||||||
|
* Bugfix for double-escaping issue in batch sending
|
||||||
|
|
||||||
|
27 September 2009: 4.0.5
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
* Fixed a warning (#78)
|
||||||
|
* Clarified license and updated the file headers accordingly
|
||||||
|
* Added __toString() methods where toString() methods already exists
|
||||||
|
* Removed constants (SWIFT_LIB_DIRECTORY, SWIFT_MAP_DIRECTORY, SWIFT_CLASS_DIRECTORY)
|
||||||
|
* Simplified autoloading
|
||||||
|
* Added a setAuthMode() method to AuthHandler (#54)
|
||||||
|
|
||||||
|
20 January 2010: 4.0.6
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
* added a PEAR package and a script to generate PEAR packages
|
||||||
|
* fixed Swift_Transport_TransportException for SMTP connection not thrown (#109)
|
||||||
|
* fixed Message-IDs are not updated properly (#118)
|
||||||
|
|
||||||
|
-- End of Changes --
|
165
modules/khemail/vendor/swift/LICENSE
vendored
Normal file
165
modules/khemail/vendor/swift/LICENSE
vendored
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
This version of the GNU Lesser General Public License incorporates
|
||||||
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
|
0. Additional Definitions.
|
||||||
|
|
||||||
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
|
General Public License.
|
||||||
|
|
||||||
|
"The Library" refers to a covered work governed by this License,
|
||||||
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
|
An "Application" is any work that makes use of an interface provided
|
||||||
|
by the Library, but which is not otherwise based on the Library.
|
||||||
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
|
with which the Combined Work was made is also called the "Linked
|
||||||
|
Version".
|
||||||
|
|
||||||
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
2. Conveying Modified Versions.
|
||||||
|
|
||||||
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
|
facility refers to a function or data to be supplied by an Application
|
||||||
|
that uses the facility (other than as an argument passed when the
|
||||||
|
facility is invoked), then you may convey a copy of the modified
|
||||||
|
version:
|
||||||
|
|
||||||
|
a) under this License, provided that you make a good faith effort to
|
||||||
|
ensure that, in the event an Application does not supply the
|
||||||
|
function or data, the facility still operates, and performs
|
||||||
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
|
this License applicable to that copy.
|
||||||
|
|
||||||
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
|
|
||||||
|
The object code form of an Application may incorporate material from
|
||||||
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
|
material is not limited to numerical parameters, data structure
|
||||||
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the object code that the
|
||||||
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
4. Combined Works.
|
||||||
|
|
||||||
|
You may convey a Combined Work under terms of your choice that,
|
||||||
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
|
engineering for debugging such modifications, if you also do each of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
c) For a Combined Work that displays copyright notices during
|
||||||
|
execution, include the copyright notice for the Library among
|
||||||
|
these notices, as well as a reference directing the user to the
|
||||||
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
|
d) Do one of the following:
|
||||||
|
|
||||||
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
|
suitable for, and under terms that permit, the user to
|
||||||
|
recombine or relink the Application with a modified version of
|
||||||
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
|
Corresponding Source.
|
||||||
|
|
||||||
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
|
Version.
|
||||||
|
|
||||||
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
|
GNU GPL, and only to the extent that such information is
|
||||||
|
necessary to install and execute a modified version of the
|
||||||
|
Combined Work produced by recombining or relinking the
|
||||||
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
|
5. Combined Libraries.
|
||||||
|
|
||||||
|
You may place library facilities that are a work based on the
|
||||||
|
Library side by side in a single library together with other library
|
||||||
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
|
choice, if you do both of the following:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work based
|
||||||
|
on the Library, uncombined with any other library facilities,
|
||||||
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library that part of it
|
||||||
|
is a work based on the Library, and explaining where to find the
|
||||||
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
|
published by the Free Software Foundation. If the Library as you
|
||||||
|
received it does not specify a version number of the GNU Lesser
|
||||||
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
|
General Public License ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Library as you received it specifies that a proxy can decide
|
||||||
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
|
permanent authorization for you to choose that version for the
|
||||||
|
Library.
|
30
modules/khemail/vendor/swift/README
vendored
Normal file
30
modules/khemail/vendor/swift/README
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
Swift Mailer, by Chris Corbyn
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Swift Mailer is a component based mailing solution for PHP 5.
|
||||||
|
It is released under the LGPL license.
|
||||||
|
|
||||||
|
Homepage: http://swiftmailer.org
|
||||||
|
Documentation: http://swiftmailer.org/docs
|
||||||
|
Mailing List: http://groups.google.com/group/swiftmailer
|
||||||
|
Bugs: http://swiftmailer.lighthouseapp.com/
|
||||||
|
Repository: http://github.com/swiftmailer/swiftmailer
|
||||||
|
|
||||||
|
Swift Mailer is highly object-oriented by design and lends itself
|
||||||
|
to use in complex web application with a great deal of flexibility.
|
||||||
|
|
||||||
|
For full details on usage, see the documentation.
|
||||||
|
|
||||||
|
IMPORTANT: Users upgrading from version 3.x or earlier absolutely
|
||||||
|
MUST read the documentation. In short, the API is considerably
|
||||||
|
different so your old code won't "just work".
|
||||||
|
|
||||||
|
If you'd like to make a donation, we are working on a system where
|
||||||
|
donations are taken on a per-feature-request basis via the website
|
||||||
|
with target amounts for each feature. In the meantime however you
|
||||||
|
may donate directly to the author via PayPal:
|
||||||
|
|
||||||
|
PayPal: chris@w3style.co.uk
|
||||||
|
|
||||||
|
Donations are certainly voluntary, but seriously, you donors are
|
||||||
|
complete legends and drive this project! :)
|
1
modules/khemail/vendor/swift/VERSION
vendored
Normal file
1
modules/khemail/vendor/swift/VERSION
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
Swift-4.0.6
|
57
modules/khemail/vendor/swift/classes/Swift.php
vendored
Normal file
57
modules/khemail/vendor/swift/classes/Swift.php
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General utility class in Swift Mailer, not to be instantiated.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
*
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
abstract class Swift
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Swift Mailer Version number generated during dist release process */
|
||||||
|
const VERSION = '4.0.6';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal autoloader for spl_autoload_register().
|
||||||
|
*
|
||||||
|
* @param string $class
|
||||||
|
*/
|
||||||
|
public static function autoload($class)
|
||||||
|
{
|
||||||
|
//Don't interfere with other autoloaders
|
||||||
|
if (0 !== strpos($class, 'Swift'))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = dirname(__FILE__).'/'.str_replace('_', '/', $class).'.php';
|
||||||
|
|
||||||
|
if (!file_exists($path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure autoloading using Swift Mailer.
|
||||||
|
*
|
||||||
|
* This is designed to play nicely with other autoloaders.
|
||||||
|
*/
|
||||||
|
public static function registerAutoload()
|
||||||
|
{
|
||||||
|
spl_autoload_register(array('Swift', 'autoload'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
75
modules/khemail/vendor/swift/classes/Swift/Attachment.php
vendored
Normal file
75
modules/khemail/vendor/swift/classes/Swift/Attachment.php
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Attachment.php';
|
||||||
|
//@require 'Swift/ByteStream/FileByteStream.php';
|
||||||
|
//@require 'Swift/DependencyContainer.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attachment class for attaching files to a {@link Swift_Mime_Message}.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Attachment extends Swift_Mime_Attachment
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Attachment.
|
||||||
|
* Details may be optionally provided to the constructor.
|
||||||
|
* @param string|Swift_OutputByteStream $data
|
||||||
|
* @param string $filename
|
||||||
|
* @param string $contentType
|
||||||
|
*/
|
||||||
|
public function __construct($data = null, $filename = null,
|
||||||
|
$contentType = null)
|
||||||
|
{
|
||||||
|
call_user_func_array(
|
||||||
|
array($this, 'Swift_Mime_Attachment::__construct'),
|
||||||
|
Swift_DependencyContainer::getInstance()
|
||||||
|
->createDependenciesFor('mime.attachment')
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->setBody($data);
|
||||||
|
$this->setFilename($filename);
|
||||||
|
if ($contentType)
|
||||||
|
{
|
||||||
|
$this->setContentType($contentType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Attachment.
|
||||||
|
* @param string|Swift_OutputByteStream $data
|
||||||
|
* @param string $filename
|
||||||
|
* @param string $contentType
|
||||||
|
* @return Swift_Mime_Attachment
|
||||||
|
*/
|
||||||
|
public static function newInstance($data = null, $filename = null,
|
||||||
|
$contentType = null)
|
||||||
|
{
|
||||||
|
return new self($data, $filename, $contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Attachment from a filesystem path.
|
||||||
|
* @param string $path
|
||||||
|
* @param string $contentType optional
|
||||||
|
* @return Swift_Mime_Attachment
|
||||||
|
*/
|
||||||
|
public static function fromPath($path, $contentType = null)
|
||||||
|
{
|
||||||
|
return self::newInstance()->setFile(
|
||||||
|
new Swift_ByteStream_FileByteStream($path),
|
||||||
|
$contentType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
178
modules/khemail/vendor/swift/classes/Swift/ByteStream/AbstractFilterableInputStream.php
vendored
Normal file
178
modules/khemail/vendor/swift/classes/Swift/ByteStream/AbstractFilterableInputStream.php
vendored
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/Filterable.php';
|
||||||
|
//@require 'Swift/StreamFilter.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the base functionality for an InputStream supporting filters.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage ByteStream
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
abstract class Swift_ByteStream_AbstractFilterableInputStream
|
||||||
|
implements Swift_InputByteStream, Swift_Filterable
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Write sequence */
|
||||||
|
private $_sequence = 0;
|
||||||
|
|
||||||
|
/** StreamFilters */
|
||||||
|
private $_filters = array();
|
||||||
|
|
||||||
|
/** A buffer for writing */
|
||||||
|
private $_writeBuffer = '';
|
||||||
|
|
||||||
|
/** Bound streams */
|
||||||
|
private $_mirrors = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit the given bytes to the storage medium immediately.
|
||||||
|
* @param string $bytes
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
abstract protected function _commit($bytes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush any buffers/content with immediate effect.
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
abstract protected function _flush();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a StreamFilter to this InputByteStream.
|
||||||
|
* @param Swift_StreamFilter $filter
|
||||||
|
* @param string $key
|
||||||
|
*/
|
||||||
|
public function addFilter(Swift_StreamFilter $filter, $key)
|
||||||
|
{
|
||||||
|
$this->_filters[$key] = $filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove an already present StreamFilter based on its $key.
|
||||||
|
* @param string $key
|
||||||
|
*/
|
||||||
|
public function removeFilter($key)
|
||||||
|
{
|
||||||
|
unset($this->_filters[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes $bytes to the end of the stream.
|
||||||
|
* @param string $bytes
|
||||||
|
* @throws Swift_IoException
|
||||||
|
*/
|
||||||
|
public function write($bytes)
|
||||||
|
{
|
||||||
|
$this->_writeBuffer .= $bytes;
|
||||||
|
foreach ($this->_filters as $filter)
|
||||||
|
{
|
||||||
|
if ($filter->shouldBuffer($this->_writeBuffer))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_doWrite($this->_writeBuffer);
|
||||||
|
return ++$this->_sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For any bytes that are currently buffered inside the stream, force them
|
||||||
|
* off the buffer.
|
||||||
|
*
|
||||||
|
* @throws Swift_IoException
|
||||||
|
*/
|
||||||
|
public function commit()
|
||||||
|
{
|
||||||
|
$this->_doWrite($this->_writeBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
if ($this->_writeBuffer !== '')
|
||||||
|
{
|
||||||
|
$stream->write($this->_filter($this->_writeBuffer));
|
||||||
|
}
|
||||||
|
unset($this->_mirrors[$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush the contents of the stream (empty it) and set the internal pointer
|
||||||
|
* to the beginning.
|
||||||
|
* @throws Swift_IoException
|
||||||
|
*/
|
||||||
|
public function flushBuffers()
|
||||||
|
{
|
||||||
|
if ($this->_writeBuffer !== '')
|
||||||
|
{
|
||||||
|
$this->_doWrite($this->_writeBuffer);
|
||||||
|
}
|
||||||
|
$this->_flush();
|
||||||
|
|
||||||
|
foreach ($this->_mirrors as $stream)
|
||||||
|
{
|
||||||
|
$stream->flushBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Private methods
|
||||||
|
|
||||||
|
/** Run $bytes through all filters */
|
||||||
|
private function _filter($bytes)
|
||||||
|
{
|
||||||
|
foreach ($this->_filters as $filter)
|
||||||
|
{
|
||||||
|
$bytes = $filter->filter($bytes);
|
||||||
|
}
|
||||||
|
return $bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Just write the bytes to the stream */
|
||||||
|
private function _doWrite($bytes)
|
||||||
|
{
|
||||||
|
$this->_commit($this->_filter($bytes));
|
||||||
|
|
||||||
|
foreach ($this->_mirrors as $stream)
|
||||||
|
{
|
||||||
|
$stream->write($bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_writeBuffer = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
190
modules/khemail/vendor/swift/classes/Swift/ByteStream/ArrayByteStream.php
vendored
Normal file
190
modules/khemail/vendor/swift/classes/Swift/ByteStream/ArrayByteStream.php
vendored
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows reading and writing of bytes to and from an array.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage ByteStream
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_ByteStream_ArrayByteStream
|
||||||
|
implements Swift_InputByteStream, Swift_OutputByteStream
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The internal stack of bytes.
|
||||||
|
* @var string[]
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_array = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The size of the stack
|
||||||
|
* @var int
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_arraySize = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The internal pointer offset.
|
||||||
|
* @var int
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_offset = 0;
|
||||||
|
|
||||||
|
/** Bound streams */
|
||||||
|
private $_mirrors = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ArrayByteStream.
|
||||||
|
* If $stack is given the stream will be populated with the bytes it contains.
|
||||||
|
* @param mixed $stack of bytes in string or array form, optional
|
||||||
|
*/
|
||||||
|
public function __construct($stack = null)
|
||||||
|
{
|
||||||
|
if (is_array($stack))
|
||||||
|
{
|
||||||
|
$this->_array = $stack;
|
||||||
|
$this->_arraySize = count($stack);
|
||||||
|
}
|
||||||
|
elseif (is_string($stack))
|
||||||
|
{
|
||||||
|
$this->write($stack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->_array = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ($this->_offset == $this->_arraySize)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't use array slice
|
||||||
|
$end = $length + $this->_offset;
|
||||||
|
$end = $this->_arraySize<$end
|
||||||
|
?$this->_arraySize
|
||||||
|
:$end;
|
||||||
|
$ret = '';
|
||||||
|
for (; $this->_offset < $end; ++$this->_offset)
|
||||||
|
{
|
||||||
|
$ret .= $this->_array[$this->_offset];
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes $bytes to the end of the stream.
|
||||||
|
* @param string $bytes
|
||||||
|
*/
|
||||||
|
public function write($bytes)
|
||||||
|
{
|
||||||
|
$to_add = str_split($bytes);
|
||||||
|
foreach ($to_add as $value)
|
||||||
|
{
|
||||||
|
$this->_array[] = $value;
|
||||||
|
}
|
||||||
|
$this->_arraySize = count($this->_array);
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the internal read pointer to $byteOffset in the stream.
|
||||||
|
* @param int $byteOffset
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function setReadPointer($byteOffset)
|
||||||
|
{
|
||||||
|
if ($byteOffset > $this->_arraySize)
|
||||||
|
{
|
||||||
|
$byteOffset = $this->_arraySize;
|
||||||
|
}
|
||||||
|
elseif ($byteOffset < 0)
|
||||||
|
{
|
||||||
|
$byteOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_offset = $byteOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush the contents of the stream (empty it) and set the internal pointer
|
||||||
|
* to the beginning.
|
||||||
|
*/
|
||||||
|
public function flushBuffers()
|
||||||
|
{
|
||||||
|
$this->_offset = 0;
|
||||||
|
$this->_array = array();
|
||||||
|
$this->_arraySize = 0;
|
||||||
|
|
||||||
|
foreach ($this->_mirrors as $stream)
|
||||||
|
{
|
||||||
|
$stream->flushBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
177
modules/khemail/vendor/swift/classes/Swift/ByteStream/FileByteStream.php
vendored
Normal file
177
modules/khemail/vendor/swift/classes/Swift/ByteStream/FileByteStream.php
vendored
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/ByteStream/AbstractFilterableInputStream.php';
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/FileStream.php';
|
||||||
|
//@require 'Swift/IoException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows reading and writing of bytes to and from a file.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage ByteStream
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_ByteStream_FileByteStream
|
||||||
|
extends Swift_ByteStream_AbstractFilterableInputStream
|
||||||
|
implements Swift_FileStream
|
||||||
|
{
|
||||||
|
|
||||||
|
/** The internal pointer offset */
|
||||||
|
private $_offset = 0;
|
||||||
|
|
||||||
|
/** The path to the file */
|
||||||
|
private $_path;
|
||||||
|
|
||||||
|
/** The mode this file is opened in for writing */
|
||||||
|
private $_mode;
|
||||||
|
|
||||||
|
/** A lazy-loaded resource handle for reading the file */
|
||||||
|
private $_reader;
|
||||||
|
|
||||||
|
/** A lazy-loaded resource handle for writing the file */
|
||||||
|
private $_writer;
|
||||||
|
|
||||||
|
/** If magic_quotes_runtime is on, this will be true */
|
||||||
|
private $_quotes = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new FileByteStream for $path.
|
||||||
|
* @param string $path
|
||||||
|
* @param string $writable if true
|
||||||
|
*/
|
||||||
|
public function __construct($path, $writable = false)
|
||||||
|
{
|
||||||
|
$this->_path = $path;
|
||||||
|
$this->_mode = $writable ? 'w+b' : 'rb';
|
||||||
|
$this->_quotes = get_magic_quotes_runtime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the complete path to the file.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPath()
|
||||||
|
{
|
||||||
|
return $this->_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* @throws Swift_IoException
|
||||||
|
*/
|
||||||
|
public function read($length)
|
||||||
|
{
|
||||||
|
$fp = $this->_getReadHandle();
|
||||||
|
if (!feof($fp))
|
||||||
|
{
|
||||||
|
if ($this->_quotes)
|
||||||
|
{
|
||||||
|
set_magic_quotes_runtime(0);
|
||||||
|
}
|
||||||
|
$bytes = fread($fp, $length);
|
||||||
|
if ($this->_quotes)
|
||||||
|
{
|
||||||
|
set_magic_quotes_runtime(1);
|
||||||
|
}
|
||||||
|
$this->_offset = ftell($fp);
|
||||||
|
return $bytes;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the internal read pointer to $byteOffset in the stream.
|
||||||
|
* @param int $byteOffset
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function setReadPointer($byteOffset)
|
||||||
|
{
|
||||||
|
if (isset($this->_reader))
|
||||||
|
{
|
||||||
|
fseek($this->_reader, $byteOffset, SEEK_SET);
|
||||||
|
}
|
||||||
|
$this->_offset = $byteOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Private methods
|
||||||
|
|
||||||
|
/** Just write the bytes to the file */
|
||||||
|
protected function _commit($bytes)
|
||||||
|
{
|
||||||
|
fwrite($this->_getWriteHandle(), $bytes);
|
||||||
|
$this->_resetReadHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Not used */
|
||||||
|
protected function _flush()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the resource for reading */
|
||||||
|
private function _getReadHandle()
|
||||||
|
{
|
||||||
|
if (!isset($this->_reader))
|
||||||
|
{
|
||||||
|
if (!$this->_reader = fopen($this->_path, 'rb'))
|
||||||
|
{
|
||||||
|
throw new Swift_IoException(
|
||||||
|
'Unable to open file for reading [' . $this->_path . ']'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
fseek($this->_reader, $this->_offset, SEEK_SET);
|
||||||
|
}
|
||||||
|
return $this->_reader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the resource for writing */
|
||||||
|
private function _getWriteHandle()
|
||||||
|
{
|
||||||
|
if (!isset($this->_writer))
|
||||||
|
{
|
||||||
|
if (!$this->_writer = fopen($this->_path, $this->_mode))
|
||||||
|
{
|
||||||
|
throw new Swift_IoException(
|
||||||
|
'Unable to open file for writing [' . $this->_path . ']'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->_writer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Force a reload of the resource for writing */
|
||||||
|
private function _resetWriteHandle()
|
||||||
|
{
|
||||||
|
if (isset($this->_writer))
|
||||||
|
{
|
||||||
|
fclose($this->_writer);
|
||||||
|
$this->_writer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Force a reload of the resource for reading */
|
||||||
|
private function _resetReadHandle()
|
||||||
|
{
|
||||||
|
if (isset($this->_reader))
|
||||||
|
{
|
||||||
|
fclose($this->_reader);
|
||||||
|
$this->_reader = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
60
modules/khemail/vendor/swift/classes/Swift/CharacterReader.php
vendored
Normal file
60
modules/khemail/vendor/swift/classes/Swift/CharacterReader.php
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyzes characters for a specific character set.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
* @author Xavier De Cock <xdecock@gmail.com>
|
||||||
|
*/
|
||||||
|
interface Swift_CharacterReader
|
||||||
|
{
|
||||||
|
const MAP_TYPE_INVALID = 0x01;
|
||||||
|
const MAP_TYPE_FIXED_LEN = 0x02;
|
||||||
|
const MAP_TYPE_POSITIONS = 0x03;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the complete charactermap
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param int $startOffset
|
||||||
|
* @param array $currentMap
|
||||||
|
* @param mixed $ignoredChars
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns mapType
|
||||||
|
* @int mapType
|
||||||
|
*/
|
||||||
|
public function getMapType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an integer which specifies how many more bytes to read.
|
||||||
|
* A positive integer indicates the number of more bytes to fetch before invoking
|
||||||
|
* this method again.
|
||||||
|
* A value of zero means this is already a valid character.
|
||||||
|
* A value of -1 means this cannot possibly be a valid character.
|
||||||
|
* @param int[] $bytes
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function validateByteSequence($bytes, $size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of bytes which should be read to start each character.
|
||||||
|
* For fixed width character sets this should be the number of
|
||||||
|
* octets-per-character. For multibyte character sets this will probably be 1.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getInitialByteSize();
|
||||||
|
|
||||||
|
}
|
96
modules/khemail/vendor/swift/classes/Swift/CharacterReader/GenericFixedWidthReader.php
vendored
Normal file
96
modules/khemail/vendor/swift/classes/Swift/CharacterReader/GenericFixedWidthReader.php
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/CharacterReader.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides fixed-width byte sizes for reading fixed-width character sets.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
* @author Xavier De Cock <xdecock@gmail.com>
|
||||||
|
*/
|
||||||
|
class Swift_CharacterReader_GenericFixedWidthReader
|
||||||
|
implements Swift_CharacterReader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of bytes in a single character.
|
||||||
|
* @var int
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GenericFixedWidthReader using $width bytes per character.
|
||||||
|
* @param int $width
|
||||||
|
*/
|
||||||
|
public function __construct($width)
|
||||||
|
{
|
||||||
|
$this->_width = $width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the complete charactermap
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param int $startOffset
|
||||||
|
* @param array $currentMap
|
||||||
|
* @param mixed $ignoredChars
|
||||||
|
* @return $int
|
||||||
|
*/
|
||||||
|
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
|
||||||
|
{
|
||||||
|
$strlen = strlen($string);
|
||||||
|
// % and / are CPU intensive, so, maybe find a better way
|
||||||
|
$ignored = $strlen%$this->_width;
|
||||||
|
$ignoredChars = substr($string, - $ignored);
|
||||||
|
$currentMap = $this->_width;
|
||||||
|
return ($strlen - $ignored)/$this->_width;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns mapType
|
||||||
|
* @int mapType
|
||||||
|
*/
|
||||||
|
public function getMapType()
|
||||||
|
{
|
||||||
|
return self::MAP_TYPE_FIXED_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an integer which specifies how many more bytes to read.
|
||||||
|
* A positive integer indicates the number of more bytes to fetch before invoking
|
||||||
|
* this method again.
|
||||||
|
* A value of zero means this is already a valid character.
|
||||||
|
* A value of -1 means this cannot possibly be a valid character.
|
||||||
|
* @param string $bytes
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function validateByteSequence($bytes, $size)
|
||||||
|
{
|
||||||
|
$needed = $this->_width - $size;
|
||||||
|
return ($needed > -1)
|
||||||
|
? $needed
|
||||||
|
: -1
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of bytes which should be read to start each character.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getInitialByteSize()
|
||||||
|
{
|
||||||
|
return $this->_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
83
modules/khemail/vendor/swift/classes/Swift/CharacterReader/UsAsciiReader.php
vendored
Normal file
83
modules/khemail/vendor/swift/classes/Swift/CharacterReader/UsAsciiReader.php
vendored
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/CharacterReader.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyzes US-ASCII characters.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_CharacterReader_UsAsciiReader
|
||||||
|
implements Swift_CharacterReader
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the complete charactermap
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param int $startOffset
|
||||||
|
* @param string $ignoredChars
|
||||||
|
*/
|
||||||
|
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
|
||||||
|
{
|
||||||
|
$strlen=strlen($string);
|
||||||
|
$ignoredChars='';
|
||||||
|
for( $i = 0; $i < $strlen; ++$i)
|
||||||
|
{
|
||||||
|
if ($string[$i]>"\x07F")
|
||||||
|
{ // Invalid char
|
||||||
|
$currentMap[$i+$startOffset]=$string[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $strlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns mapType
|
||||||
|
* @int mapType
|
||||||
|
*/
|
||||||
|
public function getMapType()
|
||||||
|
{
|
||||||
|
return self::MAP_TYPE_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an integer which specifies how many more bytes to read.
|
||||||
|
* A positive integer indicates the number of more bytes to fetch before invoking
|
||||||
|
* this method again.
|
||||||
|
* A value of zero means this is already a valid character.
|
||||||
|
* A value of -1 means this cannot possibly be a valid character.
|
||||||
|
* @param string $bytes
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function validateByteSequence($bytes, $size)
|
||||||
|
{
|
||||||
|
$byte = reset($bytes);
|
||||||
|
if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of bytes which should be read to start each character.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getInitialByteSize()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
183
modules/khemail/vendor/swift/classes/Swift/CharacterReader/Utf8Reader.php
vendored
Normal file
183
modules/khemail/vendor/swift/classes/Swift/CharacterReader/Utf8Reader.php
vendored
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/CharacterReader.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyzes UTF-8 characters.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
* @author Xavier De Cock <xdecock@gmail.com>
|
||||||
|
*/
|
||||||
|
class Swift_CharacterReader_Utf8Reader
|
||||||
|
implements Swift_CharacterReader
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Pre-computed for optimization */
|
||||||
|
private static $length_map=array(
|
||||||
|
//N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x0N
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x1N
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x2N
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x3N
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x4N
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x5N
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x6N
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x7N
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0x8N
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0x9N
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0xAN
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0xBN
|
||||||
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, //0xCN
|
||||||
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, //0xDN
|
||||||
|
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, //0xEN
|
||||||
|
4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0 //0xFN
|
||||||
|
);
|
||||||
|
private static $s_length_map=array(
|
||||||
|
"\x00"=>1, "\x01"=>1, "\x02"=>1, "\x03"=>1, "\x04"=>1, "\x05"=>1, "\x06"=>1, "\x07"=>1,
|
||||||
|
"\x08"=>1, "\x09"=>1, "\x0a"=>1, "\x0b"=>1, "\x0c"=>1, "\x0d"=>1, "\x0e"=>1, "\x0f"=>1,
|
||||||
|
"\x10"=>1, "\x11"=>1, "\x12"=>1, "\x13"=>1, "\x14"=>1, "\x15"=>1, "\x16"=>1, "\x17"=>1,
|
||||||
|
"\x18"=>1, "\x19"=>1, "\x1a"=>1, "\x1b"=>1, "\x1c"=>1, "\x1d"=>1, "\x1e"=>1, "\x1f"=>1,
|
||||||
|
"\x20"=>1, "\x21"=>1, "\x22"=>1, "\x23"=>1, "\x24"=>1, "\x25"=>1, "\x26"=>1, "\x27"=>1,
|
||||||
|
"\x28"=>1, "\x29"=>1, "\x2a"=>1, "\x2b"=>1, "\x2c"=>1, "\x2d"=>1, "\x2e"=>1, "\x2f"=>1,
|
||||||
|
"\x30"=>1, "\x31"=>1, "\x32"=>1, "\x33"=>1, "\x34"=>1, "\x35"=>1, "\x36"=>1, "\x37"=>1,
|
||||||
|
"\x38"=>1, "\x39"=>1, "\x3a"=>1, "\x3b"=>1, "\x3c"=>1, "\x3d"=>1, "\x3e"=>1, "\x3f"=>1,
|
||||||
|
"\x40"=>1, "\x41"=>1, "\x42"=>1, "\x43"=>1, "\x44"=>1, "\x45"=>1, "\x46"=>1, "\x47"=>1,
|
||||||
|
"\x48"=>1, "\x49"=>1, "\x4a"=>1, "\x4b"=>1, "\x4c"=>1, "\x4d"=>1, "\x4e"=>1, "\x4f"=>1,
|
||||||
|
"\x50"=>1, "\x51"=>1, "\x52"=>1, "\x53"=>1, "\x54"=>1, "\x55"=>1, "\x56"=>1, "\x57"=>1,
|
||||||
|
"\x58"=>1, "\x59"=>1, "\x5a"=>1, "\x5b"=>1, "\x5c"=>1, "\x5d"=>1, "\x5e"=>1, "\x5f"=>1,
|
||||||
|
"\x60"=>1, "\x61"=>1, "\x62"=>1, "\x63"=>1, "\x64"=>1, "\x65"=>1, "\x66"=>1, "\x67"=>1,
|
||||||
|
"\x68"=>1, "\x69"=>1, "\x6a"=>1, "\x6b"=>1, "\x6c"=>1, "\x6d"=>1, "\x6e"=>1, "\x6f"=>1,
|
||||||
|
"\x70"=>1, "\x71"=>1, "\x72"=>1, "\x73"=>1, "\x74"=>1, "\x75"=>1, "\x76"=>1, "\x77"=>1,
|
||||||
|
"\x78"=>1, "\x79"=>1, "\x7a"=>1, "\x7b"=>1, "\x7c"=>1, "\x7d"=>1, "\x7e"=>1, "\x7f"=>1,
|
||||||
|
"\x80"=>0, "\x81"=>0, "\x82"=>0, "\x83"=>0, "\x84"=>0, "\x85"=>0, "\x86"=>0, "\x87"=>0,
|
||||||
|
"\x88"=>0, "\x89"=>0, "\x8a"=>0, "\x8b"=>0, "\x8c"=>0, "\x8d"=>0, "\x8e"=>0, "\x8f"=>0,
|
||||||
|
"\x90"=>0, "\x91"=>0, "\x92"=>0, "\x93"=>0, "\x94"=>0, "\x95"=>0, "\x96"=>0, "\x97"=>0,
|
||||||
|
"\x98"=>0, "\x99"=>0, "\x9a"=>0, "\x9b"=>0, "\x9c"=>0, "\x9d"=>0, "\x9e"=>0, "\x9f"=>0,
|
||||||
|
"\xa0"=>0, "\xa1"=>0, "\xa2"=>0, "\xa3"=>0, "\xa4"=>0, "\xa5"=>0, "\xa6"=>0, "\xa7"=>0,
|
||||||
|
"\xa8"=>0, "\xa9"=>0, "\xaa"=>0, "\xab"=>0, "\xac"=>0, "\xad"=>0, "\xae"=>0, "\xaf"=>0,
|
||||||
|
"\xb0"=>0, "\xb1"=>0, "\xb2"=>0, "\xb3"=>0, "\xb4"=>0, "\xb5"=>0, "\xb6"=>0, "\xb7"=>0,
|
||||||
|
"\xb8"=>0, "\xb9"=>0, "\xba"=>0, "\xbb"=>0, "\xbc"=>0, "\xbd"=>0, "\xbe"=>0, "\xbf"=>0,
|
||||||
|
"\xc0"=>2, "\xc1"=>2, "\xc2"=>2, "\xc3"=>2, "\xc4"=>2, "\xc5"=>2, "\xc6"=>2, "\xc7"=>2,
|
||||||
|
"\xc8"=>2, "\xc9"=>2, "\xca"=>2, "\xcb"=>2, "\xcc"=>2, "\xcd"=>2, "\xce"=>2, "\xcf"=>2,
|
||||||
|
"\xd0"=>2, "\xd1"=>2, "\xd2"=>2, "\xd3"=>2, "\xd4"=>2, "\xd5"=>2, "\xd6"=>2, "\xd7"=>2,
|
||||||
|
"\xd8"=>2, "\xd9"=>2, "\xda"=>2, "\xdb"=>2, "\xdc"=>2, "\xdd"=>2, "\xde"=>2, "\xdf"=>2,
|
||||||
|
"\xe0"=>3, "\xe1"=>3, "\xe2"=>3, "\xe3"=>3, "\xe4"=>3, "\xe5"=>3, "\xe6"=>3, "\xe7"=>3,
|
||||||
|
"\xe8"=>3, "\xe9"=>3, "\xea"=>3, "\xeb"=>3, "\xec"=>3, "\xed"=>3, "\xee"=>3, "\xef"=>3,
|
||||||
|
"\xf0"=>4, "\xf1"=>4, "\xf2"=>4, "\xf3"=>4, "\xf4"=>4, "\xf5"=>4, "\xf6"=>4, "\xf7"=>4,
|
||||||
|
"\xf8"=>5, "\xf9"=>5, "\xfa"=>5, "\xfb"=>5, "\xfc"=>6, "\xfd"=>6, "\xfe"=>0, "\xff"=>0,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the complete charactermap
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param int $startOffset
|
||||||
|
* @param array $currentMap
|
||||||
|
* @param mixed $ignoredChars
|
||||||
|
*/
|
||||||
|
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
|
||||||
|
{
|
||||||
|
if (!isset($currentMap['i']) || !isset($currentMap['p']))
|
||||||
|
{
|
||||||
|
$currentMap['p'] = $currentMap['i'] = array();
|
||||||
|
}
|
||||||
|
$strlen=strlen($string);
|
||||||
|
$charPos=count($currentMap['p']);
|
||||||
|
$foundChars=0;
|
||||||
|
$invalid=false;
|
||||||
|
for ($i=0; $i<$strlen; ++$i)
|
||||||
|
{
|
||||||
|
$char=$string[$i];
|
||||||
|
$size=self::$s_length_map[$char];
|
||||||
|
if ($size==0)
|
||||||
|
{
|
||||||
|
/* char is invalid, we must wait for a resync */
|
||||||
|
$invalid=true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($invalid==true)
|
||||||
|
{
|
||||||
|
/* We mark the chars as invalid and start a new char */
|
||||||
|
$currentMap['p'][$charPos+$foundChars]=$startOffset+$i;
|
||||||
|
$currentMap['i'][$charPos+$foundChars]=true;
|
||||||
|
++$foundChars;
|
||||||
|
$invalid=false;
|
||||||
|
}
|
||||||
|
if (($i+$size) > $strlen){
|
||||||
|
$ignoredChars=substr($string, $i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for ($j=1; $j<$size; ++$j)
|
||||||
|
{
|
||||||
|
$char=$string[$i+$j];
|
||||||
|
if ($char>"\x7F" && $char<"\xC0")
|
||||||
|
{
|
||||||
|
// Valid - continue parsing
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* char is invalid, we must wait for a resync */
|
||||||
|
$invalid=true;
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Ok we got a complete char here */
|
||||||
|
$lastChar=$currentMap['p'][$charPos+$foundChars]=$startOffset+$i+$size;
|
||||||
|
$i+=$j-1;
|
||||||
|
++$foundChars;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $foundChars;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns mapType
|
||||||
|
* @int mapType
|
||||||
|
*/
|
||||||
|
public function getMapType()
|
||||||
|
{
|
||||||
|
return self::MAP_TYPE_POSITIONS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an integer which specifies how many more bytes to read.
|
||||||
|
* A positive integer indicates the number of more bytes to fetch before invoking
|
||||||
|
* this method again.
|
||||||
|
* A value of zero means this is already a valid character.
|
||||||
|
* A value of -1 means this cannot possibly be a valid character.
|
||||||
|
* @param string $bytes
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function validateByteSequence($bytes, $size)
|
||||||
|
{
|
||||||
|
if ($size<1){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
$needed = self::$length_map[$bytes[0]] - $size;
|
||||||
|
return ($needed > -1)
|
||||||
|
? $needed
|
||||||
|
: -1
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of bytes which should be read to start each character.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getInitialByteSize()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
modules/khemail/vendor/swift/classes/Swift/CharacterReaderFactory.php
vendored
Normal file
29
modules/khemail/vendor/swift/classes/Swift/CharacterReaderFactory.php
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/CharacterReader.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A factory for creating CharacterReaders.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_CharacterReaderFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a CharacterReader suitable for the charset applied.
|
||||||
|
* @param string $charset
|
||||||
|
* @return Swift_CharacterReader
|
||||||
|
*/
|
||||||
|
public function getReaderFor($charset);
|
||||||
|
|
||||||
|
}
|
119
modules/khemail/vendor/swift/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php
vendored
Normal file
119
modules/khemail/vendor/swift/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php
vendored
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/CharacterReaderFactory.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard factory for creating CharacterReaders.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory
|
||||||
|
implements Swift_CharacterReaderFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of charset patterns to their implementation classes.
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_map = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factories which have already been loaded.
|
||||||
|
* @var Swift_CharacterReaderFactory[]
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_loaded = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new CharacterReaderFactory.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$prefix = 'Swift_CharacterReader_';
|
||||||
|
|
||||||
|
$singleByte = array(
|
||||||
|
'class' => $prefix . 'GenericFixedWidthReader',
|
||||||
|
'constructor' => array(1)
|
||||||
|
);
|
||||||
|
|
||||||
|
$doubleByte = array(
|
||||||
|
'class' => $prefix . 'GenericFixedWidthReader',
|
||||||
|
'constructor' => array(2)
|
||||||
|
);
|
||||||
|
|
||||||
|
$fourBytes = array(
|
||||||
|
'class' => $prefix . 'GenericFixedWidthReader',
|
||||||
|
'constructor' => array(4)
|
||||||
|
);
|
||||||
|
|
||||||
|
//Utf-8
|
||||||
|
$this->_map['utf-?8'] = array(
|
||||||
|
'class' => $prefix . 'Utf8Reader',
|
||||||
|
'constructor' => array()
|
||||||
|
);
|
||||||
|
|
||||||
|
//7-8 bit charsets
|
||||||
|
$this->_map['(us-)?ascii'] = $singleByte;
|
||||||
|
$this->_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte;
|
||||||
|
$this->_map['windows-?125[0-9]'] = $singleByte;
|
||||||
|
$this->_map['cp-?[0-9]+'] = $singleByte;
|
||||||
|
$this->_map['ansi'] = $singleByte;
|
||||||
|
$this->_map['macintosh'] = $singleByte;
|
||||||
|
$this->_map['koi-?7'] = $singleByte;
|
||||||
|
$this->_map['koi-?8-?.+'] = $singleByte;
|
||||||
|
$this->_map['mik'] = $singleByte;
|
||||||
|
$this->_map['(cork|t1)'] = $singleByte;
|
||||||
|
$this->_map['v?iscii'] = $singleByte;
|
||||||
|
|
||||||
|
//16 bits
|
||||||
|
$this->_map['(ucs-?2|utf-?16)'] = $doubleByte;
|
||||||
|
|
||||||
|
//32 bits
|
||||||
|
$this->_map['(ucs-?4|utf-?32)'] = $fourBytes;
|
||||||
|
|
||||||
|
//Fallback
|
||||||
|
$this->_map['.*'] = $singleByte;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a CharacterReader suitable for the charset applied.
|
||||||
|
* @param string $charset
|
||||||
|
* @return Swift_CharacterReader
|
||||||
|
*/
|
||||||
|
public function getReaderFor($charset)
|
||||||
|
{
|
||||||
|
$charset = trim(strtolower($charset));
|
||||||
|
foreach ($this->_map as $pattern => $spec)
|
||||||
|
{
|
||||||
|
$re = '/^' . $pattern . '$/D';
|
||||||
|
if (preg_match($re, $charset))
|
||||||
|
{
|
||||||
|
if (!array_key_exists($pattern, $this->_loaded))
|
||||||
|
{
|
||||||
|
$reflector = new ReflectionClass($spec['class']);
|
||||||
|
if ($reflector->getConstructor())
|
||||||
|
{
|
||||||
|
$reader = $reflector->newInstanceArgs($spec['constructor']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$reader = $reflector->newInstance();
|
||||||
|
}
|
||||||
|
$this->_loaded[$pattern] = $reader;
|
||||||
|
}
|
||||||
|
return $this->_loaded[$pattern];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
86
modules/khemail/vendor/swift/classes/Swift/CharacterStream.php
vendored
Normal file
86
modules/khemail/vendor/swift/classes/Swift/CharacterStream.php
vendored
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/OutputByteStream.php';
|
||||||
|
require_once dirname(__FILE__) . '/CharacterReaderFactory.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract means of reading and writing data in terms of characters as opposed
|
||||||
|
* to bytes.
|
||||||
|
* Classes implementing this interface may use a subsystem which requires less
|
||||||
|
* memory than working with large strings of data.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage CharacterStream
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_CharacterStream
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the character set used in this CharacterStream.
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function setCharacterSet($charset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the CharacterReaderFactory for multi charset support.
|
||||||
|
* @param Swift_CharacterReaderFactory $factory
|
||||||
|
*/
|
||||||
|
public function setCharacterReaderFactory(
|
||||||
|
Swift_CharacterReaderFactory $factory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwrite this character stream using the byte sequence in the byte stream.
|
||||||
|
* @param Swift_OutputByteStream $os output stream to read from
|
||||||
|
*/
|
||||||
|
public function importByteStream(Swift_OutputByteStream $os);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import a string a bytes into this CharacterStream, overwriting any existing
|
||||||
|
* data in the stream.
|
||||||
|
* @param string $string
|
||||||
|
*/
|
||||||
|
public function importString($string);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read $length characters from the stream and move the internal pointer
|
||||||
|
* $length further into the stream.
|
||||||
|
* @param int $length
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function read($length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read $length characters from the stream and return a 1-dimensional array
|
||||||
|
* containing there octet values.
|
||||||
|
* @param int $length
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
public function readBytes($length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write $chars to the end of the stream.
|
||||||
|
* @param string $chars
|
||||||
|
*/
|
||||||
|
public function write($chars);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the internal pointer to $charOffset in the stream.
|
||||||
|
* @param int $charOffset
|
||||||
|
*/
|
||||||
|
public function setPointer($charOffset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty the stream and reset the internal pointer.
|
||||||
|
*/
|
||||||
|
public function flushContents();
|
||||||
|
|
||||||
|
}
|
319
modules/khemail/vendor/swift/classes/Swift/CharacterStream/ArrayCharacterStream.php
vendored
Normal file
319
modules/khemail/vendor/swift/classes/Swift/CharacterStream/ArrayCharacterStream.php
vendored
Normal file
@ -0,0 +1,319 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/CharacterStream.php';
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A CharacterStream implementation which stores characters in an internal array.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage CharacterStream
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_CharacterStream_ArrayCharacterStream
|
||||||
|
implements Swift_CharacterStream
|
||||||
|
{
|
||||||
|
|
||||||
|
/** A map of byte values and their respective characters */
|
||||||
|
private static $_charMap;
|
||||||
|
|
||||||
|
/** A map of characters and their derivative byte values */
|
||||||
|
private static $_byteMap;
|
||||||
|
|
||||||
|
/** The char reader (lazy-loaded) for the current charset */
|
||||||
|
private $_charReader;
|
||||||
|
|
||||||
|
/** A factory for creatiing CharacterReader instances */
|
||||||
|
private $_charReaderFactory;
|
||||||
|
|
||||||
|
/** The character set this stream is using */
|
||||||
|
private $_charset;
|
||||||
|
|
||||||
|
/** Array of characters */
|
||||||
|
private $_array = array();
|
||||||
|
|
||||||
|
/** Size of the array of character */
|
||||||
|
private $_array_size = array();
|
||||||
|
|
||||||
|
/** The current character offset in the stream */
|
||||||
|
private $_offset = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new CharacterStream with the given $chars, if set.
|
||||||
|
* @param Swift_CharacterReaderFactory $factory for loading validators
|
||||||
|
* @param string $charset used in the stream
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_CharacterReaderFactory $factory,
|
||||||
|
$charset)
|
||||||
|
{
|
||||||
|
self::_initializeMaps();
|
||||||
|
$this->setCharacterReaderFactory($factory);
|
||||||
|
$this->setCharacterSet($charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the character set used in this CharacterStream.
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function setCharacterSet($charset)
|
||||||
|
{
|
||||||
|
$this->_charset = $charset;
|
||||||
|
$this->_charReader = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the CharacterReaderFactory for multi charset support.
|
||||||
|
* @param Swift_CharacterReaderFactory $factory
|
||||||
|
*/
|
||||||
|
public function setCharacterReaderFactory(
|
||||||
|
Swift_CharacterReaderFactory $factory)
|
||||||
|
{
|
||||||
|
$this->_charReaderFactory = $factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwrite this character stream using the byte sequence in the byte stream.
|
||||||
|
* @param Swift_OutputByteStream $os output stream to read from
|
||||||
|
*/
|
||||||
|
public function importByteStream(Swift_OutputByteStream $os)
|
||||||
|
{
|
||||||
|
if (!isset($this->_charReader))
|
||||||
|
{
|
||||||
|
$this->_charReader = $this->_charReaderFactory
|
||||||
|
->getReaderFor($this->_charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$startLength = $this->_charReader->getInitialByteSize();
|
||||||
|
while (false !== $bytes = $os->read($startLength))
|
||||||
|
{
|
||||||
|
$c = array();
|
||||||
|
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i)
|
||||||
|
{
|
||||||
|
$c[] = self::$_byteMap[$bytes[$i]];
|
||||||
|
}
|
||||||
|
$size = count($c);
|
||||||
|
$need = $this->_charReader
|
||||||
|
->validateByteSequence($c, $size);
|
||||||
|
if ($need > 0 &&
|
||||||
|
false !== $bytes = $os->read($need))
|
||||||
|
{
|
||||||
|
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i)
|
||||||
|
{
|
||||||
|
$c[] = self::$_byteMap[$bytes[$i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_array[] = $c;
|
||||||
|
++$this->_array_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import a string a bytes into this CharacterStream, overwriting any existing
|
||||||
|
* data in the stream.
|
||||||
|
* @param string $string
|
||||||
|
*/
|
||||||
|
public function importString($string)
|
||||||
|
{
|
||||||
|
$this->flushContents();
|
||||||
|
$this->write($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read $length characters from the stream and move the internal pointer
|
||||||
|
* $length further into the stream.
|
||||||
|
* @param int $length
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function read($length)
|
||||||
|
{
|
||||||
|
if ($this->_offset == $this->_array_size)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't use array slice
|
||||||
|
$arrays = array();
|
||||||
|
$end = $length + $this->_offset;
|
||||||
|
for ($i = $this->_offset; $i < $end; ++$i)
|
||||||
|
{
|
||||||
|
if (!isset($this->_array[$i]))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$arrays[] = $this->_array[$i];
|
||||||
|
}
|
||||||
|
$this->_offset += $i - $this->_offset; // Limit function calls
|
||||||
|
$chars = false;
|
||||||
|
foreach ($arrays as $array)
|
||||||
|
{
|
||||||
|
$chars .= implode('', array_map('chr', $array));
|
||||||
|
}
|
||||||
|
return $chars;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read $length characters from the stream and return a 1-dimensional array
|
||||||
|
* containing there octet values.
|
||||||
|
* @param int $length
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
public function readBytes($length)
|
||||||
|
{
|
||||||
|
if ($this->_offset == $this->_array_size)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$arrays = array();
|
||||||
|
$end = $length + $this->_offset;
|
||||||
|
for ($i = $this->_offset; $i < $end; ++$i)
|
||||||
|
{
|
||||||
|
if (!isset($this->_array[$i]))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$arrays[] = $this->_array[$i];
|
||||||
|
}
|
||||||
|
$this->_offset += ($i - $this->_offset); // Limit function calls
|
||||||
|
return call_user_func_array('array_merge', $arrays);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write $chars to the end of the stream.
|
||||||
|
* @param string $chars
|
||||||
|
*/
|
||||||
|
public function write($chars)
|
||||||
|
{
|
||||||
|
if (!isset($this->_charReader))
|
||||||
|
{
|
||||||
|
$this->_charReader = $this->_charReaderFactory->getReaderFor(
|
||||||
|
$this->_charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$startLength = $this->_charReader->getInitialByteSize();
|
||||||
|
|
||||||
|
$fp = fopen('php://memory', 'w+b');
|
||||||
|
fwrite($fp, $chars);
|
||||||
|
unset($chars);
|
||||||
|
fseek($fp, 0, SEEK_SET);
|
||||||
|
|
||||||
|
$buffer = array(0);
|
||||||
|
$buf_pos = 1;
|
||||||
|
$buf_len = 1;
|
||||||
|
$has_datas = true;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
$bytes = array();
|
||||||
|
// Buffer Filing
|
||||||
|
if ($buf_len - $buf_pos < $startLength)
|
||||||
|
{
|
||||||
|
$buf = array_splice($buffer, $buf_pos);
|
||||||
|
$new = $this->_reloadBuffer($fp, 100);
|
||||||
|
if ($new)
|
||||||
|
{
|
||||||
|
$buffer = array_merge($buf, $new);
|
||||||
|
$buf_len = count($buffer);
|
||||||
|
$buf_pos = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$has_datas = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($buf_len - $buf_pos > 0)
|
||||||
|
{
|
||||||
|
$size = 0;
|
||||||
|
for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i)
|
||||||
|
{
|
||||||
|
++$size;
|
||||||
|
$bytes[] = $buffer[$buf_pos++];
|
||||||
|
}
|
||||||
|
$need = $this->_charReader->validateByteSequence(
|
||||||
|
$bytes, $size);
|
||||||
|
if ($need > 0)
|
||||||
|
{
|
||||||
|
if ($buf_len - $buf_pos < $need)
|
||||||
|
{
|
||||||
|
$new = $this->_reloadBuffer($fp, $need);
|
||||||
|
|
||||||
|
if ($new)
|
||||||
|
{
|
||||||
|
$buffer = array_merge($buffer, $new);
|
||||||
|
$buf_len = count($buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i)
|
||||||
|
{
|
||||||
|
$bytes[] = $buffer[$buf_pos++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_array[] = $bytes;
|
||||||
|
++$this->_array_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while ($has_datas);
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the internal pointer to $charOffset in the stream.
|
||||||
|
* @param int $charOffset
|
||||||
|
*/
|
||||||
|
public function setPointer($charOffset)
|
||||||
|
{
|
||||||
|
if ($charOffset > $this->_array_size)
|
||||||
|
{
|
||||||
|
$charOffset = $this->_array_size;
|
||||||
|
}
|
||||||
|
elseif ($charOffset < 0)
|
||||||
|
{
|
||||||
|
$charOffset = 0;
|
||||||
|
}
|
||||||
|
$this->_offset = $charOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty the stream and reset the internal pointer.
|
||||||
|
*/
|
||||||
|
public function flushContents()
|
||||||
|
{
|
||||||
|
$this->_offset = 0;
|
||||||
|
$this->_array = array();
|
||||||
|
$this->_array_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _reloadBuffer($fp, $len)
|
||||||
|
{
|
||||||
|
if (!feof($fp) && ($bytes = fread($fp, $len)) !== false)
|
||||||
|
{
|
||||||
|
$buf = array();
|
||||||
|
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i)
|
||||||
|
{
|
||||||
|
$buf[] = self::$_byteMap[$bytes[$i]];
|
||||||
|
}
|
||||||
|
return $buf;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function _initializeMaps()
|
||||||
|
{
|
||||||
|
if (!isset(self::$_charMap))
|
||||||
|
{
|
||||||
|
self::$_charMap = array();
|
||||||
|
for ($byte = 0; $byte < 256; ++$byte)
|
||||||
|
{
|
||||||
|
self::$_charMap[$byte] = chr($byte);
|
||||||
|
}
|
||||||
|
self::$_byteMap = array_flip(self::$_charMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
300
modules/khemail/vendor/swift/classes/Swift/CharacterStream/NgCharacterStream.php
vendored
Normal file
300
modules/khemail/vendor/swift/classes/Swift/CharacterStream/NgCharacterStream.php
vendored
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
CharacterStream implementation using an array in Swift Mailer.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/CharacterStream.php';
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A CharacterStream implementation which stores characters in an internal array.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage CharacterStream
|
||||||
|
* @author Xavier De Cock <xdecock@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
349
modules/khemail/vendor/swift/classes/Swift/DependencyContainer.php
vendored
Normal file
349
modules/khemail/vendor/swift/classes/Swift/DependencyContainer.php
vendored
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/DependencyException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dependency Injection container.
|
||||||
|
* @package Swift
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_DependencyContainer
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Constant for literal value types */
|
||||||
|
const TYPE_VALUE = 0x0001;
|
||||||
|
|
||||||
|
/** Constant for new instance types */
|
||||||
|
const TYPE_INSTANCE = 0x0010;
|
||||||
|
|
||||||
|
/** Constant for shared instance types */
|
||||||
|
const TYPE_SHARED = 0x0100;
|
||||||
|
|
||||||
|
/** Constant for aliases */
|
||||||
|
const TYPE_ALIAS = 0x1000;
|
||||||
|
|
||||||
|
/** Singleton instance */
|
||||||
|
private static $_instance = null;
|
||||||
|
|
||||||
|
/** The data container */
|
||||||
|
private $_store = array();
|
||||||
|
|
||||||
|
/** The current endpoint in the data container */
|
||||||
|
private $_endPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor should not be used.
|
||||||
|
* Use {@link getInstance()} instead.
|
||||||
|
*/
|
||||||
|
public function __construct() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a singleton of the DependencyContainer.
|
||||||
|
* @return Swift_DependencyContainer
|
||||||
|
*/
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
if (!isset(self::$_instance))
|
||||||
|
{
|
||||||
|
self::$_instance = new self();
|
||||||
|
}
|
||||||
|
return self::$_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List the names of all items stored in the Container.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function listItems()
|
||||||
|
{
|
||||||
|
return array_keys($this->_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
modules/khemail/vendor/swift/classes/Swift/DependencyException.php
vendored
Normal file
30
modules/khemail/vendor/swift/classes/Swift/DependencyException.php
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/SwiftException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DependencyException thrown when a requested dependeny is missing.
|
||||||
|
* @package Swift
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_DependencyException extends Swift_SwiftException
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new DependencyException with $message.
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
public function __construct($message)
|
||||||
|
{
|
||||||
|
parent::__construct($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
73
modules/khemail/vendor/swift/classes/Swift/EmbeddedFile.php
vendored
Normal file
73
modules/khemail/vendor/swift/classes/Swift/EmbeddedFile.php
vendored
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Attachment.php';
|
||||||
|
//@require 'Swift/DependencyContainer.php';
|
||||||
|
//@require 'Swift/ByteStream/FileByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An embedded file, in a multipart message.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new EmbeddedFile.
|
||||||
|
* Details may be optionally provided to the constructor.
|
||||||
|
* @param string|Swift_OutputByteStream $data
|
||||||
|
* @param string $filename
|
||||||
|
* @param string $contentType
|
||||||
|
*/
|
||||||
|
public function __construct($data = null, $filename = null,
|
||||||
|
$contentType = null)
|
||||||
|
{
|
||||||
|
call_user_func_array(
|
||||||
|
array($this, 'Swift_Mime_EmbeddedFile::__construct'),
|
||||||
|
Swift_DependencyContainer::getInstance()
|
||||||
|
->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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
modules/khemail/vendor/swift/classes/Swift/Encoder.php
vendored
Normal file
32
modules/khemail/vendor/swift/classes/Swift/Encoder.php
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/CharsetObserver.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for all Encoder schemes.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Encoder extends Swift_Mime_CharsetObserver
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode a given string to produce an encoded string.
|
||||||
|
* @param string $string
|
||||||
|
* @param int $firstLineOffset if first line needs to be shorter
|
||||||
|
* @param int $maxLineLength - 0 indicates the default length for this encoding
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function encodeString($string, $firstLineOffset = 0,
|
||||||
|
$maxLineLength = 0);
|
||||||
|
|
||||||
|
}
|
63
modules/khemail/vendor/swift/classes/Swift/Encoder/Base64Encoder.php
vendored
Normal file
63
modules/khemail/vendor/swift/classes/Swift/Encoder/Base64Encoder.php
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Encoder.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles Base 64 Encoding in Swift Mailer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Encoder_Base64Encoder implements Swift_Encoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes an unencoded string and produces a Base64 encoded string from it.
|
||||||
|
* Base64 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
|
||||||
|
* @param int $maxLineLength, optional, 0 indicates the default of 76 bytes
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function encodeString($string, $firstLineOffset = 0,
|
||||||
|
$maxLineLength = 0)
|
||||||
|
{
|
||||||
|
if (0 >= $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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
263
modules/khemail/vendor/swift/classes/Swift/Encoder/QpEncoder.php
vendored
Normal file
263
modules/khemail/vendor/swift/classes/Swift/Encoder/QpEncoder.php
vendored
Normal file
@ -0,0 +1,263 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Encoder.php';
|
||||||
|
//@require 'Swift/CharacterStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles Quoted Printable (QP) Encoding in Swift Mailer.
|
||||||
|
* Possibly the most accurate RFC 2045 QP implementation found in PHP.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CharacterStream used for reading characters (as opposed to bytes).
|
||||||
|
* @var Swift_CharacterStream
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $_charStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A filter used if input should be canonicalized.
|
||||||
|
* @var Swift_StreamFilter
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $_filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre-computed QP for HUGE optmization.
|
||||||
|
* @var string[]
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected static $_qpMap = array(
|
||||||
|
0 => '=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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
89
modules/khemail/vendor/swift/classes/Swift/Encoder/Rfc2231Encoder.php
vendored
Normal file
89
modules/khemail/vendor/swift/classes/Swift/Encoder/Rfc2231Encoder.php
vendored
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Encoder.php';
|
||||||
|
//@require 'Swift/CharacterStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles RFC 2231 specified Encoding in Swift Mailer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A character stream to use when reading a string as characters instead of bytes.
|
||||||
|
* @var Swift_CharacterStream
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_charStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Rfc2231Encoder using the given character stream instance.
|
||||||
|
* @param Swift_CharacterStream
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_CharacterStream $charStream)
|
||||||
|
{
|
||||||
|
$this->_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
70
modules/khemail/vendor/swift/classes/Swift/Encoding.php
vendored
Normal file
70
modules/khemail/vendor/swift/classes/Swift/Encoding.php
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/DependencyContainer.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides quick access to each encoding type.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Encoder
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Encoding
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Encoder that provides 7-bit encoding.
|
||||||
|
*
|
||||||
|
* @return Swift_Mime_ContentEncoder
|
||||||
|
*/
|
||||||
|
public static function get7BitEncoding()
|
||||||
|
{
|
||||||
|
return self::_lookup('mime.7bitcontentencoder');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Encoder that provides 8-bit encoding.
|
||||||
|
*
|
||||||
|
* @return Swift_Mime_ContentEncoder
|
||||||
|
*/
|
||||||
|
public static function get8BitEncoding()
|
||||||
|
{
|
||||||
|
return self::_lookup('mime.8bitcontentencoder');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Encoder that provides Quoted-Printable (QP) encoding.
|
||||||
|
*
|
||||||
|
* @return Swift_Mime_ContentEncoder
|
||||||
|
*/
|
||||||
|
public static function getQpEncoding()
|
||||||
|
{
|
||||||
|
return self::_lookup('mime.qpcontentencoder');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Encoder that provides Base64 encoding.
|
||||||
|
*
|
||||||
|
* @return Swift_Mime_ContentEncoder
|
||||||
|
*/
|
||||||
|
public static function getBase64Encoding()
|
||||||
|
{
|
||||||
|
return self::_lookup('mime.base64contentencoder');
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Private Static Methods
|
||||||
|
|
||||||
|
private static function _lookup($key)
|
||||||
|
{
|
||||||
|
return Swift_DependencyContainer::getInstance()->lookup($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
67
modules/khemail/vendor/swift/classes/Swift/Events/CommandEvent.php
vendored
Normal file
67
modules/khemail/vendor/swift/classes/Swift/Events/CommandEvent.php
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventObject.php';
|
||||||
|
//@require 'Swift/Transport.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated when a command is sent over an SMTP connection.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Events_CommandEvent extends Swift_Events_EventObject
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The command sent to the server.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of codes which a successful response will contain.
|
||||||
|
* @var int[]
|
||||||
|
*/
|
||||||
|
private $_successCodes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new CommandEvent for $source with $command.
|
||||||
|
* @param Swift_Transport $source
|
||||||
|
* @param string $command
|
||||||
|
* @param array $successCodes
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Transport $source,
|
||||||
|
$command, $successCodes = array())
|
||||||
|
{
|
||||||
|
parent::__construct($source);
|
||||||
|
$this->_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
modules/khemail/vendor/swift/classes/Swift/Events/CommandListener.php
vendored
Normal file
29
modules/khemail/vendor/swift/classes/Swift/Events/CommandListener.php
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventListener.php';
|
||||||
|
//@require 'Swift/Events/CommandEvent.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens for Transports to send commands to the server.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Events_CommandListener extends Swift_Events_EventListener
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked immediately following a command being sent.
|
||||||
|
* @param Swift_Events_ResponseEvent $evt
|
||||||
|
*/
|
||||||
|
public function commandSent(Swift_Events_CommandEvent $evt);
|
||||||
|
|
||||||
|
}
|
39
modules/khemail/vendor/swift/classes/Swift/Events/Event.php
vendored
Normal file
39
modules/khemail/vendor/swift/classes/Swift/Events/Event.php
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum interface for an Event.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Events_Event
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the source object of this event.
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function getSource();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent this Event from bubbling any further up the stack.
|
||||||
|
* @param boolean $cancel, optional
|
||||||
|
*/
|
||||||
|
public function cancelBubble($cancel = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this Event will not bubble any further up the stack.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function bubbleCancelled();
|
||||||
|
|
||||||
|
}
|
81
modules/khemail/vendor/swift/classes/Swift/Events/EventDispatcher.php
vendored
Normal file
81
modules/khemail/vendor/swift/classes/Swift/Events/EventDispatcher.php
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventListener.php';
|
||||||
|
//@require 'Swift/Event.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for the EventDispatcher which handles the event dispatching layer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Events_EventDispatcher
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new TransportChangeEvent for $source.
|
||||||
|
* @param Swift_Transport $source
|
||||||
|
* @return Swift_Events_TransportChangeEvent
|
||||||
|
*/
|
||||||
|
public function createTransportChangeEvent(Swift_Transport $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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind an event listener to this dispatcher.
|
||||||
|
* @param Swift_Events_EventListener $listener
|
||||||
|
*/
|
||||||
|
public function bindEventListener(Swift_Events_EventListener $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);
|
||||||
|
|
||||||
|
}
|
19
modules/khemail/vendor/swift/classes/Swift/Events/EventListener.php
vendored
Normal file
19
modules/khemail/vendor/swift/classes/Swift/Events/EventListener.php
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An identity interface which all EventListeners must extend.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Events_EventListener
|
||||||
|
{
|
||||||
|
}
|
65
modules/khemail/vendor/swift/classes/Swift/Events/EventObject.php
vendored
Normal file
65
modules/khemail/vendor/swift/classes/Swift/Events/EventObject.php
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/Event.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A base Event which all Event classes inherit from.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Events_EventObject implements Swift_Events_Event
|
||||||
|
{
|
||||||
|
|
||||||
|
/** The source of this Event */
|
||||||
|
private $_source;
|
||||||
|
|
||||||
|
/** The state of this Event (should it bubble up the stack?) */
|
||||||
|
private $_bubbleCancelled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new EventObject originating at $source.
|
||||||
|
* @param object $source
|
||||||
|
*/
|
||||||
|
public function __construct($source)
|
||||||
|
{
|
||||||
|
$this->_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
65
modules/khemail/vendor/swift/classes/Swift/Events/ResponseEvent.php
vendored
Normal file
65
modules/khemail/vendor/swift/classes/Swift/Events/ResponseEvent.php
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventObject.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated when a response is received on a SMTP connection.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Events_ResponseEvent extends Swift_Events_EventObject
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The overall result.
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $_valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The response received from the server.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ResponseEvent for $source and $response.
|
||||||
|
* @param Swift_Transport $source
|
||||||
|
* @param string $response
|
||||||
|
* @param boolean $valid
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Transport $source, $response, $valid = false)
|
||||||
|
{
|
||||||
|
parent::__construct($source);
|
||||||
|
$this->_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
modules/khemail/vendor/swift/classes/Swift/Events/ResponseListener.php
vendored
Normal file
29
modules/khemail/vendor/swift/classes/Swift/Events/ResponseListener.php
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventListener.php';
|
||||||
|
//@require 'Swift/Events/ResponseEvent.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens for responses from a remote SMTP server.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Events_ResponseListener extends Swift_Events_EventListener
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked immediately following a response coming back.
|
||||||
|
* @param Swift_Events_ResponseEvent $evt
|
||||||
|
*/
|
||||||
|
public function responseReceived(Swift_Events_ResponseEvent $evt);
|
||||||
|
|
||||||
|
}
|
127
modules/khemail/vendor/swift/classes/Swift/Events/SendEvent.php
vendored
Normal file
127
modules/khemail/vendor/swift/classes/Swift/Events/SendEvent.php
vendored
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventObject.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated when a message is being sent.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Events_SendEvent extends Swift_Events_EventObject
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Sending has yet to occur */
|
||||||
|
const RESULT_PENDING = 0x0001;
|
||||||
|
|
||||||
|
/** Sending was successful */
|
||||||
|
const RESULT_SUCCESS = 0x0010;
|
||||||
|
|
||||||
|
/** Sending worked, but there were some failures */
|
||||||
|
const RESULT_TENTATIVE = 0x0100;
|
||||||
|
|
||||||
|
/** Sending failed */
|
||||||
|
const RESULT_FAILED = 0x1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Message being sent.
|
||||||
|
* @var Swift_Mime_Message
|
||||||
|
*/
|
||||||
|
private $_message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Transport used in sending.
|
||||||
|
* @var Swift_Transport
|
||||||
|
*/
|
||||||
|
private $_transport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any recipients which failed after sending.
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
private $failedRecipients = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The overall result as a bitmask from the class constants.
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new SendEvent for $source and $message.
|
||||||
|
* @param Swift_Transport $source
|
||||||
|
* @param Swift_Mime_Message $message
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Transport $source,
|
||||||
|
Swift_Mime_Message $message)
|
||||||
|
{
|
||||||
|
parent::__construct($source);
|
||||||
|
$this->_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
35
modules/khemail/vendor/swift/classes/Swift/Events/SendListener.php
vendored
Normal file
35
modules/khemail/vendor/swift/classes/Swift/Events/SendListener.php
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventListener.php';
|
||||||
|
//@require 'Swift/Events/SendEvent.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens for Messages being sent from within the Transport system.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Events_SendListener extends Swift_Events_EventListener
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
}
|
175
modules/khemail/vendor/swift/classes/Swift/Events/SimpleEventDispatcher.php
vendored
Normal file
175
modules/khemail/vendor/swift/classes/Swift/Events/SimpleEventDispatcher.php
vendored
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventDispatcher.php';
|
||||||
|
//@require 'Swift/Events/EventListener.php';
|
||||||
|
//@require 'Swift/Events/EventObject.php';
|
||||||
|
//@require 'Swift/Events/CommandEvent.php';
|
||||||
|
//@require 'Swift/Events/ResponseEvent.php';
|
||||||
|
//@require 'Swift/Events/SendEvent.php';
|
||||||
|
//@require 'Swift/Events/TransportChangeEvent.php';
|
||||||
|
//@require 'Swift/Events/TransportExceptionEvent.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The EventDispatcher which handles the event dispatching layer.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||||
|
{
|
||||||
|
|
||||||
|
/** A map of event types to their associated listener types */
|
||||||
|
private $_eventMap = array();
|
||||||
|
|
||||||
|
/** Event listeners bound to this dispatcher */
|
||||||
|
private $_listeners = array();
|
||||||
|
|
||||||
|
/** Listeners queued to have an Event bubbled up the stack to them */
|
||||||
|
private $_bubbleQueue = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new EventDispatcher.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeEvent.php
vendored
Normal file
31
modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeEvent.php
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventObject.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated when the state of a Transport is changed (i.e. stopped/started).
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Events_TransportChangeEvent extends Swift_Events_EventObject
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Transport.
|
||||||
|
* @return Swift_Transport
|
||||||
|
*/
|
||||||
|
public function getTransport()
|
||||||
|
{
|
||||||
|
return $this->getSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeListener.php
vendored
Normal file
53
modules/khemail/vendor/swift/classes/Swift/Events/TransportChangeListener.php
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventListener.php';
|
||||||
|
//@require 'Swift/Events/TransportChangeEvent.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens for changes within the Transport system.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
*
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Events_TransportChangeListener extends Swift_Events_EventListener
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked just before a Transport is started.
|
||||||
|
*
|
||||||
|
* @param Swift_Events_TransportChangeEvent $evt
|
||||||
|
*/
|
||||||
|
public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked immediately after the Transport is started.
|
||||||
|
*
|
||||||
|
* @param Swift_Events_TransportChangeEvent $evt
|
||||||
|
*/
|
||||||
|
public function transportStarted(Swift_Events_TransportChangeEvent $evt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked just before a Transport is stopped.
|
||||||
|
*
|
||||||
|
* @param Swift_Events_TransportChangeEvent $evt
|
||||||
|
*/
|
||||||
|
public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked immediately after the Transport is stopped.
|
||||||
|
*
|
||||||
|
* @param Swift_Events_TransportChangeEvent $evt
|
||||||
|
*/
|
||||||
|
public function transportStopped(Swift_Events_TransportChangeEvent $evt);
|
||||||
|
|
||||||
|
}
|
50
modules/khemail/vendor/swift/classes/Swift/Events/TransportExceptionEvent.php
vendored
Normal file
50
modules/khemail/vendor/swift/classes/Swift/Events/TransportExceptionEvent.php
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventObject.php';
|
||||||
|
//@require 'Swift/TransportException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated when a TransportException is thrown from the Transport system.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Exception thrown.
|
||||||
|
* @var Swift_TransportException
|
||||||
|
*/
|
||||||
|
private $_exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new TransportExceptionEvent for $transport.
|
||||||
|
* @param Swift_Transport $transport
|
||||||
|
* @param Swift_TransportException $ex
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Transport $transport,
|
||||||
|
Swift_TransportException $ex)
|
||||||
|
{
|
||||||
|
parent::__construct($transport);
|
||||||
|
$this->_exception = $ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the TransportException thrown.
|
||||||
|
* @return Swift_TransportException
|
||||||
|
*/
|
||||||
|
public function getException()
|
||||||
|
{
|
||||||
|
return $this->_exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
modules/khemail/vendor/swift/classes/Swift/Events/TransportExceptionListener.php
vendored
Normal file
30
modules/khemail/vendor/swift/classes/Swift/Events/TransportExceptionListener.php
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Events/EventListener.php';
|
||||||
|
//@require 'Swift/Events/TransportExceptionEvent.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens for Exceptions thrown from within the Transport system.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Events
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Events_TransportExceptionListener
|
||||||
|
extends Swift_Events_EventListener
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked as a TransportException is thrown in the Transport system.
|
||||||
|
* @param Swift_Events_TransportExceptionEvent $evt
|
||||||
|
*/
|
||||||
|
public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt);
|
||||||
|
|
||||||
|
}
|
48
modules/khemail/vendor/swift/classes/Swift/FailoverTransport.php
vendored
Normal file
48
modules/khemail/vendor/swift/classes/Swift/FailoverTransport.php
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Transport/FailoverTransport.php';
|
||||||
|
//@require 'Swift/DependencyContainer.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains a list of redundant Transports so when one fails, the next is used.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Transport
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_FailoverTransport extends Swift_Transport_FailoverTransport
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new FailoverTransport with $transports.
|
||||||
|
* @param array $transports
|
||||||
|
*/
|
||||||
|
public function __construct($transports = array())
|
||||||
|
{
|
||||||
|
call_user_func_array(
|
||||||
|
array($this, 'Swift_Transport_FailoverTransport::__construct'),
|
||||||
|
Swift_DependencyContainer::getInstance()
|
||||||
|
->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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
modules/khemail/vendor/swift/classes/Swift/FileStream.php
vendored
Normal file
28
modules/khemail/vendor/swift/classes/Swift/FileStream.php
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An OutputByteStream which specifically reads from a file.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage ByteStream
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_FileStream extends Swift_OutputByteStream
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the complete path to the file.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPath();
|
||||||
|
|
||||||
|
}
|
34
modules/khemail/vendor/swift/classes/Swift/Filterable.php
vendored
Normal file
34
modules/khemail/vendor/swift/classes/Swift/Filterable.php
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/StreamFilter.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows StreamFilters to operate on a stream.
|
||||||
|
* @package Swift
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Filterable
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new StreamFilter, referenced by $key.
|
||||||
|
* @param Swift_StreamFilter $filter
|
||||||
|
* @param string $key
|
||||||
|
*/
|
||||||
|
public function addFilter(Swift_StreamFilter $filter, $key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove an existing filter using $key.
|
||||||
|
* @param string $key
|
||||||
|
*/
|
||||||
|
public function removeFilter($key);
|
||||||
|
|
||||||
|
}
|
62
modules/khemail/vendor/swift/classes/Swift/Image.php
vendored
Normal file
62
modules/khemail/vendor/swift/classes/Swift/Image.php
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Image.php';
|
||||||
|
//@require 'Swift/ByteStream/FileByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An image, embedded in a multipart message.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Image extends Swift_EmbeddedFile
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new EmbeddedFile.
|
||||||
|
* Details may be optionally provided to the constructor.
|
||||||
|
* @param string|Swift_OutputByteStream $data
|
||||||
|
* @param string $filename
|
||||||
|
* @param string $contentType
|
||||||
|
*/
|
||||||
|
public function __construct($data = null, $filename = null,
|
||||||
|
$contentType = null)
|
||||||
|
{
|
||||||
|
parent::__construct($data, $filename, $contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Image.
|
||||||
|
* @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 Image from a filesystem path.
|
||||||
|
* @param string $path
|
||||||
|
* @return Swift_Mime_EmbeddedFile
|
||||||
|
*/
|
||||||
|
public static function fromPath($path)
|
||||||
|
{
|
||||||
|
$image = self::newInstance()->setFile(
|
||||||
|
new Swift_ByteStream_FileByteStream($path)
|
||||||
|
);
|
||||||
|
return $image;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
modules/khemail/vendor/swift/classes/Swift/InputByteStream.php
vendored
Normal file
72
modules/khemail/vendor/swift/classes/Swift/InputByteStream.php
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract means of writing data.
|
||||||
|
* Classes implementing this interface may use a subsystem which requires less
|
||||||
|
* memory than working with large strings of data.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage ByteStream
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_InputByteStream
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes $bytes to the end of the stream.
|
||||||
|
*
|
||||||
|
* Writing may not happen immediately if the stream chooses to buffer. If
|
||||||
|
* you want to write these bytes with immediate effect, call {@link commit()}
|
||||||
|
* after calling write().
|
||||||
|
*
|
||||||
|
* This method returns the sequence ID of the write (i.e. 1 for first, 2 for
|
||||||
|
* second, etc etc).
|
||||||
|
*
|
||||||
|
* @param string $bytes
|
||||||
|
* @return int
|
||||||
|
* @throws Swift_IoException
|
||||||
|
*/
|
||||||
|
public function write($bytes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For any bytes that are currently buffered inside the stream, force them
|
||||||
|
* off the buffer.
|
||||||
|
*
|
||||||
|
* @throws Swift_IoException
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush the contents of the stream (empty it) and set the internal pointer
|
||||||
|
* to the beginning.
|
||||||
|
* @throws Swift_IoException
|
||||||
|
*/
|
||||||
|
public function flushBuffers();
|
||||||
|
|
||||||
|
}
|
30
modules/khemail/vendor/swift/classes/Swift/IoException.php
vendored
Normal file
30
modules/khemail/vendor/swift/classes/Swift/IoException.php
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/SwiftException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I/O Exception class.
|
||||||
|
* @package Swift
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_IoException extends Swift_SwiftException
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new IoException with $message.
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
public function __construct($message)
|
||||||
|
{
|
||||||
|
parent::__construct($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
99
modules/khemail/vendor/swift/classes/Swift/KeyCache.php
vendored
Normal file
99
modules/khemail/vendor/swift/classes/Swift/KeyCache.php
vendored
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a mechanism for storing data using two keys.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage KeyCache
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_KeyCache
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Mode for replacing existing cached data */
|
||||||
|
const MODE_WRITE = 1;
|
||||||
|
|
||||||
|
/** Mode for appending data to the end of existing cached data */
|
||||||
|
const MODE_APPEND = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a ByteStream which when written to, writes data to $itemKey.
|
||||||
|
* NOTE: The stream will always write in append mode.
|
||||||
|
* If the optional third parameter is passed all writes will go through $is.
|
||||||
|
* @param string $nsKey
|
||||||
|
* @param string $itemKey
|
||||||
|
* @param Swift_InputByteStream $is, optional
|
||||||
|
* @return Swift_InputByteStream
|
||||||
|
*/
|
||||||
|
public function getInputByteStream($nsKey, $itemKey,
|
||||||
|
Swift_InputByteStream $is = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data back out of the cache as a string.
|
||||||
|
* @param string $nsKey
|
||||||
|
* @param string $itemKey
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getString($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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given $itemKey exists in the namespace $nsKey.
|
||||||
|
* @param string $nsKey
|
||||||
|
* @param string $itemKey
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasKey($nsKey, $itemKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear data for $itemKey in the namespace $nsKey if it exists.
|
||||||
|
* @param string $nsKey
|
||||||
|
* @param string $itemKey
|
||||||
|
*/
|
||||||
|
public function clearKey($nsKey, $itemKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all data in the namespace $nsKey if it exists.
|
||||||
|
* @param string $nsKey
|
||||||
|
*/
|
||||||
|
public function clearAll($nsKey);
|
||||||
|
|
||||||
|
}
|
209
modules/khemail/vendor/swift/classes/Swift/KeyCache/ArrayKeyCache.php
vendored
Normal file
209
modules/khemail/vendor/swift/classes/Swift/KeyCache/ArrayKeyCache.php
vendored
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/KeyCache.php';
|
||||||
|
//@require 'Swift/KeyCacheInputStream.php';
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/OutputByteStrean.php';
|
||||||
|
//@require 'Swift/SwiftException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A basic KeyCache backed by an array.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage KeyCache
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache contents.
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_contents = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An InputStream for cloning.
|
||||||
|
* @var Swift_KeyCache_KeyCacheInputStream
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ArrayKeyCache with the given $stream for cloning to make
|
||||||
|
* InputByteStreams.
|
||||||
|
* @param Swift_KeyCache_KeyCacheInputStream $stream
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_KeyCache_KeyCacheInputStream $stream)
|
||||||
|
{
|
||||||
|
$this->_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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
316
modules/khemail/vendor/swift/classes/Swift/KeyCache/DiskKeyCache.php
vendored
Normal file
316
modules/khemail/vendor/swift/classes/Swift/KeyCache/DiskKeyCache.php
vendored
Normal file
@ -0,0 +1,316 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/KeyCache.php';
|
||||||
|
//@require 'Swift/KeyCacheInputStream.php';
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/OutputByteStrean.php';
|
||||||
|
//@require 'Swift/SwiftException.php';
|
||||||
|
//@require 'Swift/IoException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A KeyCache which streams to and from disk.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage KeyCache
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Signal to place pointer at start of file */
|
||||||
|
const POSITION_START = 0;
|
||||||
|
|
||||||
|
/** Signal to place pointer at end of file */
|
||||||
|
const POSITION_END = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An InputStream for cloning.
|
||||||
|
* @var Swift_KeyCache_KeyCacheInputStream
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A path to write to.
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stored keys.
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_keys = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will be true if magic_quotes_runtime is turned on.
|
||||||
|
* @var boolean
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_quotes = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new DiskKeyCache with the given $stream for cloning to make
|
||||||
|
* InputByteStreams, and the given $path to save to.
|
||||||
|
* @param Swift_KeyCache_KeyCacheInputStream $stream
|
||||||
|
* @param string $path to save to
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path)
|
||||||
|
{
|
||||||
|
$this->_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
modules/khemail/vendor/swift/classes/Swift/KeyCache/KeyCacheInputStream.php
vendored
Normal file
53
modules/khemail/vendor/swift/classes/Swift/KeyCache/KeyCacheInputStream.php
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/KeyCache.php';
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes data to a KeyCache using a stream.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage KeyCache
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_KeyCache_KeyCacheInputStream extends Swift_InputByteStream
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the KeyCache to wrap.
|
||||||
|
* @param Swift_KeyCache $keyCache
|
||||||
|
*/
|
||||||
|
public function setKeyCache(Swift_KeyCache $keyCache);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the nsKey which will be written to.
|
||||||
|
* @param string $nsKey
|
||||||
|
*/
|
||||||
|
public function setNsKey($nsKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the itemKey which will be written to.
|
||||||
|
* @param string $itemKey
|
||||||
|
*/
|
||||||
|
public function setItemKey($itemKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify a stream to write through for each write().
|
||||||
|
* @param Swift_InputByteStream $is
|
||||||
|
*/
|
||||||
|
public function setWriteThroughStream(Swift_InputByteStream $is);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any implementation should be cloneable, allowing the clone to access a
|
||||||
|
* separate $nsKey and $itemKey.
|
||||||
|
*/
|
||||||
|
public function __clone();
|
||||||
|
|
||||||
|
}
|
110
modules/khemail/vendor/swift/classes/Swift/KeyCache/NullKeyCache.php
vendored
Normal file
110
modules/khemail/vendor/swift/classes/Swift/KeyCache/NullKeyCache.php
vendored
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/KeyCache.php';
|
||||||
|
//@require 'Swift/KeyCacheInputStream.php';
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/OutputByteStrean.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A null KeyCache that does not cache at all.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage KeyCache
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_KeyCache_NullKeyCache implements Swift_KeyCache
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data back out of the cache as a string.
|
||||||
|
* @param string $nsKey
|
||||||
|
* @param string $itemKey
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getString($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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given $itemKey exists in the namespace $nsKey.
|
||||||
|
* @param string $nsKey
|
||||||
|
* @param string $itemKey
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasKey($nsKey, $itemKey)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear data for $itemKey in the namespace $nsKey if it exists.
|
||||||
|
* @param string $nsKey
|
||||||
|
* @param string $itemKey
|
||||||
|
*/
|
||||||
|
public function clearKey($nsKey, $itemKey)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all data in the namespace $nsKey if it exists.
|
||||||
|
* @param string $nsKey
|
||||||
|
*/
|
||||||
|
public function clearAll($nsKey)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
131
modules/khemail/vendor/swift/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php
vendored
Normal file
131
modules/khemail/vendor/swift/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php
vendored
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/KeyCache.php';
|
||||||
|
//@require 'Swift/KeyCacheInputStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes data to a KeyCache using a stream.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage KeyCache
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_KeyCache_SimpleKeyCacheInputStream
|
||||||
|
implements Swift_KeyCache_KeyCacheInputStream
|
||||||
|
{
|
||||||
|
|
||||||
|
/** The KeyCache being written to */
|
||||||
|
private $_keyCache;
|
||||||
|
|
||||||
|
/** The nsKey of the KeyCache being written to */
|
||||||
|
private $_nsKey;
|
||||||
|
|
||||||
|
/** The itemKey of the KeyCache being written to */
|
||||||
|
private $_itemKey;
|
||||||
|
|
||||||
|
/** A stream to write through on each write() */
|
||||||
|
private $_writeThrough = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the KeyCache to wrap.
|
||||||
|
* @param Swift_KeyCache $keyCache
|
||||||
|
*/
|
||||||
|
public function setKeyCache(Swift_KeyCache $keyCache)
|
||||||
|
{
|
||||||
|
$this->_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
48
modules/khemail/vendor/swift/classes/Swift/LoadBalancedTransport.php
vendored
Normal file
48
modules/khemail/vendor/swift/classes/Swift/LoadBalancedTransport.php
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Transport/LoadBalancedTransport.php';
|
||||||
|
//@require 'Swift/DependencyContainer.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redudantly and rotationally uses several Transport implementations when sending.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Transport
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new LoadBalancedTransport with $transports.
|
||||||
|
* @param array $transports
|
||||||
|
*/
|
||||||
|
public function __construct($transports = array())
|
||||||
|
{
|
||||||
|
call_user_func_array(
|
||||||
|
array($this, 'Swift_Transport_LoadBalancedTransport::__construct'),
|
||||||
|
Swift_DependencyContainer::getInstance()
|
||||||
|
->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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
48
modules/khemail/vendor/swift/classes/Swift/MailTransport.php
vendored
Normal file
48
modules/khemail/vendor/swift/classes/Swift/MailTransport.php
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Transport/MailTransport.php';
|
||||||
|
//@require 'Swift/DependencyContainer.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends Messages using the mail() function.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Transport
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_MailTransport extends Swift_Transport_MailTransport
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new MailTransport, optionally specifying $extraParams.
|
||||||
|
* @param string $extraParams
|
||||||
|
*/
|
||||||
|
public function __construct($extraParams = '-f%s')
|
||||||
|
{
|
||||||
|
call_user_func_array(
|
||||||
|
array($this, 'Swift_Transport_MailTransport::__construct'),
|
||||||
|
Swift_DependencyContainer::getInstance()
|
||||||
|
->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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
173
modules/khemail/vendor/swift/classes/Swift/Mailer.php
vendored
Normal file
173
modules/khemail/vendor/swift/classes/Swift/Mailer.php
vendored
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Transport.php';
|
||||||
|
//@require 'Swift/Mime/Message.php';
|
||||||
|
//@require 'Swift/Mailer/RecipientIterator.php';
|
||||||
|
//@require 'Swift/Events/EventListener.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swift Mailer class.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mailer
|
||||||
|
{
|
||||||
|
|
||||||
|
/** The Transport used to send messages */
|
||||||
|
private $_transport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Mailer using $transport for delivery.
|
||||||
|
*
|
||||||
|
* @param Swift_Transport $transport
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Transport $transport)
|
||||||
|
{
|
||||||
|
$this->_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;
|
||||||
|
}
|
||||||
|
}
|
59
modules/khemail/vendor/swift/classes/Swift/Mailer/ArrayRecipientIterator.php
vendored
Normal file
59
modules/khemail/vendor/swift/classes/Swift/Mailer/ArrayRecipientIterator.php
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mailer/RecipientIterator.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a standard PHP array in an interator.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mailer
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mailer_ArrayRecipientIterator
|
||||||
|
implements Swift_Mailer_RecipientIterator
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of recipients.
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_recipients = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ArrayRecipientIterator from $recipients.
|
||||||
|
* @param array $recipients
|
||||||
|
*/
|
||||||
|
public function __construct(array $recipients)
|
||||||
|
{
|
||||||
|
$this->_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
34
modules/khemail/vendor/swift/classes/Swift/Mailer/RecipientIterator.php
vendored
Normal file
34
modules/khemail/vendor/swift/classes/Swift/Mailer/RecipientIterator.php
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an abstract way of specifying recipients for batch sending.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mailer
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mailer_RecipientIterator
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true only if there are more recipients to send to.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasNext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
}
|
82
modules/khemail/vendor/swift/classes/Swift/Message.php
vendored
Normal file
82
modules/khemail/vendor/swift/classes/Swift/Message.php
vendored
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/SimpleMessage.php';
|
||||||
|
//@require 'Swift/MimePart.php';
|
||||||
|
//@require 'Swift/DependencyContainer.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Message class for building emails.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Message extends Swift_Mime_SimpleMessage
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Message.
|
||||||
|
* Details may be optionally passed into the constructor.
|
||||||
|
* @param string $subject
|
||||||
|
* @param string $body
|
||||||
|
* @param string $contentType
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function __construct($subject = null, $body = null,
|
||||||
|
$contentType = null, $charset = null)
|
||||||
|
{
|
||||||
|
call_user_func_array(
|
||||||
|
array($this, 'Swift_Mime_SimpleMessage::__construct'),
|
||||||
|
Swift_DependencyContainer::getInstance()
|
||||||
|
->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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
143
modules/khemail/vendor/swift/classes/Swift/Mime/Attachment.php
vendored
Normal file
143
modules/khemail/vendor/swift/classes/Swift/Mime/Attachment.php
vendored
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/SimpleMimeEntity.php';
|
||||||
|
//@require 'Swift/Mime/ContentEncoder.php';
|
||||||
|
//@require 'Swift/Mime/HeaderSet.php';
|
||||||
|
//@require 'Swift/FileStream.php';
|
||||||
|
//@require 'Swift/KeyCache.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An attachment, in a multipart message.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Recognized MIME types */
|
||||||
|
private $_mimeTypes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Attachment with $headers, $encoder and $cache.
|
||||||
|
* @param Swift_Mime_HeaderSet $headers
|
||||||
|
* @param Swift_Mime_ContentEncoder $encoder
|
||||||
|
* @param Swift_KeyCache $cache
|
||||||
|
* @param array $mimeTypes optional
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Mime_HeaderSet $headers,
|
||||||
|
Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache,
|
||||||
|
$mimeTypes = array())
|
||||||
|
{
|
||||||
|
parent::__construct($headers, $encoder, $cache);
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
26
modules/khemail/vendor/swift/classes/Swift/Mime/CharsetObserver.php
vendored
Normal file
26
modules/khemail/vendor/swift/classes/Swift/Mime/CharsetObserver.php
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observes changes in an Mime entity's character set.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_CharsetObserver
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify this observer that the entity's charset has changed.
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function charsetChanged($charset);
|
||||||
|
|
||||||
|
}
|
41
modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder.php
vendored
Normal file
41
modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder.php
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Encoder.php';
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for all Transfer Encoding schemes.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_ContentEncoder extends Swift_Encoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode $in to $out.
|
||||||
|
* @param Swift_OutputByteStream $os to read from
|
||||||
|
* @param Swift_InputByteStream $is to write to
|
||||||
|
* @param int $firstLineOffset
|
||||||
|
* @param int $maxLineLength - 0 indicates the default length for this encoding
|
||||||
|
*/
|
||||||
|
public function encodeByteStream(
|
||||||
|
Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0,
|
||||||
|
$maxLineLength = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MIME name of this content encoding scheme.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName();
|
||||||
|
|
||||||
|
}
|
81
modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php
vendored
Normal file
81
modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/ContentEncoder.php';
|
||||||
|
//@require 'Swift/Encoder/Base64Encoder.php';
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles Base 64 Transfer Encoding in Swift Mailer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_ContentEncoder_Base64ContentEncoder
|
||||||
|
extends Swift_Encoder_Base64Encoder
|
||||||
|
implements Swift_Mime_ContentEncoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode stream $in to stream $out.
|
||||||
|
* @param Swift_OutputByteStream $in
|
||||||
|
* @param Swift_InputByteStream $out
|
||||||
|
* @param int $firstLineOffset
|
||||||
|
* @param int $maxLineLength, optional, 0 indicates the default of 76 bytes
|
||||||
|
*/
|
||||||
|
public function encodeByteStream(
|
||||||
|
Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0,
|
||||||
|
$maxLineLength = 0)
|
||||||
|
{
|
||||||
|
if (0 >= $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';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
175
modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php
vendored
Normal file
175
modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php
vendored
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/ContentEncoder.php';
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles binary/7/8-bit Transfer Encoding in Swift Mailer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_ContentEncoder_PlainContentEncoder
|
||||||
|
implements Swift_Mime_ContentEncoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this encoding scheme (probably 7bit or 8bit).
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if canonical transformations should be done.
|
||||||
|
* @var boolean
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_canonical;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new PlainContentEncoder with $name (probably 7bit or 8bit).
|
||||||
|
* @param string $name
|
||||||
|
* @param boolean $canonical If canonicalization transformation should be done.
|
||||||
|
*/
|
||||||
|
public function __construct($name, $canonical = false)
|
||||||
|
{
|
||||||
|
$this->_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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
117
modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php
vendored
Normal file
117
modules/khemail/vendor/swift/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php
vendored
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/ContentEncoder.php';
|
||||||
|
//@require 'Swift/Encoder/QpEncoder.php';
|
||||||
|
//@require 'Swift/InputByteStrean.php';
|
||||||
|
//@require 'Swift/OutputByteStream.php';
|
||||||
|
//@require 'Swift/CharacterStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
|
||||||
|
implements Swift_Mime_ContentEncoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new QpContentEncoder for the given CharacterStream.
|
||||||
|
* @param Swift_CharacterStream $charStream to use for reading characters
|
||||||
|
* @param Swift_StreamFilter $filter if canonicalization should occur
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_CharacterStream $charStream,
|
||||||
|
Swift_StreamFilter $filter = null)
|
||||||
|
{
|
||||||
|
parent::__construct($charStream, $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode stream $in to stream $out.
|
||||||
|
* 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 Swift_OutputByteStream $os output stream
|
||||||
|
* @param Swift_InputByteStream $is input stream
|
||||||
|
* @param int $firstLineOffset
|
||||||
|
* @param int $maxLineLength
|
||||||
|
*/
|
||||||
|
public function encodeByteStream(
|
||||||
|
Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0,
|
||||||
|
$maxLineLength = 0)
|
||||||
|
{
|
||||||
|
if ($maxLineLength > 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';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
51
modules/khemail/vendor/swift/classes/Swift/Mime/EmbeddedFile.php
vendored
Normal file
51
modules/khemail/vendor/swift/classes/Swift/Mime/EmbeddedFile.php
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Attachment.php';
|
||||||
|
//@require 'Swift/Mime/ContentEncoder.php';
|
||||||
|
//@require 'Swift/KeyCache.php';
|
||||||
|
//@require
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An embedded file, in a multipart message.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Attachment with $headers and $encoder.
|
||||||
|
* @param Swift_Mime_HeaderSet $headers
|
||||||
|
* @param Swift_Mime_ContentEncoder $encoder
|
||||||
|
* @param Swift_KeyCache $cache
|
||||||
|
* @param array $mimeTypes optional
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Mime_HeaderSet $headers,
|
||||||
|
Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache,
|
||||||
|
$mimeTypes = array())
|
||||||
|
{
|
||||||
|
parent::__construct($headers, $encoder, $cache, $mimeTypes);
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
modules/khemail/vendor/swift/classes/Swift/Mime/EncodingObserver.php
vendored
Normal file
28
modules/khemail/vendor/swift/classes/Swift/Mime/EncodingObserver.php
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/ContentEncoder.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observes changes for a Mime entity's ContentEncoder.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_EncodingObserver
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify this observer that the observed entity's ContentEncoder has changed.
|
||||||
|
* @param Swift_Mime_ContentEncoder $encoder
|
||||||
|
*/
|
||||||
|
public function encoderChanged(Swift_Mime_ContentEncoder $encoder);
|
||||||
|
|
||||||
|
}
|
85
modules/khemail/vendor/swift/classes/Swift/Mime/Header.php
vendored
Normal file
85
modules/khemail/vendor/swift/classes/Swift/Mime/Header.php
vendored
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A MIME Header.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_Header
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Text headers */
|
||||||
|
const TYPE_TEXT = 2;
|
||||||
|
|
||||||
|
/** Parameterized headers (text + params) */
|
||||||
|
const TYPE_PARAMETERIZED = 6;
|
||||||
|
|
||||||
|
/** Mailbox and address headers */
|
||||||
|
const TYPE_MAILBOX = 8;
|
||||||
|
|
||||||
|
/** Date and time headers */
|
||||||
|
const TYPE_DATE = 16;
|
||||||
|
|
||||||
|
/** Identification headers */
|
||||||
|
const TYPE_ID = 32;
|
||||||
|
|
||||||
|
/** Address path headers */
|
||||||
|
const TYPE_PATH = 64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the model for the field body.
|
||||||
|
* The actual types needed will vary depending upon the type of Header.
|
||||||
|
* @param mixed $model
|
||||||
|
*/
|
||||||
|
public function setFieldBodyModel($model);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the charset used when rendering the Header.
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function setCharset($charset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the model for the field body.
|
||||||
|
* The return type depends on the specifics of the Header.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getFieldBodyModel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of this header (e.g. Subject).
|
||||||
|
* The name is an identifier and as such will be immutable.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFieldName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the field body, prepared for folding into a final header value.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFieldBody();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get this Header rendered as a compliant string.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function toString();
|
||||||
|
|
||||||
|
}
|
28
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderEncoder.php
vendored
Normal file
28
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderEncoder.php
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Encoder.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for all Header Encoding schemes.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_HeaderEncoder extends Swift_Encoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MIME name of this content encoding scheme.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName();
|
||||||
|
|
||||||
|
}
|
36
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php
vendored
Normal file
36
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/../HeaderEncoder.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../Encoder/Base64Encoder.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles Base64 (B) Header Encoding in Swift Mailer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_HeaderEncoder_Base64HeaderEncoder
|
||||||
|
extends Swift_Encoder_Base64Encoder
|
||||||
|
implements Swift_Mime_HeaderEncoder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of this encoding scheme.
|
||||||
|
* Returns the string 'B'.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'B';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
99
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php
vendored
Normal file
99
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php
vendored
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/../HeaderEncoder.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../Encoder/QpEncoder.php';
|
||||||
|
require_once dirname(__FILE__) . '/../../CharacterStream.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles Quoted Printable (Q) Header Encoding in Swift Mailer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder
|
||||||
|
implements Swift_Mime_HeaderEncoder
|
||||||
|
{
|
||||||
|
|
||||||
|
private static $_headerSafeMap = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new QpHeaderEncoder for the given CharacterStream.
|
||||||
|
* @param Swift_CharacterStream $charStream to use for reading characters
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_CharacterStream $charStream)
|
||||||
|
{
|
||||||
|
parent::__construct($charStream);
|
||||||
|
if (empty(self::$_headerSafeMap))
|
||||||
|
{
|
||||||
|
foreach (array_merge(
|
||||||
|
range(0x61, 0x7A), range(0x41, 0x5A),
|
||||||
|
range(0x30, 0x39), array(0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F)
|
||||||
|
) as $byte)
|
||||||
|
{
|
||||||
|
self::$_headerSafeMap[$byte] = chr($byte);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of this encoding scheme.
|
||||||
|
* Returns the string 'Q'.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'Q';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes an unencoded string and produces a Q encoded string from it.
|
||||||
|
* @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)
|
||||||
|
{
|
||||||
|
return str_replace(array(' ', '=20', "=\r\n"), array('_', '_', "\r\n"),
|
||||||
|
parent::encodeString($string, $firstLineOffset, $maxLineLength)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Overridden points of extension
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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::$_headerSafeMap[$b]))
|
||||||
|
{
|
||||||
|
$ret .= self::$_headerSafeMap[$b];
|
||||||
|
++$size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret .= self::$_qpMap[$b];
|
||||||
|
$size+=3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderFactory.php
vendored
Normal file
72
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderFactory.php
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/CharsetObserver.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates MIME headers.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_HeaderFactory extends Swift_Mime_CharsetObserver
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
}
|
170
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderSet.php
vendored
Normal file
170
modules/khemail/vendor/swift/classes/Swift/Mime/HeaderSet.php
vendored
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/CharsetObserver.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection of MIME headers.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
*
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new Mailbox Header with a list of $addresses.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param array|string $addresses
|
||||||
|
*/
|
||||||
|
public function addMailboxHeader($name, $addresses = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new Date header using $timestamp (UNIX time).
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param int $timestamp
|
||||||
|
*/
|
||||||
|
public function addDateHeader($name, $timestamp = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new basic text header with $name and $value.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $value
|
||||||
|
*/
|
||||||
|
public function addTextHeader($name, $value = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new ID header for Message-ID or Content-ID.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string|array $ids
|
||||||
|
*/
|
||||||
|
public function addIdHeader($name, $ids = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new Path header with an address (path) in it.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $path
|
||||||
|
*/
|
||||||
|
public function addPathHeader($name, $path = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all headers with the given $name.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getAll($name = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all headers with the given $name.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function removeAll($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of this HeaderSet.
|
||||||
|
*
|
||||||
|
* @return Swift_Mime_HeaderSet
|
||||||
|
*/
|
||||||
|
public function newInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string with a representation of all headers.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function toString();
|
||||||
|
|
||||||
|
}
|
596
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/AbstractHeader.php
vendored
Normal file
596
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/AbstractHeader.php
vendored
Normal file
@ -0,0 +1,596 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Header.php';
|
||||||
|
//@require 'Swift/Mime/HeaderEncoder.php';
|
||||||
|
//@require 'Swift/RfcComplianceException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract base MIME Header.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special characters used in the syntax which need to be escaped.
|
||||||
|
* @var string[]
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_specials = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tokens defined in RFC 2822 (and some related RFCs).
|
||||||
|
* @var string[]
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_grammar = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this Header.
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Encoder used to encode this Header.
|
||||||
|
* @var Swift_Encoder
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_encoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum length of a line in the header.
|
||||||
|
* @var int
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_lineLength = 78;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The language used in this Header.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_lang;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The character set of the text in this Header.
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_charset = 'utf-8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of this Header, cached.
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_cachedValue = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the character set used in this Header.
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function setCharset($charset)
|
||||||
|
{
|
||||||
|
$this->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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
118
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/DateHeader.php
vendored
Normal file
118
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/DateHeader.php
vendored
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Headers/AbstractHeader.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Date MIME Header for Swift Mailer.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The UNIX timestamp value of this Header.
|
||||||
|
* @var int
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new DateHeader with $name and $timestamp.
|
||||||
|
* Example:
|
||||||
|
* <code>
|
||||||
|
* <?php
|
||||||
|
* $header = new Swift_Mime_Headers_DateHeader('Date', time());
|
||||||
|
* ?>
|
||||||
|
* </code>
|
||||||
|
* @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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
161
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/IdentificationHeader.php
vendored
Normal file
161
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/IdentificationHeader.php
vendored
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Headers/AbstractHeader.php';
|
||||||
|
//@require 'Swift/RfcComplianceException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ID MIME Header for something like Message-ID or Content-ID.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_Headers_IdentificationHeader
|
||||||
|
extends Swift_Mime_Headers_AbstractHeader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IDs used in the value of this Header.
|
||||||
|
* This may hold multiple IDs or just a single ID.
|
||||||
|
* @var string[]
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_ids = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new IdentificationHeader with the given $name and $id.
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function __construct($name)
|
||||||
|
{
|
||||||
|
$this->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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
316
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/MailboxHeader.php
vendored
Normal file
316
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/MailboxHeader.php
vendored
Normal file
@ -0,0 +1,316 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Headers/AbstractHeader.php';
|
||||||
|
//@require 'Swift/Mime/HeaderEncoder.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Mailbox Address MIME Header for something like From or Sender.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mailboxes used in this Header.
|
||||||
|
* @var string[]
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_mailboxes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new MailboxHeader with $name.
|
||||||
|
* @param string $name of Header
|
||||||
|
* @param Swift_Mime_HeaderEncoder $encoder
|
||||||
|
*/
|
||||||
|
public function __construct($name, Swift_Mime_HeaderEncoder $encoder)
|
||||||
|
{
|
||||||
|
$this->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:
|
||||||
|
* <code>
|
||||||
|
* <?php
|
||||||
|
* //Sets two mailboxes in the Header, one with a personal name
|
||||||
|
* $header->setNameAddresses(array(
|
||||||
|
* 'chris@swiftmailer.org' => 'Chris Corbyn',
|
||||||
|
* 'mark@swiftmailer.org' //No associated personal name
|
||||||
|
* ));
|
||||||
|
* ?>
|
||||||
|
* </code>
|
||||||
|
* @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:
|
||||||
|
* <code>
|
||||||
|
* <?php
|
||||||
|
* $header = new Swift_Mime_Headers_MailboxHeader('From',
|
||||||
|
* array('chris@swiftmailer.org' => 'Chris Corbyn',
|
||||||
|
* 'mark@swiftmailer.org' => 'Mark Corbyn')
|
||||||
|
* );
|
||||||
|
* print_r($header->getNameAddressStrings());
|
||||||
|
* // array (
|
||||||
|
* // 0 => Chris Corbyn <chris@swiftmailer.org>,
|
||||||
|
* // 1 => Mark Corbyn <mark@swiftmailer.org>
|
||||||
|
* // )
|
||||||
|
* ?>
|
||||||
|
* </code>
|
||||||
|
* @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:
|
||||||
|
* <code>
|
||||||
|
* <?php
|
||||||
|
* $header = new Swift_Mime_Headers_MailboxHeader('From',
|
||||||
|
* array('chris@swiftmailer.org' => 'Chris Corbyn',
|
||||||
|
* 'mark@swiftmailer.org' => 'Mark Corbyn')
|
||||||
|
* );
|
||||||
|
* print_r($header->getNameAddresses());
|
||||||
|
* // array (
|
||||||
|
* // chris@swiftmailer.org => Chris Corbyn,
|
||||||
|
* // mark@swiftmailer.org => Mark Corbyn
|
||||||
|
* // )
|
||||||
|
* ?>
|
||||||
|
* </code>
|
||||||
|
* @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:
|
||||||
|
* <code>
|
||||||
|
* <?php
|
||||||
|
* //Sets three email addresses as the Header data
|
||||||
|
* $header->setAddresses(
|
||||||
|
* array('one@domain.tld', 'two@domain.tld', 'three@domain.tld')
|
||||||
|
* );
|
||||||
|
* ?>
|
||||||
|
* </code>
|
||||||
|
* @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.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
274
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/ParameterizedHeader.php
vendored
Normal file
274
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/ParameterizedHeader.php
vendored
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Headers/UnstructuredHeader.php';
|
||||||
|
//@require 'Swift/Mime/HeaderEncoder.php';
|
||||||
|
//@require 'Swift/Mime/ParameterizedHeader.php';
|
||||||
|
//@require 'Swift/Encoder.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract base MIME Header.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_Headers_ParameterizedHeader
|
||||||
|
extends Swift_Mime_Headers_UnstructuredHeader
|
||||||
|
implements Swift_Mime_ParameterizedHeader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Encoder used to encode the parameters.
|
||||||
|
* @var Swift_Encoder
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_paramEncoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parameters as an associative array.
|
||||||
|
* @var string[]
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_params = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RFC 2231's definition of a token.
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_tokenRe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ParameterizedHeader with $name.
|
||||||
|
* @param string $name
|
||||||
|
* @param Swift_Mime_HeaderEncoder $encoder
|
||||||
|
* @param Swift_Encoder $paramEncoder, optional
|
||||||
|
*/
|
||||||
|
public function __construct($name, Swift_Mime_HeaderEncoder $encoder,
|
||||||
|
Swift_Encoder $paramEncoder = null)
|
||||||
|
{
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
126
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/PathHeader.php
vendored
Normal file
126
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/PathHeader.php
vendored
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Headers/AbstractHeader.php';
|
||||||
|
//@require 'Swift/RfcComplianceException.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Path Header in Swift Mailer, such a Return-Path.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The address in this Header (if specified).
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new PathHeader with the given $name.
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function __construct($name)
|
||||||
|
{
|
||||||
|
$this->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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
108
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/UnstructuredHeader.php
vendored
Normal file
108
modules/khemail/vendor/swift/classes/Swift/Mime/Headers/UnstructuredHeader.php
vendored
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Headers/AbstractHeader.php';
|
||||||
|
//@require 'Swift/Mime/HeaderEncoder.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Simple MIME Header.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_Headers_UnstructuredHeader
|
||||||
|
extends Swift_Mime_Headers_AbstractHeader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of this Header.
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private $_value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SimpleHeader with $name.
|
||||||
|
* @param string $name
|
||||||
|
* @param Swift_Mime_HeaderEncoder $encoder
|
||||||
|
*/
|
||||||
|
public function __construct($name, Swift_Mime_HeaderEncoder $encoder)
|
||||||
|
{
|
||||||
|
$this->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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
230
modules/khemail/vendor/swift/classes/Swift/Mime/Message.php
vendored
Normal file
230
modules/khemail/vendor/swift/classes/Swift/Mime/Message.php
vendored
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/MimeEntity.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Message (RFC 2822) object.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
*
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_Message extends Swift_Mime_MimeEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a valid Message-ID and switches to it.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function generateId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the subject of the message.
|
||||||
|
*
|
||||||
|
* @param string $subject
|
||||||
|
*/
|
||||||
|
public function setSubject($subject);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the subject of the message.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSubject();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the origination date of the message as a UNIX timestamp.
|
||||||
|
*
|
||||||
|
* @param int $date
|
||||||
|
*/
|
||||||
|
public function setDate($date);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the origination date of the message as a UNIX timestamp.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getDate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the return-path (bounce-detect) address.
|
||||||
|
*
|
||||||
|
* @param string $address
|
||||||
|
*/
|
||||||
|
public function setReturnPath($address);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the return-path (bounce-detect) address.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReturnPath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the sender of this message.
|
||||||
|
*
|
||||||
|
* If multiple addresses are present in the From field, this SHOULD be set.
|
||||||
|
*
|
||||||
|
* According to RFC 2822 it is a requirement when there are multiple From
|
||||||
|
* addresses, but Swift itself does not require it directly.
|
||||||
|
*
|
||||||
|
* An associative array (with one element!) can be used to provide a display-
|
||||||
|
* name: i.e. array('email@address' => '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();
|
||||||
|
|
||||||
|
}
|
108
modules/khemail/vendor/swift/classes/Swift/Mime/MimeEntity.php
vendored
Normal file
108
modules/khemail/vendor/swift/classes/Swift/Mime/MimeEntity.php
vendored
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/InputByteStream.php';
|
||||||
|
//@require 'Swift/Mime/EncodingObserver.php';
|
||||||
|
//@require 'Swift/Mime/CharsetObserver.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A MIME entity, such as an attachment.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_MimeEntity
|
||||||
|
extends Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Main message document; there can only be one of these */
|
||||||
|
const LEVEL_TOP = 16;
|
||||||
|
|
||||||
|
/** An entity which nests with the same precedence as an attachment */
|
||||||
|
const LEVEL_MIXED = 256;
|
||||||
|
|
||||||
|
/** An entity which nests with the same precedence as a mime part */
|
||||||
|
const LEVEL_ALTERNATIVE = 4096;
|
||||||
|
|
||||||
|
/** An entity which nests with the same precedence as embedded content */
|
||||||
|
const LEVEL_RELATED = 65536;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the level at which this entity shall be nested in final document.
|
||||||
|
* The lower the value, the more outermost the entity will be nested.
|
||||||
|
* @return int
|
||||||
|
* @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE
|
||||||
|
*/
|
||||||
|
public function getNestingLevel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the qualified content-type of this mime entity.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getContentType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a unique ID for this entity.
|
||||||
|
* For most entities this will likely be the Content-ID, though it has
|
||||||
|
* no explicit semantic meaning and can be considered an identifier for
|
||||||
|
* programming logic purposes.
|
||||||
|
* If a Content-ID header is present, this value SHOULD match the value of
|
||||||
|
* the header.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all children nested inside this entity.
|
||||||
|
* These are not just the immediate children, but all children.
|
||||||
|
* @return Swift_Mime_MimeEntity[]
|
||||||
|
*/
|
||||||
|
public function getChildren();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set all children nested inside this entity.
|
||||||
|
* This includes grandchildren.
|
||||||
|
* @param Swift_Mime_MimeEntity[] $children
|
||||||
|
*/
|
||||||
|
public function setChildren(array $children);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the collection of Headers in this Mime entity.
|
||||||
|
* @return Swift_Mime_Header[]
|
||||||
|
*/
|
||||||
|
public function getHeaders();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the body content of this entity as a string.
|
||||||
|
* Returns NULL if no body has been set.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBody();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the body content of this entity as a string.
|
||||||
|
* @param string $body
|
||||||
|
* @param string $contentType optional
|
||||||
|
*/
|
||||||
|
public function setBody($body, $contentType = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get this entire entity in its string form.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function toString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get this entire entity as a ByteStream.
|
||||||
|
* @param Swift_InputByteStream $is to write to
|
||||||
|
*/
|
||||||
|
public function toByteStream(Swift_InputByteStream $is);
|
||||||
|
|
||||||
|
}
|
196
modules/khemail/vendor/swift/classes/Swift/Mime/MimePart.php
vendored
Normal file
196
modules/khemail/vendor/swift/classes/Swift/Mime/MimePart.php
vendored
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/SimpleMimeEntity.php';
|
||||||
|
//@require 'Swift/Mime/ContentEncoder.php';
|
||||||
|
//@require 'Swift/Mime/HeaderSet.php';
|
||||||
|
//@require 'Swift/KeyCache.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A MIME part, in a multipart message.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
/** The format parameter last specified by the user */
|
||||||
|
protected $_userFormat;
|
||||||
|
|
||||||
|
/** The charset last specified by the user */
|
||||||
|
protected $_userCharset;
|
||||||
|
|
||||||
|
/** The delsp parameter last specified by the user */
|
||||||
|
protected $_userDelSp;
|
||||||
|
|
||||||
|
/** The nesting level of this MimePart */
|
||||||
|
private $_nestingLevel = self::LEVEL_ALTERNATIVE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new MimePart with $headers, $encoder and $cache.
|
||||||
|
*
|
||||||
|
* @param Swift_Mime_HeaderSet $headers
|
||||||
|
* @param Swift_Mime_ContentEncoder $encoder
|
||||||
|
* @param Swift_KeyCache $cache
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Mime_HeaderSet $headers,
|
||||||
|
Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, $charset = null)
|
||||||
|
{
|
||||||
|
parent::__construct($headers, $encoder, $cache);
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
35
modules/khemail/vendor/swift/classes/Swift/Mime/ParameterizedHeader.php
vendored
Normal file
35
modules/khemail/vendor/swift/classes/Swift/Mime/ParameterizedHeader.php
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/Header.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A MIME Header with parameters.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
interface Swift_Mime_ParameterizedHeader extends Swift_Mime_Header
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of $parameter.
|
||||||
|
* @param string $parameter
|
||||||
|
* @param string $value
|
||||||
|
*/
|
||||||
|
public function setParameter($parameter, $value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of $parameter.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getParameter($parameter);
|
||||||
|
|
||||||
|
}
|
187
modules/khemail/vendor/swift/classes/Swift/Mime/SimpleHeaderFactory.php
vendored
Normal file
187
modules/khemail/vendor/swift/classes/Swift/Mime/SimpleHeaderFactory.php
vendored
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/HeaderFactory.php';
|
||||||
|
//@require 'Swift/Mime/HeaderEncoder.php';
|
||||||
|
//@require 'Swift/Encoder.php';
|
||||||
|
//@require 'Swift/Mime/Headers/MailboxHeader.php';
|
||||||
|
//@require 'Swift/Mime/Headers/DateHeader.php';
|
||||||
|
//@require 'Swift/Mime/Headers/UnstructuredHeader.php';
|
||||||
|
//@require 'Swift/Mime/Headers/ParameterizedHeader.php';
|
||||||
|
//@require 'Swift/Mime/Headers/IdentificationHeader.php';
|
||||||
|
//@require 'Swift/Mime/Headers/PathHeader.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates MIME headers.
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
/** The HeaderEncoder used by these headers */
|
||||||
|
private $_encoder;
|
||||||
|
|
||||||
|
/** The Encoder used by parameters */
|
||||||
|
private $_paramEncoder;
|
||||||
|
|
||||||
|
/** The charset of created Headers */
|
||||||
|
private $_charset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SimpleHeaderFactory using $encoder and $paramEncoder.
|
||||||
|
* @param Swift_Mime_HeaderEncoder $encoder
|
||||||
|
* @param Swift_Encoder $paramEncoder
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Mime_HeaderEncoder $encoder,
|
||||||
|
Swift_Encoder $paramEncoder, $charset = null)
|
||||||
|
{
|
||||||
|
$this->_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
396
modules/khemail/vendor/swift/classes/Swift/Mime/SimpleHeaderSet.php
vendored
Normal file
396
modules/khemail/vendor/swift/classes/Swift/Mime/SimpleHeaderSet.php
vendored
Normal file
@ -0,0 +1,396 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of SwiftMailer.
|
||||||
|
* (c) 2004-2009 Chris Corbyn
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@require 'Swift/Mime/HeaderSet.php';
|
||||||
|
//@require 'Swift/Mime/HeaderFactory.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection of MIME headers.
|
||||||
|
*
|
||||||
|
* @package Swift
|
||||||
|
* @subpackage Mime
|
||||||
|
*
|
||||||
|
* @author Chris Corbyn
|
||||||
|
*/
|
||||||
|
class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||||
|
{
|
||||||
|
|
||||||
|
/** HeaderFactory */
|
||||||
|
private $_factory;
|
||||||
|
|
||||||
|
/** Collection of set Headers */
|
||||||
|
private $_headers = array();
|
||||||
|
|
||||||
|
/** Field ordering details */
|
||||||
|
private $_order = array();
|
||||||
|
|
||||||
|
/** List of fields which are required to be displayed */
|
||||||
|
private $_required = array();
|
||||||
|
|
||||||
|
/** The charset used by Headers */
|
||||||
|
private $_charset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new SimpleHeaderSet with the given $factory.
|
||||||
|
*
|
||||||
|
* @param Swift_Mime_HeaderFactory $factory
|
||||||
|
* @param string $charset
|
||||||
|
*/
|
||||||
|
public function __construct(Swift_Mime_HeaderFactory $factory,
|
||||||
|
$charset = null)
|
||||||
|
{
|
||||||
|
$this->_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user