thinkphp3.2根据ip判断地址

<?php
public function ip(){
  $yip=get_client_ip();
  $Ip = new   \Org\Net\IpLocation('UTFWry.dat'); 
  $area = $Ip->getlocation($yip);
  $address=$area['country'].$area['area'];
  $this->assign('yip',$yip);
  $this->assign('address',$address);
  $this->display();
}
    
public function cip(){  
  $ipp=$_POST['ipp'];
  $is=isip($ipp);
  if($is){
    $Ip = new   \Org\Net\IpLocation('UTFWry.dat'); 
    $area = $Ip->getlocation($ipp);
    $cip=$area['ip'];
    $address=$area['country'].$area['area'];
    $this->assign('cip',$cip);
    $this->assign('address',$address);
    $this->display();
  } else {
    $this->error('Not ip','ip');
  }
}

你可能感兴趣的:(thinkphp3.2根据ip判断地址)