PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.2.2
Defender Security – Malware Scanner, Login Security & Firewall v6.2.2
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / component / altcha / class-base-challenge-options.php

class-base-challenge-options.php in Defender Security – Malware Scanner, Login Security & Firewall 6.2.2, at src/component/altcha/class-base-challenge-options.php

61 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Base_Challenge_Options
4 *
5 * @package WP_Defender\Component\Altcha
6 */
7
8 namespace WP_Defender\Component\Altcha;
9
10 /**
11 * Base class for challenge options.
12 *
13 * @phpstan-type ChallengeParams array<string, null|scalar>
14 */
15 class Base_Challenge_Options {
16 public const DEFAULT_MAX_NUMBER = 1000000;
17
18 /**
19 * The salt used in hashing.
20 *
21 * @var string
22 */
23 public string $salt;
24
25 /**
26 * Options for creation of a new challenge.
27 *
28 * @see Challenge_Options for options with sane defaults.
29 *
30 * @param string $algorithm The hashing algorithm.
31 * @param int $max_number The maximum number associated with the challenge.
32 * @param null|\DateTimeInterface $expires Optional expiration time for the challenge.
33 * @param string $salt The salt used in hashing.
34 * @param int $number The number associated with the challenge.
35 * @param array $params Optional URL-encoded query parameters.
36 */
37 public function __construct(
38 public string $algorithm,
39 public int $max_number,
40 public ?\DateTimeInterface $expires,
41 string $salt,
42 public int $number,
43 public array $params
44 ) {
45 if ( $expires ) {
46 $params['expires'] = $expires->getTimestamp();
47 }
48
49 if ( is_array( $params ) && array() !== $params ) {
50 $salt .= '?' . http_build_query( $params );
51 }
52
53 // Add a delimiter to prevent parameter splicing.
54 if ( ! str_ends_with( $salt, '&' ) ) {
55 $salt .= '&';
56 }
57
58 $this->salt = $salt;
59 }
60 }
61