diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php index be6bb8f006..7ce17cb77e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php @@ -140,6 +140,8 @@ class Export implements ControllerProviderInterface } $success = false; + $msg = _('Error while connecting to FTP'); + try { $ftpClient = $app['phraseanet.ftp.client']($request->request->get('addr', ''), 21, 90, !!$request->request->get('ssl')); $ftpClient->login($request->request->get('login', ''), $request->request->get('pwd', '')); @@ -147,7 +149,6 @@ class Export implements ControllerProviderInterface $msg = _('Connection to FTP succeed'); $success = true; } catch (\Exception $e) { - $msg = sprintf(_('Error while connecting to FTP')); } return $app->json(array( diff --git a/lib/classes/ftpclient.php b/lib/classes/ftpclient.php index 4063d6edeb..cabc395f08 100644 --- a/lib/classes/ftpclient.php +++ b/lib/classes/ftpclient.php @@ -34,15 +34,21 @@ class ftpclient throw new Exception('Nom d\'hote incorrect ' . $host); } - if ($ssl === true) { - if (($this->connexion = ftp_ssl_connect($host, $port, $timeout)) === false) { - throw new Exception('Impossible de se connecter au serveur FTP en SSL'); - } - } else { - if (($this->connexion = ftp_connect($host, $port, $timeout)) === false) { - throw new Exception('Impossible de se connecter au serveur FTP ' . $host . ":$port $timeout"); + try { + if ($ssl === true) { + if (($this->connexion = @ftp_ssl_connect($host, $port, $timeout)) === false) { + throw new Exception('Impossible de se connecter au serveur FTP en SSL'); + } + } else { + if (($this->connexion = @ftp_connect($host, $port, $timeout)) === false) { + throw new Exception('Impossible de se connecter au serveur FTP ' . $host . ":$port $timeout"); + } } } + catch(\Exception $e) { + // any unknown pb + throw $e; + } return $this; } diff --git a/templates/web/common/dialog_export.html.twig b/templates/web/common/dialog_export.html.twig index 6527309c8f..571a3f6f48 100644 --- a/templates/web/common/dialog_export.html.twig +++ b/templates/web/common/dialog_export.html.twig @@ -2,61 +2,63 @@ {% macro print_ftp_form(datas) %}
{% trans 'export::mail: fichiers joint' %}
- {% for name, values in download.get_display_ftp() %} - {% if values.available > 0 %} -