mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
Small fixes
This commit is contained in:
parent
fc10f20770
commit
3849fd02b4
9 changed files with 113 additions and 29 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue