Limit ebook downloads per IP address

This commit is contained in:
Mike Colagrosso 2025-07-16 18:20:30 -06:00 committed by Alex Cabal
parent 6c69ee0bdf
commit 0a71382a25
4 changed files with 58 additions and 9 deletions

View file

@ -149,6 +149,17 @@ class Formatter{
return $output;
}
/**
* Format a valid IPv4 address to IPv6. Other strings are unchanged.
*/
public static function ToIpv6(?string $ipAddress): ?string{
if(filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
return '::ffff:' . $ipAddress;
}
return $ipAddress;
}
/**
* Format a float into a USD currency string. The result is prepended with `$`.
*