Language: EN FR PT ES NL DE SV RU
<?php 
class PUGClass {
    private 
$chan_regs = array ('#pugbot' => 'na','#urtpickup' => 'eu','#urtpickup.ts' => 'eu','#pugbot-priv' => 'na','#urtpickup.admins' => 'eu','#pugbot.eu' => 'eu','#pugbot.eu.ts' => 'eu' );
    
    public function 
ip2region($ip) {

    
// split up the IP into 4 parts (octets) 
    
$playerip_array explode(".",$ip);
    
$ip1            $playerip_array[0];
    
$ip2            $playerip_array[1];
    
$ip3            $playerip_array[2];
    
$ip4            $playerip_array[3];
    
    
// set ip key
    
$playeripkey    = (($ip1*256+$ip2)*256+$ip3)*256 $ip4;
    
    
// geolcation
    
$geolocation    mysql_fetch_array(mysql_query("SELECT * FROM `ip_group_city` where `ip_start` <= '$playeripkey' order by ip_start desc limit 1;"));
    
$ccode          $geolocation['country_code'];
    return 
$this->ccode2region($ccode);
    }
    
    public function 
ip2channel($ip) {
        
$region  $this->ip2region($ip);
        
$channel $this->region2channel($region);
        return 
$channel;
    }
    
    public function 
region2channel($region) {
        switch (
$region) {
            case 
"au" :
                
$channel "pugbot.au";
                break;
            case 
"na" :
                
$channel "pugbot";
                break;
            case 
"eu" :
                
$channel "pugbot.eu";
                break;
            case 
"sa" :
                
$channel "pugbot.sa";
                break;
            default :
                
$channel "pugbot";
                break;
        }
        return 
$channel;
    }
    
    
    public function 
ccode2region($ccode) {
        switch (
$ccode) {
            case 
"AU":
                
$reg_pref "na";
                break;
            case 
"US":
                
$reg_pref "na";
                break;
            case 
"CA":
                
$reg_pref "na";
                break;
            case 
"MX":
                
$reg_pref "na";
                break;
            case 
"BR":
                
$reg_pref "na";
                break;
            case 
"CO":
                
$reg_pref "na";
                break;
            case 
"NZ":
                
$reg_pref "na";
                break;
            case 
"VE":
                
$reg_pref "na";
                break;
            case 
"UY":
                
$reg_pref "na";
                break;
            case 
"PE":
                
$reg_pref "na";
                break;
            case 
"CL":
                
$reg_pref "na";
                break;
            case 
"AR":
                
$reg_pref "na";
                break;
            case 
"HN":
                
$reg_pref "na";
                break;
            case 
"NL":
                
$reg_pref "eu";
                break;
            case 
"PT":
                
$reg_pref "eu";
                break;
            case 
"ES":
                
$reg_pref "eu";
                break;
            case 
"RO":
                
$reg_pref "eu";
                break;
            case 
"DK":
                
$reg_pref "eu";
                break;
            case 
"DE":
                
$reg_pref "eu";
                break;
            case 
"GB":
                
$reg_pref "eu";
                break;
            case 
"SE":
                
$reg_pref "eu";
                break;
            case 
"NO":
                
$reg_pref "eu";
                break;
            case 
"RU":
                
$reg_pref "eu";
                break;
            case 
"TR":
                
$reg_pref "eu";
                break;
            case 
"FR":
                
$reg_pref "eu";
                break;
            case 
"IT":
                
$reg_pref "eu";
                break;
            case 
"CZ":
                
$reg_pref "eu";
                break;
            case 
"HK":
                
$reg_pref "na";
                break;
            case 
"NC":
                
$reg_pref "na";
                break;
            case 
"CN":
                
$reg_pref "na";
                break;
            default :
                
$reg_pref "na";
                break;
        }
        return 
$reg_pref;
    }

    public function 
get_region($chan$ccode) {
        
//if (isset($this->chan_regs[$chan])) {
        //    return $this->chan_regs[$chan];
        //} else {
            
return $this->ccode2region($ccode);
        
//}
    
}
}
?>