//地区限制
if($config['area']!=='全国'){
require('ipclass.php');
$iplocation = new IpLocation();   
$location = $iplocation->getlocation($ip);   
$country=to_utf8($location['country']);
$config_country=$config['area'].$config['city'];
$country2=str_replace('地区','',$config_country);
if($country!==$country2){
exit('您的地区IP不在此文章浏览范围之内,禁止浏览');
}
}这个代码是限制注册ID 用的 想把这个代码嵌入到文章里面,文章的数据表中也添加了area(省) city(城市)两个字段代码中ipclass.php可以获取浏览者ip 如何实现与数据库中一篇文章的地区对比呢,config是源码里面的一个文件 不能从这调取  想从数据库中调取

解决方案 »

  1.   

    万事俱备,只欠东风
    https://www.baidu.com/s?wd=ip%20地址%20接口&rsv_spt=1&rsv_iqid=0xaf98333700033bd6&issp=1&f=8&rsv_bp=0&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=1&rsv_sug3=5&rsv_sug1=5&rsv_sug7=100&rsv_sug2=0&inputT=2390&rsv_sug4=2391
      

  2.   

    假定你从数据库中读取的数据保存在 $row 中
    就将你主贴的代码中的 $config 改成 $row