From ec252a5df4a2d17626c57368af644325b3162d0f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 7 Oct 2008 19:08:44 +0000 Subject: [PATCH] BUG Backup restore for windows --- html/admin/setup.php | 4 ++-- html/backup.php | 4 ++-- include/config_file.php | 21 +++++++++++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/html/admin/setup.php b/html/admin/setup.php index a3d5314d6..8fabcc292 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -64,14 +64,14 @@ if ( strpos($inc_path,";") != 0 ) { $os=0; /* $os is 0 for unix */ } else { $new_path=$inc_path.':../../include:addon'; - $os=1; /* $os is 0 for windos */ + $os=1; /* $os is 1 for windos */ } set_include_path($new_path); require_once('config_file.php'); /* The config file is created here */ if (isset($_POST['save_config'])) { - $url=config_file_create($_POST); + $url=config_file_create($_POST,1,$os); } diff --git a/html/backup.php b/html/backup.php index 8fec18056..0e887e337 100644 --- a/html/backup.php +++ b/html/backup.php @@ -39,9 +39,9 @@ if ($User->admin != 1) { * \brief Make and restore backup */ /* For windows we need to set the path correctly */ -if ( isset(PG_PATH)) { +if ( defined ('PG_PATH') ) putenv("PATH=",PG_PATH); -} + if ( isset ($_REQUEST['sa']) ) { if ( ! isset ($_REQUEST['d']) || ! isset($_REQUEST['t'])) diff --git a/include/config_file.php b/include/config_file.php index 68812db9e..fcdbd65cd 100644 --- a/include/config_file.php +++ b/include/config_file.php @@ -88,7 +88,7 @@ function config_file_form($p_array=null) *\see *\todo */ -function config_file_create($p_array,$from_setup=1) { +function config_file_create($p_array,$from_setup=1,$os=0) { extract ($p_array); $add=($from_setup==1)?'..'.DIRECTORY_SEPARATOR:''; $hFile= fopen($add.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php','w'); @@ -100,11 +100,20 @@ function config_file_create($p_array,$from_setup=1) { fputs($hFile,"\n\r"); fputs($hFile, 'define("PG_PATH","'.$cpath'");'); fputs($hFile,"\n\r"); - fputs($hFile, 'define("PG_RESTORE","'.$cpath.DIRECTORY_SEPARATOR.'pg_restore ");'); - fputs($hFile,"\n\r"); - fputs($hFile, 'define("PG_DUMP","'.$cpath.DIRECTORY_SEPARATOR.'pg_dump ");'); - fputs($hFile,"\n\r"); - fputs($hFile, 'define ("PSQL","'.$cpath.DIRECTORY_SEPARATOR.'psql");'); + if ( $os == 0 ) { + fputs($hFile, 'define("PG_RESTORE","'.$cpath.DIRECTORY_SEPARATOR.'pg_restore ");'); + fputs($hFile,"\n\r"); + fputs($hFile, 'define("PG_DUMP","'.$cpath.DIRECTORY_SEPARATOR.'pg_dump ");'); + fputs($hFile,"\n\r"); + fputs($hFile, 'define ("PSQL","'.$cpath.DIRECTORY_SEPARATOR.'psql");'); + } + else { + fputs($hFile, 'define("PG_RESTORE","pg_restore.exe");'); + fputs($hFile,"\n\r"); + fputs($hFile, 'define("PG_DUMP","pg_dump.exe");'); + fputs($hFile,"\n\r"); + fputs($hFile, 'define ("PSQL","psql.exe");'); + } fputs($hFile,"\n\r"); fputs($hFile, 'define ("phpcompta_user","'.$cuser.'");'); fputs($hFile,"\n\r");