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>
|