NEW : dol_uncompress new extensions
This commit is contained in:
parent
e96061dd18
commit
57ed890b73
@ -2083,8 +2083,12 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring
|
|||||||
*/
|
*/
|
||||||
function dol_uncompress($inputfile, $outputdir)
|
function dol_uncompress($inputfile, $outputdir)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs, $db;
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT."/core/class/utils.class.php";
|
||||||
|
$utils = new Utils($db);
|
||||||
|
$fileinfo = pathinfo($inputfile);
|
||||||
|
if ($fileinfo["extension"] == "zip") {
|
||||||
if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS)) {
|
if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS)) {
|
||||||
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
|
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
|
||||||
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
|
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
|
||||||
@ -2142,6 +2146,34 @@ function dol_uncompress($inputfile, $outputdir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return array('error'=>'ErrNoZipEngine');
|
return array('error'=>'ErrNoZipEngine');
|
||||||
|
} elseif ($fileinfo["extension"] == "gz" || $fileinfo["extension"] == "bz2") {
|
||||||
|
$extension = pathinfo($fileinfo["filename"], PATHINFO_EXTENSION);
|
||||||
|
if ($extension == "tar") {
|
||||||
|
$cmd = "tar -C ".$outputdir." -xvf ".$fileinfo["dirname"]."/".$fileinfo["basename"];
|
||||||
|
$resarray = $utils->executeCLI($cmd, $outputdir);
|
||||||
|
} else {
|
||||||
|
$program = "";
|
||||||
|
if ($fileinfo["extension"] == "gz") {
|
||||||
|
$program = "gzip";
|
||||||
|
} elseif ($fileinfo["extension"] == "bz2") {
|
||||||
|
$program = "bzip2";
|
||||||
|
} else {
|
||||||
|
return array('error'=>'ErrFileExtension');
|
||||||
|
}
|
||||||
|
$cmd = $program." -dc ".$fileinfo["dirname"]."/".$fileinfo["basename"];
|
||||||
|
$outputfilename = $outputdir."/".$fileinfo["filename"];
|
||||||
|
$resarray = $utils->executeCLI($cmd, $outputfilename, 0, $outputfilename);
|
||||||
|
if ($resarray["output"] == 2) {
|
||||||
|
$resarray["error"] = "ErrFilePermOrFileNotFound";
|
||||||
|
}
|
||||||
|
if ($resarray["output"] == 1) {
|
||||||
|
$resarray["error"] = "Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $resarray["output"] != 0 ? $resarray["error"] : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array('error'=>'ErrFileExtension');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user