Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function get_country_code($ip_addr='')
- {
- if($ip_addr!='' && $ip_addr!=$this->ip)
- $this->set_ip($ip_addr);
- if($ip_addr=='')
- {
- if($this->ip!=$this->get_client_ip())
- $this->set_ip();
- }
- if($this->country_code!='')
- return $this->country_code;
- $sq="SELECT country_code,country_name FROM ip2country WHERE ". $this->ip_num." BETWEEN begin_ip_num AND end_ip_num";
- $r=@mysql_query($sq);
- if(!$r)
- return '';
- $row=@mysql_fetch_assoc($r);
- $this->close();
- $country_name = $row['country_name'];
- $country_code = $row['country_code'];
- $smarty->assign( "ip2c", $country_code );
- return $row['country_code'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement