Jump to content

can't connect tfp ssl server and get some file


duurenbayar

Recommended Posts

<?php
      
        $ftp_server='***.***.***.***';//serverip
        $port='21';
        $conn_id = ftp_ssl_connect($ftp_server,$port);

        // login with username and password
    $user="*****";
    $passwd="******";
   $login_result = ftp_login($conn_id, $user, $passwd);

// check connection
   if ((!$conn_id) || (!$login_result)) {
        echo "FTP connection has failed!";
        echo "Attempted to connect to $ftp_server for user $ftp_user_name";
        die;
    } else {
        echo "<br>Connected to $ftp_server, for user $user<br>";
    }

// check name is PS
        function check_name_is_ps($content)
        {       $str = substr($content, 0, 2);
                if($str == 'ps' or $str == 'PS')    return true;
                else    return false;
        }
// check filename is in sf_statistic
        function file_is_new($content)
        {       $sql = 'SELECT * FROM sf_statistic WHERE filename = "'.$content.'"';
                $res = mysql_query($sql);
                if(mysql_num_rows($res) > 0)    return false;   // тухайн файлыг өмнө нь хуулÑан байна
                else return true;       // тухайн файлыг өмнө нь хуулаагүй бөгөөд ÑˆÐ¸Ð½Ñ Ñ„Ð°Ð¹Ð»
        }
?>
<?php
        $contents = ftp_nlist($conn_id, '.');
    $succeed_payment = 0;
        $unsuccesful_payment = 0;

  foreach($contents as $content)
        {       if(check_name_is_ps($content) == true)
                {       if(file_is_new($content) == true)
                        {       $local_file = '/var/www/modules/customer/import_files/'.$content;          // remote machine
                                //$local_file = 'import_files/'.$content;
                                echo $content.'<br/>';
                                if (ftp_get($login_result, $local_file, $content, FTP_BINARY)) {

..

...

...

                               }
                                else {
                                        echo "There was a problem\n<br/>";
                                }
                        }
                        else
                        {       echo 'there is no new file<br/>';
                        }
                }
        }
    ftp_close($conn_id);
?>
                             

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.