N°3952 - code hardening (merged from support/2.6)

This commit is contained in:
Eric
2021-05-27 09:55:16 +02:00
5 changed files with 54 additions and 21 deletions

View File

@@ -2019,6 +2019,7 @@ JS
}
$sUID = hash('sha256', rand());
file_put_contents(APPROOT.'data/setup/authent', $sUID);
$_SESSION['setup_token'] = $sUID;
return $sUID;
}
@@ -2043,6 +2044,33 @@ JS
}
}
/**
* Check setup transaction and create a new one if necessary
*
* @return bool
*/
public static function IsSessionSetupTokenValid()
{
if (isset($_SESSION['setup_token'])) {
$sAuth = $_SESSION['setup_token'];
$sTokenFile = APPROOT.'data/setup/authent';
if (file_exists($sTokenFile) && $sAuth === file_get_contents($sTokenFile)) {
return true;
}
}
return false;
}
public static function EraseSetupToken()
{
$sTokenFile = APPROOT.'data/setup/authent';
if (is_file($sTokenFile)) {
unlink($sTokenFile);
}
unset($_SESSION['setup_token']);
}
private final static function Log($sText)
{
if (class_exists('SetupPage'))