This commit is contained in:
ldestailleur 2025-08-09 13:27:23 +02:00
parent 04241d4f83
commit 92a2c2a2e0

View file

@ -49,14 +49,24 @@ if (!file_exists($conffile)) {
print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
}
require_once $conffile;
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
global $langs;
/**
* @var Conf $conf
* @var Translate $langs
*
* @var string $dolibarr_main_db_type
* @var string $dolibarr_main_db_host
* @var string $dolibarr_main_db_port
* @var string $dolibarr_main_db_name
* @var string $dolibarr_main_db_user
* @var string $dolibarr_main_db_pass
* @var string $dolibarr_main_document_root
* @var string $dolibarr_main_db_encryption
* @var string $dolibarr_main_db_encrypted_pass
* @var string $dolibarr_main_db_cryptkey
*/
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
global $langs;
$grant_query = '';
$step = 2;
@ -130,15 +140,15 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$error = 0;
// If password is encoded, we decode it
if ((!empty($dolibarr_main_db_pass) && preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)) || preg_match('/dolcrypt:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
if ((!empty($dolibarr_main_db_pass) && preg_match('/(crypted|dolcrypt):/i', (string) $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
if (!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
if (!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', (string) $dolibarr_main_db_pass)) {
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', (string) $dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially encrypted
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
} elseif (preg_match('/dolcrypt:/i', $dolibarr_main_db_pass)) {
$dolibarr_main_db_pass = dol_decode((string) $dolibarr_main_db_pass);
} elseif (preg_match('/dolcrypt:/i', (string) $dolibarr_main_db_pass)) {
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially encrypted
$dolibarr_main_db_pass = dolDecrypt($dolibarr_main_db_pass);
$dolibarr_main_db_pass = dolDecrypt((string) $dolibarr_main_db_pass);
} else {
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}