'', 'ip' => $ip, 'path' => Rabbitproof_Guard::path( $uri ), ), Rabbitproof_Api::CHECK_TIMEOUT ); if ( is_wp_error( $answer ) || 200 !== $answer['_status'] ) { Rabbitproof_Guard::unreachable(); self::remember( $key, 'watch', self::RETRY ); return ''; } $what = ! empty( $answer['block'] ) ? 'block' : 'watch'; self::remember( $key, $what, self::REMEMBER ); return $what; } private static function recall( $key ) { $m = get_option( self::MEMORY, array() ); return is_array( $m ) && isset( $m[ $key ][0], $m[ $key ][1] ) && (int) $m[ $key ][1] > time() ? (string) $m[ $key ][0] : ''; } private static function remember( $key, $what, $for ) { $now = time(); $m = get_option( self::MEMORY, array() ); $m = is_array( $m ) ? array_filter( $m, function ( $e ) use ( $now ) { return is_array( $e ) && isset( $e[1] ) && (int) $e[1] > $now; } ) : array(); $m[ $key ] = array( $what, $now + (int) $for ); if ( count( $m ) > self::MEMORY_MAX ) { uasort( $m, function ( $a, $b ) { return (int) $a[1] - (int) $b[1]; } ); $m = array_slice( $m, -self::MEMORY_MAX, null, true ); } update_option( self::MEMORY, $m, false ); } private static function refuse() { status_header( 403 ); nocache_headers(); header( 'Content-Type: text/plain; charset=utf-8' ); header( 'X-Robots-Tag: noindex' ); echo 'Forbidden'; exit; } }