SS2 FS fixes. Props DD32. fixes #8210
git-svn-id: http://svn.automattic.com/wordpress/trunk@11063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -630,7 +630,7 @@ function get_filesystem_method($args = array()) {
|
||||
unlink($temp_file);
|
||||
}
|
||||
|
||||
if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') ) $method = 'ssh2';
|
||||
if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && extension_loaded('sockets') ) $method = 'ssh2';
|
||||
if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
|
||||
if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
|
||||
return apply_filters('filesystem_method', $method);
|
||||
@@ -657,15 +657,16 @@ function request_filesystem_credentials($form_post, $type = '', $error = false)
|
||||
if ( 'direct' == $type )
|
||||
return true;
|
||||
|
||||
$credentials = get_option('ftp_credentials', array());
|
||||
$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
|
||||
|
||||
// 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)
|
||||
$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']);
|
||||
$credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']);
|
||||
$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']);
|
||||
$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : '');
|
||||
|
||||
// Check to see if we are setting the public/private keys for ssh
|
||||
$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? $_POST['public_key'] : $credentials['public_key']);
|
||||
$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? $_POST['private_key'] : $credentials['private_key']);
|
||||
$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? $_POST['public_key'] : '');
|
||||
$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? $_POST['private_key'] : '');
|
||||
|
||||
//sanitize the hostname, Some people might pass in odd-data:
|
||||
$credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
|
||||
@@ -682,7 +683,11 @@ function request_filesystem_credentials($form_post, $type = '', $error = false)
|
||||
else if ( !isset($credentials['connection_type']) || (isset($_POST['connection_type']) && 'ftp' == $_POST['connection_type']) )
|
||||
$credentials['connection_type'] = 'ftp';
|
||||
|
||||
if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
|
||||
if ( ! $error &&
|
||||
(
|
||||
( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) ||
|
||||
( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) )
|
||||
) ) {
|
||||
$stored_credentials = $credentials;
|
||||
if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
|
||||
$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
|
||||
@@ -745,7 +750,7 @@ jQuery(function($){
|
||||
<label for="public_key"><?php _e('Public Key:') ?></label ><br />
|
||||
<label for="private_key"><?php _e('Private Key:') ?></label>
|
||||
</div></th>
|
||||
<td><br /><input name="public_key" type="text" id="public_key" value=""<?php if( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value=""<?php if( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" />
|
||||
<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo attribute_escape($public_key) ?>"<?php if( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo attribute_escape($private_key) ?>"<?php if( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" />
|
||||
<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td>
|
||||
</tr>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user