Ticket #7690: 7690.2.diff
| File 7690.2.diff, 5.3 KB (added by , 17 years ago) |
|---|
-
wp-admin/includes/file.php
448 448 449 449 require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); 450 450 451 $method = get_filesystem_method( );451 $method = get_filesystem_method($args); 452 452 453 453 if ( ! $method ) 454 454 return false; … … 471 471 return true; 472 472 } 473 473 474 function get_filesystem_method( ) {474 function get_filesystem_method($args = array()) { 475 475 $method = false; 476 476 if( function_exists('getmyuid') && function_exists('fileowner') ){ 477 477 $temp_file = wp_tempnam(); … … 480 480 unlink($temp_file); 481 481 } 482 482 483 if ( isset($args['connection_type']) && 'ssh' == $args['connection_type'] ) { 484 $method = 'SSH2'; 485 return apply_filters('filesystem_method', $method); 486 } 487 483 488 if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; 484 489 if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread 485 490 return apply_filters('filesystem_method', $method); … … 493 498 if ( empty($type) ) 494 499 $type = get_filesystem_method(); 495 500 496 if ( 'direct' == $type )497 return true;501 // if ( 'direct' == $type ) 502 // return true; 498 503 499 504 if( ! $credentials = get_option('ftp_credentials') ) 500 505 $credentials = array(); … … 502 507 $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']); 503 508 $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); 504 509 $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'; 506 516 507 517 if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) { 508 518 $stored_credentials = $credentials; … … 525 535 <p><?php _e('To perform the requested action, FTP connection information is required.') ?></p> 526 536 <table class="form-table"> 527 537 <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> 529 539 <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> 530 540 </tr> 531 541 <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> 533 543 <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> 534 544 </tr> 535 545 <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> 537 547 <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> 538 548 </tr> 539 549 <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> 541 551 <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> 550 557 </td> 551 558 </tr> 552 559 </table> -
wp-admin/includes/class-wp-filesystem-ftpext.php
72 72 else 73 73 $this->options['password'] = $opt['password']; 74 74 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'] ); 76 80 } 77 81 78 82 function connect() {