Fix: conf file corrupted when using password with special char

This commit is contained in:
Laurent Destailleur 2012-01-07 23:42:36 +01:00
parent ebf8a6eef4
commit 896cfe62ba
2 changed files with 5 additions and 4 deletions

View File

@ -427,7 +427,8 @@ print '</form>';
print '</div>'; print '</div>';
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -416,11 +416,11 @@ function encodedecode_dbpassconf($level=0)
// Add value at end of file // Add value at end of file
if ($level == 0) if ($level == 0)
{ {
$config .= '$dolibarr_main_db_pass="'.$passwd.'";'."\n"; $config .= '$dolibarr_main_db_pass=\''.$passwd.'\';'."\n";
} }
if ($level == 1) if ($level == 1)
{ {
$config .= '$dolibarr_main_db_pass="crypted:'.$passwd_crypted.'";'."\n"; $config .= '$dolibarr_main_db_pass=\'crypted:'.$passwd_crypted.'\';'."\n";
} }
//print 'passwd = '.$passwd.' - passwd_crypted = '.$passwd_crypted; //print 'passwd = '.$passwd.' - passwd_crypted = '.$passwd_crypted;
@ -437,7 +437,7 @@ function encodedecode_dbpassconf($level=0)
$file=DOL_DOCUMENT_ROOT.'/conf/conf.php'; $file=DOL_DOCUMENT_ROOT.'/conf/conf.php';
if ($fp = @fopen($file,'w')) if ($fp = @fopen($file,'w'))
{ {
fputs($fp, $config, dol_strlen($config)); fputs($fp, $config);
fclose($fp); fclose($fp);
// It's config file, so we set read permission for creator only. // It's config file, so we set read permission for creator only.
// Should set permission to web user and groups for users used by batch // Should set permission to web user and groups for users used by batch