mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-06 14:58:19 +08:00
Cleanup some PHP code
This commit is contained in:
parent
ce63ba506a
commit
8e5d56e15f
3 changed files with 13 additions and 30 deletions
|
@ -89,7 +89,6 @@ class Service
|
|||
private function localHandle() : self
|
||||
{
|
||||
$sResult = '';
|
||||
$bCached = false;
|
||||
|
||||
$sQuery = $this->oActions->ParseQueryAuthString();
|
||||
|
||||
|
@ -145,7 +144,7 @@ class Service
|
|||
|
||||
if ($bIndex)
|
||||
{
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
\header('Content-Type: text/html; charset=utf-8');
|
||||
$this->oHttp->ServerNoCache();
|
||||
|
||||
if (!\is_dir(APP_DATA_FOLDER_PATH) || !\is_writable(APP_DATA_FOLDER_PATH))
|
||||
|
@ -170,8 +169,9 @@ class Service
|
|||
$sResult = $this->oActions->Cacher()->Get($sCacheFileName);
|
||||
}
|
||||
|
||||
if (0 === \strlen($sResult))
|
||||
{
|
||||
if ($sResult) {
|
||||
$sResult .= '<!--cached-->';
|
||||
} else {
|
||||
$aTemplateParameters['{{BaseAppThemeCss}}'] = $this->oActions->compileCss($this->oActions->GetTheme($bAdmin), $bAdmin);
|
||||
$aTemplateParameters['{{BaseLanguage}}'] = $this->oActions->compileLanguage($sLanguage, $bAdmin);
|
||||
$aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false);
|
||||
|
@ -182,20 +182,8 @@ class Service
|
|||
$this->oActions->Cacher()->Set($sCacheFileName, $sResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bCached = true;
|
||||
}
|
||||
|
||||
$sResult .= '<!--';
|
||||
$sResult .= '[time:'.\substr(\microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], 0, 6);
|
||||
$sResult .= '][AGPLv3';
|
||||
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
||||
// $sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
// $sResult .= '][session:'.\md5(Utils::GetShortToken());
|
||||
$sResult .= ']-->';
|
||||
}
|
||||
else if (!headers_sent())
|
||||
else if (!\headers_sent())
|
||||
{
|
||||
\header('X-XSS-Protection: 1; mode=block');
|
||||
}
|
||||
|
|
|
@ -576,18 +576,15 @@ class ServiceActions
|
|||
$sResult = $this->Cacher()->Get($sCacheFileName);
|
||||
}
|
||||
|
||||
if (0 === \strlen($sResult))
|
||||
if (!$sResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
$sResult = $this->oActions->compileCss($sTheme, $bAdmin);
|
||||
|
||||
if ($bCacheEnabled)
|
||||
if ($bCacheEnabled && $sCacheFileName)
|
||||
{
|
||||
if (0 < \strlen($sCacheFileName))
|
||||
{
|
||||
$this->Cacher()->Set($sCacheFileName, $sResult);
|
||||
}
|
||||
$this->Cacher()->Set($sCacheFileName, $sResult);
|
||||
}
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
|
|
|
@ -161,13 +161,11 @@ class Utils
|
|||
public static function ClearHtmlOutput(string $sHtml) : string
|
||||
{
|
||||
// return $sHtml;
|
||||
return \trim(\str_replace('> <', '><',
|
||||
\str_replace('" />', '"/>',
|
||||
\preg_replace('/[\s]+ /i', ' ',
|
||||
\preg_replace('/ [\s]+/i', ' ',
|
||||
\preg_replace('/[\r\n\t]+/', ' ',
|
||||
$sHtml
|
||||
))))));
|
||||
return \preg_replace(
|
||||
['@"\\s*/>@', '/\\s* /i', '/ \\s*/i', '/[\\r\\n\\t]+/', '/>\\s+</'],
|
||||
['">', ' ', ' ', ' ', '><'],
|
||||
\trim($sHtml)
|
||||
);
|
||||
}
|
||||
|
||||
public static function CompileTemplates(array &$aList, string $sDirName, string $sNameSuffix = '')
|
||||
|
|
Loading…
Reference in a new issue