mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-07 05:34:12 +08:00
Added MailSo hooks
This commit is contained in:
parent
cfbda969d1
commit
e1d3010054
9 changed files with 79 additions and 31 deletions
|
@ -4,7 +4,6 @@ namespace MailSo;
|
|||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Base
|
||||
*/
|
||||
class Config
|
||||
{
|
||||
|
|
46
rainloop/v/0.0.0/app/libraries/MailSo/Hooks.php
Normal file
46
rainloop/v/0.0.0/app/libraries/MailSo/Hooks.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
*/
|
||||
class Hooks
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
static $aCallbacks = array();
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param array $aArg
|
||||
*/
|
||||
static public function Run($sName, $aArg = array())
|
||||
{
|
||||
if (isset(\MailSo\Hooks::$aCallbacks[$sName]))
|
||||
{
|
||||
foreach (\MailSo\Hooks::$aCallbacks[$sName] as $mCallback)
|
||||
{
|
||||
\call_user_func_array($mCallback, $aArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param mixed $mCallback
|
||||
*/
|
||||
static public function Add($sName, $mCallback)
|
||||
{
|
||||
if (\is_callable($mCallback))
|
||||
{
|
||||
if (!isset(\MailSo\Hooks::$aCallbacks[$sName]))
|
||||
{
|
||||
\MailSo\Hooks::$aCallbacks[$sName] = array();
|
||||
}
|
||||
|
||||
\MailSo\Hooks::$aCallbacks[$sName][] = $mCallback;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -147,12 +147,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$this->IsSupported('STARTTLS'), $this->iSecurityType))
|
||||
{
|
||||
$this->SendRequestWithCheck('STARTTLS');
|
||||
if (!@\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Imap\Exceptions\RuntimeException('Cannot enable STARTTLS'),
|
||||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
$this->EnableCrypto();
|
||||
|
||||
$this->aCapabilityItems = null;
|
||||
}
|
||||
|
|
|
@ -242,14 +242,18 @@ abstract class NetClient
|
|||
// $iErrorNo, $sErrorStr, $this->iConnectTimeOut);
|
||||
|
||||
$bVerifySsl = !!$bVerifySsl;
|
||||
$rStreamContext = \stream_context_create(array(
|
||||
$aStreamContextSettings = array(
|
||||
'ssl' => array(
|
||||
'verify_host' => $bVerifySsl,
|
||||
'verify_peer' => $bVerifySsl,
|
||||
'verify_peer_name' => $bVerifySsl,
|
||||
'allow_self_signed' => !$bVerifySsl
|
||||
)
|
||||
));
|
||||
);
|
||||
|
||||
\MailSo\Hooks::Run('Net.NetClient.StreamContextSettings/Filter', array(&$aStreamContextSettings));
|
||||
|
||||
$rStreamContext = \stream_context_create($aStreamContextSettings);
|
||||
|
||||
\set_error_handler(array(&$this, 'capturePhpErrorWithException'));
|
||||
|
||||
|
@ -287,6 +291,23 @@ abstract class NetClient
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {int} $iCryptoType = STREAM_CRYPTO_METHOD_TLS_CLIENT
|
||||
*/
|
||||
public function EnableCrypto($iCryptoType = STREAM_CRYPTO_METHOD_TLS_CLIENT)
|
||||
{
|
||||
if (\is_resource($this->rConnect) &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_socket_enable_crypto'))
|
||||
{
|
||||
if (!@\stream_socket_enable_crypto($this->rConnect, true, $iCryptoType))
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Net\Exceptions\Exception('Cannot enable STARTTLS. [type='.$iCryptoType.']'),
|
||||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -73,12 +73,7 @@ class Pop3Client extends \MailSo\Net\NetClient
|
|||
in_array('STLS', $this->Capa()), $this->iSecurityType))
|
||||
{
|
||||
$this->sendRequestWithCheck('STLS');
|
||||
if (!@stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Pop3\Exceptions\RuntimeException('Cannot enable STARTTLS'),
|
||||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
$this->EnableCrypto();
|
||||
|
||||
$this->aCapa = null;
|
||||
}
|
||||
|
|
|
@ -101,12 +101,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
$this->IsSupported('STARTTLS'), $this->iSecurityType))
|
||||
{
|
||||
$this->sendRequestWithCheck('STARTTLS');
|
||||
if (!@stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Sieve\Exceptions\RuntimeException('Cannot enable STARTTLS'),
|
||||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
$this->EnableCrypto();
|
||||
|
||||
$mResponse = $this->parseResponse();
|
||||
$this->validateResponse($mResponse);
|
||||
|
|
|
@ -528,13 +528,8 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
$this->IsSupported('STARTTLS'), $this->iSecurityType, $this->HasSupportedAuth()))
|
||||
{
|
||||
$this->sendRequestWithCheck('STARTTLS', 220);
|
||||
if (!@\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Smtp\Exceptions\RuntimeException('Cannot enable STARTTLS'),
|
||||
\MailSo\Log\Enumerations\Type::WARNING, true);
|
||||
}
|
||||
|
||||
$this->EnableCrypto();
|
||||
|
||||
$this->ehloOrHelo($sEhloHost);
|
||||
}
|
||||
else if (\MailSo\Net\Enumerations\ConnectionSecurityType::STARTTLS === $this->iSecurityType)
|
||||
|
|
|
@ -101,7 +101,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
'Enable CSRF protection (http://en.wikipedia.org/wiki/Cross-site_request_forgery)'),
|
||||
|
||||
'custom_server_signature' => array('RainLoop'),
|
||||
'x_frame_options_header' => array('SAMEORIGIN'),
|
||||
'x_frame_options_header' => array(''),
|
||||
'openpgp' => array(false),
|
||||
'use_rsa_encryption' => array(false),
|
||||
'admin_login' => array('admin', 'Login and password for web admin panel'),
|
||||
|
|
|
@ -468,7 +468,8 @@ class PdoAddressBook
|
|||
else
|
||||
{
|
||||
$sSql = 'INSERT INTO rainloop_ab_contacts '.
|
||||
'( id_user, id_contact_str, display, changed, etag) VALUES '.
|
||||
'( id_user, id_contact_str, display, changed, etag)'.
|
||||
' VALUES '.
|
||||
'(:id_user, :id_contact_str, :display, :changed, :etag)';
|
||||
|
||||
$this->prepareAndExecute($sSql,
|
||||
|
@ -514,7 +515,8 @@ class PdoAddressBook
|
|||
if (0 < \count($aParams))
|
||||
{
|
||||
$sSql = 'INSERT INTO rainloop_ab_properties '.
|
||||
'( id_contact, id_user, prop_type, prop_type_str, prop_value, prop_value_custom, prop_frec) VALUES '.
|
||||
'( id_contact, id_user, prop_type, prop_type_str, prop_value, prop_value_custom, prop_frec)'.
|
||||
' VALUES '.
|
||||
'(:id_contact, :id_user, :prop_type, :prop_type_str, :prop_value, :prop_value_custom, :prop_frec)';
|
||||
|
||||
$this->prepareAndExecute($sSql, $aParams, true);
|
||||
|
|
Loading…
Add table
Reference in a new issue