PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
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
← All changes | src/component/class-unlock-me.php +16 -10 5.7.2 → 6.3.0 View file →
@@ -41,9 +41,10 @@
41 41 *
42 42 * @return string Time string relative to current time.
43 43 */
44 44 public static function get_expired_time(): string {
45 - return (string) apply_filters( 'wpdef_firewall_unlockout_expired_time', '-30 minutes' );
45 + $expired_time = apply_filters( 'wpdef_firewall_unlockout_expired_time', '-30 minutes' );
46 + return is_string( $expired_time ) ? $expired_time : (string) $expired_time;
46 47 }
47 48
48 49 /**
49 50 * This is a receiver to unlock IP(-s) using email.
@@ -56,9 +57,9 @@
56 57 $hash = HTTP::get( 'hash', '' );
57 58 $login = HTTP::get( 'login', '' );
58 59 // Get Unlock ID(-s).
59 60 $string_uid = HTTP::get( 'uid', '' );
60 - if ( empty( $hash ) || empty( $login ) || empty( $string_uid ) ) {
61 + if ( '' === $hash || '' === $login || '' === $string_uid ) {
61 62 return false;
62 63 }
63 64
64 65 $user = get_user_by( 'login', $login );
@@ -98,11 +99,13 @@
98 99 $ips[] = $resolved_ip;
99 100 }
100 101 }
101 102
102 - // All is good. IP's were unblocked.
103 - if ( empty( $ips ) ) {
104 - return true;
103 + // No valid or pending tokens found.
104 + if ( array() === $ips ) {
105 + $this->log( 'Unlock Me. Incorrect result. No pending tokens.', Firewall::FIREWALL_LOG );
106 +
107 + return false;
105 108 }
106 109 // Work with IP's.
107 110 $ips = array_unique( $ips );
108 111 $first_ip = $ips[0];
@@ -129,9 +132,9 @@
129 132 );
130 133 }
131 134 } else {
132 135 $ip = Lockout_Ip::get_unlocked_ip_by( $first_ip );
133 - if ( ! empty( $ip ) ) {
136 + if ( '' !== $ip ) {
134 137 $this->log(
135 138 'Unlock Me. Success. IP ' . $ip . ' have been unblocked from Active lockouts.',
136 139 Firewall::FIREWALL_LOG
137 140 );
@@ -185,9 +188,9 @@
185 188 *
186 189 * @return bool
187 190 */
188 191 public static function is_displayed( string $reason, array $ips ): bool {
189 - $excluded_reasons = (array) apply_filters(
192 + $excluded_reasons = apply_filters(
190 193 'wpdef_firewall_unlockout_excluded_reasons',
191 194 array(
192 195 'country',
193 196 'demo',
@@ -192,11 +195,13 @@
192 195 'country',
193 196 'demo',
194 197 )
195 198 );
196 - $is_displayed = ! in_array( $reason, $excluded_reasons, true ) && ! empty( $ips );
199 + $excluded_reasons = is_array( $excluded_reasons ) ? $excluded_reasons : (array) $excluded_reasons;
200 + $is_displayed = ! in_array( $reason, $excluded_reasons, true ) && array() !== $ips;
201 + $is_displayed = apply_filters( 'wpdef_firewall_unlockout_is_displayed', $is_displayed );
197 202
198 - return (bool) apply_filters( 'wpdef_firewall_unlockout_is_displayed', $is_displayed );
203 + return is_bool( $is_displayed ) ? $is_displayed : (bool) $is_displayed;
199 204 }
200 205
201 206 /**
202 207 * Get the limit of failed attempts.
@@ -203,9 +208,10 @@
203 208 *
204 209 * @return int
205 210 */
206 211 public static function get_attempt_limit(): int {
207 - return (int) apply_filters( 'wpdef_firewall_unlockout_attempt_limit', 5 );
212 + $limit = apply_filters( 'wpdef_firewall_unlockout_attempt_limit', 5 );
213 + return is_int( $limit ) ? $limit : (int) $limit;
208 214 }
209 215
210 216 /**
211 217 * Creates a URL for unlocking based on email, user login, and UID array.