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>
当前名称:ThinkPHP判断IP地区位置
当前路径:https://www.cdcxhl.com/article6/ppjoig.html
成都网站建设公司_创新互联,为您提供面包屑导航、网站设计公司、网站改版、商城网站、Google、响应式网站
广告
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源:
创新互联