php代码
<script language="javascript" type="text/javascript" src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script> <script language="javascript" type="text/javascript"> var city = remote_ip_info['city']; if(city == '北京' || city == '成都' ){ document.write("感谢来访,我们正在建设中,需要很长时间。请过些时候来访问"); }else{ } </script>
<?php /* +--------------------------------------------+ +程序授权说明 + +作者:森林 + +--------------------------------------------+ */ //-------------------------函数封装------------------------------------ function ipdy($ipaddr) { $oo0ooo=base64_decode('aHR0cDovL2lwLnRhb2Jhby5jb20vc2VydmljZS9nZXRJcEluZm8ucGhwP2lwPQ=='); $ipInfoApi= $oo0ooo.$ipaddr; $areaInfo= file_get_contents($ipInfoApi); $areaInfo= json_decode($areaInfo); $ipjg=$areaInfo->data->country.$areaInfo->data->area.$areaInfo->data->region.$areaInfo->data->city.$areaInfo->data->isp; $ipjg=iconv('UTF-8','GBK',$ipjg); return $ipjg; } //----------------IP----------- function get_real_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']); } //--------------------------------- $ip=get_real_ip(); $ip_str=ipdy($ip)
<?php /* +--------------------------------------------+ +程序授权说明:该版本为GBK版即网页为GBK编码 + +作者:森林 + */ include("ip_config.php"); //------------------------------以下根据情况修改------------------------ if(stristr($ip_str,'北京') || stristr($ip_str,'广东')){ exit("感谢来访,我们正在建设中,需要很长时间。请过些时候来访问。"); }