Ticket #7690: wordpress_ssh2_transfer_2.7.x.patch

File wordpress_ssh2_transfer_2.7.x.patch, 10.5 KB (added by ShaneF, 4 years ago)

this is the patch file for the current files.

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

     
    1818        var $method = ''; 
    1919 
    2020        function abspath() { 
     21                // @todo: Add SSH2_BASE 
    2122                if ( defined('FTP_BASE') && strpos($this->method, 'ftp') !== false ) 
    2223                        return FTP_BASE; 
    2324                return $this->find_folder(ABSPATH); 
    2425        } 
    2526        function wp_content_dir() { 
     27                // @todo: Add SSH2_CONTENT_DIR 
    2628                if ( defined('FTP_CONTENT_DIR') && strpos($this->method, 'ftp') !== false ) 
    2729                        return FTP_CONTENT_DIR; 
    2830                return $this->find_folder(WP_CONTENT_DIR); 
    2931        } 
    3032        function wp_plugins_dir() { 
     33                // @todo: Add SSH2_PLUGIN_DIR 
    3134                if ( defined('FTP_PLUGIN_DIR') && strpos($this->method, 'ftp') !== false ) 
    3235                        return FTP_PLUGIN_DIR; 
    3336                return $this->find_folder(WP_PLUGIN_DIR); 
  • wp-admin/includes/file.php

     
    480480                unlink($temp_file); 
    481481        } 
    482482 
    483         if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; 
     483        if ( ! $method && extension_loaded("ssh2") && (get_option('transfer_protocol') == "ssh2") ) $method = 'ssh2'; 
     484        if ( ! $method && extension_loaded('ftp') && (get_option('transfer_protocol') == "ftp") ) $method = 'ftpext'; 
    484485        if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread 
     486         
    485487        return apply_filters('filesystem_method', $method); 
    486488} 
    487489 
     
    496498        if ( 'direct' == $type ) 
    497499                return true; 
    498500 
    499         if( ! $credentials = get_option('ftp_credentials') ) 
     501        if( ! $credentials = get_option('transfer_credentials') ) 
    500502                $credentials = array(); 
    501503        // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option) 
    502         $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']); 
    503         $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); 
    504         $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']); 
    505         $credentials['ssl']      = defined('FTP_SSL')  ? FTP_SSL  : ( isset($_POST['ssl'])      ? $_POST['ssl']      : $credentials['ssl']); 
     504         
     505        switch ($type) 
     506        { 
     507                case 'ftp': { 
     508                                $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']); 
     509                                $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); 
     510                                $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']); 
     511                                $credentials['ssl']      = defined('FTP_SSL')  ? FTP_SSL  : ( isset($_POST['ssl'])      ? $_POST['ssl']      : $credentials['ssl']); 
     512                        break; 
     513                } 
     514                case 'ssh2': { 
     515                                $credentials['hostname'] = defined('SSH2_HOST') ? SSH2_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']); 
     516                                $credentials['username'] = defined('SSH2_USER') ? SSH2_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); 
     517                                $credentials['password'] = defined('SSH2_PASS') ? SSH2_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']); 
     518                                $credentials['ssl'] = '';       // no ssl in ssh2 
     519                        break; 
     520                } 
     521        } 
     522         
    506523 
     524 
    507525        if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) { 
    508526                $stored_credentials = $credentials; 
    509527                unset($stored_credentials['password']); 
    510                 update_option('ftp_credentials', $stored_credentials); 
     528                update_option('transfer_credentials', $stored_credentials); 
    511529                return $credentials; 
    512530        } 
    513531        $hostname = ''; 
     
    521539?> 
    522540<form action="<?php echo $form_post ?>" method="post"> 
    523541<div class="wrap"> 
    524 <h2><?php _e('FTP Connection Information') ?></h2> 
    525 <p><?php _e('To perform the requested action, FTP connection information is required.') ?></p> 
     542<?php $connection_method = strtoupper(get_option('transfer_protocol')); ?> 
     543<h2><?php _e($connection_method.' Connection Information') ?></h2> 
     544<p><?php _e('To perform the requested action, '.$connection_method.' connection information is required.') ?></p> 
    526545<table class="form-table"> 
    527546<tr valign="top"> 
    528547<th scope="row"><label for="hostname"><?php _e('Hostname:') ?></label></th> 
    529 <td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname) ?>"<?php if( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td> 
     548<td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname) ?>"<?php if( defined('FTP_HOST') || defined('SSH2_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td> 
    530549</tr> 
    531550<tr valign="top"> 
    532551<th scope="row"><label for="username"><?php _e('Username:') ?></label></th> 
    533 <td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>"<?php if( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td> 
     552<td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>"<?php if( defined('FTP_USER') || defined('SSH2_USER') ) echo ' disabled="disabled"' ?> size="40" /></td> 
    534553</tr> 
    535554<tr valign="top"> 
    536555<th scope="row"><label for="password"><?php _e('Password:') ?></label></th> 
    537 <td><input name="password" type="password" id="password" value=""<?php if( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /><?php if( defined('FTP_PASS') && !empty($password) ) echo '<em>'.__('(Password not shown)').'</em>'; ?></td> 
     556<td><input name="password" type="password" id="password" value=""<?php if( defined('FTP_PASS') || defined('SSH2_PASS') ) echo ' disabled="disabled"' ?> size="40" /><?php if( (defined('FTP_PASS') || defined('SSH2_PASS')) && !empty($password) ) echo '<em>'.__('(Password not shown)').'</em>'; ?></td> 
    538557</tr> 
     558<?php if (get_option('transfer_protocol') == "ftp") { ?> 
    539559<tr valign="top"> 
    540560<th scope="row"><label for="ssl"><?php _e('Use SSL:') ?></label></th> 
    541561<td> 
     
    549569</select> 
    550570</td> 
    551571</tr> 
     572<?php } ?> 
    552573</table> 
    553574<p class="submit"> 
    554575<input type="submit" name="submit" value="<?php _e('Proceed'); ?>" /> 
  • wp-admin/includes/update-core.php

     
    188188        $maintenance_file = $to . '.maintenance'; 
    189189        $wp_filesystem->delete($maintenance_file); 
    190190        $wp_filesystem->put_contents($maintenance_file, $maintenance_string, 0644); 
    191  
     191         
    192192        // Copy new versions of WP files into place. 
    193193        $result = copy_dir($from . '/wordpress', $to); 
    194194        if ( is_wp_error($result) ) { 
  • wp-admin/includes/upgrade.php

     
    764764function upgrade_270() { 
    765765        if ( $wp_current_db_version < 8530 ) 
    766766                populate_roles_270(); 
     767         
     768         
     769        // @todo: change the setting... ftp_credentials to transfer_credentials in the options table. Then set it to "ftp" as default. 
     770         
    767771} 
    768772 
    769773 
  • wp-admin/options-misc.php

     
    2121<form method="post" action="options.php"> 
    2222<input type='hidden' name='option_page' value='misc' /> 
    2323<?php wp_nonce_field('misc-options') ?> 
     24<h3><?php _e('Transfer/Upgrading Settings'); ?></h3> 
     25<table class="form-table"> 
     26<?php if (extension_loaded("ssh2")) { ?> 
     27<tr valign="top"> 
     28<th scope="row"><?php _e('Select the file transfer type your like to use') ?></th> 
     29<td><fieldset><legend class="hidden"><?php _e('Select the file transfer type your like to use') ?></legend> 
     30<?php 
     31        $transfer_protocols = array('ftp' => 'FTP', 'ssh2' => 'SSH2'); 
     32        foreach ($transfer_protocols as $type => $name) { ?> 
     33                <input type="radio" name="transfer_protocol" id="transfer_protocol_<?php echo $type; ?>" value="<?php echo $type; ?>"<?php echo (get_option('transfer_protocol') == $type ? ' checked="checked"' : ''); ?> />                    
     34                <label for="transfer_protocol_<?php echo $type; ?>"><?php _e($name); ?></label> 
     35        <?php 
     36        } 
     37?> 
     38</fieldset></td> 
     39</tr> 
     40<?php } ?> 
     41<!-- @todo: Add option for what the message will be when updating the core of the wordpress. --> 
     42</table> 
    2443<h3><?php _e('Uploading'); ?></h3> 
    2544<table class="form-table"> 
    2645<tr valign="top"> 
  • wp-admin/options.php

     
    2424$whitelist_options = array( 
    2525        'general' => array('blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'comment_registration', 'default_role'), 
    2626        'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating' ), 
    27         'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'large_size_w', 'large_size_h' ), 
     27        'misc' => array( 'transfer_protocol', 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'large_size_w', 'large_size_h' ), 
    2828        'privacy' => array( 'blog_public' ), 
    2929        'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'gzipcompression', 'show_on_front', 'page_on_front', 'page_for_posts' ), 
    3030        'writing' => array( 'default_post_edit_rows', 'use_smilies', 'ping_sites', 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'enable_app', 'enable_xmlrpc' ),