1.下载ip类库和地址文件,并拷贝到如图目录extend/Org/Net下
模型里
<?php
namespace app\admin\model;
use think\Model;
use think\Db;
use think\captcha\Captcha;
use think\Request;
use think\Loader;
use Org\Net\IpLocation;
class Admin extends Model
{
public function login($data){
$captcha = new Captcha();
if (!$captcha->check($data['code'])) {
return 4;
}
$user=Db::name('admin')->where('username','=',$data['username'])->find();
if($user){
if($user['password'] == md5($data['password'])){
session('username',$user['username']);
session('uid',$user['id']);
/*获取登录ip*/