wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
verify_file_md5 › WordPress Function
Seit3.7.0
Veraltetn/v
› verify_file_md5 ( $filename, $expected_md5 )
Parameter: (2) |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Calculates and compares the MD5 of a file to its expected value.
Ähnliche Funktionen: verify_file_signature, get_file_data, wp_verify_nonce, get_filesystem_method, get_real_file_to_edit
Quellcode
function verify_file_md5( $filename, $expected_md5 ) { if ( 32 === strlen( $expected_md5 ) ) { $expected_raw_md5 = pack( 'H*', $expected_md5 ); } elseif ( 24 === strlen( $expected_md5 ) ) { $expected_raw_md5 = base64_decode( $expected_md5 ); } else { return false; // Unknown format. } $file_md5 = md5_file( $filename, true ); if ( $file_md5 === $expected_raw_md5 ) { return true; } return new WP_Error( 'md5_mismatch', sprintf( /* translators: 1: File checksum, 2: Expected checksum value. */ __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) ); }