Changeset 40729 for branches/4.2/src/wp-admin/includes/file.php
- Timestamp:
- 05/16/2017 02:53:56 PM (8 years ago)
- Location:
- branches/4.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.2
-
branches/4.2/src/wp-admin/includes/file.php
r32324 r40729 1031 1031 $credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => '')); 1032 1032 1033 $submitted_form = wp_unslash( $_POST ); 1034 1035 // Verify nonce, or unset submitted form field values on failure 1036 if ( ! isset( $_POST['_fs_nonce'] ) || ! wp_verify_nonce( $_POST['_fs_nonce'], 'filesystem-credentials' ) ) { 1037 unset( 1038 $submitted_form['hostname'], 1039 $submitted_form['username'], 1040 $submitted_form['password'], 1041 $submitted_form['public_key'], 1042 $submitted_form['private_key'], 1043 $submitted_form['connection_type'] 1044 ); 1045 } 1046 1033 1047 // 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) 1034 $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($ _POST['hostname']) ? wp_unslash( $_POST['hostname'] ): $credentials['hostname']);1035 $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($ _POST['username']) ? wp_unslash( $_POST['username'] ): $credentials['username']);1036 $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($ _POST['password']) ? wp_unslash( $_POST['password'] ): '');1048 $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($submitted_form['hostname']) ? $submitted_form['hostname'] : $credentials['hostname']); 1049 $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($submitted_form['username']) ? $submitted_form['username'] : $credentials['username']); 1050 $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($submitted_form['password']) ? $submitted_form['password'] : ''); 1037 1051 1038 1052 // Check to see if we are setting the public/private keys for ssh 1039 $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($ _POST['public_key']) ? wp_unslash( $_POST['public_key'] ): '');1040 $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($ _POST['private_key']) ? wp_unslash( $_POST['private_key'] ): '');1053 $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($submitted_form['public_key']) ? $submitted_form['public_key'] : ''); 1054 $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($submitted_form['private_key']) ? $submitted_form['private_key'] : ''); 1041 1055 1042 1056 // Sanitize the hostname, Some people might pass in odd-data: … … 1055 1069 } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL 1056 1070 $credentials['connection_type'] = 'ftps'; 1057 } elseif ( ! empty( $ _POST['connection_type'] ) ) {1058 $credentials['connection_type'] = wp_unslash( $_POST['connection_type'] );1071 } elseif ( ! empty( $submitted_form['connection_type'] ) ) { 1072 $credentials['connection_type'] = $submitted_form['connection_type']; 1059 1073 } elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP 1060 1074 $credentials['connection_type'] = 'ftp'; … … 1189 1203 <?php 1190 1204 foreach ( (array) $extra_fields as $field ) { 1191 if ( isset( $ _POST[ $field ] ) )1192 echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] )) . '" />';1205 if ( isset( $submitted_form[ $field ] ) ) 1206 echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />'; 1193 1207 } 1194 1208 ?> 1195 1209 <p class="request-filesystem-credentials-action-buttons"> 1210 <?php wp_nonce_field( 'filesystem-credentials', '_fs_nonce', false, true ); ?> 1196 1211 <button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button> 1197 1212 <?php submit_button( __( 'Proceed' ), 'button', 'upgrade', false ); ?>
Note: See TracChangeset
for help on using the changeset viewer.