3
当网站使用CDN后获取客户端真实IP的方法
source link: https://blogread.cn/it/article/1870?f=hot1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
当网站使用CDN后获取客户端真实IP的方法
浏览:4134次 出处信息
- function get_client_ip()
- $ip=false;
- if(!empty($_SERVER["HTTP_CLIENT_IP"]))
- $ip = $_SERVER["HTTP_CLIENT_IP"];
- if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
- $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
- if ($ip)
- array_unshift($ips, $ip); $ip = FALSE;
- for ($i = 0; $i < count($ips); $i++)
- if (!eregi ("^(10|172\.16|192\.168)\.", $ips[$i]))
- $ip = $ips[$i];
- break;
- return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
建议继续学习:
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
扫一扫订阅我的微信号:IT技术博客大学习
- 作者:cevin 来源: 司徒楠,一个PHP程序员
- 标签: CDN IP
- 发布时间:2010-06-27 22:29:17
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK