diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index 5658728c6a07004a2b03130a87feef7b7c5eb6d3..233bf9be7fdba7c5d938c37f8a9bff36977a1e51 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -75,20 +75,33 @@ if (GETPOST('action','alpha')=='install') $result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'],$newfile,1,0,$_FILES['fileinstall']['error']); if ($result > 0) { - $rutax=DOL_DOCUMENT_ROOT_ALT; - $result=dol_uncompress($newfile,$_FILES['fileinstall']['type'],$rutax); - if ($result==2) + $documentrootalt=DOL_DOCUMENT_ROOT_ALT; + $result=dol_uncompress($newfile,$_FILES['fileinstall']['type'],$documentrootalt); + if (! empty($result['error'])) { - $langs->load("errors"); - $mesg = "<font class=\"error\">".$langs->trans("ErrorOSSystem")."</font>"; + if ($result['error'] == -1) + { + $langs->load("errors"); + $mesg = '<div class="error">'.$langs->trans("ErrorBadFileFormat").'</div>'; + } + elseif ($result['error'] == -2) + { + $langs->load("errors"); + $mesg = '<div class="error">'.$langs->trans("ErrorOSSystem").'</div>'; + } + elseif ($result['error'] == -3) + { + $langs->load("errors"); + $mesg = '<div class="warning">'.$langs->trans("ErrorUncompFile",$_FILES['fileinstall']['name']).'</div>'; + } + elseif ($result['error'] == -4) + { + $langs->load("errors"); + $mesg = '<div class="error">'.$langs->trans("ErrorUncompFile",$_FILES['fileinstall']['name']).'</div>'; + } } - elseif ($result==3) + else { - $langs->load("errors"); - $mesg = "<font class=\"error\">".$langs->trans("ErrorUncompFile",$_FILES['fileinstall']['name'])."</font>"; - } - - else { $mesg = "<font class=\"ok\">".$langs->trans("SetupIsReadyForUse")."</font>"; } } @@ -146,7 +159,7 @@ print '<b>'.$langs->trans("StepNb",3).'</b>: '; print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).'<br>'; if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE)) { - if ($vale == 1 && $dirins != 'DOL_DOCUMENT_ROOT_ALT' && ($system=="Linux")) + if ($vale == 1 && $dirins != 'DOL_DOCUMENT_ROOT_ALT' && ($system=="Linux" || $system=="Darwin")) { print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">'; print '<input type="hidden" name="action" value="install">'; @@ -173,6 +186,16 @@ else } print '</form>'; +if (! empty($result['return'])) +{ + print '<br>'; + + foreach($result['return'] as $value) + { + echo $value.'<br>'; + } +} + llxFooter(); $db->close(); ?> \ No newline at end of file diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 40897263a4ff9fc20eeccab49817429899a55a60..85cd1c1eb7e7f1b4918a597e21b5d49e7c3027e4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -629,14 +629,16 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable function dol_uncompress($newfile,$typefile,$dstdir) { global $conf; - $error=0; + + $error=0; + $output=array(); $system=PHP_OS; //TODO: See best method for this - if ($system=="Linux") + if ($system=="Linux" || $system=="Darwin") { - if ($typefile == 'application/x-gzip') + if ($typefile == 'application/x-gzip' || $typefile == 'application/x-gtar') { $prog= "tar -xzvf "; } @@ -646,22 +648,33 @@ function dol_uncompress($newfile,$typefile,$dstdir) } else { - $error=1; + $output['error'] = -1; + $error++; } } else { - $error=2; + $output['error'] = -2; + $error++; + } + + if (! $error) + { + $original_file=basename($_FILES["fileinstall"]["name"]); + $dir=$conf->admin->dir_temp.'/'.$original_file; + $file=$dir.'/'.$original_file; + $command= $prog.$file.' 2>&1'; + + chdir($dstdir); + + exec($command, $out, $return_var); + if ($return_var == 1) $output['error'] = -3; // OK with Warning + elseif ($return_var == 127) $output['error'] = -4; // KO + + $output['return'] = $out; } - $original_file=basename($_FILES["fileinstall"]["name"]); - $diruncom=$conf->admin->dir_temp.'/'.$original_file; - $ruta=$diruncom.'/'.$original_file; - chdir ($dstdir); - $command= $prog.$ruta; - $res=exec($command); - if (! $res) $error=3; - return $error; + return $output; } /**