Index: trunk/extensions/Deployment/Deployment.i18n.php |
— | — | @@ -27,4 +27,5 @@ |
28 | 28 | 'deploy-ftp-username-required' => 'FTP username is required', |
29 | 29 | 'deploy-ftp-password-required' => 'FTP password is required', |
30 | 30 | 'deploy-ftp-hostname-required' => 'FTP hostname is required', |
| 31 | + 'deploy-ftp-connect-failed' => 'Failed to connect to FTP server $1:$2' |
31 | 32 | ); |
Index: trunk/extensions/Deployment/includes/filesystems/FtpFilesystem.php |
— | — | @@ -76,8 +76,9 @@ |
77 | 77 | * @see Filesystem::connect |
78 | 78 | */ |
79 | 79 | public function connect() { |
| 80 | + // Attempt to create a connection, either with ssl or without. |
80 | 81 | if ( $this->options['ssl'] && function_exists( 'ftp_ssl_connect' ) ) { |
81 | | - // TODO |
| 82 | + $this->connection = @ftp_ssl_connect( $this->options['hostname'], $this->options['port'], $this->options['timeout'] ); |
82 | 83 | } |
83 | 84 | else { |
84 | 85 | // If this is true, ftp_ssl_connect was not defined, so add an error. |
— | — | @@ -85,11 +86,23 @@ |
86 | 87 | $this->addError( 'deploy-ftp-ssl-not-loaded' ); |
87 | 88 | } |
88 | 89 | |
89 | | - // TODO |
| 90 | + $this->connection = @ftp_connect( $this->options['hostname'], $this->options['port'], $this->options['timeout'] ); |
90 | 91 | } |
91 | 92 | |
92 | | - // TODO |
| 93 | + // Check if a connection has been established. |
| 94 | + if ( !$this->connection ) { |
| 95 | + $this->addErrorMessage( wfMsgExt( 'deploy-ftp-connect-failed', $this->options['hostname'], $this->options['port'] ) ); |
| 96 | + return false; |
| 97 | + } |
93 | 98 | |
| 99 | + // Attempt to set the connection to use passive FTP. |
| 100 | + @ftp_pasv( $this->connection, true ); |
| 101 | + |
| 102 | + // Make sure the timeout is at least as much as the option. |
| 103 | + if ( @ftp_get_option( $this->connection, FTP_TIMEOUT_SEC ) < $this->options['timeout'] ) { |
| 104 | + @ftp_set_option( $this->connection, FTP_TIMEOUT_SEC, $this->options['timeout'] ); |
| 105 | + } |
| 106 | + |
94 | 107 | return true; |
95 | 108 | } |
96 | 109 | |