Created
October 3, 2024 20:58
-
-
Save morontt/2af7fe71c2d48cdccb4d98e96a8f469e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* examples: | |
* 10.10.85.13/32 | |
* 10.10.85.13/24 | |
*/ | |
[$subnet, $mask] = explode('/', $cidr); | |
return (ip2long($clientIP) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment