Small fixes

This commit is contained in:
RainLoop Team 2015-07-23 21:57:46 +04:00
parent fc10f20770
commit 3849fd02b4
9 changed files with 113 additions and 29 deletions

View file

@ -43,14 +43,16 @@ class TempFile
/**
* @param string $sHash
* @param string $sFileName
*
* @return resource|bool
*/
public static function CreateStream($sHash)
public static function CreateStream($sHash, &$sFileName = '')
{
self::Reg();
return fopen(self::STREAM_NAME.'://'.$sHash, 'r+b');
$sFileName = self::STREAM_NAME.'://'.$sHash;
return fopen($sFileName, 'r+b');
}
/**
@ -72,6 +74,7 @@ class TempFile
is_resource(self::$aStreams[$sHashName]))
{
$this->rSream = self::$aStreams[$sHashName];
\fseek($this->rSream, 0);
$bResult = true;
}
else
@ -93,7 +96,7 @@ class TempFile
*/
public function stream_close()
{
return -1 !== fseek($this->rSream, 0);
return true;
}
/**

View file

@ -2448,6 +2448,38 @@ END;
return ('' === $sUser ? '' : $sUser.'@').$sDomain;
}
/**
* @param string $sHash
* @param string $sSalt
*
* @return int
*/
public static function HashToId($sHash, $sSalt = '')
{
$sData = $sHash ? @\MailSo\Base\Crypt::XxteaDecrypt(\hex2bin($sHash), \md5($sSalt)) : null;
$aMatch = array();
if ($sData && preg_match('/^id:(\d+)$/', $sData, $aMatch) && isset($aMatch[1]))
{
return is_numeric($aMatch[1]) ? (int) $aMatch[1] : null;
}
return null;
}
/**
* @param int $iID
* @param string $sSalt
*
* @return string
*/
public static function IdToHash($iID, $sSalt = '')
{
return is_int($iID) ?
\bin2hex(\MailSo\Base\Crypt::XxteaEncrypt('id:'.$iID, \md5($sSalt))) : null
;
}
/**
* @param string $sPassword
*

View file

@ -371,6 +371,33 @@ class Logger extends \MailSo\Base\Collection
return false;
}
/**
* @param \Exception $oException
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
* @param string $sName = ''
* @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
public function WriteExceptionShort($oException, $iType = \MailSo\Log\Enumerations\Type::NOTICE, $sName = '',
$bSearchSecretWords = true, $bDiplayCrLf = false)
{
if ($oException instanceof \Exception)
{
if (isset($oException->__LOGINNED__))
{
return true;
}
$oException->__LOGINNED__ = true;
return $this->Write($oException->getMessage(), $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
}
return false;
}
/**
* @param mixed $mData
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE