WordPress.org

Make WordPress Core

Ticket #7940: wordpress-passive-ftp.diff

File wordpress-passive-ftp.diff, 2.5 KB (added by mcs_trekkie, 10 years ago)

patch to add passive FTP transfer mode in wp-filesystem-ftpext

  • wp-admin/includes/class-wp-filesystem-ftpext.php

    diff -urN wordpress.orig/wp-admin/includes/class-wp-filesystem-ftpext.php wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php
    old new  
    5858                        $this->options['password'] = $opt['password'];
    5959
    6060                $this->options['ssl'] = ( !empty($opt['ssl']) );
     61                $this->options['pasv'] = ( !empty($opt['pasv']) );
    6162        }
    6263
    6364        function connect() {
     
    7677                        return false;
    7778                }
    7879
     80                // this enteres passive FTP mode if the server does have problems connection the FTP server due to some firewalling this could help
     81                if( $this->options['pasv'] )
     82                        @ftp_pasv( $this->link, 1 );
     83
    7984                return true;
    8085        }
    8186
  • wp-admin/update.php

    diff -urN wordpress.orig/wp-admin/update.php wordpress/wp-admin/update.php
    old new  
    2323        $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']);
    2424        $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']);
    2525        $credentials['ssl']      = defined('FTP_SSL')  ? FTP_SSL  : ( isset($_POST['ssl'])      ? $_POST['ssl']      : $credentials['ssl']);
     26        $credentials['pasv']      = defined('FTP_PASV')  ? FTP_PASV  : ( isset($_POST['pasv'])      ? $_POST['pasv']      : $credentials['pasv']);
    2627
    2728        if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
    2829                $stored_credentials = $credentials;
     
    3435        $username = '';
    3536        $password = '';
    3637        $ssl = '';
     38        $pasv = '';
    3739        if ( !empty($credentials) )
    3840                extract($credentials, EXTR_OVERWRITE);
    3941        if( $error )
     
    6971</select>
    7072</td>
    7173</tr>
     74<tr valign="top">
     75<th scope="row"><label for="pasv"><?php _e('Use passive FTP connection:') ?></label></th>
     76<td>
     77<select name="pasv" id="pasv"<?php if( defined('FTP_PASV') ) echo ' disabled="disabled"' ?>>
     78<?php
     79foreach ( array(0 => __('No'), 1 => __('Yes')) as $key => $value ) :
     80        $selected = ($pasv == $value) ? 'selected="selected"' : '';
     81        echo "\n\t<option value='$key' $selected>" . $value . '</option>';
     82endforeach;
     83?>
     84</select>
     85</td>
     86</tr>
    7287</table>
    7388<p class="submit">
    7489<input type="submit" name="submit" value="<?php _e('Proceed'); ?>" />