Created
July 20, 2017 06:28
-
-
Save wilon/38807f3e9323040a5fe0251a45144023 to your computer and use it in GitHub Desktop.
是否是内网IP,>1为是
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
function isIplongInnerUse($ipLong) | |
{ | |
// 0.0.0.0 – 0.255.255.255 软件 | |
if ($ipLong >= 0 && $ipLong <= 16777215) return 16777215 + 1; | |
// 10.0.0.0 – 10.255.255.255 专用网络 | |
if ($ipLong >= 167772160 && $ipLong <= 184549375) return 184549375 + 1; | |
// 100.64.0.0 – 100.127.255.255 专用网络 | |
if ($ipLong >= 1681915904 && $ipLong <= 1686110207) return 1686110207 + 1; | |
// 127.0.0.0 – 127.255.255.255 主机 | |
if ($ipLong >= 2130706432 && $ipLong <= 2147483647) return 2147483647 + 1; | |
// 169.254.0.0 – 169.254.255.255 子网 | |
if ($ipLong >= 2851995648 && $ipLong <= 2852061183) return 2852061183 + 1; | |
// 172.16.0.0 – 172.31.255.255 专用网络 | |
if ($ipLong >= 2886729728 && $ipLong <= 2887778303) return 2887778303 + 1; | |
// 192.0.0.0 – 192.0.0.255 专用网络 | |
if ($ipLong >= 3221225472 && $ipLong <= 3221225727) return 3221225727 + 1; | |
// 192.0.2.0 – 192.0.2.255 文档 | |
if ($ipLong >= 3221225984 && $ipLong <= 3221226239) return 3221226239 + 1; | |
// 192.88.99.0 – 192.88.99.255 互联网 | |
if ($ipLong >= 3227017984 && $ipLong <= 3227018239) return 3227018239 + 1; | |
// 192.168.0.0 – 192.168.255.255 专用网络 | |
if ($ipLong >= 3232235520 && $ipLong <= 3232301055) return 3232301055 + 1; | |
// 198.18.0.0 – 198.19.255.255 专用网络 | |
if ($ipLong >= 3323068416 && $ipLong <= 3323199487) return 3323199487 + 1; | |
// 198.51.100.0 – 198.51.100.255 文档 | |
if ($ipLong >= 3325256704 && $ipLong <= 3325256959) return 3325256959 + 1; | |
// 203.0.113.0 – 203.0.113.255 文档 | |
if ($ipLong >= 3405803776 && $ipLong <= 3405804031) return 3405804031 + 1; | |
// 224.0.0.0 – 239.255.255.255 互联网 | |
if ($ipLong >= 3758096384 && $ipLong <= 4026531839) return 4026531839 + 1; | |
// 240.0.0.0 – 255.255.255.254 互联网 | |
if ($ipLong >= 4026531840 && $ipLong <= 4294967294) return 4294967294 + 1; | |
// 255.255.255.255 子网 | |
if ($ipLong == 4294967295) return 4294967295 + 1; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment