Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public function get_country_code($ip_addr='')
  2. {
  3. if($ip_addr!='' && $ip_addr!=$this->ip)
  4. $this->set_ip($ip_addr);
  5.  
  6. if($ip_addr=='')
  7. {
  8. if($this->ip!=$this->get_client_ip())
  9. $this->set_ip();
  10. }
  11.  
  12. if($this->country_code!='')
  13. return $this->country_code;
  14.  
  15.  
  16.  
  17. $sq="SELECT country_code,country_name FROM ip2country WHERE ". $this->ip_num." BETWEEN begin_ip_num AND end_ip_num";
  18. $r=@mysql_query($sq);
  19.  
  20. if(!$r)
  21. return '';
  22.  
  23. $row=@mysql_fetch_assoc($r);
  24. $this->close();
  25.  
  26. $country_name = $row['country_name'];
  27. $country_code = $row['country_code'];
  28.  
  29. $smarty->assign( "ip2c", $country_code );
  30. return $row['country_code'];
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement