Skip to content
Snippets Groups Projects
Commit 8cf1da4d authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: mac os compatibility

parent b48f2ae1
No related branches found
No related tags found
No related merge requests found
...@@ -75,20 +75,33 @@ if (GETPOST('action','alpha')=='install') ...@@ -75,20 +75,33 @@ if (GETPOST('action','alpha')=='install')
$result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'],$newfile,1,0,$_FILES['fileinstall']['error']); $result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'],$newfile,1,0,$_FILES['fileinstall']['error']);
if ($result > 0) if ($result > 0)
{ {
$rutax=DOL_DOCUMENT_ROOT_ALT; $documentrootalt=DOL_DOCUMENT_ROOT_ALT;
$result=dol_uncompress($newfile,$_FILES['fileinstall']['type'],$rutax); $result=dol_uncompress($newfile,$_FILES['fileinstall']['type'],$documentrootalt);
if ($result==2) if (! empty($result['error']))
{
if ($result['error'] == -1)
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = "<font class=\"error\">".$langs->trans("ErrorOSSystem")."</font>"; $mesg = '<div class="error">'.$langs->trans("ErrorBadFileFormat").'</div>';
} }
elseif ($result==3) elseif ($result['error'] == -2)
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = "<font class=\"error\">".$langs->trans("ErrorUncompFile",$_FILES['fileinstall']['name'])."</font>"; $mesg = '<div class="error">'.$langs->trans("ErrorOSSystem").'</div>';
} }
elseif ($result['error'] == -3)
else { {
$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>';
}
}
else
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupIsReadyForUse")."</font>"; $mesg = "<font class=\"ok\">".$langs->trans("SetupIsReadyForUse")."</font>";
} }
} }
...@@ -146,7 +159,7 @@ print '<b>'.$langs->trans("StepNb",3).'</b>: '; ...@@ -146,7 +159,7 @@ print '<b>'.$langs->trans("StepNb",3).'</b>: ';
print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).'<br>'; print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).'<br>';
if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE)) 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 '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
print '<input type="hidden" name="action" value="install">'; print '<input type="hidden" name="action" value="install">';
...@@ -173,6 +186,16 @@ else ...@@ -173,6 +186,16 @@ else
} }
print '</form>'; print '</form>';
if (! empty($result['return']))
{
print '<br>';
foreach($result['return'] as $value)
{
echo $value.'<br>';
}
}
llxFooter(); llxFooter();
$db->close(); $db->close();
?> ?>
\ No newline at end of file
...@@ -629,14 +629,16 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable ...@@ -629,14 +629,16 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
function dol_uncompress($newfile,$typefile,$dstdir) function dol_uncompress($newfile,$typefile,$dstdir)
{ {
global $conf; global $conf;
$error=0; $error=0;
$output=array();
$system=PHP_OS; $system=PHP_OS;
//TODO: See best method for this //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 "; $prog= "tar -xzvf ";
} }
...@@ -646,22 +648,33 @@ function dol_uncompress($newfile,$typefile,$dstdir) ...@@ -646,22 +648,33 @@ function dol_uncompress($newfile,$typefile,$dstdir)
} }
else else
{ {
$error=1; $output['error'] = -1;
$error++;
} }
} }
else else
{ {
$error=2; $output['error'] = -2;
$error++;
} }
if (! $error)
{
$original_file=basename($_FILES["fileinstall"]["name"]); $original_file=basename($_FILES["fileinstall"]["name"]);
$diruncom=$conf->admin->dir_temp.'/'.$original_file; $dir=$conf->admin->dir_temp.'/'.$original_file;
$ruta=$diruncom.'/'.$original_file; $file=$dir.'/'.$original_file;
$command= $prog.$file.' 2>&1';
chdir($dstdir); chdir($dstdir);
$command= $prog.$ruta;
$res=exec($command);
if (! $res) $error=3;
return $error; 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;
}
return $output;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment