Make WordPress Core


Ignore:
Timestamp:
09/11/2008 05:44:43 PM (18 years ago)
Author:
ryan
Message:

Handle ssh keys in ssf2 fs. Props ShaneF. see #7690

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r8852 r8865  
    406406                        $tmppath = $to . implode('/', array_slice($path, 0, $i) );
    407407                        if ( $fs->is_dir($tmppath) ) {//Found the highest folder that exists, Create from here
    408                                 for ( $i = $i + 1; $i < count($path); $i++ ) { //< count() no file component please.
     408                                for ( $i = $i + 1; $i <= count($path); $i++ ) { //< count() no file component please.
    409409                                        $tmppath = $to . implode('/', array_slice($path, 0, $i) );
    410410                                        if ( ! $fs->mkdir($tmppath, 0755) )
    … …  
    511511        $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']);
    512512       
     513        // Check to see if we are setting the public/private keys for ssh
     514        $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? $_POST['public_key'] : $credentials['public_key']);
     515        $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? $_POST['private_key'] : $credentials['private_key']);               
     516       
    513517        if ( strpos($credentials['hostname'], ':') )
    514518                list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
    … …  
    523527        if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
    524528                $stored_credentials = $credentials;
    525                 unset($stored_credentials['password']);
     529                unset($stored_credentials['password'], $stored_credentials['private_key'], $stored_credentials['public_key']);
    526530                update_option('ftp_credentials', $stored_credentials);
    527531                return $credentials;
    … …  
    540544        }
    541545?>
     546<script type="text/javascript">
     547<!--
     548jQuery(function($){
     549        jQuery("#ssh").click(function () {
     550                jQuery("#ssh_keys").show();             
     551        });
     552        jQuery("#ftp").click(function () {
     553                jQuery("#ssh_keys").hide();             
     554        });     
     555        jQuery("#ftps").click(function () {
     556                jQuery("#ssh_keys").hide();             
     557        });
     558        jQuery(document).ready(function(){
     559                if ( jQuery("#ssh:checked").length )
     560                {
     561                        jQuery("#ssh_keys").show();
     562                }
     563        });
     564});
     565-->
     566</script>
    542567<form action="<?php echo $form_post ?>" method="post">
    543568<div class="wrap">
    … …  
    557582<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>
    558583</tr>
     584<tr id="ssh_keys" valign="top" style="display:none">
     585<th scope="row"><label id="keys" for="keys"><?php _e('Authentication Keys') ?></label></th>
     586<td><label for="public_key"><?php _e('Public Key:') ?></label ><input name="public_key" type="text" id="public_key" value=""<?php if( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /> <label for="private_key"><?php _e('Private Key:') ?></label> <input name="private_key" type="text" id="private_key" value=""<?php if( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" /><br/><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>
     587</tr>
    559588<tr valign="top">
    560589<th scope="row"><?php _e('Connection Type') ?></th>
    561590<td>
    562591<fieldset><legend class="hidden"><?php _e('Connection Type') ?> </legend>
    563 <p><label><input name="connection_type"  type="radio" value="ftp" <?php checked('ftp', $connection_type); ?>    /> <?php _e('FTP') ?></label><br />
    564 <label><input name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); ?> /> <?php _e('FTPS (SSL)') ?></label><br />
    565 <?php if ( extension_loaded('ssh2') ) { ?><label><input name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type); ?> /> <?php _e('SSH') ?></label><?php } ?></p>
     592<p><label><input id="ftp" name="connection_type"  type="radio" value="ftp" <?php checked('ftp', $connection_type); ?>   /> <?php _e('FTP') ?></label><br />
     593<label><input id="ftps" name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); ?> /> <?php _e('FTPS (SSL)') ?></label><br />
     594<?php if ( extension_loaded('ssh2') ) { ?><label><input id="ssh" name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type); ?> /> <?php _e('SSH') ?></label><?php } ?></p>
    566595</fieldset>
    567596</td>
Note: See TracChangeset for help on using the changeset viewer.