Fix: encrypt key don't exist in install mode

This commit is contained in:
Regis Houssin 2009-09-16 08:23:08 +00:00
parent 164c8d37a4
commit c19df2514d
2 changed files with 4 additions and 4 deletions

View File

@ -190,7 +190,7 @@ if ($_POST["action"] == "set" || eregi('upgrade',$_POST["action"]))
dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey)."='MAIN_VERSION_LAST_INSTALL'");
if (! $resql) dol_print_error($db,'Error in setup program');
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey,1).",".$db->encrypt("'".$targetversion."'",$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey,1).",'chaine',0,'Dolibarr version when install',0)");
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL',$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey,1).",".$db->encrypt($targetversion,$conf->db->dolibarr_main_db_encryption,$conf->db->dolibarr_main_db_cryptkey,1).",'chaine',0,'Dolibarr version when install',0)");
if (! $resql) dol_print_error($db,'Error in setup program');
$conf->global->MAIN_VERSION_LAST_INSTALL=$targetversion;

View File

@ -698,17 +698,17 @@ class DoliDb
*/
function encrypt($fieldorvalue, $cryptType=0, $cryptKey='', $withQuotes=0)
{
$return = $fieldorvalue;
$return = ($withQuotes?"'":"").addslashes($fieldorvalue).($withQuotes?"'":"");
if ($cryptType && !empty($cryptKey))
{
if ($cryptType == 2)
{
$return = 'AES_ENCRYPT('.($withQuotes?"'":"").addslashes($fieldorvalue).($withQuotes?"'":"").',\''.$cryptKey.'\')';
$return = 'AES_ENCRYPT('.$return.',\''.$cryptKey.'\')';
}
else if ($cryptType == 1)
{
$return = 'DES_ENCRYPT('.($withQuotes?"'":"").addslashes($fieldorvalue).($withQuotes?"'":"").',\''.$cryptKey.'\')';
$return = 'DES_ENCRYPT('.$return.',\''.$cryptKey.'\')';
}
}