destoon ip接口失效修改 修改后偶尔会加载很慢

因为百度ip转换增加了密匙验证,所以导致之前的接口无法再转换ip地址的信息,修复方法如下:
打开include\cloud.func.php文件
搜索:

  1. function iplookup($ip) {

  2. $url = 'http://apistore.baidu.com/microservice/iplookup?ip='.$ip;

  3. $rec = dcurl($url);

  4. $area = '';

  5. if(strpos($rec, 'retData') !== false) {

  6. $tmp = json_decode($rec, true);

  7. $arr = $tmp['retData'];

  8. if(base64_encode($arr['country']) != '5Lit5Zu9') {

  9. if(isset($arr['country'])) $area .= $arr['country'];

  10. if(isset($arr['area'])) $area .= $arr['area'];

  11. }

  12. if(isset($arr['province'])) $area .= $arr['province'];

  13. if(isset($arr['city']) && $arr['city'] != $arr['province']) $area .= $arr['city'];

  14. if(isset($arr['district'])) $area .= $arr['district'];

  15. if(isset($arr['carrier'])) $area .= ' '.$arr['carrier'];

  16. }

  17. return $area ? convert($area, 'UTF-8', DT_CHARSET) : 'Unknown';

  18. }

复制代码

替换修改为:

  1. function iplookup($ip) {

  2. $url = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$ip;

  3. $rec = dcurl($url);

  4. $area = '';

  5. if(strpos($rec, 'data') !== false) {

  6. $tmp = json_decode($rec, true);

  7. $arr = $tmp['data'];

  8. if(base64_encode($arr['country']) != '5Lit5Zu9') {

  9. if(isset($arr['country'])) $area .= $arr['country'];

  10. if(isset($arr['area'])) $area .= $arr['area'];

  11. }

  12. if(isset($arr['region'])) $area .= $arr['region'];

  13. if(isset($arr['city']) && $arr['city'] != $arr['region']) $area .= $arr['city'];

  14. if(isset($arr['district'])) $area .= $arr['district'];

  15. if(isset($arr['isp'])) $area .= ' '.$arr['isp'];

  16. }

  17. return $area ? convert($area, 'UTF-8', DT_CHARSET) : 'Unknown';

  18. }

复制代码

上一篇:UE4 中的 C++ 编程介绍


下一篇:ZooKeeper动态增加Server(动态增加节点)的研究(待实践)