WPCF7_Submission::verify_posted_data_hash()
Verifies that the given string is equivalent to the posted data hash.
Метод класса: WPCF7_Submission{}
Хуков нет.
Возвращает
int|true|false
. 1 if $hash is created 0-30 minutes ago,
2 if $hash is created 30-60 minutes ago, false if $hash is invalid.
Использование
$WPCF7_Submission = new WPCF7_Submission(); $WPCF7_Submission->verify_posted_data_hash( $hash );
- $hash(строка)
- This value will be compared to the current posted data hash for the submission. If not specified, the value of $_POST['_wpcf7_posted_data_hash'] will be used.
По умолчанию: ''
Код WPCF7_Submission::verify_posted_data_hash() WPCF7 Submission::verify posted data hash CF7 5.7.7
public function verify_posted_data_hash( $hash = '' ) { if ( '' === $hash and ! empty( $_POST['_wpcf7_posted_data_hash'] ) ) { $hash = trim( $_POST['_wpcf7_posted_data_hash'] ); } if ( '' === $hash ) { return false; } $tick = $this->posted_data_hash_tick(); // Hash created 0-30 minutes ago. $expected_1 = $this->create_posted_data_hash( $tick ); if ( hash_equals( $expected_1, $hash ) ) { return 1; } // Hash created 30-60 minutes ago. $expected_2 = $this->create_posted_data_hash( $tick - 1 ); if ( hash_equals( $expected_2, $hash ) ) { return 2; } return false; }