mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
#PHRAS-223 #time 6h
This commit is contained in:
@@ -140,6 +140,8 @@ class Export implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$success = false;
|
$success = false;
|
||||||
|
$msg = _('Error while connecting to FTP');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$ftpClient = $app['phraseanet.ftp.client']($request->request->get('addr', ''), 21, 90, !!$request->request->get('ssl'));
|
$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', ''));
|
$ftpClient->login($request->request->get('login', ''), $request->request->get('pwd', ''));
|
||||||
@@ -147,7 +149,6 @@ class Export implements ControllerProviderInterface
|
|||||||
$msg = _('Connection to FTP succeed');
|
$msg = _('Connection to FTP succeed');
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$msg = sprintf(_('Error while connecting to FTP'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $app->json(array(
|
return $app->json(array(
|
||||||
|
|||||||
@@ -34,15 +34,21 @@ class ftpclient
|
|||||||
throw new Exception('Nom d\'hote incorrect ' . $host);
|
throw new Exception('Nom d\'hote incorrect ' . $host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
if ($ssl === true) {
|
if ($ssl === true) {
|
||||||
if (($this->connexion = ftp_ssl_connect($host, $port, $timeout)) === false) {
|
if (($this->connexion = @ftp_ssl_connect($host, $port, $timeout)) === false) {
|
||||||
throw new Exception('Impossible de se connecter au serveur FTP en SSL');
|
throw new Exception('Impossible de se connecter au serveur FTP en SSL');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (($this->connexion = ftp_connect($host, $port, $timeout)) === false) {
|
if (($this->connexion = @ftp_connect($host, $port, $timeout)) === false) {
|
||||||
throw new Exception('Impossible de se connecter au serveur FTP ' . $host . ":$port $timeout");
|
throw new Exception('Impossible de se connecter au serveur FTP ' . $host . ":$port $timeout");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
// any unknown pb
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
{% macro print_ftp_form(datas) %}
|
{% macro print_ftp_form(datas) %}
|
||||||
<div class="ftp_form ftp_form_{{datas.usr_id}}">
|
<div class="ftp_form ftp_form_{{datas.usr_id}}">
|
||||||
|
<form id="ftp_user_{{datas.usr_id}}" action="{{ path('export_ftp') }}" method="post" target="_blank" class="form-horizontal" style="text-align: left;">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="addrFTP_{{datas.usr_id}}">{% trans 'phraseanet:: adresse' %} ftp://</label>
|
<label class="control-label" for="addrFTP_{{datas.usr_id}}">{% trans 'phraseanet:: adresse' %} ftp://</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
@@ -57,6 +58,7 @@
|
|||||||
<input type="checkbox" class=ftp_logfile_check" name="logfile" id="logfile_{{datas.usr_id}}" value="1" />
|
<input type="checkbox" class=ftp_logfile_check" name="logfile" id="logfile_{{datas.usr_id}}" value="1" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
@@ -415,9 +417,6 @@
|
|||||||
<div id="ftp">
|
<div id="ftp">
|
||||||
<div style="padding:10px; text-align: center;">
|
<div style="padding:10px; text-align: center;">
|
||||||
<h4>{% trans 'export:: FTP' %}</h4>
|
<h4>{% trans 'export:: FTP' %}</h4>
|
||||||
<form action="{{ path('export_ftp') }}" method="post" target="_blank" class="form-horizontal" style="text-align: left;">
|
|
||||||
<input type="hidden" name="lst" value="{{lst}}"/>
|
|
||||||
<input type="hidden" name="ssttid" value="{{ssttid}}"/>
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="ftp_form_selector">
|
<label class="control-label" for="ftp_form_selector">
|
||||||
{% trans 'phraseanet:: prereglages'%}
|
{% trans 'phraseanet:: prereglages'%}
|
||||||
@@ -437,6 +436,9 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<form id="ftp_joined" class="form-horizontal" style="text-align: left;">
|
||||||
|
<input type="hidden" name="lst" value="{{lst}}"/>
|
||||||
|
<input type="hidden" name="ssttid" value="{{ssttid}}"/>
|
||||||
<div>
|
<div>
|
||||||
<p>{% trans 'export::mail: fichiers joint' %}</p>
|
<p>{% trans 'export::mail: fichiers joint' %}</p>
|
||||||
{% for name, values in download.get_display_ftp() %}
|
{% for name, values in download.get_display_ftp() %}
|
||||||
@@ -485,6 +487,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</form>
|
||||||
<div class="buttons_line">
|
<div class="buttons_line">
|
||||||
<button type="button" class="tryftp_button btn btn-inverse">{% trans 'boutton::essayer'%}</button>
|
<button type="button" class="tryftp_button btn btn-inverse">{% trans 'boutton::essayer'%}</button>
|
||||||
<img class="tryftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
|
<img class="tryftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
|
||||||
@@ -492,7 +495,7 @@
|
|||||||
<img class="ftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
|
<img class="ftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
|
||||||
<button type="button" class="close_button btn btn-inverse">{% trans 'boutton::annuler'%}</button>
|
<button type="button" class="close_button btn btn-inverse">{% trans 'boutton::annuler'%}</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
@@ -734,18 +737,21 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#ftp .ftp_button_loader').css('visibility','visible');
|
$('#ftp .ftp_button_loader').show();
|
||||||
|
|
||||||
$('#ftp .ftp_form:hidden').remove();
|
$('#ftp .ftp_form:hidden').remove();
|
||||||
|
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var options = $('#ftp form').serialize();
|
|
||||||
|
var options_addr = $('#ftp_form_stock form:visible').serialize();
|
||||||
|
var options_join = $('#ftp_joined').serialize();
|
||||||
|
|
||||||
$this.attr('disabled','disabled');
|
$this.attr('disabled','disabled');
|
||||||
$.post("../prod/export/ftp/"
|
$.post("../prod/export/ftp/"
|
||||||
, options
|
, options_addr + '&' + options_join
|
||||||
, function(data){
|
, function(data){
|
||||||
$this.removeAttr('disabled');
|
$this.removeAttr('disabled');
|
||||||
$('#ftp .ftp_button_loader').css('visibility','hidden');
|
$('#ftp .ftp_button_loader').hide();
|
||||||
|
|
||||||
if(data.success) {
|
if(data.success) {
|
||||||
humane.info(data.message);
|
humane.info(data.message);
|
||||||
@@ -770,9 +776,10 @@
|
|||||||
$('#ftp .tryftp_button_loader').css('visibility','visible');
|
$('#ftp .tryftp_button_loader').css('visibility','visible');
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
$this.attr('disabled','disabled');
|
$this.attr('disabled','disabled');
|
||||||
var options = $('#ftp form').serialize();
|
var options_addr = $('#ftp_form_stock form:visible').serialize();
|
||||||
|
|
||||||
$.post("../prod/export/ftp/test/"
|
$.post("../prod/export/ftp/test/"
|
||||||
, options
|
, options_addr // no need to include 'ftp_joined' checkboxes to test ftp
|
||||||
, function(data){
|
, function(data){
|
||||||
$('#ftp .tryftp_button_loader').css('visibility','hidden');
|
$('#ftp .tryftp_button_loader').css('visibility','hidden');
|
||||||
|
|
||||||
@@ -782,7 +789,7 @@
|
|||||||
title : data.success ? '{% trans "Success !" %}' : '{% trans "Warning !" %}'
|
title : data.success ? '{% trans "Success !" %}' : '{% trans "Warning !" %}'
|
||||||
};
|
};
|
||||||
|
|
||||||
p4.Dialog.Create(options, 2).setContent(data.message);
|
p4.Dialog.Create(options, 3).setContent(data.message);
|
||||||
|
|
||||||
$this.removeAttr('disabled');
|
$this.removeAttr('disabled');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user