1.在Action目錄下添加如下代碼
- public function index(){
- $where = 'TRUE';
- $membersModel = new Model("Members");
- $rows = $membersModel->where($where)->select();
-
- if($rows){
- import('ORG.Net.IpLocation');// 導(dǎo)入IpLocation類(lèi)
- $Ip = new IpLocation('UTFWry.dat'); // 實(shí)例化類(lèi) 參數(shù)表示IP地址庫(kù)文件。下載dat文件到net目錄下
- foreach ($rows as $k=>$v){
- $area = $Ip->getlocation($v['regIP']);
- $rows[$k]['location'] = isset($area['country'])?$area['country']:'未知地址';// 獲取某個(gè)IP地址所在的位置
- }
- }
- $this->assign('rows',$rows);
- $this->display();
- }
2.在html頁(yè)面上添加
- <table class="table table-striped table-hover table-condensed">
- <tr>
- <th>用戶名</th>
- <th>郵箱</th>
- <th>注冊(cè)時(shí)間</th>
- <th>注冊(cè)IP</th>
- <th>激活狀態(tài)</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>
當(dāng)前名稱:ThinkPHP判斷IP地區(qū)位置
當(dāng)前路徑:http://jinyejixie.com/article6/ppjoig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站改版、商城網(wǎng)站、Google、響應(yīng)式網(wǎng)站
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源:
創(chuàng)新互聯(lián)