mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
Uploading and preparing the repository to the dev version.
Original unminified source code (dev folder - js, css, less) (fixes #6) Grunt build system Multiple identities correction (fixes #9) Compose html editor (fixes #12) New general settings - Loading Description New warning about default admin password Split general and login screen settings
This commit is contained in:
parent
afad45137e
commit
4cc2207513
846 changed files with 99453 additions and 2123 deletions
116
rainloop/v/0.0.0/app/libraries/MailSo/Base/ResourceRegistry.php
Normal file
116
rainloop/v/0.0.0/app/libraries/MailSo/Base/ResourceRegistry.php
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Base;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Base
|
||||
*/
|
||||
class ResourceRegistry
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $Resources = array();
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @staticvar bool $bInited
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function regResourcesShutdownFunc()
|
||||
{
|
||||
static $bInited = false;
|
||||
if (!$bInited)
|
||||
{
|
||||
$bInited = true;
|
||||
\register_shutdown_function(function () {
|
||||
if (\is_array(\MailSo\Base\ResourceRegistry::$Resources))
|
||||
{
|
||||
foreach (\array_keys(\MailSo\Base\ResourceRegistry::$Resources) as $sKey)
|
||||
{
|
||||
if (\is_resource(\MailSo\Base\ResourceRegistry::$Resources[$sKey]))
|
||||
{
|
||||
\MailSo\Base\Loader::IncStatistic('CloseMemoryResource');
|
||||
\fclose(\MailSo\Base\ResourceRegistry::$Resources[$sKey]);
|
||||
}
|
||||
\MailSo\Base\ResourceRegistry::$Resources[$sKey] = null;
|
||||
}
|
||||
}
|
||||
|
||||
\MailSo\Base\ResourceRegistry::$Resources = array();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iMemoryMaxInMb = 5
|
||||
*
|
||||
* @return resource | bool
|
||||
*/
|
||||
public static function CreateMemoryResource($iMemoryMaxInMb = 5)
|
||||
{
|
||||
self::regResourcesShutdownFunc();
|
||||
|
||||
$oResult = @\fopen('php://temp/maxmemory:'.($iMemoryMaxInMb * 1024 * 1024), 'r+b');
|
||||
if (\is_resource($oResult))
|
||||
{
|
||||
\MailSo\Base\Loader::IncStatistic('CreateMemoryResource');
|
||||
\MailSo\Base\ResourceRegistry::$Resources[(string) $oResult] = $oResult;
|
||||
return $oResult;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sString
|
||||
*
|
||||
* @return resource | bool
|
||||
*/
|
||||
public static function CreateMemoryResourceFromString($sString)
|
||||
{
|
||||
$oResult = self::CreateMemoryResource();
|
||||
if (\is_resource($oResult))
|
||||
{
|
||||
\fwrite($oResult, $sString);
|
||||
\rewind($oResult);
|
||||
}
|
||||
|
||||
return $oResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $rResource
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function CloseMemoryResource(&$rResource)
|
||||
{
|
||||
if (\is_resource($rResource))
|
||||
{
|
||||
$sKey = (string) $rResource;
|
||||
if (isset(\MailSo\Base\ResourceRegistry::$Resources[$sKey]))
|
||||
{
|
||||
\fclose(\MailSo\Base\ResourceRegistry::$Resources[$sKey]);
|
||||
\MailSo\Base\ResourceRegistry::$Resources[$sKey] = null;
|
||||
unset(\MailSo\Base\ResourceRegistry::$Resources[$sKey]);
|
||||
\MailSo\Base\Loader::IncStatistic('CloseMemoryResource');
|
||||
}
|
||||
|
||||
if (\is_resource($rResource))
|
||||
{
|
||||
\fclose($rResource);
|
||||
}
|
||||
|
||||
$rResource = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue