ThinkPHP判断IP地区位置
admin
2023-07-05 10:44:41
0次
1.在Action目录下添加如下代码
点击(此处)折叠或打开
- public function index(){
- $where = 'TRUE';
- $membersModel = new Model("Members");
- $rows = $membersModel->where($where)->select();
-
- if($rows){
- import('ORG.Net.IpLocation');// 导入IpLocation类
- $Ip = new IpLocation('UTFWry.dat'); // 实例化类 参数表示IP地址库文件。下载dat文件到net目录下
- foreach ($rows as $k=>$v){
- $area = $Ip->getlocation($v['regIP']);
- $rows[$k]['location'] = isset($area['country'])?$area['country']:'未知地址';// 获取某个IP地址所在的位置
- }
- }
- $this->assign('rows',$rows);
- $this->display();
- }
2.在html页面上添加
点击(此处)折叠或打开
- <table class="table table-striped table-hover table-condensed">
- <tr>
- <th>用户名</th>
- <th>邮箱</th>
- <th>注册时间</th>
- <th>注册IP</th>
- <th>激活状态</th>
- </tr>
-
- <volist name="rows" id="v">
- <tr>
- <th>{$v.username}</th>
- <th>{$v.email}</th>
- <th>{:date('Y-m-d H:i:s',$v['regTime'])}</th>
- <th>{$v.location}{$v.regIP}</th>
- <th><eq name="v.status" value="0"><span style="color: red">未激活</span><else/><span style="color:blue">已激活</span></eq></th>
-
- </tr>
- </volist>
- </table>
相关内容
空调哪个符号是除湿的
空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
空调用多长时间需要加氟一次
一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
空调开多久需要休息多长时间
问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次
1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次
看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...