diff --git a/htdocs/ftp/admin/ftpclient.php b/htdocs/ftp/admin/ftpclient.php
index ed4176da689..bbc8b229537 100644
--- a/htdocs/ftp/admin/ftpclient.php
+++ b/htdocs/ftp/admin/ftpclient.php
@@ -74,10 +74,10 @@ if ($action == 'add' || GETPOST('modify','alpha'))
if (! $error)
{
-
$ftp_port = "FTP_PORT_" . $entry;
$ftp_user = "FTP_USER_" . $entry;
$ftp_password = "FTP_PASSWORD_" . $entry;
+ $ftp_passive = "FTP_PASSIVE_" . $entry;
$db->begin();
@@ -86,8 +86,9 @@ if ($action == 'add' || GETPOST('modify','alpha'))
if ($result2) $result3=dolibarr_set_const($db, "FTP_USER_" . $entry,GETPOST($ftp_user,'alpha'),'chaine',0,'',$conf->entity);
if ($result3) $result4=dolibarr_set_const($db, "FTP_PASSWORD_" . $entry,GETPOST($ftp_password,'alpha'),'chaine',0,'',$conf->entity);
if ($result4) $result5=dolibarr_set_const($db, "FTP_NAME_" . $entry,GETPOST($ftp_name,'alpha'),'chaine',0,'',$conf->entity);
+ if ($result5) $result6=dolibarr_set_const($db, "FTP_PASSIVE_" . $entry,GETPOST($ftp_passive,'alpha'),'chaine',0,'',$conf->entity);
- if ($result1 && $result2 && $result3 && $result4 && $result5)
+ if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6)
{
$db->commit();
//$mesg='
'.$langs->trans("Success").'
';
@@ -108,17 +109,18 @@ if (GETPOST('delete','alpha'))
{
$db->begin();
- $result1=dolibarr_del_const($db,"ftp_port_" . $entry,$conf->entity);
- if ($result1) $result2=dolibarr_del_const($db,"ftp_server_" . $entry,$conf->entity);
- if ($result2) $result3=dolibarr_del_const($db,"ftp_user_" . $entry,$conf->entity);
- if ($result3) $result4=dolibarr_del_const($db,"ftp_password_" . $entry,$conf->entity);
- if ($result4) $result5=dolibarr_del_const($db,"ftp_name_" . $entry,$conf->entity);
-
- if ($result1 && $result2 && $result3 && $result4 && $result5)
+ $result1=dolibarr_del_const($db,"FTP_PORT_" . $entry,$conf->entity);
+ if ($result1) $result2=dolibarr_del_const($db,"FTP_SERVER_" . $entry,$conf->entity);
+ if ($result2) $result3=dolibarr_del_const($db,"FTP_USER_" . $entry,$conf->entity);
+ if ($result3) $result4=dolibarr_del_const($db,"FTP_PASSWORD_" . $entry,$conf->entity);
+ if ($result4) $result5=dolibarr_del_const($db,"FTP_NAME_" . $entry,$conf->entity);
+ if ($result4) $result5=dolibarr_del_const($db,"FTP_PASSIVE_" . $entry,$conf->entity);
+
+ if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6)
{
$db->commit();
//$mesg=''.$langs->trans("Success").'
';
- header("Location: ftpclient.php");
+ header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
@@ -134,6 +136,8 @@ if (GETPOST('delete','alpha'))
* View
*/
+$form=new Form($db);
+
llxHeader();
$linkback=''.$langs->trans("BackToModuleList").'';
@@ -159,34 +163,42 @@ else
print '';
print '| '.$langs->trans("Label").' | ';
- print ' | ';
+ print ' | ';
print 'My FTP access | ';
print '
';
print '';
print '| '.$langs->trans("Server").' | ';
- print ' | ';
+ print ' | ';
print 'localhost | ';
print '
';
print '';
print '| '.$langs->trans("Port").' | ';
- print ' | ';
+ print ' | ';
print '21 | ';
print '
';
print '';
print '| '.$langs->trans("User").' | ';
- print ' | ';
+ print ' | ';
print 'myftplogin | ';
print '
';
print '';
print '| '.$langs->trans("Password").' | ';
- print ' | ';
+ print ' | ';
print 'myftppassword | ';
print '
';
+ print '';
+ print '| '.$langs->trans("Passive").' | ';
+ $defaultpassive=GETPOST("FTP_PASSIVE_" . ($lastftpentry+1));
+ if (! isset($_POST["FTP_PASSIVE_" . ($lastftpentry+1)])) $defaultpassive=empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT)?0:1;
+ print ''.$form->selectyesno('FTP_PASSIVE_'.($lastftpentry+1), $defaultpassive, 2).' | ';
+ print ''.$langs->trans("No").' | ';
+ print '
';
+
?>
|
">
@@ -263,6 +275,12 @@ else
print " | | ";
print "
";
+ $var=!$var;
+ print "";
+ print "| ".$langs->trans("Passive")." | ";
+ print ''.$form->selectyesno('FTP_PASSIVE_'.$idrss, @constant("FTP_PASSIVE_" . $idrss), 1).' | ';
+ print "
";
+
print "";
print "";
print "trans("Modify")."\">";
@@ -288,7 +306,8 @@ else
dol_htmloutput_mesg($mesg);
-$db->close();
llxFooter();
+
+$db->close();
?>
diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php
index 18dd8191304..161420a9275 100644
--- a/htdocs/ftp/index.php
+++ b/htdocs/ftp/index.php
@@ -63,11 +63,13 @@ $s_ftp_server='FTP_SERVER_'.$numero_ftp;
$s_ftp_port='FTP_PORT_'.$numero_ftp;
$s_ftp_user='FTP_USER_'.$numero_ftp;
$s_ftp_password='FTP_PASSWORD_'.$numero_ftp;
+$s_ftp_passive='FTP_PASSIVE_'.$numero_ftp;
$ftp_name=$conf->global->$s_ftp_name;
$ftp_server=$conf->global->$s_ftp_server;
$ftp_port=$conf->global->$s_ftp_port; if (empty($ftp_port)) $ftp_port=21;
$ftp_user=$conf->global->$s_ftp_user;
-$ftp_password=$conf->global->$s_ftp_password;
+$ftp_password=$conf->global->$s_ftp_password;
+$ftp_passive=$conf->global->$s_ftp_passive;
$conn_id=0; // FTP connection ID
@@ -413,7 +415,7 @@ else
}
print $langs->trans("Server").': '.$ftp_server.' ';
- print $langs->trans("Port").': '.$ftp_port.' ';
+ print $langs->trans("Port").': '.$ftp_port.' '.($ftp_passive?"(Passive)":"(Active)").' ';
print $langs->trans("User").': '.$ftp_user.' ';
print $langs->trans("Directory").': ';
@@ -638,9 +640,10 @@ llxFooter();
* @param string $ftp_user FTP user
* @param string $ftp_password FTP password
* @param string $section Directory
+ * @param string $ftp_passive Use a passive mode
* @return int <0 if OK, >0 if KO
*/
-function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section)
+function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive=0)
{
global $langs;
@@ -657,13 +660,13 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
$conn_id = ftp_connect($ftp_server, $ftp_port, 20);
if ($conn_id)
{
- // turn on passive mode transfers
- //ftp_pasv ($conn_id, true);
-
if ($ftp_user)
{
if (ftp_login($conn_id, $ftp_user, $ftp_password))
{
+ // Turn on passive mode transfers (must be after a successful login
+ if ($ftp_passive) ftp_pasv($conn_id, true);
+
// Change the dir
$newsectioniso=utf8_decode($section);
ftp_chdir($conn_id, $newsectioniso);
|