39function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive = 0)
 
   49  if (!is_numeric($ftp_port)) {
 
   50    $mesg = $langs->transnoentitiesnoconv(
"FailedToConnectToFTPServer", $ftp_server, $ftp_port);
 
   58      dol_syslog(
'Try to connect with ssh2_connect');
 
   59      $tmp_conn_id = ssh2_connect($ftp_server, (
int) $ftp_port);
 
   61      dol_syslog(
'Try to connect with ftp_ssl_connect');
 
   62      $connect_id = ftp_ssl_connect($ftp_server, (
int) $ftp_port, $connecttimeout);
 
   65      $connect_id = ftp_connect($ftp_server, (
int) $ftp_port, $connecttimeout);
 
   67    if (!empty($connect_id) || !empty($tmp_conn_id)) {
 
   70          dol_syslog(
'Try to authenticate with ssh2_auth_password');
 
   71          if (!empty($tmp_conn_id) && ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) {
 
   76            $newsectioniso = mb_convert_encoding($section, 
'ISO-8859-1');
 
   78            $connect_id = ssh2_sftp($tmp_conn_id);
 
   80              dol_syslog(
'Failed to connect to SFTP after sssh authentication', LOG_DEBUG);
 
   81              $mesg = $langs->transnoentitiesnoconv(
"FailedToConnectToSFTPAfterSSHAuthentication");
 
   86            dol_syslog(
'Failed to connect to FTP with login '.$ftp_user, LOG_DEBUG);
 
   87            $mesg = $langs->transnoentitiesnoconv(
"FailedToConnectToFTPServerWithCredentials");
 
   92          if (!empty($connect_id) && ftp_login($connect_id, $ftp_user, $ftp_password)) {
 
   95              ftp_pasv($connect_id, 
true);
 
   99            $newsectioniso = mb_convert_encoding($section, 
'ISO-8859-1');
 
  100            if (!ftp_chdir($connect_id, $newsectioniso)) {
 
  102              $mesg = $langs->transnoentitiesnoconv(
"FailedToChdirOnFTPServer");
 
  106            $mesg = $langs->transnoentitiesnoconv(
"FailedToConnectToFTPServerWithCredentials");
 
  111      dol_syslog(
'FailedToConnectToFTPServer '.$ftp_server.
' '.$ftp_port, LOG_ERR);
 
  112      $mesg = $langs->transnoentitiesnoconv(
"FailedToConnectToFTPServer", $ftp_server, $ftp_port);
 
  117  $arrayresult = array(
'conn_id' => $connect_id, 
'ok' => $ok, 
'mesg' => $mesg, 
'curdir' => $section, 
'curdiriso' => $newsectioniso);
 
 
  171    $newsection = ssh2_sftp_realpath($connect_id, 
".").
'/./'; 
 
  176  $remotefile = $newsection.(preg_match(
'@[\\\/]$@', $newsection) ? 
'' : 
'/').$file;
 
  177  $newremotefileiso = mb_convert_encoding($remotefile, 
'ISO-8859-1');
 
  180  dol_syslog(
"ftp/index.php ftp_delete ".$newremotefileiso);
 
  182    return ssh2_sftp_unlink($connect_id, $newremotefileiso);
 
  184    return @ftp_delete($connect_id, $newremotefileiso);
 
 
  202    $newsection = ssh2_sftp_realpath($connect_id, 
".").
'/./'; 
 
  207  $remotefile = $newsection.(preg_match(
'@[\\\/]$@', $newsection) ? 
'' : 
'/').$file;
 
  208  $newremotefileiso = mb_convert_encoding($remotefile, 
'ISO-8859-1');
 
  211    return fopen(
'ssh2.sftp://'.intval($connect_id).$newremotefileiso, 
'r');
 
  213    return ftp_get($connect_id, $localfile, $newremotefileiso, FTP_BINARY);
 
 
  231    $newsection = ssh2_sftp_realpath($connect_id, 
".").
'/./'; 
 
  236  $remotefile = $newsection.(preg_match(
'@[\\\/]$@', $newsection) ? 
'' : 
'/').$file;
 
  237  $newremotefileiso = mb_convert_encoding($remotefile, 
'ISO-8859-1');
 
  240    return ssh2_scp_send($connect_id, $localfile, $newremotefileiso, 0644);
 
  242    return ftp_put($connect_id, $newremotefileiso, $localfile, FTP_BINARY);
 
 
  259    $newsection = ssh2_sftp_realpath($connect_id, 
".").
'/./'; 
 
  264  $remotefile = $newsection.(preg_match(
'@[\\\/]$@', $newsection) ? 
'' : 
'/').$file;
 
  265  $newremotefileiso = mb_convert_encoding($remotefile, 
'ISO-8859-1');
 
  268    return ssh2_sftp_rmdir($connect_id, $newremotefileiso);
 
  270    return @ftp_rmdir($connect_id, $newremotefileiso);
 
 
  288    $newsection = ssh2_sftp_realpath($connect_id, 
".").
'/./'; 
 
  292  $newremotefileiso = $newsection.(preg_match(
'@[\\\/]$@', $newsection) ? 
'' : 
'/').$newdir;
 
  293  $newremotefileiso = mb_convert_encoding($newremotefileiso, 
'ISO-8859-1');
 
  296    return ssh2_sftp_mkdir($connect_id, $newremotefileiso, 0777);
 
  298    return @ftp_mkdir($connect_id, $newremotefileiso);
 
 
dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive=0)
Connect to FTP server.
 
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.