Clean code

This commit is contained in:
Laurent Destailleur
2024-02-02 19:50:43 +01:00
parent ff04c99542
commit 32e205b5d1
7 changed files with 58 additions and 17 deletions

View File

@@ -2060,10 +2060,15 @@ class Setup extends DolibarrApi
$file_list = array('missing' => array(), 'updated' => array());
// Local file to compare to
$xmlshortfile = dol_sanitizeFileName(GETPOST('xmlshortfile', 'alpha') ? GETPOST('xmlshortfile', 'alpha') : 'filelist-'.DOL_VERSION.(!getDolGlobalString('MAIN_FILECHECK_LOCAL_SUFFIX') ? '' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'.(!getDolGlobalString('MAIN_FILECHECK_LOCAL_EXT') ? '' : $conf->global->MAIN_FILECHECK_LOCAL_EXT));
$xmlshortfile = dol_sanitizeFileName('filelist-'.DOL_VERSION.getDolGlobalString('MAIN_FILECHECK_LOCAL_SUFFIX').'.xml'.getDolGlobalString('MAIN_FILECHECK_LOCAL_EXT'));
$xmlfile = DOL_DOCUMENT_ROOT.'/install/'.$xmlshortfile;
if (!preg_match('/\.zip$/i', $xmlfile) && dol_is_file($xmlfile.'.zip')) {
$xmlfile = $xmlfile.'.zip';
}
// Remote file to compare to
$xmlremote = ($target == 'default' ? '' : $target);
$xmlremote = (($target == 'default' || $target == 'local') ? '' : $target);
if (empty($xmlremote) && getDolGlobalString('MAIN_FILECHECK_URL')) {
$xmlremote = getDolGlobalString('MAIN_FILECHECK_URL');
}
@@ -2093,7 +2098,7 @@ class Setup extends DolibarrApi
if (dol_is_file($xmlfile)) {
$xml = simplexml_load_file($xmlfile);
} else {
throw new RestException(500, $langs->trans('XmlNotFound').': '.$xmlfile);
throw new RestException(500, $langs->trans('XmlNotFound').': /install/'.$xmlshortfile);
}
} else {
$xmlarray = getURLContent($xmlremote, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only. Same is used into filecheck.php.