mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
FIX: dol_delete_file must work in a context without db handler loaded
Conflicts: htdocs/core/lib/files.lib.php
This commit is contained in:
parent
7eaa2011ba
commit
4c21ad4e4e
|
|
@ -1031,7 +1031,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
|
|||
if (preg_match('/\.\./',$file) || preg_match('/[<>|]/',$file))
|
||||
{
|
||||
dol_syslog("Refused to delete file ".$file, LOG_WARNING);
|
||||
return False;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($nohook))
|
||||
|
|
@ -1080,18 +1080,21 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
|
|||
{
|
||||
$rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
|
||||
|
||||
dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$result = $ecmfile->fetch(0, '', $rel_filetodelete);
|
||||
if ($result >= 0 && $ecmfile->id > 0)
|
||||
{
|
||||
$result = $ecmfile->delete($user);
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
if (is_object($db)) // $db may not be defined when lib is in a context with define('NOREQUIREDB',1)
|
||||
{
|
||||
dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$result = $ecmfile->fetch(0, '', $rel_filetodelete);
|
||||
if ($result >= 0 && $ecmfile->id > 0)
|
||||
{
|
||||
$result = $ecmfile->delete($user);
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
|
||||
|
|
@ -1130,7 +1133,7 @@ function dol_delete_dir($dir,$nophperrors=0)
|
|||
if (preg_match('/\.\./',$dir) || preg_match('/[<>|]/',$dir))
|
||||
{
|
||||
dol_syslog("Refused to delete dir ".$dir, LOG_WARNING);
|
||||
return False;
|
||||
return false;
|
||||
}
|
||||
|
||||
$dir_osencoded=dol_osencode($dir);
|
||||
|
|
@ -1711,7 +1714,7 @@ function dol_uncompress($inputfile,$outputdir)
|
|||
dol_syslog("Class ZipArchive is set so we unzip using ZipArchive to unzip into ".$outputdir);
|
||||
$zip = new ZipArchive;
|
||||
$res = $zip->open($inputfile);
|
||||
if ($res === TRUE)
|
||||
if ($res === true)
|
||||
{
|
||||
$zip->extractTo($outputdir.'/');
|
||||
$zip->close();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user