= self::MIN_AGE && $age <= self::MAX_AGE; } /** * A látogató IP-je: alapból REMOTE_ADDR (az X-Forwarded-For hamisítható, * a throttle-t kikerülné). „Az oldal Cloudflare mögött van” kapcsolóval a * CF-Connecting-IP — de csak Cloudflare-tartományból jövő kérésnél. Más * CDN/proxy mögött a host a filterrel adhatja meg a valódi címet. */ public static function client_ip(): string { $ip = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '0.0.0.0'; if ( ! empty( FormSettings::load()['behind_cloudflare'] ) ) { $visitor = CloudflareRanges::visitor_ip(); if ( null !== $visitor ) { $ip = $visitor; } } /** * A beküldő IP-je a throttle-hoz és a consent-naplóhoz. * * @param string $ip REMOTE_ADDR, vagy Cloudflare mögött a CF-Connecting-IP */ $filtered = apply_filters( 'mowl_client_ip', $ip ); return is_string( $filtered ) && '' !== trim( $filtered ) ? sanitize_text_field( $filtered ) : $ip; } /** Számláló transientben; a 11. beküldés 10 percen belül elakad. */ private static function throttled( string $ip ): bool { return (int) get_transient( self::rate_key( $ip ) ) >= self::RATE_LIMIT; } /** * Egy beküldés beszámítása a throttle-ba. A handler csak az alap * e-mail-ellenőrzés után hívja, hogy egy hibás cím ne fogyassza a keretet. */ public static function record_attempt( string $ip ): void { $key = self::rate_key( $ip ); set_transient( $key, (int) get_transient( $key ) + 1, self::RATE_WINDOW ); } private static function rate_key( string $ip ): string { return 'mowl_rl_' . md5( $ip ); } }