From 2941cf1c1930510559cdecbb358d1ac1322a0a32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Jul 2025 15:29:15 +0200 Subject: [PATCH] Fix CI --- htdocs/core/lib/ftp.lib.php | 64 ++++++++++++++----------------------- 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php index e071b2c0de5..96e4caf9996 100644 --- a/htdocs/core/lib/ftp.lib.php +++ b/htdocs/core/lib/ftp.lib.php @@ -1,7 +1,7 @@ +/* Copyright (C) 2022-2025 Laurent Destailleur * Copyright (C) 2022 Anthony Berton - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -122,9 +122,9 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect /** * Tell if an entry is a FTP directory * - * @param resource $connect_id Connection handler - * @param string $dir Directory - * @return int 1=directory, 0=not a directory + * @param resource|FTP\Connection $connect_id Connection handler + * @param string $dir Directory + * @return int 1=directory, 0=not a directory */ function ftp_isdir($connect_id, $dir) { @@ -139,13 +139,11 @@ function ftp_isdir($connect_id, $dir) /** * Tell if an entry is a FTP directory * - * @param resource $connect_id Connection handler - * @return boolean Result of closing + * @param resource|FTP\Connection $connect_id Connection handler + * @return boolean Result of closing */ function dol_ftp_close($connect_id) { - global $conf; - // Close FTP connection if ($connect_id) { if (!getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { @@ -158,21 +156,18 @@ function dol_ftp_close($connect_id) /** * Delete a FTP file * - * @param resource $connect_id Connection handler - * @param string $file File - * @param string $newsection $newsection + * @param resource|FTP\Connection $connect_id Connection handler + * @param string $file File + * @param string $newsection Directory * @return bool */ function dol_ftp_delete($connect_id, $file, $newsection) { - global $conf; - if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { $newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } // Remote file - $filename = $file; $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1'); @@ -188,22 +183,19 @@ function dol_ftp_delete($connect_id, $file, $newsection) /** * Download a FTP file * - * @param resource $connect_id Connection handler - * @param string $localfile The local file path - * @param string $file The remote file path - * @param string $newsection $newsection + * @param resource|FTP\Connection $connect_id Connection handler + * @param string $localfile The local file path + * @param string $file The remote file path + * @param string $newsection Directory * @return bool|resource */ function dol_ftp_get($connect_id, $localfile, $file, $newsection) { - global $conf; - if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { $newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } // Remote file - $filename = $file; $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1'); @@ -217,22 +209,19 @@ function dol_ftp_get($connect_id, $localfile, $file, $newsection) /** * Upload a FTP file * - * @param resource $connect_id Connection handler - * @param string $file File name - * @param string $localfile The path to the local file - * @param string $newsection $newsection + * @param resource|FTP\Connection $connect_id Connection handler + * @param string $file File name + * @param string $localfile The path to the local file + * @param string $newsection Directory * @return bool */ function dol_ftp_put($connect_id, $file, $localfile, $newsection) { - global $conf; - if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { $newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } // Remote file - $filename = $file; $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1'); @@ -246,21 +235,18 @@ function dol_ftp_put($connect_id, $file, $localfile, $newsection) /** * Remove FTP directory * - * @param resource $connect_id Connection handler - * @param string $file File - * @param string $newsection $newsection + * @param resource|FTP\Connection $connect_id Connection handler + * @param string $file File + * @param string $newsection Directory * @return bool */ function dol_ftp_rmdir($connect_id, $file, $newsection) { - global $conf; - if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { $newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } // Remote file - $filename = $file; $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1'); @@ -275,15 +261,13 @@ function dol_ftp_rmdir($connect_id, $file, $newsection) /** * Remove FTP directory * - * @param resource $connect_id Connection handler - * @param string $newdir Dir create - * @param string $newsection $newsection + * @param resource|FTP\Connection $connect_id Connection handler + * @param string $newdir Dir create + * @param string $newsection Directory * @return bool|string */ function dol_ftp_mkdir($connect_id, $newdir, $newsection) { - global $conf; - if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { $newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 }