mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03: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
|
private function localHandle() : self
|
||||||
{
|
{
|
||||||
$sResult = '';
|
$sResult = '';
|
||||||
$bCached = false;
|
|
||||||
|
|
||||||
$sQuery = $this->oActions->ParseQueryAuthString();
|
$sQuery = $this->oActions->ParseQueryAuthString();
|
||||||
|
|
||||||
|
|
@ -145,7 +144,7 @@ class Service
|
||||||
|
|
||||||
if ($bIndex)
|
if ($bIndex)
|
||||||
{
|
{
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
\header('Content-Type: text/html; charset=utf-8');
|
||||||
$this->oHttp->ServerNoCache();
|
$this->oHttp->ServerNoCache();
|
||||||
|
|
||||||
if (!\is_dir(APP_DATA_FOLDER_PATH) || !\is_writable(APP_DATA_FOLDER_PATH))
|
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);
|
$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['{{BaseAppThemeCss}}'] = $this->oActions->compileCss($this->oActions->GetTheme($bAdmin), $bAdmin);
|
||||||
$aTemplateParameters['{{BaseLanguage}}'] = $this->oActions->compileLanguage($sLanguage, $bAdmin);
|
$aTemplateParameters['{{BaseLanguage}}'] = $this->oActions->compileLanguage($sLanguage, $bAdmin);
|
||||||
$aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false);
|
$aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false);
|
||||||
|
|
@ -182,20 +182,8 @@ class Service
|
||||||
$this->oActions->Cacher()->Set($sCacheFileName, $sResult);
|
$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');
|
\header('X-XSS-Protection: 1; mode=block');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -576,18 +576,15 @@ class ServiceActions
|
||||||
$sResult = $this->Cacher()->Get($sCacheFileName);
|
$sResult = $this->Cacher()->Get($sCacheFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 === \strlen($sResult))
|
if (!$sResult)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$sResult = $this->oActions->compileCss($sTheme, $bAdmin);
|
$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)
|
catch (\Throwable $oException)
|
||||||
|
|
|
||||||
|
|
@ -161,13 +161,11 @@ class Utils
|
||||||
public static function ClearHtmlOutput(string $sHtml) : string
|
public static function ClearHtmlOutput(string $sHtml) : string
|
||||||
{
|
{
|
||||||
// return $sHtml;
|
// return $sHtml;
|
||||||
return \trim(\str_replace('> <', '><',
|
return \preg_replace(
|
||||||
\str_replace('" />', '"/>',
|
['@"\\s*/>@', '/\\s* /i', '/ \\s*/i', '/[\\r\\n\\t]+/', '/>\\s+</'],
|
||||||
\preg_replace('/[\s]+ /i', ' ',
|
['">', ' ', ' ', ' ', '><'],
|
||||||
\preg_replace('/ [\s]+/i', ' ',
|
\trim($sHtml)
|
||||||
\preg_replace('/[\r\n\t]+/', ' ',
|
);
|
||||||
$sHtml
|
|
||||||
))))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function CompileTemplates(array &$aList, string $sDirName, string $sNameSuffix = '')
|
public static function CompileTemplates(array &$aList, string $sDirName, string $sNameSuffix = '')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue