mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-12 07:11:42 +09:00
Remove trailing whitespace
This commit is contained in:
parent
3b0030e82b
commit
a9f72a5cd2
81 changed files with 2455 additions and 2455 deletions
|
|
@ -9,47 +9,47 @@ interface CacheInterface
|
|||
{
|
||||
/**
|
||||
* Create a new instance of the current cache driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
public static function getInstance(array $config);
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current cache driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported();
|
||||
|
||||
|
||||
/**
|
||||
* Validate cache settings.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param mixed $config
|
||||
* @return bool
|
||||
*/
|
||||
public static function validateSettings($config);
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a key.
|
||||
*
|
||||
*
|
||||
* This method returns null if the key was not found.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key);
|
||||
|
||||
|
||||
/**
|
||||
* Set the value to a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* $ttl is measured in seconds. If it is zero, the key should not expire.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
|
|
@ -57,57 +57,57 @@ interface CacheInterface
|
|||
* @return bool
|
||||
*/
|
||||
public function set($key, $value, $ttl = 0, $force = false);
|
||||
|
||||
|
||||
/**
|
||||
* Delete a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* If the key does not exist, it should return false.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($key);
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key exists.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($key);
|
||||
|
||||
|
||||
/**
|
||||
* Increase the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
*/
|
||||
public function incr($key, $amount);
|
||||
|
||||
|
||||
/**
|
||||
* Decrease the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
*/
|
||||
public function decr($key, $amount);
|
||||
|
||||
|
||||
/**
|
||||
* Clear all keys from the cache.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear();
|
||||
|
|
|
|||
|
|
@ -9,61 +9,61 @@ interface MailInterface
|
|||
{
|
||||
/**
|
||||
* Create a new instance of the current mail driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
public static function getInstance(array $config);
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this mail driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName();
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig();
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of API types supported by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAPITypes();
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint();
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint();
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported();
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,47 +9,47 @@ interface PushInterface
|
|||
{
|
||||
/**
|
||||
* Create a new instance of the current Push driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
public static function getInstance(array $config): PushInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this Push driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName(): string;
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this Push driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig(): array;
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields optionally used by this Push driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getOptionalConfig(): array;
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current SMS driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported(): bool;
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @param array $tokens
|
||||
* @return \stdClass
|
||||
|
|
|
|||
|
|
@ -9,61 +9,61 @@ interface SMSInterface
|
|||
{
|
||||
/**
|
||||
* Create a new instance of the current SMS driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
public static function getInstance(array $config);
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName();
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig();
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields optionally used by this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getOptionalConfig();
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of API types supported by this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAPITypes();
|
||||
|
||||
|
||||
/**
|
||||
* Get the spec for this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAPISpec();
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current SMS driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported();
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param array $messages
|
||||
* @param object $original
|
||||
* @return bool
|
||||
|
|
|
|||
64
common/framework/drivers/cache/apc.php
vendored
64
common/framework/drivers/cache/apc.php
vendored
|
|
@ -11,23 +11,23 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
* Set this flag to false to disable cache prefixes.
|
||||
*/
|
||||
public $prefix = true;
|
||||
|
||||
|
||||
/**
|
||||
* The singleton instance is stored here.
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the current cache driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -39,24 +39,24 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current cache driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return function_exists('apcu_exists');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate cache settings.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param mixed $config
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -64,12 +64,12 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a key.
|
||||
*
|
||||
*
|
||||
* This method returns null if the key was not found.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -78,13 +78,13 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
$value = apcu_fetch($key);
|
||||
return $value === false ? null : $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value to a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* $ttl is measured in seconds. If it is zero, the key should not expire.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
|
|
@ -95,13 +95,13 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return apcu_store($key, $value, $ttl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* If the key does not exist, it should return false.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -109,12 +109,12 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return apcu_delete($key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key exists.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -122,13 +122,13 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return apcu_exists($key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increase the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -143,13 +143,13 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrease the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -164,12 +164,12 @@ class APC implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all keys from the cache.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
|
|
|
|||
38
common/framework/drivers/cache/dummy.php
vendored
38
common/framework/drivers/cache/dummy.php
vendored
|
|
@ -11,32 +11,32 @@ class Dummy extends File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
* Set this flag to false to disable cache prefixes.
|
||||
*/
|
||||
public $prefix = false;
|
||||
|
||||
|
||||
/**
|
||||
* The singleton instance is stored here.
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Dummy data is stored here.
|
||||
*/
|
||||
public $data = array();
|
||||
|
||||
|
||||
/**
|
||||
* Override the isSupported() method of the file driver.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a key.
|
||||
*
|
||||
*
|
||||
* This method returns null if the key was not found.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -61,13 +61,13 @@ class Dummy extends File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value to a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* $ttl is measured in seconds. If it is zero, the key should not expire.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
|
|
@ -86,13 +86,13 @@ class Dummy extends File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* If the key does not exist, it should return false.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -112,12 +112,12 @@ class Dummy extends File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key exists.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -125,12 +125,12 @@ class Dummy extends File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return parent::exists($key) || isset($this->data[$key]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all keys from the cache.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
|
|
|
|||
68
common/framework/drivers/cache/file.php
vendored
68
common/framework/drivers/cache/file.php
vendored
|
|
@ -13,17 +13,17 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
* Set this flag to false to disable cache prefixes.
|
||||
*/
|
||||
public $prefix = false;
|
||||
|
||||
|
||||
/**
|
||||
* The singleton instance is stored here.
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* The cache directory.
|
||||
*/
|
||||
protected $_dir;
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
|
|
@ -35,10 +35,10 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
Storage::createDirectory($this->_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the current cache driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -50,23 +50,23 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return static::$_instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Since Rhymix 2.1, This method always returns false.
|
||||
* The file cache driver can only be used through the dummy driver.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate cache settings.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param mixed $config
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -74,12 +74,12 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a key.
|
||||
*
|
||||
*
|
||||
* This method returns null if the key was not found.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -87,7 +87,7 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
$filename = $this->_getFilename($key);
|
||||
$data = Storage::readPHPData($filename);
|
||||
|
||||
|
||||
if ($data === false)
|
||||
{
|
||||
return null;
|
||||
|
|
@ -102,13 +102,13 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return $data[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value to a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* $ttl is measured in seconds. If it is zero, the key should not expire.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
|
|
@ -119,13 +119,13 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return Storage::writePHPData($this->_getFilename($key), array($ttl ? (time() + $ttl) : 0, $value), $key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* If the key does not exist, it should return false.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -133,12 +133,12 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return Storage::delete($this->_getFilename($key));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key exists.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -146,13 +146,13 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return $this->get($key) !== null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increase the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -163,13 +163,13 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
$success = $this->set($key, $value + $amount, 0, true);
|
||||
return $success ? ($value + $amount) : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrease the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -178,22 +178,22 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return $this->incr($key, 0 - $amount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all keys from the cache.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
return Storage::deleteDirectory($this->_dir) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the filename to store a key.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
70
common/framework/drivers/cache/memcached.php
vendored
70
common/framework/drivers/cache/memcached.php
vendored
|
|
@ -11,18 +11,18 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
* Set this flag to false to disable cache prefixes.
|
||||
*/
|
||||
public $prefix = true;
|
||||
|
||||
|
||||
/**
|
||||
* The singleton instance is stored here.
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* The Memcached connection is stored here.
|
||||
*/
|
||||
protected $_conn = null;
|
||||
protected $_ext = null;
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
|
|
@ -42,7 +42,7 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
foreach ($config as $url)
|
||||
{
|
||||
if (starts_with('/', $url))
|
||||
|
|
@ -59,10 +59,10 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the current cache driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -74,24 +74,24 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current cache driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return class_exists('\\Memcached', false) || class_exists('\\Memcache', false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate cache settings.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param mixed $config
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -111,7 +111,7 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
foreach ($config as $url)
|
||||
{
|
||||
if (starts_with('/', $url))
|
||||
|
|
@ -127,7 +127,7 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for ($i = 0; $i < 5; $i++)
|
||||
{
|
||||
$key = 'rhymix:test:' . md5($i);
|
||||
|
|
@ -136,12 +136,12 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a key.
|
||||
*
|
||||
*
|
||||
* This method returns null if the key was not found.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -157,13 +157,13 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value to a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* $ttl is measured in seconds. If it is zero, the key should not expire.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
|
|
@ -181,13 +181,13 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return $this->_conn->set($key, $value, MEMCACHE_COMPRESSED, $ttl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* If the key does not exist, it should return false.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -195,12 +195,12 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return $this->_conn->delete($key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key exists.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -208,13 +208,13 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return $this->_conn->get($key) !== false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increase the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -229,13 +229,13 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrease the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -250,12 +250,12 @@ class Memcached implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all keys from the cache.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
|
|
|
|||
68
common/framework/drivers/cache/redis.php
vendored
68
common/framework/drivers/cache/redis.php
vendored
|
|
@ -11,17 +11,17 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
* Set this flag to false to disable cache prefixes.
|
||||
*/
|
||||
public $prefix = true;
|
||||
|
||||
|
||||
/**
|
||||
* The singleton instance is stored here.
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* The Redis connection is stored here.
|
||||
*/
|
||||
protected $_conn = null;
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
|
|
@ -71,10 +71,10 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
$this->_conn = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the current cache driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -86,24 +86,24 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current cache driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return class_exists('\\Redis', false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate cache settings.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param mixed $config
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -150,12 +150,12 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a key.
|
||||
*
|
||||
*
|
||||
* This method returns null if the key was not found.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -169,7 +169,7 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if ($value === false)
|
||||
{
|
||||
return null;
|
||||
|
|
@ -178,7 +178,7 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
$value = unserialize($value);
|
||||
if ($value === false)
|
||||
{
|
||||
|
|
@ -186,13 +186,13 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value to a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* $ttl is measured in seconds. If it is zero, the key should not expire.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
|
|
@ -211,13 +211,13 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* If the key does not exist, it should return false.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -232,12 +232,12 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key exists.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -252,13 +252,13 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increase the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -274,13 +274,13 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrease the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -296,12 +296,12 @@ class Redis implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all keys from the cache.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
|
|
|
|||
86
common/framework/drivers/cache/sqlite.php
vendored
86
common/framework/drivers/cache/sqlite.php
vendored
|
|
@ -13,18 +13,18 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
* Set this flag to false to disable cache prefixes.
|
||||
*/
|
||||
public $prefix = false;
|
||||
|
||||
|
||||
/**
|
||||
* The singleton instance is stored here.
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* The database handle and prepared statements are stored here.
|
||||
*/
|
||||
protected $_dbh = null;
|
||||
protected $_ps = array();
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
|
|
@ -35,7 +35,7 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
Storage::createDirectory($dir);
|
||||
}
|
||||
|
||||
|
||||
$key = substr(hash_hmac('sha256', $dir, config('crypto.authentication_key')), 0, 32);
|
||||
$filename = "$dir/$key.db";
|
||||
if (Storage::exists($filename))
|
||||
|
|
@ -51,10 +51,10 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Connect to an SQLite3 database.
|
||||
*
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -65,10 +65,10 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
$this->_dbh->exec('PRAGMA journal_mode = MEMORY');
|
||||
$this->_dbh->exec('PRAGMA synchronous = OFF');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the current cache driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -80,24 +80,24 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current cache driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return class_exists('\\SQLite3', false) && config('crypto.authentication_key') !== null && stripos(\PHP_SAPI, 'win') === false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate cache settings.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param mixed $config
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -105,12 +105,12 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a key.
|
||||
*
|
||||
*
|
||||
* This method returns null if the key was not found.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
@ -122,14 +122,14 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$stmt->bindValue(':key', $key, \SQLITE3_TEXT);
|
||||
$result = $stmt->execute();
|
||||
if (!$result)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$row = $result->fetchArray(\SQLITE3_NUM);
|
||||
if ($row)
|
||||
{
|
||||
|
|
@ -148,13 +148,13 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value to a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* $ttl is measured in seconds. If it is zero, the key should not expire.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
|
|
@ -169,19 +169,19 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$stmt->bindValue(':key', $key, \SQLITE3_TEXT);
|
||||
$stmt->bindValue(':val', serialize($value), \SQLITE3_TEXT);
|
||||
$stmt->bindValue(':exp', $ttl ? (time() + $ttl) : 0, \SQLITE3_INTEGER);
|
||||
return $stmt->execute() ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a key.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
* If the key does not exist, it should return false.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -193,16 +193,16 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$stmt->bindValue(':key', $key, \SQLITE3_TEXT);
|
||||
return $stmt->execute() ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a key exists.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -214,7 +214,7 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$stmt->bindValue(':key', $key, \SQLITE3_TEXT);
|
||||
$stmt->bindValue(':exp', time(), \SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
|
@ -222,7 +222,7 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$row = $result->fetchArray(\SQLITE3_NUM);
|
||||
if ($row)
|
||||
{
|
||||
|
|
@ -233,13 +233,13 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increase the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -260,13 +260,13 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrease the value of a key by $amount.
|
||||
*
|
||||
*
|
||||
* If the key does not exist, this method assumes that the current value is zero.
|
||||
* This method returns the new value.
|
||||
*
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $amount
|
||||
* @return int
|
||||
|
|
@ -275,12 +275,12 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
return $this->incr($key, 0 - $amount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all keys from the cache.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
|
|
@ -289,12 +289,12 @@ class SQLite implements \Rhymix\Framework\Drivers\CacheInterface
|
|||
{
|
||||
$this->_dbh->exec('DROP TABLE cache_' . $i);
|
||||
}
|
||||
|
||||
|
||||
for ($i = 0; $i < 32; $i++)
|
||||
{
|
||||
$this->_dbh->exec('CREATE TABLE cache_' . $i . ' (k TEXT PRIMARY KEY, v TEXT, exp INT)');
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ abstract class Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
* The configuration is stored here.
|
||||
*/
|
||||
protected $_config = null;
|
||||
|
||||
|
||||
/**
|
||||
* The mailer instance is stored here.
|
||||
*/
|
||||
protected $_mailer = null;
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
|
|
@ -24,10 +24,10 @@ abstract class Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
{
|
||||
$this->_config = $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the current mail driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return object
|
||||
*/
|
||||
|
|
@ -35,74 +35,74 @@ abstract class Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
{
|
||||
return new static($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this mail driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return class_basename(get_called_class());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of API types supported by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAPITypes()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,21 +9,21 @@ class Dummy extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
{
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,44 +15,44 @@ class MailFunction extends Base implements \Rhymix\Framework\Drivers\MailInterfa
|
|||
include_once \RX_BASEDIR . 'common/libraries/swift_mail.php';
|
||||
$this->mailer = new \Swift_Mailer(new \Swift_MailTransport);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this mail driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'mail() Function';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'ip4:$SERVER_ADDR';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -67,7 +67,7 @@ class MailFunction extends Base implements \Rhymix\Framework\Drivers\MailInterfa
|
|||
$message->errors[] = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
foreach ($errors as $error)
|
||||
{
|
||||
$message->errors[] = $error;
|
||||
|
|
|
|||
|
|
@ -11,54 +11,54 @@ class Mailgun extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
* The API URL.
|
||||
*/
|
||||
protected static $_url = 'https://api.mailgun.net/v3';
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('api_domain', 'api_token');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'include:mailgun.org';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
{
|
||||
return 'mailo._domainkey';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -87,7 +87,7 @@ class Mailgun extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$recipients[] = $address;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Prepare data and options for Requests.
|
||||
$boundary = str_repeat('-', 24) . substr(md5(mt_rand()), 0, 16);
|
||||
$headers = array(
|
||||
|
|
@ -112,12 +112,12 @@ class Mailgun extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
'timeout' => 5,
|
||||
'useragent' => 'PHP',
|
||||
);
|
||||
|
||||
|
||||
// Send the API request.
|
||||
$url = self::$_url . '/' . $this->_config['api_domain'] . '/messages.mime';
|
||||
$request = \Requests::post($url, $headers, $data, $options);
|
||||
$result = @json_decode($request->body);
|
||||
|
||||
|
||||
// Parse the result.
|
||||
if (!$result)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,30 +19,30 @@ class Mandrill extends SMTP implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$config['smtp_pass'] = $config['api_token'];
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('api_user', 'api_token');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'include:spf.mandrillapp.com';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
|
|
|
|||
|
|
@ -19,30 +19,30 @@ class Postmark extends SMTP implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$config['smtp_pass'] = $config['api_token'];
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('api_token');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'include:spf.mtasv.net';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
|
|
|
|||
|
|
@ -11,54 +11,54 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
* The API URL.
|
||||
*/
|
||||
protected static $_url = 'https://api.sendgrid.com/v3/mail/send';
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('api_token');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'include:sendgrid.net';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
{
|
||||
return 'smtpapi._domainkey';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -70,11 +70,11 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$message->errors[] = 'SendGrid: Please use API key (token) instead of username and password.';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Initialize the request data.
|
||||
$data = [];
|
||||
$data['personalizations'] = [];
|
||||
|
||||
|
||||
// Assemble the list of recipients.
|
||||
$to_list = [];
|
||||
if ($to = $message->message->getTo())
|
||||
|
|
@ -103,7 +103,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
}
|
||||
$data['personalizations'][] = ['bcc' => $bcc_list];
|
||||
}
|
||||
|
||||
|
||||
// Set the sender information.
|
||||
$from = $message->message->getFrom();
|
||||
if ($from)
|
||||
|
|
@ -114,21 +114,21 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$data['from']['name'] = array_first($from);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set the Reply-To address.
|
||||
$replyTo = $message->message->getReplyTo();
|
||||
if ($replyTo)
|
||||
{
|
||||
$data['reply_to']['email'] = array_first_key($from);
|
||||
}
|
||||
|
||||
|
||||
// Set the subject.
|
||||
$data['subject'] = strval($message->getSubject()) ?: 'Title';
|
||||
|
||||
|
||||
// Set the body.
|
||||
$data['content'][0]['type'] = $message->getContentType();
|
||||
$data['content'][0]['value'] = $message->getBody();
|
||||
|
||||
|
||||
// Add attachments.
|
||||
foreach ($message->getAttachments() as $attachment)
|
||||
{
|
||||
|
|
@ -142,7 +142,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
}
|
||||
$data['attachments'][] = $file_info;
|
||||
}
|
||||
|
||||
|
||||
// Prepare data and options for Requests.
|
||||
$headers = array(
|
||||
'Authorization' => 'Bearer ' . $this->_config['api_token'],
|
||||
|
|
@ -152,11 +152,11 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
'timeout' => 8,
|
||||
'useragent' => 'PHP',
|
||||
);
|
||||
|
||||
|
||||
// Send the API request.
|
||||
$request = \Requests::post(self::$_url, $headers, json_encode($data), $options);
|
||||
$response_code = intval($request->status_code);;
|
||||
|
||||
|
||||
// Parse the result.
|
||||
if (!$response_code)
|
||||
{
|
||||
|
|
@ -168,7 +168,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$message->errors[] = 'SendGrid: Response code ' . $response_code . ': ' . $request->body;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class SES extends SMTP implements \Rhymix\Framework\Drivers\MailInterface
|
|||
* Cache the message here for debug access.
|
||||
*/
|
||||
protected $_message;
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
|
|
@ -22,30 +22,30 @@ class SES extends SMTP implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$config['smtp_security'] = 'tls';
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this mail driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Amazon SES (SMTP)';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('smtp_user', 'smtp_pass', 'api_type');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of API types supported by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAPITypes()
|
||||
|
|
@ -57,20 +57,20 @@ class SES extends SMTP implements \Rhymix\Framework\Drivers\MailInterface
|
|||
'ap-southeast-1', 'ap-southeast-2', 'ap-south-1',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'include:amazonses.com';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
|
|
|
|||
|
|
@ -23,34 +23,34 @@ class SMTP extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
}
|
||||
$this->mailer = new \Swift_Mailer($transport);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('smtp_host', 'smtp_port', 'smtp_security', 'smtp_user', 'smtp_pass');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return function_exists('proc_open');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -65,7 +65,7 @@ class SMTP extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$message->errors[] = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
foreach ($errors as $error)
|
||||
{
|
||||
$message->errors[] = 'Failed to send to ' . $error;
|
||||
|
|
|
|||
|
|
@ -11,54 +11,54 @@ class SparkPost extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
* The API URL.
|
||||
*/
|
||||
protected static $_url = 'https://api.sparkpost.com/api/v1/transmissions';
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('api_token');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'include:sparkpostmail.com';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
{
|
||||
return '********._domainkey';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -87,7 +87,7 @@ class SparkPost extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$recipients[] = array('address' => array('name' => $name, 'email' => $address));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Prepare data and options for Requests.
|
||||
$headers = array(
|
||||
'Authorization' => $this->_config['api_token'],
|
||||
|
|
@ -106,11 +106,11 @@ class SparkPost extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
'timeout' => 5,
|
||||
'useragent' => 'PHP',
|
||||
);
|
||||
|
||||
|
||||
// Send the API request.
|
||||
$request = \Requests::post(self::$_url, $headers, $data, $options);
|
||||
$result = @json_decode($request->body);
|
||||
|
||||
|
||||
// Parse the result.
|
||||
if (!$result)
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@ class SparkPost extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$message->errors[] = 'SparkPost: ' . $error->message . ': ' . $error->description . ' (code ' . $error->code . ')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($result->results)
|
||||
{
|
||||
return $result->results->total_accepted_recipients > 0 ? true : false;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Woorimail extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
* The API URL.
|
||||
*/
|
||||
protected static $_url = 'https://woorimail.com/index.php';
|
||||
|
||||
|
||||
/**
|
||||
* Error codes and messages.
|
||||
*/
|
||||
|
|
@ -25,69 +25,69 @@ class Woorimail extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
'me_007' => '이메일과 등록일 갯수가 다릅니다.',
|
||||
'me_008' => '이메일 갯수가 2,000개가 넘습니다.',
|
||||
'me_009' => 'type이 api가 아닙니다.',
|
||||
'me_010' => '인증키가 없습니다.',
|
||||
'me_010' => '인증키가 없습니다.',
|
||||
'me_011' => '인증키가 부정확합니다.',
|
||||
'me_012' => '포인트가 부족합니다.',
|
||||
'me_013' => '전용채널에 도메인이 등록되어 있지 않습니다.',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('api_domain', 'api_token', 'api_type');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of API types supported by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAPITypes()
|
||||
{
|
||||
return array('free', 'paid');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'include:woorimail.com';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -112,7 +112,7 @@ class Woorimail extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
'callback' => '',
|
||||
'is_sendok' => 'W',
|
||||
);
|
||||
|
||||
|
||||
// Fill the sender info.
|
||||
$from = $message->message->getFrom();
|
||||
foreach($from as $email => $name)
|
||||
|
|
@ -137,7 +137,7 @@ class Woorimail extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$data['sender_email'] = $replyTo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fill the recipient info.
|
||||
if ($to = $message->message->getTo())
|
||||
{
|
||||
|
|
@ -166,7 +166,7 @@ class Woorimail extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$data['member_regdate'] = implode(',', array_fill(0, count($data['receiver_email']), date('YmdHis')));
|
||||
$data['receiver_email'] = implode(',', $data['receiver_email']);
|
||||
$data['receiver_nickname'] = implode(',', $data['receiver_nickname']);
|
||||
|
||||
|
||||
// Define connection options.
|
||||
$headers = array(
|
||||
'Accept' => 'application/json, text/javascript, */*; q=0.1',
|
||||
|
|
@ -175,7 +175,7 @@ class Woorimail extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
'timeout' => 5,
|
||||
'useragent' => 'PHP',
|
||||
);
|
||||
|
||||
|
||||
// Send the API request.
|
||||
try
|
||||
{
|
||||
|
|
@ -187,7 +187,7 @@ class Woorimail extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$message->errors[] = 'Woorimail: ' . $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Parse the result.
|
||||
if (!$result)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,34 +12,34 @@ class APNs extends Base implements \Rhymix\Framework\Drivers\PushInterface
|
|||
*/
|
||||
protected static $_required_config = array('certificate', 'passphrase');
|
||||
protected static $_optional_config = array();
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this Push driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'APNs';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current Push driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @param array $tokens
|
||||
* @return \stdClass
|
||||
|
|
@ -86,7 +86,7 @@ class APNs extends Base implements \Rhymix\Framework\Drivers\PushInterface
|
|||
$output->success[] = $token;
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ abstract class Base implements PushInterface
|
|||
* The configuration is stored here.
|
||||
*/
|
||||
protected $_config = null;
|
||||
|
||||
|
||||
/**
|
||||
* Config keys used by this driver are stored here.
|
||||
*/
|
||||
protected static $_required_config = array();
|
||||
protected static $_optional_config = array();
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
|
|
@ -27,10 +27,10 @@ abstract class Base implements PushInterface
|
|||
{
|
||||
$this->_config = $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the current Push driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return PushInterface
|
||||
*/
|
||||
|
|
@ -38,54 +38,54 @@ abstract class Base implements PushInterface
|
|||
{
|
||||
return new static($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this Push driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName(): string
|
||||
{
|
||||
return class_basename(get_called_class());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this Push driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig(): array
|
||||
{
|
||||
return static::$_required_config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields optionally used by this Push driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getOptionalConfig(): array
|
||||
{
|
||||
return static::$_optional_config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current Push driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @param array $tokens
|
||||
* @return \stdClass
|
||||
|
|
|
|||
|
|
@ -12,34 +12,34 @@ class FCM extends Base implements \Rhymix\Framework\Drivers\PushInterface
|
|||
*/
|
||||
protected static $_required_config = array('api_key');
|
||||
protected static $_optional_config = array();
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this Push driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Google FCM';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current Push driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @param array $tokens
|
||||
* @return \stdClass
|
||||
|
|
|
|||
|
|
@ -23,34 +23,34 @@ class ApiStore extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
'mms_supported' => false,
|
||||
'delay_supported' => true,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Config keys used by this driver are stored here.
|
||||
*/
|
||||
protected static $_required_config = array('api_user', 'api_key');
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current SMS driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store the last response.
|
||||
*/
|
||||
protected $_last_response = '';
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param array $messages
|
||||
* @param object $original
|
||||
* @return bool
|
||||
|
|
@ -58,7 +58,7 @@ class ApiStore extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
public function send(array $messages, \Rhymix\Framework\SMS $original)
|
||||
{
|
||||
$status = true;
|
||||
|
||||
|
||||
foreach ($messages as $i => $message)
|
||||
{
|
||||
$data = array();
|
||||
|
|
@ -69,7 +69,7 @@ class ApiStore extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
{
|
||||
$data['subject'] = $message->subject;
|
||||
}
|
||||
|
||||
|
||||
$result = $this->_apiCall(sprintf('message/%s', strtolower($message->type)), $data);
|
||||
if (!$result)
|
||||
{
|
||||
|
|
@ -81,13 +81,13 @@ class ApiStore extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
$message->errors[] = 'ApiStore API error: ' . $result->result_code . ' ' . $result->result_message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API call.
|
||||
*
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $data
|
||||
* @param string $method (optional)
|
||||
|
|
@ -106,12 +106,12 @@ class ApiStore extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
$version = 1;
|
||||
}
|
||||
$url = sprintf('http://api.apistore.co.kr/ppurio/%d/%s/%s', $version, trim($url, '/'), $this->_config['api_user']);
|
||||
|
||||
|
||||
// Set the API key in the header.
|
||||
$headers = array(
|
||||
'x-waple-authorization' => $this->_config['api_key'],
|
||||
);
|
||||
|
||||
|
||||
// Send the API reqeust.
|
||||
if ($method === 'GET')
|
||||
{
|
||||
|
|
@ -128,10 +128,10 @@ class ApiStore extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
$result = @json_decode($this->_last_response);
|
||||
return $result ?: false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the last API response.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _getLastResponse()
|
||||
|
|
|
|||
|
|
@ -11,18 +11,18 @@ abstract class Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
* The configuration is stored here.
|
||||
*/
|
||||
protected $_config = null;
|
||||
|
||||
|
||||
/**
|
||||
* The driver specification is stored here.
|
||||
*/
|
||||
protected static $_spec = array();
|
||||
|
||||
|
||||
/**
|
||||
* Config keys used by this driver are stored here.
|
||||
*/
|
||||
protected static $_required_config = array();
|
||||
protected static $_optional_config = array();
|
||||
|
||||
|
||||
/**
|
||||
* Direct invocation of the constructor is not permitted.
|
||||
*/
|
||||
|
|
@ -30,10 +30,10 @@ abstract class Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
{
|
||||
$this->_config = $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the current SMS driver, using the given settings.
|
||||
*
|
||||
*
|
||||
* @param array $config
|
||||
* @return object
|
||||
*/
|
||||
|
|
@ -41,74 +41,74 @@ abstract class Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
{
|
||||
return new static($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the human-readable name of this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return class_basename(get_called_class());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return static::$_required_config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields optionally used by this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getOptionalConfig()
|
||||
{
|
||||
return static::$_optional_config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of API types supported by this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAPITypes()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the spec for this SMS driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAPISpec()
|
||||
{
|
||||
return static::$_spec;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current SMS driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param array $messages
|
||||
* @param object $original
|
||||
* @return bool
|
||||
|
|
|
|||
|
|
@ -31,30 +31,30 @@ class CoolSMS extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
'image_max_filesize' => 300000,
|
||||
'delay_supported' => true,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Config keys used by this driver are stored here.
|
||||
*/
|
||||
protected static $_required_config = array('api_key', 'api_secret');
|
||||
protected static $_optional_config = array('sender_key');
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current SMS driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param array $messages
|
||||
* @param object $original
|
||||
* @return bool
|
||||
|
|
@ -111,7 +111,7 @@ class CoolSMS extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
$status = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
catch (\Nurigo\Exceptions\CoolsmsException $e)
|
||||
|
|
|
|||
|
|
@ -31,29 +31,29 @@ class Dummy extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
'image_max_filesize' => 300000,
|
||||
'delay_supported' => true,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Sent messages are stored here for debugging and testing.
|
||||
*/
|
||||
protected $_sent_messages = array();
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current SMS driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param array $messages
|
||||
* @param object $original
|
||||
* @return bool
|
||||
|
|
@ -66,20 +66,20 @@ class Dummy extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get sent messages.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSentMessages()
|
||||
{
|
||||
return $this->_sent_messages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset sent messages.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetSentMessages()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
* API endpoint URL (fallback if URL is not explicitly configured)
|
||||
*/
|
||||
const LEGACY_API_URL = 'https://sms.service.iwinv.kr/send/';
|
||||
|
||||
|
||||
/**
|
||||
* API specifications.
|
||||
*/
|
||||
|
|
@ -54,10 +54,10 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of API URLs supported by this driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getApiUrls()
|
||||
|
|
@ -81,7 +81,7 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
{
|
||||
$status = true;
|
||||
$curl = null;
|
||||
|
||||
|
||||
foreach ($messages as $i => $message)
|
||||
{
|
||||
// Authentication
|
||||
|
|
@ -89,7 +89,7 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
'Content-Type: multipart/form-data',
|
||||
'secret: ' . base64_encode($this->_config['api_key'] . '&' . $this->_config['api_secret']),
|
||||
);
|
||||
|
||||
|
||||
// Sender and recipient
|
||||
$data = array();
|
||||
$data['from'] = str_replace('-', '', \Rhymix\Framework\Korea::formatPhoneNumber($message->from));
|
||||
|
|
@ -100,26 +100,26 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
{
|
||||
$data['to'] = array_first($data['to']);
|
||||
}
|
||||
|
||||
|
||||
// Subject and content
|
||||
if ($message->type === 'LMS' && $message->subject)
|
||||
{
|
||||
$data['title'] = $message->subject;
|
||||
}
|
||||
$data['text'] = $message->content;
|
||||
|
||||
|
||||
// Image attachment
|
||||
if ($message->image)
|
||||
{
|
||||
$data['image'] = curl_file_create(realpath($message->image));
|
||||
}
|
||||
|
||||
|
||||
// Set delay
|
||||
if ($message->delay && $message->delay > time() + 900)
|
||||
{
|
||||
$data['date'] = gmdate('Y-m-d H:i:s', $message->delay + (3600 * 9));
|
||||
}
|
||||
|
||||
|
||||
// Set API URL
|
||||
if (!empty($this->_config['api_url']))
|
||||
{
|
||||
|
|
@ -129,7 +129,7 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
{
|
||||
$api_url = self::LEGACY_API_URL;
|
||||
}
|
||||
|
||||
|
||||
// We need to use curl because Filehandler::getRemoteResource() doesn't work with this API for some reason.
|
||||
if (!$curl)
|
||||
{
|
||||
|
|
@ -143,7 +143,7 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
curl_setopt($curl, \CURLOPT_HTTPHEADER, $headers);
|
||||
$result = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
|
||||
// Check the result.
|
||||
if ($err)
|
||||
{
|
||||
|
|
@ -161,12 +161,12 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
$status = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($curl)
|
||||
{
|
||||
@curl_close($curl);
|
||||
}
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,29 +23,29 @@ class Ppurio extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
'mms_supported' => false,
|
||||
'delay_supported' => true,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Config keys used by this driver are stored here.
|
||||
*/
|
||||
protected static $_required_config = array('api_user');
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current SMS driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param array $messages
|
||||
* @param object $original
|
||||
* @return bool
|
||||
|
|
@ -59,26 +59,26 @@ class Ppurio extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
// Authentication and basic information
|
||||
$data = array();
|
||||
$data['userid'] = $this->_config['api_user'];
|
||||
|
||||
|
||||
// Sender and recipient
|
||||
$data['callback'] = preg_replace('/[^0-9]/', '', $message->from);
|
||||
$data['phone'] = implode('|', array_map(function($num) {
|
||||
return preg_replace('/[^0-9]/', '', $num);
|
||||
}, $message->to));
|
||||
|
||||
|
||||
// Subject and content
|
||||
if ($message->type === 'LMS' && $message->subject)
|
||||
{
|
||||
$data['subject'] = $message->subject;
|
||||
}
|
||||
$data['msg'] = $message->content;
|
||||
|
||||
|
||||
// Set delay
|
||||
if ($message->delay && $message->delay > time() + 600)
|
||||
{
|
||||
$data['appdate'] = gmdate('YmdHis', $message->delay + (3600 * 9));
|
||||
}
|
||||
|
||||
|
||||
// Send!
|
||||
$url = 'https://www.ppurio.com/api/send_utf8_json.php';
|
||||
$result = \FileHandler::getRemoteResource($url, $data, 5, 'POST');
|
||||
|
|
@ -97,7 +97,7 @@ class Ppurio extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Rhymix\Framework\Drivers\SMS;
|
|||
class SolAPI extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
||||
{
|
||||
const appId = 'PAOe9c8ftH8R';
|
||||
|
||||
|
||||
/**
|
||||
* API specifications.
|
||||
*/
|
||||
|
|
@ -115,7 +115,7 @@ class SolAPI extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
}
|
||||
$groupArray[] = $options;
|
||||
}
|
||||
|
||||
|
||||
if($groupMessage)
|
||||
{
|
||||
$jsonObject = new \stdClass();
|
||||
|
|
@ -156,7 +156,7 @@ class SolAPI extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create header string for http protocol
|
||||
* @param $config
|
||||
|
|
@ -212,7 +212,7 @@ class SolAPI extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
private function request($method, $url, $data = false)
|
||||
{
|
||||
$url = 'https://api.solapi.com/' . $url;
|
||||
|
||||
|
||||
if(!$data)
|
||||
{
|
||||
$data = null;
|
||||
|
|
@ -222,7 +222,7 @@ class SolAPI extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
$data = json_encode($data);
|
||||
}
|
||||
$result = \FileHandler::getRemoteResource($url, $data, 3, $method, 'application/json', array('Authorization' => $this->getHeader()));
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue