N°6648 - Use \utils::GetDataPath() instead of hard-coded paths (#555)

* N°6648 - Use \utils::GetDataPath() instead of hard-coded paths

* Update setup/applicationinstaller.class.inc.php

Co-authored-by: Thomas Casteleyn <thomas.casteleyn@super-visions.com>

---------

Co-authored-by: Thomas Casteleyn <thomas.casteleyn@super-visions.com>
This commit is contained in:
Molkobain
2024-01-22 21:06:08 +01:00
committed by GitHub
parent 750dfe746e
commit e18ea88735
25 changed files with 122 additions and 122 deletions

View File

@@ -1581,7 +1581,7 @@ JS
if (is_dir($oWizard->GetParameter('copy_extensions_from'))) {
$aDirsToScan[] = $oWizard->GetParameter('copy_extensions_from');
}
$sExtraDir = APPROOT.'data/production-modules/';
$sExtraDir = utils::GetDataPath().'production-modules/';
if (is_dir($sExtraDir))
{
$aDirsToScan[] = $sExtraDir;
@@ -1935,7 +1935,7 @@ JS
if (empty($sEnv)) {
$aLicenceFiles = array_merge($aLicenceFiles, glob(APPROOT.'datamodels/*/*/license.*.xml'));
$aLicenceFiles = array_merge($aLicenceFiles, glob(APPROOT.'extensions/{*,*/*}/license.*.xml', GLOB_BRACE));
$aLicenceFiles = array_merge($aLicenceFiles, glob(APPROOT.'data/*-modules/{*,*/*}/license.*.xml', GLOB_BRACE));
$aLicenceFiles = array_merge($aLicenceFiles, glob(utils::GetDataPath().'*-modules/{*,*/*}/license.*.xml', GLOB_BRACE));
}
else
{
@@ -2067,11 +2067,11 @@ JS
if (!is_dir(APPROOT.'data')) {
mkdir(APPROOT.'data');
}
if (!is_dir(APPROOT.'data/setup')) {
mkdir(APPROOT.'data/setup');
if (!is_dir(utils::GetDataPath().'setup')) {
mkdir(utils::GetDataPath().'setup');
}
$sUID = hash('sha256', rand());
file_put_contents(APPROOT.'data/setup/authent', $sUID);
file_put_contents(utils::GetDataPath().'setup/authent', $sUID);
Session::Set('setup_token', $sUID);
return $sUID;
}
@@ -2087,7 +2087,7 @@ JS
final public static function CheckSetupToken($bRemoveToken = false)
{
$sAuthent = utils::ReadParam('authent', '', false, 'raw_data');
$sTokenFile = APPROOT.'data/setup/authent';
$sTokenFile = utils::GetDataPath().'setup/authent';
if (!file_exists($sTokenFile) || $sAuthent !== file_get_contents($sTokenFile)) {
throw new SecurityException('Setup operations are not allowed outside of the setup');
}
@@ -2106,7 +2106,7 @@ JS
{
if (Session::IsSet('setup_token')) {
$sAuth = Session::Get('setup_token');
$sTokenFile = APPROOT.'data/setup/authent';
$sTokenFile = utils::GetDataPath().'setup/authent';
if (file_exists($sTokenFile) && $sAuth === file_get_contents($sTokenFile)) {
return true;
}
@@ -2120,7 +2120,7 @@ JS
*/
public static function EraseSetupToken()
{
$sTokenFile = APPROOT.'data/setup/authent';
$sTokenFile = utils::GetDataPath().'setup/authent';
if (is_file($sTokenFile)) {
unlink($sTokenFile);
}