Fix: mac os compatibility
This commit is contained in:
parent
b48f2ae1f9
commit
8cf1da4ddb
@ -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();
|
||||
?>
|
||||
@ -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++;
|
||||
}
|
||||
$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;
|
||||
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;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user