first commit

This commit is contained in:
2026-04-30 14:38:11 +02:00
commit e22bbde336
1994 changed files with 613950 additions and 0 deletions

130
system/vendor/swift/Swift/Cache/Disk.php vendored Normal file
View File

@@ -0,0 +1,130 @@
<?php
/**
* Swift Mailer disk runtime cache
* Please read the LICENSE file
* @author Chris Corbyn <chris@w3style.co.uk>
* @package Swift_Cache
* @license GNU Lesser General Public License
*/
require_once dirname(__FILE__) . "/../ClassLoader.php";
Swift_ClassLoader::load("Swift_Cache");
/**
* Caches data in files on disk - this is the best approach if possible
* @package Swift_Cache
* @author Chris Corbyn <chris@w3style.co.uk>
*/
class Swift_Cache_Disk extends Swift_Cache
{
/**
* Open file handles
* @var array
*/
protected $open = array();
/**
* The prefix to prepend to files
* @var string
*/
protected $prefix;
/**
* The save path on disk
* @var string
*/
protected static $save_path = "/tmp";
/**
* Ctor
*/
public function __construct()
{
$this->prefix = md5(uniqid(microtime(), true));
}
/**
* Set the save path of the disk - this is a global setting and called statically!
* @param string The path to a writable directory
*/
public static function setSavePath($path="/tmp")
{
self::$save_path = realpath($path);
}
/**
* Write data to the cache
* @param string The cache key
* @param string The data to write
*/
public function write($key, $data)
{
$handle = fopen(self::$save_path . "/" . $this->prefix . $key, "ab");
if (false === fwrite($handle, $data))
{
Swift_ClassLoader::load("Swift_FileException");
throw new Swift_FileException("Disk Caching failed. Tried to write to file at [" .
self::$save_path . "/" . $this->prefix . $key . "] but failed. Check the permissions, or don't use disk caching.");
}
fclose($handle);
}
/**
* Clear the cached data (unlink)
* @param string The cache key
*/
public function clear($key)
{
@unlink(self::$save_path . "/" . $this->prefix . $key);
}
/**
* Check if data is cached for $key
* @param string The cache key
* @return boolean
*/
public function has($key)
{
return file_exists(self::$save_path . "/" . $this->prefix . $key);
}
/**
* Read data from the cache for $key
* @param string The cache key
* @param int The number of bytes to read
* @return string
*/
public function read($key, $size=null)
{
if ($size === null) $size = 8190;
if (!$this->has($key)) return false;
if (!isset($this->open[$key]))
{
$this->open[$key] = fopen(self::$save_path . "/" . $this->prefix . $key, "rb");
}
if (feof($this->open[$key]))
{
fclose($this->open[$key]);
unset($this->open[$key]);
return false;
}
$ret = fread($this->open[$key], $size);
if ($ret !== false)
{
return $ret;
}
else
{
fclose($this->open[$key]);
unset($this->open[$key]);
return false;
}
}
/**
* Dtor.
* Clear out cached data at end of script execution or cache destruction
*/
public function __destruct()
{
$list = glob(self::$save_path . "/" . $this->prefix . "*");
foreach ((array)$list as $f)
{
@unlink($f);
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Swift Mailer Joint Output stream to chain multiple output streams together
* Please read the LICENSE file
* @author Chris Corbyn <chris@w3style.co.uk>
* @package Swift_Cache
* @license GNU Lesser General Public License
*/
require_once dirname(__FILE__) . "/../ClassLoader.php";
Swift_ClassLoader::load("Swift_Cache_OutputStream");
/**
* Makes multiple output streams act as one super sream
* @package Swift_Cache
* @author Chris Corbyn <chris@w3style.co.uk>
*/
class Swift_Cache_JointOutputStream extends Swift_Cache_OutputStream
{
/**
* The streams to join
* @var array
*/
protected $streams = array();
/**
* The current stream in use
* @var int
*/
protected $pointer = 0;
/**
* Ctor
* @param array An array of Swift_Cache_OutputStream instances
*/
public function __construct($streams=array())
{
$this->streams = $streams;
}
/**
* Add a new output stream
* @param Swift_Cache_OutputStream
*/
public function addStream(Swift_Cache_OutputStream $stream)
{
$this->streams[] = $stream;
}
/**
* Read data from all streams as if they are one stream
* @param int The number of bytes to read from each stream
* @return string
*/
public function read($size=null)
{
$ret = $this->streams[$this->pointer]->read($size);
if ($ret !== false)
{
return $ret;
}
else
{
if (isset($this->streams[($this->pointer+1)]))
{
$this->pointer++;
return $this->read($size);
}
else
{
$this->pointer = 0;
return false;
}
}
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* Swift Mailer Native memory runtime cache
* Please read the LICENSE file
* @author Chris Corbyn <chris@w3style.co.uk>
* @package Swift_Cache
* @license GNU Lesser General Public License
*/
require_once dirname(__FILE__) . "/../ClassLoader.php";
Swift_ClassLoader::load("Swift_Cache");
/**
* Caches data in variables - uses memory!
* @package Swift_Cache
* @author Chris Corbyn <chris@w3style.co.uk>
*/
class Swift_Cache_Memory extends Swift_Cache
{
/**
* The storage container for this cache
* @var array
*/
protected $store = array();
/**
* The key which was last requested
* @var string
*/
protected $requested;
/**
* Write data to the cache
* @param string The cache key
* @param string The data to write
*/
public function write($key, $data)
{
if (!isset($this->store[$key])) $this->store[$key] = $data;
else $this->store[$key] .= $data;
}
/**
* Clear the cached data (unset)
* @param string The cache key
*/
public function clear($key)
{
$this->store[$key] = null;
unset($this->store[$key]);
}
/**
* Check if data is cached for $key
* @param string The cache key
* @return boolean
*/
public function has($key)
{
return array_key_exists($key, $this->store);
}
/**
* Read data from the cache for $key
* It makes no difference to memory/speed if data is read in chunks so arguments are ignored
* @param string The cache key
* @return string
*/
public function read($key, $size=null)
{
if (!$this->has($key)) return false;
if ($this->requested == $key)
{
$this->requested = null;
return false;
}
$this->requested = $key;
return $this->store[$key];
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* Swift Mailer Output stream to read bytes from cached data
* Please read the LICENSE file
* @author Chris Corbyn <chris@w3style.co.uk>
* @package Swift_Cache
* @license GNU Lesser General Public License
*/
/**
* The wraps the streaming functionality of the cache
* @package Swift_Cache
* @author Chris Corbyn <chris@w3style.co.uk>
*/
class Swift_Cache_OutputStream
{
/**
* The key to read in the actual cache
* @var string
*/
protected $key;
/**
* The cache object to read
* @var Swift_Cache
*/
protected $cache;
/**
* Ctor.
* @param Swift_Cache The cache to read from
* @param string The key for the cached data
*/
public function __construct(Swift_Cache $cache, $key)
{
$this->cache = $cache;
$this->key = $key;
}
/**
* Read bytes from the cache and seek through the buffer
* Returns false if EOF is reached
* @param int The number of bytes to read (could be ignored)
* @return string The read bytes
*/
public function read($size=null)
{
return $this->cache->read($this->key, $size);
}
/**
* Read the entire cached data as one string
* @return string
*/
public function readFull()
{
$ret = "";
while (false !== $bytes = $this->read())
$ret .= $bytes;
return $ret;
}
}