mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
Uploading and preparing the repository to the dev version.
Original unminified source code (dev folder - js, css, less) (fixes #6) Grunt build system Multiple identities correction (fixes #9) Compose html editor (fixes #12) New general settings - Loading Description New warning about default admin password Split general and login screen settings
This commit is contained in:
parent
afad45137e
commit
4cc2207513
846 changed files with 99453 additions and 2123 deletions
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Poppassd\Exceptions;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Poppassd
|
||||
* @subpackage Exceptions
|
||||
*/
|
||||
class Exception extends \MailSo\Base\Exceptions\Exception {}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Poppassd\Exceptions;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Poppassd
|
||||
* @subpackage Exceptions
|
||||
*/
|
||||
class LoginBadCredentialsException extends \MailSo\Poppassd\Exceptions\NegativeResponseException {}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Poppassd\Exceptions;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Poppassd
|
||||
* @subpackage Exceptions
|
||||
*/
|
||||
class NegativeResponseException extends \MailSo\Poppassd\Exceptions\ResponseException {}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Poppassd\Exceptions;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Poppassd
|
||||
* @subpackage Exceptions
|
||||
*/
|
||||
class ResponseException extends \MailSo\Poppassd\Exceptions\Exception
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aResponses;
|
||||
|
||||
/**
|
||||
* @param array $aResponses = array
|
||||
* @param string $sMessage = ''
|
||||
* @param int $iCode = 0
|
||||
* @param \Exception $oPrevious = null
|
||||
*/
|
||||
public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null)
|
||||
{
|
||||
parent::__construct($sMessage, $iCode, $oPrevious);
|
||||
|
||||
if (\is_array($aResponses))
|
||||
{
|
||||
$this->aResponses = $aResponses;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function GetResponses()
|
||||
{
|
||||
return $this->aResponses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Poppassd\Response | null
|
||||
*/
|
||||
public function GetLastResponse()
|
||||
{
|
||||
return 0 < \count($this->aResponses) ? $this->aResponses[count($this->aResponses) - 1] : null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Poppassd\Exceptions;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Poppassd
|
||||
* @subpackage Exceptions
|
||||
*/
|
||||
class RuntimeException extends \MailSo\Poppassd\Exceptions\Exception {}
|
||||
|
|
@ -0,0 +1,277 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Poppassd;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Poppassd
|
||||
*/
|
||||
class PoppassdClient extends \MailSo\Net\NetClient
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bIsLoggined;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iRequestTime;
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
$this->bIsLoggined = false;
|
||||
$this->iRequestTime = 0;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*/
|
||||
public static function NewInstance()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sServerName
|
||||
* @param int $iPort = 106
|
||||
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
|
||||
*
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Poppassd\Exceptions\ResponseException
|
||||
*/
|
||||
public function Connect($sServerName, $iPort = 106,
|
||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT)
|
||||
{
|
||||
$this->iRequestTime = \microtime(true);
|
||||
|
||||
parent::Connect($sServerName, $iPort, $iSecurityType);
|
||||
$this->validateResponse();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sLogin = ''
|
||||
* @param string $sPassword = ''
|
||||
*
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Poppassd\Exceptions\ResponseException
|
||||
*/
|
||||
public function Login($sLogin, $sPassword)
|
||||
{
|
||||
if ($this->bIsLoggined)
|
||||
{
|
||||
$this->writeLogException(
|
||||
new Exceptions\RuntimeException('Already authenticated for this session'),
|
||||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
|
||||
$sLogin = \trim($sLogin);
|
||||
$sPassword = $sPassword;
|
||||
|
||||
try
|
||||
{
|
||||
$this->sendRequestWithCheck('user', $sLogin, true);
|
||||
$this->sendRequestWithCheck('pass', $sPassword, true);
|
||||
}
|
||||
catch (\MailSo\Poppassd\Exceptions\NegativeResponseException $oException)
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Poppassd\Exceptions\LoginBadCredentialsException(
|
||||
$oException->GetResponses(), '', 0, $oException),
|
||||
\MailSo\Log\Enumerations\Type::NOTICE, true);
|
||||
}
|
||||
|
||||
$this->bIsLoggined = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Poppassd\Exceptions\Exception
|
||||
*/
|
||||
public function Logout()
|
||||
{
|
||||
if ($this->bIsLoggined)
|
||||
{
|
||||
$this->sendRequestWithCheck('quit');
|
||||
}
|
||||
|
||||
$this->bIsLoggined = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sNewPassword
|
||||
*
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Poppassd\Exceptions\Exception
|
||||
*/
|
||||
public function NewPass($sNewPassword)
|
||||
{
|
||||
if ($this->bIsLoggined)
|
||||
{
|
||||
$this->sendRequestWithCheck('newpass', $sNewPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Poppassd\Exceptions\RuntimeException('Required login'),
|
||||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sCommand
|
||||
* @param string $sAddToCommand
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function secureRequestParams($sCommand, $sAddToCommand)
|
||||
{
|
||||
$sResult = null;
|
||||
if (0 < \strlen($sAddToCommand))
|
||||
{
|
||||
switch (\strtolower($sCommand))
|
||||
{
|
||||
case 'pass':
|
||||
case 'newpass':
|
||||
$sResult = '*******';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sCommand
|
||||
* @param string $sAddToCommand = ''
|
||||
*
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
*/
|
||||
private function sendRequest($sCommand, $sAddToCommand = '')
|
||||
{
|
||||
if (0 === \strlen(\trim($sCommand)))
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
||||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
|
||||
$this->IsConnected(true);
|
||||
|
||||
$sCommand = \trim($sCommand);
|
||||
$sRealCommand = $sCommand.(0 === \strlen($sAddToCommand) ? '' : ' '.$sAddToCommand);
|
||||
|
||||
$sFakeCommand = '';
|
||||
$sFakeAddToCommand = $this->secureRequestParams($sCommand, $sAddToCommand);
|
||||
if (0 < \strlen($sFakeAddToCommand))
|
||||
{
|
||||
$sFakeCommand = $sCommand.' '.$sFakeAddToCommand;
|
||||
}
|
||||
|
||||
$this->iRequestTime = \microtime(true);
|
||||
$this->sendRaw($sRealCommand, true, $sFakeCommand);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sCommand
|
||||
* @param string $sAddToCommand = ''
|
||||
* @param bool $bAuthRequestValidate = false
|
||||
*
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Poppassd\Exceptions\Exception
|
||||
*/
|
||||
private function sendRequestWithCheck($sCommand, $sAddToCommand = '', $bAuthRequestValidate = false)
|
||||
{
|
||||
$this->sendRequest($sCommand, $sAddToCommand);
|
||||
$this->validateResponse($bAuthRequestValidate);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bAuthRequestValidate = false
|
||||
*
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Poppassd\Exceptions\ResponseException
|
||||
*/
|
||||
private function validateResponse($bAuthRequestValidate = false)
|
||||
{
|
||||
$this->getNextBuffer();
|
||||
|
||||
$bResult = false;
|
||||
if ($bAuthRequestValidate)
|
||||
{
|
||||
$bResult = (bool) \preg_match('/^[23]\d\d/', trim($this->sResponseBuffer));
|
||||
}
|
||||
else
|
||||
{
|
||||
$bResult = (bool) \preg_match('/^2\d\d/', trim($this->sResponseBuffer));
|
||||
}
|
||||
|
||||
if (!$bResult)
|
||||
{
|
||||
$this->writeLogException(
|
||||
new Exceptions\NegativeResponseException(),
|
||||
\MailSo\Log\Enumerations\Type::WARNING, true);
|
||||
}
|
||||
|
||||
$this->writeLog((\microtime(true) - $this->iRequestTime),
|
||||
\MailSo\Log\Enumerations\Type::TIME);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getLogName()
|
||||
{
|
||||
return 'POPPASSD';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Log\Logger $oLogger
|
||||
*
|
||||
* @return \MailSo\Poppassd\PoppassdClient
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function SetLogger($oLogger)
|
||||
{
|
||||
parent::SetLogger($oLogger);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue