diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php
index 455ff696a11..d38c7ee0c69 100644
--- a/htdocs/ftp/index.php
+++ b/htdocs/ftp/index.php
@@ -62,10 +62,12 @@ $offset = $limit * $page ;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="label";
+$s_ftp_name='FTP_NAME_'.$numero_ftp;
$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;
+$ftp_name=$conf->global->$s_ftp_name;
$ftp_server=$conf->global->$s_ftp_server;
$ftp_port=$conf->global->$s_ftp_port;
$ftp_user=$conf->global->$s_ftp_user;
@@ -319,7 +321,6 @@ $userstatic = new User($db);
print_fiche_titre($langs->trans("FTPArea"));
print $langs->trans("FTPAreaDesc")."
";
-print "
\n";
if (! function_exists('ftp_connect'))
{
@@ -333,7 +334,7 @@ else
// Confirm remove file
if ($_GET['action'] == 'delete')
{
- $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
if ($ret == 'html') print '
';
}
@@ -343,7 +344,7 @@ else
// Confirmation de la suppression d'une ligne categorie
if ($_GET['action'] == 'delete_section')
{
- $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
if ($ret == 'html') print '
';
}
@@ -365,7 +366,7 @@ else
print '
'.$langs->trans("Group").' | '."\n";
print ''.$langs->trans("Permissions").' | '."\n";
print '';
- print ''.img_picto($langs->trans("Refresh"),'refresh').' ';
+ print ''.img_picto($langs->trans("Refresh"),'refresh').' ';
print ' | '."\n";
print ''."\n";
@@ -460,7 +461,7 @@ else
print '';
if ($is_directory)
{
- if ($file != '..') print ''.img_delete().'';
+ if ($file != '..') print ''.img_delete().'';
else print ' ';
}
else if ($is_link)
@@ -469,9 +470,9 @@ else
}
else
{
- print ''.img_file().'';
+ print ''.img_file().'';
print ' ';
- print ''.img_delete().'';
+ print ''.img_delete().'';
}
print ' | ';
print ''."\n";
@@ -524,43 +525,58 @@ llxFooter('$Date$ - $Revision$');
*/
function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section)
{
+ global $langs;
+
$ok=1;
- $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))
- {
- // Change the dir
- $newsectioniso=utf8_decode($section);
- ftp_chdir($conn_id, $newsectioniso);
- }
- else
- {
- $mesg=$langs->trans("FailedToConnectToFTPServerWithCredentials");
- $ok=0;
- }
- }
- }
- else
+ if (! is_numeric($ftp_port))
{
$mesg=$langs->trans("FailedToConnectToFTPServer",$ftp_server,$ftp_port);
$ok=0;
}
- $arrayresult=array('conn_id'=>$conn_id, 'ok'=>$ok, 'mesg'=>$mesg);
+ if ($ok)
+ {
+ $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))
+ {
+ // Change the dir
+ $newsectioniso=utf8_decode($section);
+ ftp_chdir($conn_id, $newsectioniso);
+ }
+ else
+ {
+ $mesg=$langs->trans("FailedToConnectToFTPServerWithCredentials");
+ $ok=0;
+ }
+ }
+ }
+ else
+ {
+ $mesg=$langs->trans("FailedToConnectToFTPServer",$ftp_server,$ftp_port);
+ $ok=0;
+ }
+ }
+
+ $arrayresult=array('conn_id'=>$conn_id, 'ok'=>$ok, 'mesg'=>$mesg);
return $arrayresult;
}
/**
-*/
+ * Tell if an entry is a FTP directory
+ *
+ * @param unknown_type $connect_id
+ * @param unknown_type $dir
+ * @return unknown
+ */
function ftp_isdir($connect_id,$dir)
{
if(ftp_chdir($connect_id,$dir))
diff --git a/htdocs/ftp/pre.inc.php b/htdocs/ftp/pre.inc.php
index f96932bd3f3..32d78d5acce 100644
--- a/htdocs/ftp/pre.inc.php
+++ b/htdocs/ftp/pre.inc.php
@@ -36,6 +36,20 @@ function llxHeader($head = '', $title='', $help_url='', $morehtml='')
$menu = new Menu();
+ $MAXFTP=20;
+ $i=1;
+ while ($i <= $MAXFTP)
+ {
+ $paramkey='FTP_NAME_'.$i;
+ //print $paramkey;
+ if (! empty($conf->global->$paramkey))
+ {
+ $link=DOL_URL_ROOT."/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i;
+
+ $menu->add($link, dol_trunc($conf->global->$paramkey,24));
+ }
+ $i++;
+ }
left_menu($menu->liste, $help_url, $morehtml);
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index ee24b4f4112..7d42fa1c942 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -927,6 +927,7 @@ function dolibarr_trunc($string,$size=40,$trunc='right',$stringencoding='')
* \param string String to truncate
* \param size Max string size. 0 for no limit.
* \param trunc Where to trunc: right, left, middle
+ * \param stringencoding Tell what is source string encoding
* \return string Truncated string
* \remarks USE_SHORT_TITLE=0 can disable all truncings
*/