本文整理自网络,侵删。
本文实例讲述了帝国CMS调用新浪iplookup实现根据ip跳转到不同域名的方法。分享给大家供大家参考。
具体实现代码如下:
代码如下:
$IP_str=file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php');
$IP_tmp = explode("\n", $IP_str);
$IPcou=count($IP_tmp)-1;
$IP_tmp1 = explode(" ", $IP_tmp[0]);
if($IP_tmp1[5]){
$user_IP=$IP_tmp1[5];
}else{
$user_IP=$IP_tmp1[4];
}
if($user_IP == '上海'){
header('Location: A.php');
}elseif($user_IP == '北京'){
header('Location: B.php');
}else{
header('Location: C.php');
}
$IP_str=file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php');
$IP_tmp = explode("\n", $IP_str);
$IPcou=count($IP_tmp)-1;
$IP_tmp1 = explode(" ", $IP_tmp[0]);
if($IP_tmp1[5]){
$user_IP=$IP_tmp1[5];
}else{
$user_IP=$IP_tmp1[4];
}
if($user_IP == '上海'){
header('Location: A.php');
}elseif($user_IP == '北京'){
header('Location: B.php');
}else{
header('Location: C.php');
}
希望本文所述对大家的帝国CMS建站有所帮助。
标签:帝国CMS
相关阅读 >>
帝国CMS7.5搜索页面模板不支持灵动标签和万能标签的解决方法
discuz! x3.1 判断会员登录状态及外部调用注册登录框的实现代码
帝国CMS后台系统设置网站地址改了信息地址域名不变的解决方法
帝国CMS升级到7.0 出现unknown column 'checked' in 'field list' 错误的解决方法
更多相关阅读请进入《帝国CMS》频道 >>