From c8db19331b32d2f1917dbec1ce94f5a1e009c03b Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 15 Mar 2024 18:36:54 +0100 Subject: [PATCH] Handle ftp_chdir error --- htdocs/core/lib/ftp.lib.php | 10 ++++++---- htdocs/langs/en_US/other.lang | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php index 3782a170242..d72d98d7f94 100644 --- a/htdocs/core/lib/ftp.lib.php +++ b/htdocs/core/lib/ftp.lib.php @@ -89,18 +89,20 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect } } else { if (ftp_login($connect_id, $ftp_user, $ftp_password)) { - // Turn on passive mode transfers (must be after a successful login + // Turn on passive mode transfers (must be after a successful login) if ($ftp_passive) { ftp_pasv($connect_id, true); } // Change the dir $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1'); - ftp_chdir($connect_id, $newsectioniso); + if (!ftp_chdir($connect_id, $newsectioniso)) { + $ok = 0; + $mesg = $langs->transnoentitiesnoconv("FailedToChdirOnFTPServer"); + } } else { - $mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); $ok = 0; - $error++; + $mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); } } } diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a1e25cea1af..32cd6681507 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -327,6 +327,7 @@ SetupOfFTPClientModuleNotComplete=The setup of the FTP or SFTP client module see FTPFeatureNotSupportedByYourPHP=Your PHP does not support FTP or SFTP functions FailedToConnectToFTPServer=Failed to connect to server (server %s, port %s) FailedToConnectToFTPServerWithCredentials=Failed to login to server with defined login/password +FailedToChdirOnFTPServer=Failed to change directory on the FTP server FTPFailedToRemoveFile=Failed to remove file %s. FTPFailedToRemoveDir=Failed to remove directory %s: check permissions and that the directory is empty. FTPPassiveMode=Passive mode