Make WordPress Core

Ticket #7690: 7690.2.diff

File 7690.2.diff, 5.3 KB (added by ryan, 17 years ago)

connection type radios

  • wp-admin/includes/file.php

     
    448448
    449449        require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
    450450
    451         $method = get_filesystem_method();
     451        $method = get_filesystem_method($args);
    452452
    453453        if ( ! $method )
    454454                return false;
     
    471471        return true;
    472472}
    473473
    474 function get_filesystem_method() {
     474function get_filesystem_method($args = array()) {
    475475        $method = false;
    476476        if( function_exists('getmyuid') && function_exists('fileowner') ){
    477477                $temp_file = wp_tempnam();
     
    480480                unlink($temp_file);
    481481        }
    482482
     483        if ( isset($args['connection_type']) && 'ssh' == $args['connection_type'] ) {
     484                $method = 'SSH2';
     485                return apply_filters('filesystem_method', $method);
     486        }
     487
    483488        if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
    484489        if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
    485490        return apply_filters('filesystem_method', $method);
     
    493498        if ( empty($type) )
    494499                $type = get_filesystem_method();
    495500
    496         if ( 'direct' == $type )
    497                 return true;
     501//      if ( 'direct' == $type )
     502//              return true;
    498503
    499504        if( ! $credentials = get_option('ftp_credentials') )
    500505                $credentials = array();
     
    502507        $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']);
    503508        $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']);
    504509        $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']);
     510        if ( defined('FTP_SSH') || 'ssh' == $_POST['connection_type'] )
     511                $credentials['connection_type'] = 'ssh';
     512        else if ( defined('FTP_SSL') || 'ftps' == $_POST['connection_type'] )
     513                $credentials['connection_type'] = 'ftps';
     514        else
     515                $credentials['connection_type'] = 'ftp';
    506516
    507517        if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
    508518                $stored_credentials = $credentials;
     
    525535<p><?php _e('To perform the requested action, FTP connection information is required.') ?></p>
    526536<table class="form-table">
    527537<tr valign="top">
    528 <th scope="row"><label for="hostname"><?php _e('Hostname:') ?></label></th>
     538<th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th>
    529539<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>
    530540</tr>
    531541<tr valign="top">
    532 <th scope="row"><label for="username"><?php _e('Username:') ?></label></th>
     542<th scope="row"><label for="username"><?php _e('Username') ?></label></th>
    533543<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>
    534544</tr>
    535545<tr valign="top">
    536 <th scope="row"><label for="password"><?php _e('Password:') ?></label></th>
     546<th scope="row"><label for="password"><?php _e('Password') ?></label></th>
    537547<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>
    538548</tr>
    539549<tr valign="top">
    540 <th scope="row"><label for="ssl"><?php _e('Use SSL:') ?></label></th>
     550<th scope="row"><?php _e('Connection Type') ?></th>
    541551<td>
    542 <select name="ssl" id="ssl"<?php if( defined('FTP_SSL') ) echo ' disabled="disabled"' ?>>
    543 <?php
    544 foreach ( array(0 => __('No'), 1 => __('Yes')) as $key => $value ) :
    545         $selected = ($ssl == $value) ? 'selected="selected"' : '';
    546         echo "\n\t<option value='$key' $selected>" . $value . '</option>';
    547 endforeach;
    548 ?>
    549 </select>
     552<fieldset><legend class="hidden"><?php _e('Connection Type') ?> </legend>
     553<p><label><input name="connection_type"  type="radio" value="ftp" <?php checked('ftp', $connection_type); ?>    /> <?php _e('FTP') ?></label><br />
     554<label><input name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); ?> /> <?php _e('FTPS (SSL)') ?></label><br />
     555<label><input name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type); ?> /> <?php _e('SSH') ?></label></p>
     556</fieldset>
    550557</td>
    551558</tr>
    552559</table>
  • wp-admin/includes/class-wp-filesystem-ftpext.php

     
    7272                else
    7373                        $this->options['password'] = $opt['password'];
    7474
    75                 $this->options['ssl'] = ( !empty($opt['ssl']) );
     75                $this->options['ssl'] = false;
     76                if ( isset($opt['ssl']) )
     77                        $this->options['ssl'] = ( !empty($opt['ssl']) );
     78                elseif ( isset( $opt['connection_type']) )
     79                        $this->options['ssl'] = ( 'ftps' == $opt['connection_type'] );
    7680        }
    7781
    7882        function connect() {