mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
New Message View (with attachments thumbnails)
This commit is contained in:
parent
1c7f1928c7
commit
06e6f1a2da
22 changed files with 3046 additions and 162 deletions
|
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of MailSo.
|
||||
*
|
||||
* (c) 2014 Usenko Timur
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace MailSo\Base\StreamWrappers;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Base
|
||||
* @subpackage StreamWrappers
|
||||
*/
|
||||
class TempFile
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const STREAM_NAME = 'mailsotempfile';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $aStreams = array();
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $rSream;
|
||||
|
||||
public static function Reg()
|
||||
{
|
||||
if (!in_array(self::STREAM_NAME, stream_get_wrappers()))
|
||||
{
|
||||
stream_wrapper_register(self::STREAM_NAME, '\MailSo\Base\StreamWrappers\TempFile');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHash
|
||||
*
|
||||
* @return resource|bool
|
||||
*/
|
||||
public static function CreateStream($sHash)
|
||||
{
|
||||
self::Reg();
|
||||
|
||||
return fopen(self::STREAM_NAME.'://'.$sHash, 'r+b');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPath
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_open($sPath)
|
||||
{
|
||||
$bResult = false;
|
||||
$aPath = parse_url($sPath);
|
||||
|
||||
if (isset($aPath['host']) && isset($aPath['scheme']) &&
|
||||
0 < strlen($aPath['host']) && 0 < strlen($aPath['scheme']) &&
|
||||
self::STREAM_NAME === $aPath['scheme'])
|
||||
{
|
||||
$sHashName = $aPath['host'];
|
||||
if (isset(self::$aStreams[$sHashName]) &&
|
||||
is_resource(self::$aStreams[$sHashName]))
|
||||
{
|
||||
$this->rSream = self::$aStreams[$sHashName];
|
||||
$bResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->rSream = fopen('php://memory', 'r+b');
|
||||
self::$aStreams[$sHashName] = $this->rSream;
|
||||
|
||||
$bResult = true;
|
||||
|
||||
\MailSo\Base\Loader::IncStatistic('CreateStream/TempFile');
|
||||
}
|
||||
}
|
||||
|
||||
return $bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_close()
|
||||
{
|
||||
return -1 !== fseek($this->rSream, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_flush()
|
||||
{
|
||||
return fflush($this->rSream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iLen
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function stream_read($iLen)
|
||||
{
|
||||
return fread($this->rSream, $iLen);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sInputString
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function stream_write($sInputString)
|
||||
{
|
||||
return fwrite($this->rSream, $sInputString);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function stream_tell()
|
||||
{
|
||||
return ftell($this->rSream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function stream_eof()
|
||||
{
|
||||
return feof($this->rSream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function stream_stat()
|
||||
{
|
||||
return fstat($this->rSream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iOffset
|
||||
* @param int $iWhence = SEEK_SET
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function stream_seek($iOffset, $iWhence = SEEK_SET)
|
||||
{
|
||||
return fseek($this->rSream, $iOffset, $iWhence);
|
||||
}
|
||||
}
|
||||
|
|
@ -1215,7 +1215,7 @@ class Utils
|
|||
*/
|
||||
public static function ClearFileName($sFileName)
|
||||
{
|
||||
return \MailSo\Base\Utils::ClearNullBite(\preg_replace('/[\s]+/', ' ',
|
||||
return \MailSo\Base\Utils::ClearNullBite(\preg_replace('/[\s]+/u', ' ',
|
||||
\str_replace(array('"', '/', '\\', '*', '?', '<', '>', '|', ':'), ' ', $sFileName)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue