本文整理匯總了PHP中MailSo\Base\Utils::Md5Rand方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::Md5Rand方法的具體用法?PHP Utils::Md5Rand怎麽用?PHP Utils::Md5Rand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::Md5Rand方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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');
}
示例2: GetShortToken
/**
* @return string
*/
public static function GetShortToken()
{
$sKey = 'rlsession';
$sToken = \RainLoop\Utils::GetCookie($sKey, null);
if (null === $sToken) {
$sToken = \MailSo\Base\Utils::Md5Rand(APP_SALT);
\RainLoop\Utils::SetCookie($sKey, $sToken, 0, '/', null, null, true);
}
return \md5('Session' . APP_SALT . $sToken . 'Token' . APP_SALT);
}
示例3: parseSearchString
/**
* @param string $sSearch
*
* @return array
*/
private function parseSearchString($sSearch)
{
$aResult = array('OTHER' => '');
$aCache = array();
$sReg = 'e?mail|from|to|subject|has|is|date|text|body|size|larger|bigger|smaller|maxsize|minsize';
$sSearch = \MailSo\Base\Utils::StripSpaces($sSearch);
$sSearch = \trim(\preg_replace('/(' . $sReg . '): /i', '\\1:', $sSearch));
$mMatch = array();
\preg_match_all('/".*?(?<!\\\\)"/', $sSearch, $mMatch);
if (\is_array($mMatch) && isset($mMatch[0]) && \is_array($mMatch[0]) && 0 < \count($mMatch[0])) {
foreach ($mMatch[0] as $sItem) {
do {
$sKey = \MailSo\Base\Utils::Md5Rand();
} while (isset($aCache[$sKey]));
$aCache[$sKey] = \stripcslashes($sItem);
$sSearch = \str_replace($sItem, $sKey, $sSearch);
}
}
\preg_match_all('/\'.*?(?<!\\\\)\'/', $sSearch, $mMatch);
if (\is_array($mMatch) && isset($mMatch[0]) && \is_array($mMatch[0]) && 0 < \count($mMatch[0])) {
foreach ($mMatch[0] as $sItem) {
do {
$sKey = \MailSo\Base\Utils::Md5Rand();
} while (isset($aCache[$sKey]));
$aCache[$sKey] = \stripcslashes($sItem);
$sSearch = \str_replace($sItem, $sKey, $sSearch);
}
}
$mMatch = array();
\preg_match_all('/(' . $sReg . '):([^\\s]*)/i', $sSearch, $mMatch);
if (\is_array($mMatch) && isset($mMatch[1]) && \is_array($mMatch[1]) && 0 < \count($mMatch[1])) {
if (\is_array($mMatch[0])) {
foreach ($mMatch[0] as $sToken) {
$sSearch = \str_replace($sToken, '', $sSearch);
}
$sSearch = \MailSo\Base\Utils::StripSpaces($sSearch);
}
foreach ($mMatch[1] as $iIndex => $sName) {
if (isset($mMatch[2][$iIndex]) && 0 < \strlen($mMatch[2][$iIndex])) {
$sName = \strtoupper($sName);
$sValue = $mMatch[2][$iIndex];
switch ($sName) {
case 'TEXT':
case 'BODY':
case 'EMAIL':
case 'MAIL':
case 'FROM':
case 'TO':
case 'SUBJECT':
case 'IS':
case 'HAS':
case 'SIZE':
case 'SMALLER':
case 'LARGER':
case 'BIGGER':
case 'MAXSIZE':
case 'MINSIZE':
case 'DATE':
if ('MAIL' === $sName) {
$sName = 'EMAIL';
}
if ('BODY' === $sName) {
$sName = 'TEXT';
}
if ('SIZE' === $sName || 'BIGGER' === $sName || 'MINSIZE' === $sName) {
$sName = 'LARGER';
}
if ('MAXSIZE' === $sName) {
$sName = 'SMALLER';
}
$aResult[$sName] = $sValue;
break;
}
}
}
}
$aResult['OTHER'] = $sSearch;
foreach ($aResult as $sName => $sValue) {
if (isset($aCache[$sValue])) {
$aResult[$sName] = \trim($aCache[$sValue], '"\' ');
}
}
return $aResult;
}
示例4: Guid
/**
* @staticvar string $sCache;
*
* @return string
*/
public static function Guid()
{
static $sCache = null;
if (null === $sCache) {
$sCache = \substr(\MailSo\Base\Utils::Md5Rand(), -8);
}
return $sCache;
}
示例5: getMimeFileByHash
/**
* @param \RainLoop\Model\Account $oAccount
* @param string $sHash
*
* @return array
*/
private function getMimeFileByHash($oAccount, $sHash)
{
$aValues = $this->getDecodedRawKeyValue($sHash);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = (int) isset($aValues['Uid']) ? $aValues['Uid'] : 0;
$sMimeIndex = (string) isset($aValues['MimeIndex']) ? $aValues['MimeIndex'] : '';
$sContentTypeIn = (string) isset($aValues['MimeType']) ? $aValues['MimeType'] : '';
$sFileNameIn = (string) isset($aValues['FileName']) ? $aValues['FileName'] : '';
$oFileProvider = $this->FilesProvider();
$sResultHash = '';
$mResult = $this->MailClient()->MessageMimeStream(function ($rResource, $sContentType, $sFileName, $sMimeIndex = '') use($oAccount, $oFileProvider, $sFileNameIn, $sContentTypeIn, &$sResultHash) {
unset($sContentType, $sFileName, $sMimeIndex);
if ($oAccount && \is_resource($rResource)) {
$sHash = \MailSo\Base\Utils::Md5Rand($sFileNameIn . '~' . $sContentTypeIn);
$rTempResource = $oFileProvider->GetFile($oAccount, $sHash, 'wb+');
if (@\is_resource($rTempResource)) {
if (false !== \MailSo\Base\Utils::MultipleStreamWriter($rResource, array($rTempResource))) {
$sResultHash = $sHash;
}
@\fclose($rTempResource);
}
}
}, $sFolder, $iUid, true, $sMimeIndex);
$aValues['FileHash'] = '';
if ($mResult) {
$aValues['FileHash'] = $sResultHash;
}
return $aValues;
}
示例6: rawSmart
/**
* @param bool $bDownload
* @param bool $bThumbnail = false
*
* @return bool
*/
private function rawSmart($bDownload, $bThumbnail = false)
{
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$aValues = $this->getDecodedRawKeyValue($sRawKey);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
$sMimeIndex = isset($aValues['MimeIndex']) ? (string) $aValues['MimeIndex'] : '';
$sContentTypeIn = isset($aValues['MimeType']) ? (string) $aValues['MimeType'] : '';
$sFileNameIn = isset($aValues['FileName']) ? (string) $aValues['FileName'] : '';
$sFileHashIn = isset($aValues['FileHash']) ? (string) $aValues['FileHash'] : '';
if (!empty($sFileHashIn)) {
$this->verifyCacheByKey($sRawKey);
$oAccount = $this->getAccountFromToken();
$sContentTypeOut = empty($sContentTypeIn) ? \MailSo\Base\Utils::MimeContentType($sFileNameIn) : $sContentTypeIn;
$sFileNameOut = $this->MainClearFileName($sFileNameIn, $sContentTypeIn, $sMimeIndex);
$rResource = $this->FilesProvider()->GetFile($oAccount, $sFileHashIn);
if (\is_resource($rResource)) {
$sFileNameOut = \MailSo\Base\Utils::ConvertEncoding($sFileNameOut, \MailSo\Base\Enumerations\Charset::UTF_8, \MailSo\Base\Enumerations\Charset::CP858);
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: attachment; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
return true;
}
return false;
} else {
if (!empty($sFolder) && 0 < $iUid) {
$this->verifyCacheByKey($sRawKey);
}
}
$oAccount = $this->initMailClientConnection();
$self = $this;
return $this->MailClient()->MessageMimeStream(function ($rResource, $sContentType, $sFileName, $sMimeIndex = '') use($self, $oAccount, $sRawKey, $sContentTypeIn, $sFileNameIn, $bDownload, $bThumbnail) {
if ($oAccount && \is_resource($rResource)) {
$sContentTypeOut = $sContentTypeIn;
if (empty($sContentTypeOut)) {
$sContentTypeOut = $sContentType;
if (empty($sContentTypeOut)) {
$sContentTypeOut = empty($sFileName) ? 'text/plain' : \MailSo\Base\Utils::MimeContentType($sFileName);
}
}
$sFileNameOut = $sFileNameIn;
if (empty($sFileNameOut)) {
$sFileNameOut = $sFileName;
}
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
$self->cacheByKey($sRawKey);
$bDone = false;
if ($bThumbnail && !$bDownload) {
$sFileName = '';
$rTempResource = \MailSo\Base\StreamWrappers\TempFile::CreateStream(\MailSo\Base\Utils::Md5Rand($sFileNameOut), $sFileName);
if (@\is_resource($rTempResource)) {
$bDone = true;
\MailSo\Base\Utils::MultipleStreamWriter($rResource, array($rTempResource));
@\fclose($rTempResource);
try {
$oThumb = new \PHPThumb\GD($sFileName);
if ($oThumb) {
$oThumb->adaptiveResize(60, 60)->show();
}
} catch (\Exception $oException) {
$self->Logger()->WriteExceptionShort($oException);
}
}
}
if (!$bDone) {
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: ' . ($bDownload ? 'attachment' : 'inline') . '; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
}
}
}, $sFolder, $iUid, true, $sMimeIndex);
}
示例7: RegenerateContactStr
/**
* @return array
*/
public function RegenerateContactStr()
{
$this->IdContactStr = \class_exists('SabreForRainLoop\\DAV\\Client') ? \SabreForRainLoop\DAV\UUIDUtil::getUUID() : \MailSo\Base\Utils::Md5Rand();
}
示例8: GenerateID
/**
* @return bool
*/
public function GenerateID()
{
return $this->sId = \MailSo\Base\Utils::Md5Rand();
}
示例9: generateNewMessageId
/**
* @param string $sHostName = ''
*
* @return string
*/
private function generateNewMessageId($sHostName = '')
{
if (0 === \strlen($sHostName)) {
$sHostName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
}
if (empty($sHostName) && \MailSo\Base\Utils::FunctionExistsAndEnabled('php_uname')) {
$sHostName = \php_uname('n');
}
if (empty($sHostName)) {
$sHostName = 'localhost';
}
return '<' . \MailSo\Base\Utils::Md5Rand($sHostName . (\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? @\getmypid() : '')) . '@' . $sHostName . '>';
}
示例10: rawSmart
/**
* @param bool $bDownload
* @param bool $bThumbnail = false
*
* @return bool
*/
private function rawSmart($bDownload, $bThumbnail = false)
{
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$aValues = $this->getDecodedRawKeyValue($sRawKey);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = (int) isset($aValues['Uid']) ? $aValues['Uid'] : 0;
$sMimeIndex = (string) isset($aValues['MimeIndex']) ? $aValues['MimeIndex'] : '';
$sContentTypeIn = (string) isset($aValues['MimeType']) ? $aValues['MimeType'] : '';
$sFileNameIn = (string) isset($aValues['FileName']) ? $aValues['FileName'] : '';
if (!empty($sFolder) && 0 < $iUid) {
$this->verifyCacheByKey($sRawKey);
}
$oAccount = $this->initMailClientConnection();
$self = $this;
return $this->MailClient()->MessageMimeStream(function ($rResource, $sContentType, $sFileName, $sMimeIndex = '') use($self, $oAccount, $sRawKey, $sContentTypeIn, $sFileNameIn, $bDownload, $bThumbnail) {
if ($oAccount && \is_resource($rResource)) {
$sContentTypeOut = $sContentTypeIn;
if (empty($sContentTypeOut)) {
$sContentTypeOut = $sContentType;
if (empty($sContentTypeOut)) {
$sContentTypeOut = empty($sFileName) ? 'text/plain' : \MailSo\Base\Utils::MimeContentType($sFileName);
}
}
$sFileNameOut = $sFileNameIn;
if (empty($sFileNameOut)) {
$sFileNameOut = $sFileName;
}
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
$self->cacheByKey($sRawKey);
$bDone = false;
if ($bThumbnail && !$bDownload) {
\MailSo\Base\StreamWrappers\TempFile::Reg();
$sFileName = 'mailsotempfile://' . \MailSo\Base\Utils::Md5Rand($sFileNameOut);
$rTempResource = @\fopen($sFileName, 'r+b');
if (@\is_resource($rTempResource)) {
\MailSo\Base\Utils::MultipleStreamWriter($rResource, array($rTempResource));
@\fclose($rTempResource);
$oThumb = @new \PHPThumb\GD($sFileName);
if ($oThumb) {
$oThumb->adaptiveResize(60, 60)->show();
$bDone = true;
}
}
}
if (!$bDone) {
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: ' . ($bDownload ? 'attachment' : 'inline') . '; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
}
}
}, $sFolder, $iUid, true, $sMimeIndex);
}