mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 00:14:50 +03:00
Add hash saver for future security improvements.
This commit is contained in:
parent
8dbf099934
commit
6f258f2c60
2 changed files with 30 additions and 2 deletions
|
|
@ -1631,15 +1631,19 @@ class Actions
|
|||
*/
|
||||
public function DoAppDelayStart()
|
||||
{
|
||||
$this->Plugins()->RunHook('service.app-delay-start-begin');
|
||||
|
||||
\RainLoop\Utils::UpdateConnectionToken();
|
||||
|
||||
$bMainCache = false;
|
||||
$bFilesCache = false;
|
||||
$bActivity = false;
|
||||
$bPing = false;
|
||||
$bReHash = false;
|
||||
|
||||
$iOneDay1 = 60 * 60 * 23;
|
||||
$iOneDay2 = 60 * 60 * 25;
|
||||
$iOneDay3 = $iOneDay2 * 2;
|
||||
|
||||
$sTimers = $this->StorageProvider()->Get(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'Cache/Timers', '');
|
||||
|
|
@ -1650,6 +1654,7 @@ class Actions
|
|||
$iFilesCacheTime = !empty($aTimers[1]) && \is_numeric($aTimers[1]) ? (int) $aTimers[1] : 0;
|
||||
$iActivityTime = !empty($aTimers[2]) && \is_numeric($aTimers[2]) ? (int) $aTimers[2] : 0;
|
||||
$iPingTime = !empty($aTimers[3]) && \is_numeric($aTimers[3]) ? (int) $aTimers[3] : 0;
|
||||
$iReHashTime = !empty($aTimers[4]) && \is_numeric($aTimers[4]) ? (int) $aTimers[4] : 0;
|
||||
|
||||
if (0 === $iMainCacheTime || $iMainCacheTime + $iOneDay1 < \time())
|
||||
{
|
||||
|
|
@ -1675,13 +1680,19 @@ class Actions
|
|||
$iPingTime = \time();
|
||||
}
|
||||
|
||||
if ($bMainCache || $bFilesCache || $bActivity || $bPing)
|
||||
if (0 === $iReHashTime || $iReHashTime + $iOneDay3 < \time())
|
||||
{
|
||||
$bReHash = true;
|
||||
$iReHashTime = \time();
|
||||
}
|
||||
|
||||
if ($bMainCache || $bFilesCache || $bActivity || $bPing || $bReHash)
|
||||
{
|
||||
if (!$this->StorageProvider()->Put(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'Cache/Timers',
|
||||
\implode(',', array($iMainCacheTime, $iFilesCacheTime, $iActivityTime, $iPingTime))))
|
||||
{
|
||||
$bMainCache = $bFilesCache = $bActivity = $bPing = false;
|
||||
$bMainCache = $bFilesCache = $bActivity = $bPing = $bReHash = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1711,6 +1722,15 @@ class Actions
|
|||
$this->KeenIO('Ping');
|
||||
}
|
||||
|
||||
if ($bReHash)
|
||||
{
|
||||
$sHash = \RainLoop\Utils::PathMD5(APP_VERSION_ROOT_PATH);
|
||||
$this->Logger()->Write('App Hash: '.$sHash);
|
||||
@\file_put_contents(APP_DATA_FOLDER_PATH.'HASH', $sHash);
|
||||
}
|
||||
|
||||
$this->Plugins()->RunHook('service.app-delay-start-end');
|
||||
|
||||
return $this->TrueResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
|
@ -5175,6 +5195,7 @@ class Actions
|
|||
private function setupInformation()
|
||||
{
|
||||
$aResult = array(
|
||||
'hash' => \file_exists(APP_DATA_FOLDER_PATH.'HASH') ? @\file_get_contents(APP_DATA_FOLDER_PATH.'HASH') : '',
|
||||
'version-full' => APP_VERSION,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -178,11 +178,18 @@ class Service
|
|||
$bCached = true;
|
||||
}
|
||||
|
||||
$sAppHash = '';
|
||||
if (\file_exists(APP_DATA_FOLDER_PATH.'HASH'))
|
||||
{
|
||||
$sAppHash = @\file_get_contents(APP_DATA_FOLDER_PATH.'HASH');
|
||||
}
|
||||
|
||||
$sResult .= '<!--';
|
||||
$sResult .= ' [version:'.APP_VERSION;
|
||||
$sResult .= '][time:'.substr(\microtime(true) - APP_START, 0, 6);
|
||||
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
||||
$sResult .= '][session:'.md5(\RainLoop\Utils::GetShortToken());
|
||||
$sResult .= '][hash:'.$sAppHash;
|
||||
$sResult .= '] -->';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue