Changeset 50701
- Timestamp:
- 04/12/2021 06:32:39 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r50700 r50701 2160 2160 } 2161 2161 2162 // 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). 2163 $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : ( ! empty( $submitted_form['hostname'] ) ? $submitted_form['hostname'] : $credentials['hostname'] ); 2164 $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : ( ! empty( $submitted_form['username'] ) ? $submitted_form['username'] : $credentials['username'] ); 2165 $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ( ! empty( $submitted_form['password'] ) ? $submitted_form['password'] : '' ); 2166 2167 // Check to see if we are setting the public/private keys for ssh. 2168 $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ( ! empty( $submitted_form['public_key'] ) ? $submitted_form['public_key'] : '' ); 2169 $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ( ! empty( $submitted_form['private_key'] ) ? $submitted_form['private_key'] : '' ); 2162 $ftp_constants = array( 2163 'hostname' => 'FTP_HOST', 2164 'username' => 'FTP_USER', 2165 'password' => 'FTP_PASS', 2166 'public_key' => 'FTP_PUBKEY', 2167 'private_key' => 'FTP_PRIKEY', 2168 ); 2169 2170 // If defined, set it to that. Else, if POST'd, set it to that. If not, set it to an empty string. 2171 // Otherwise, keep it as it previously was (saved details in option). 2172 foreach ( $ftp_constants as $key => $constant ) { 2173 if ( defined( $constant ) ) { 2174 $credentials[ $key ] = constant( $constant ); 2175 } elseif ( ! empty( $submitted_form[ $key ] ) ) { 2176 $credentials[ $key ] = $submitted_form[ $key ]; 2177 } elseif ( ! isset( $credentials[ $key ] ) ) { 2178 $credentials[ $key ] = ''; 2179 } 2180 } 2170 2181 2171 2182 // Sanitize the hostname, some people might pass in odd data.
Note: See TracChangeset
for help on using the changeset viewer.