本文整理匯總了PHP中MailSo\Base\Utils類的典型用法代碼示例。如果您正苦於以下問題:PHP Utils類的具體用法?PHP Utils怎麽用?PHP Utils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Utils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: clearImplementation
/**
* @return bool
*/
protected function clearImplementation()
{
if (\defined('PHP_SAPI') && 'cli' === PHP_SAPI && \MailSo\Base\Utils::FunctionExistsAndEnabled('system')) {
\system('clear');
}
return true;
}
示例2: UseStartTLS
/**
* @param bool $bSupported
* @param int $iSecurityType
* @param bool $bHasSupportedAuth = true
*
* @return bool
*/
public static function UseStartTLS($bSupported, $iSecurityType, $bHasSupportedAuth = true)
{
return ($bSupported &&
(self::STARTTLS === $iSecurityType ||
(self::AUTO_DETECT === $iSecurityType && (!$bHasSupportedAuth || \MailSo\Config::$PreferStartTlsIfAutoDetect))) &&
\defined('STREAM_CRYPTO_METHOD_TLS_CLIENT') && \MailSo\Base\Utils::FunctionExistsAndEnabled('stream_socket_enable_crypto'));
}
示例3: ChangePassword
/**
* @param \RainLoop\Model\Account $oHmailAccount
* @param string $sPrevPassword
* @param string $sNewPassword
*
* @return bool
*/
public function ChangePassword(\RainLoop\Account $oHmailAccount, $sPrevPassword, $sNewPassword)
{
if ($this->oLogger) {
$this->oLogger->Write('Try to change password for ' . $oHmailAccount->Email());
}
$bResult = false;
try {
$oHmailApp = new COM("hMailServer.Application");
$oHmailApp->Connect();
if ($oHmailApp->Authenticate($this->sLogin, $this->sPassword)) {
$sEmail = $oHmailAccount->Email();
$sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail);
$oHmailDomain = $oHmailApp->Domains->ItemByName($sDomain);
if ($oHmailDomain) {
$oHmailAccount = $oHmailDomain->Accounts->ItemByAddress($sEmail);
if ($oHmailAccount) {
$oHmailAccount->Password = $sNewPassword;
$oHmailAccount->Save();
$bResult = true;
} else {
$this->oLogger->Write('HMAILSERVER: Unknown account (' . $sEmail . ')', \MailSo\Log\Enumerations\Type::ERROR);
}
} else {
$this->oLogger->Write('HMAILSERVER: Unknown domain (' . $sDomain . ')', \MailSo\Log\Enumerations\Type::ERROR);
}
} else {
$this->oLogger->Write('HMAILSERVER: Auth error', \MailSo\Log\Enumerations\Type::ERROR);
}
} catch (\Exception $oException) {
if ($this->oLogger) {
$this->oLogger->WriteException($oException);
}
}
return $bResult;
}
示例4: ChangePassword
/**
* @param \RainLoop\Account $oAccount
* @param string $sPrevPassword
* @param string $sNewPassword
*/
public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword)
{
$mResult = false;
if ($this->oDriver instanceof \RainLoop\Providers\ChangePassword\ChangePasswordInterface && $this->PasswordChangePossibility($oAccount)) {
if ($sPrevPassword !== $oAccount->Password()) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CurrentPasswordIncorrect);
}
$sPasswordForCheck = \trim($sNewPassword);
if (6 > \strlen($sPasswordForCheck)) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordShort);
}
if (!\MailSo\Base\Utils::PasswordWeaknessCheck($sPasswordForCheck)) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordWeak);
}
if (!$this->oDriver->ChangePassword($oAccount, $sPrevPassword, $sNewPassword)) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
}
$oAccount->SetPassword($sNewPassword);
$this->oActions->SetAuthToken($oAccount);
$mResult = $this->oActions->GetSpecAuthToken();
} else {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
}
return $mResult;
}
示例5: __construct
/**
* @param string $sFileName
* @param string $sFileHeader = ''
*
* @return void
*/
public function __construct($sFileName, $sFileHeader = '')
{
$this->sFile = \APP_PRIVATE_DATA . 'configs/' . $sFileName;
$this->sFileHeader = $sFileHeader;
$this->aData = $this->defaultValues();
$this->bUseApcCache = APP_USE_APC_CACHE && \MailSo\Base\Utils::FunctionExistsAndEnabled(array('apc_fetch', 'apc_store'));
}
示例6: Connect
/**
* @return bool
*/
public function Connect()
{
$sHost = $this->bUseSsl ? 'ssl://' . $this->sHost : $this->sHost;
if ($this->IsConnected()) {
CApi::Log('already connected[' . $sHost . ':' . $this->iPort . ']: result = false', ELogLevel::Error);
$this->Disconnect();
return false;
}
$sErrorStr = '';
$iErrorNo = 0;
CApi::Log('start connect to ' . $sHost . ':' . $this->iPort);
$this->rConnect = @fsockopen($sHost, $this->iPort, $iErrorNo, $sErrorStr, $this->iConnectTimeOut);
if (!$this->IsConnected()) {
CApi::Log('connection error[' . $sHost . ':' . $this->iPort . ']: fsockopen = false (' . $iErrorNo . ': ' . $sErrorStr . ')', ELogLevel::Error);
return false;
} else {
CApi::Log('connected');
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_set_timeout')) {
@stream_set_timeout($this->rConnect, $this->iSocketTimeOut);
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('@stream_set_blocking')) {
@stream_set_blocking($this->rConnect, true);
}
return true;
}
示例7: GC
/**
* @param int $iTimeToClearInHours = 24
*
* @return bool
*/
public function GC($iTimeToClearInHours = 24)
{
if (0 < $iTimeToClearInHours) {
\MailSo\Base\Utils::RecTimeDirRemove($this->sCacheFolder, 60 * 60 * $iTimeToClearInHours, \time());
return true;
}
return false;
}
示例8: __construct
/**
* @access protected
*
* @param string $sEmailAddresses = ''
*/
protected function __construct($sEmailAddresses = '')
{
parent::__construct();
$sEmailAddresses = \MailSo\Base\Utils::Trim($sEmailAddresses);
if (0 < \strlen($sEmailAddresses)) {
$this->parseEmailAddresses($sEmailAddresses);
}
}
示例9: FilterSmtpCredentials
/**
* This function detects the SMTP Host, and if it is set to "auto", replaces it with the email domain.
*
* @param \RainLoop\Model\Account $oAccount
* @param array $aSmtpCredentials
*/
public function FilterSmtpCredentials($oAccount, &$aSmtpCredentials)
{
if ($oAccount instanceof \RainLoop\Model\Account && \is_array($aSmtpCredentials)) {
// Check for mail.$DOMAIN as entered value in RL settings
if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host']) {
$aSmtpCredentials['Host'] = \MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email());
}
}
}
示例10: CreateStream
/**
* @param array $aSubStreams
*
* @return resource|bool
*/
public static function CreateStream($aSubStreams)
{
if (!\in_array(self::STREAM_NAME, \stream_get_wrappers())) {
\stream_wrapper_register(self::STREAM_NAME, '\\MailSo\\Base\\StreamWrappers\\SubStreams');
}
$sHashName = \MailSo\Base\Utils::Md5Rand();
self::$aStreams[$sHashName] = $aSubStreams;
\MailSo\Base\Loader::IncStatistic('CreateStream/SubStreams');
return \fopen(self::STREAM_NAME . '://' . $sHashName, 'rb');
}
示例11: __construct
/**
* @param string $sFileName
* @param string $sFileHeader = ''
* @param string $sAdditionalFileName = ''
*
* @return void
*/
public function __construct($sFileName, $sFileHeader = '', $sAdditionalFileName = '')
{
$this->sFile = \APP_PRIVATE_DATA . 'configs/' . \trim($sFileName);
$sAdditionalFileName = \trim($sAdditionalFileName);
$this->sAdditionalFile = \APP_PRIVATE_DATA . 'configs/' . $sAdditionalFileName;
$this->sAdditionalFile = 0 < \strlen($sAdditionalFileName) && \file_exists($this->sAdditionalFile) ? $this->sAdditionalFile : '';
$this->sFileHeader = $sFileHeader;
$this->aData = $this->defaultValues();
$this->bUseApcCache = APP_USE_APC_CACHE && \MailSo\Base\Utils::FunctionExistsAndEnabled(array('apc_fetch', 'apc_store'));
}
示例12: convertGoogleJsonContactToResponseContact
/**
* @param array $oItem
* @param array $aPics
*
* @return array|null
*/
private function convertGoogleJsonContactToResponseContact($oItem, &$aPics)
{
$mResult = null;
if (!empty($oItem['gd$email'][0]['address'])) {
$mEmail = \MailSo\Base\Utils::IdnToAscii($oItem['gd$email'][0]['address'], true);
if (\is_array($oItem['gd$email']) && 1 < \count($oItem['gd$email'])) {
$mEmail = array();
foreach ($oItem['gd$email'] as $oEmail) {
if (!empty($oEmail['address'])) {
$mEmail[] = \MailSo\Base\Utils::IdnToAscii($oEmail['address'], true);
}
}
}
$sImg = '';
if (!empty($oItem['link']) && \is_array($oItem['link'])) {
foreach ($oItem['link'] as $oLink) {
if ($oLink && isset($oLink['type'], $oLink['href'], $oLink['rel']) && 'image/*' === $oLink['type'] && '#photo' === \substr($oLink['rel'], -6)) {
$sImg = $oLink['href'];
break;
}
}
}
$mResult = array('email' => $mEmail, 'name' => !empty($oItem['title']['$t']) ? $oItem['title']['$t'] : '');
if (0 < \strlen($sImg)) {
$sHash = \RainLoop\Utils::EncodeKeyValues(array('url' => $sImg, 'type' => 'google_access_token'));
$mData = array();
if (isset($aPics[$sHash])) {
$mData = $aPics[$sHash];
if (!\is_array($mData)) {
$mData = array($mData);
}
}
if (\is_array($mEmail)) {
$mData = \array_merge($mData, $mEmail);
$mData = \array_unique($mData);
} else {
if (0 < \strlen($mEmail)) {
$mData[] = $mEmail;
}
}
if (\is_array($mData)) {
if (1 === \count($mData) && !empty($mData[0])) {
$aPics[$sHash] = $mData[0];
} else {
if (1 < \count($mData)) {
$aPics[$sHash] = $mData;
}
}
}
}
}
return $mResult;
}
示例13: PutFile
/**
* @param \CAccount $oAccount
* @param int $iStorageType
* @param string $sKey
* @param resource $rSource
*
* @return bool
*/
public function PutFile(\CAccount $oAccount, $iStorageType, $sKey, $rSource)
{
$bResult = false;
if ($rSource) {
$rOpenOutput = @fopen($this->generateFileName($oAccount, $iStorageType, $sKey, true), 'w+b');
if ($rOpenOutput) {
$bResult = false !== \MailSo\Base\Utils::MultipleStreamWriter($rSource, array($rOpenOutput));
@fclose($rOpenOutput);
}
}
return $bResult;
}
示例14: GetDomFromText
/**
* @param string $sText
* @param string $sHtmlAttrs = ''
* @param string $sBodyAttrs = ''
*
* @return \DOMDocument|bool
*/
public static function GetDomFromText($sText, $sHtmlAttrs = '', $sBodyAttrs = '')
{
static $bOnce = true;
if ($bOnce) {
$bOnce = false;
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors')) {
@\libxml_use_internal_errors(true);
}
}
$oDom = new \DOMDocument('1.0', 'utf-8');
$oDom->encoding = 'UTF-8';
$oDom->formatOutput = false;
@$oDom->loadHTML('<' . '?xml version="1.0" encoding="utf-8"?' . '>' . '<html ' . $sHtmlAttrs . '><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body ' . $sBodyAttrs . '>' . $sText . '</body></html>');
return $oDom;
}
示例15: Statistic
/**
* @return array|null
*/
public static function Statistic()
{
$aResult = null;
if (self::$StoreStatistic) {
$aResult = array('php' => array('phpversion' => PHP_VERSION, 'ssl' => (int) \function_exists('openssl_open'), 'iconv' => (int) \function_exists('iconv')));
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('memory_get_usage') && \MailSo\Base\Utils::FunctionExistsAndEnabled('memory_get_peak_usage')) {
$aResult['php']['memory_get_usage'] = Utils::FormatFileSize(\memory_get_usage(true), 2);
$aResult['php']['memory_get_peak_usage'] = Utils::FormatFileSize(\memory_get_peak_usage(true), 2);
}
self::SetStatistic('TimeDelta', \microtime(true) - self::GetStatistic('Inited'));
$aResult['statistic'] = self::$aSetStatistic;
$aResult['counts'] = self::$aIncStatistic;
}
return $aResult;
}