This commit is contained in:
Anthony Berton 2022-07-29 11:14:28 +02:00
parent cb59edb58b
commit 8e7fa102b8
4 changed files with 8 additions and 14 deletions

View File

@ -185,7 +185,6 @@ function dol_ftp_delete($connect_id, $file, $newsection)
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
return ssh2_sftp_unlink($connect_id, $newremotefileiso); return ssh2_sftp_unlink($connect_id, $newremotefileiso);
} else { } else {
var_dump($newremotefileiso);
return @ftp_delete($connect_id, $newremotefileiso); return @ftp_delete($connect_id, $newremotefileiso);
} }
} }
@ -242,8 +241,8 @@ function dol_ftp_rmdir($connect_id, $file, $newsection)
$newremotefileiso = utf8_decode($remotefile); $newremotefileiso = utf8_decode($remotefile);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$result = ssh2_sftp_rmdir($connect_id, $newremotefileiso); return ssh2_sftp_rmdir($connect_id, $newremotefileiso);
} else { } else {
$result = @ftp_rmdir($connect_id, $newremotefileiso); return @ftp_rmdir($connect_id, $newremotefileiso);
} }
} }

View File

@ -188,17 +188,15 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang
if ($conn_id && $ok && !$mesg) { if ($conn_id && $ok && !$mesg) {
foreach (GETPOST('const', 'array') as $const) { foreach (GETPOST('const', 'array') as $const) {
var_dump($const);
if (isset($const["check"])) { // Is checkbox checked if (isset($const["check"])) { // Is checkbox checked
$langs->load("other"); $langs->load("other");
// Remote file // Remote file
$file = $const["file"]; $file = $const["file"];
$newsection = $const["section"]; $newsection = $const["section"];
$newsection = $section;
$result = dol_ftp_delete($conn_id, $file, $newsection); $result = dol_ftp_delete($conn_id, $file, $newsection);
var_dump($newsection);
if ($result) { if ($result) {
setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs'); setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
} else { } else {
@ -230,7 +228,7 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes') {
if ($conn_id && $ok && !$mesg) { if ($conn_id && $ok && !$mesg) {
$newsection = $section; $newsection = $section;
$result = dol_ftp_rmdir($connect_id, $file, $newsection); $result = dol_ftp_rmdir($conn_id, $file, $newsection);
if ($result) { if ($result) {
setEventMessages($langs->trans("DirWasRemoved", $file), null, 'mesgs'); setEventMessages($langs->trans("DirWasRemoved", $file), null, 'mesgs');
@ -361,12 +359,12 @@ if (!function_exists('ftp_connect')) {
if (!empty($ftp_server)) { if (!empty($ftp_server)) {
// Confirm remove file // Confirm remove file
if ($action == 'delete') { if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', GETPOST('file')), 'confirm_deletefile', '', '', 1);
} }
// Confirmation de la suppression d'une ligne categorie // Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_section') { if ($action == 'delete_section') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', GETPOST('file')), 'confirm_deletesection', '', '', 1);
} }
print $langs->trans("Server").': <b>'.$ftp_server.'</b><br>'; print $langs->trans("Server").': <b>'.$ftp_server.'</b><br>';
@ -456,8 +454,6 @@ if (!function_exists('ftp_connect')) {
} else { } else {
$buff = ftp_rawlist($conn_id, $newsectioniso); $buff = ftp_rawlist($conn_id, $newsectioniso);
$contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist
//var_dump($contents);
//var_dump($buff);
} }
$nboflines = count($contents); $nboflines = count($contents);
@ -467,7 +463,6 @@ if (!function_exists('ftp_connect')) {
while ($i < $nboflines && $i < 1000) { while ($i < $nboflines && $i < 1000) {
$vals = preg_split('@ +@', utf8_encode($buff[$i]), 9); $vals = preg_split('@ +@', utf8_encode($buff[$i]), 9);
//$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9); //$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9);
//var_dump($vals);
$file = $vals[8]; $file = $vals[8];
if (empty($file)) { if (empty($file)) {
$rawlisthasfailed = true; $rawlisthasfailed = true;

View File

@ -444,7 +444,7 @@ AddAddress=Add address
SupplierCategory=Vendor category SupplierCategory=Vendor category
JuridicalStatus200=Independent JuridicalStatus200=Independent
DeleteFile=Delete file DeleteFile=Delete file
ConfirmDeleteFile=Are you sure you want to delete this file? ConfirmDeleteFile=Are you sure you want to delete this file <b>%s</b>?
AllocateCommercial=Assigned to sales representative AllocateCommercial=Assigned to sales representative
Organization=Organization Organization=Organization
FiscalYearInformation=Fiscal Year FiscalYearInformation=Fiscal Year

View File

@ -443,7 +443,7 @@ AddAddress=Créer adresse
SupplierCategory=Catégorie du fournisseur SupplierCategory=Catégorie du fournisseur
JuridicalStatus200=Indépendant JuridicalStatus200=Indépendant
DeleteFile=Suppression d'un fichier DeleteFile=Suppression d'un fichier
ConfirmDeleteFile=Êtes-vous sûr de vouloir supprimer ce fichier ? ConfirmDeleteFile=Êtes-vous sûr de vouloir supprimer ce fichier <b>%s</b>?
AllocateCommercial=Affecter un commercial AllocateCommercial=Affecter un commercial
Organization=Organisme Organization=Organisme
FiscalYearInformation=Exercice fiscal FiscalYearInformation=Exercice fiscal