CreaCaptcha

cloudflare-proxies.php

Cloudflare-Range-Loader and refresher.

Table of Contents

Functions

creationell_captcha_cloudflare_snapshot()  : array{v4: string[], v6: string[], updated_at: string}
Returns the bundled Cloudflare snapshot.
creationell_captcha_cloudflare_ranges()  : array<string|int, string>
The active CF range list: cached option (if fresh and valid) → bundled snapshot.
creationell_captcha_refresh_cloudflare_ips_now()  : array{ok: bool, v4: int, v6: int, fetched_at: int|null, error: string|null}
Fetches the live Cloudflare ranges and writes them to the cache option.
creationell_captcha_clear_cloudflare_cache()  : bool
Deletes the cached Cloudflare-range option. The next read falls back to the bundled snapshot. Returns true when the option existed and was deleted, false when the option was absent or the delete failed.
creationell_captcha_fetch_cloudflare_list()  : array<string|int, string>
Fetches one Cloudflare endpoint and returns the valid CIDR entries.
creationell_captcha_sync_cloudflare_cron()  : void
Ensures the daily refresh cron slot is in sync with the auto-refresh toggle.

Functions

creationell_captcha_cloudflare_snapshot()

Returns the bundled Cloudflare snapshot.

creationell_captcha_cloudflare_snapshot() : array{v4: string[], v6: string[], updated_at: string}
Return values
array{v4: string[], v6: string[], updated_at: string}

creationell_captcha_cloudflare_ranges()

The active CF range list: cached option (if fresh and valid) → bundled snapshot.

creationell_captcha_cloudflare_ranges() : array<string|int, string>

The cached option is considered stale once it is older than 48 hours, shielding against a silently broken cron job.

Every entry is re-validated on read. The refresh path already filters what it fetches, but the option is a persisted value: it can predate the day is_valid_ip_or_cidr() started rejecting a prefix length of 0, and it can be written from outside this file (wp option update, a restored backup). One 0.0.0.0/0 in there turns every peer into a trusted proxy, which makes X-Forwarded-For — and with it the client IP the whole bypass chain runs on — spoofable (LK-13). The validator is the one in helpers.php, deliberately not a second copy of the rule.

A cached list that does not survive validation is not partially used: the bundled snapshot is the safer answer than a list somebody has been editing.

Return values
array<string|int, string> —

IPv4 and IPv6 CIDR ranges, merged.

creationell_captcha_refresh_cloudflare_ips_now()

Fetches the live Cloudflare ranges and writes them to the cache option.

creationell_captcha_refresh_cloudflare_ips_now() : array{ok: bool, v4: int, v6: int, fetched_at: int|null, error: string|null}
Return values
array{ok: bool, v4: int, v6: int, fetched_at: int|null, error: string|null}

creationell_captcha_clear_cloudflare_cache()

Deletes the cached Cloudflare-range option. The next read falls back to the bundled snapshot. Returns true when the option existed and was deleted, false when the option was absent or the delete failed.

creationell_captcha_clear_cloudflare_cache() : bool
Return values
bool

creationell_captcha_fetch_cloudflare_list()

Fetches one Cloudflare endpoint and returns the valid CIDR entries.

creationell_captcha_fetch_cloudflare_list(string $url) : array<string|int, string>
Parameters
$url : string
Return values
array<string|int, string>

creationell_captcha_sync_cloudflare_cron()

Ensures the daily refresh cron slot is in sync with the auto-refresh toggle.

creationell_captcha_sync_cloudflare_cron() : void

Hooked on update_option_creationell_captcha_settings (fires on every settings save). Deactivation cleanup is handled explicitly in creationell_captcha_deactivate() to avoid re-scheduling the slot during the deactivation handler.


        
On this page

Search results