Ejemplo n.º 1
0
 function get_domain($_ip)
 {
     $config =& SlimStatConfig::get_instance();
     $hostname = SlimStat::get_host($_ip, false);
     if ($hostname == $_ip) {
         return $_ip;
     } else {
         $portions = explode(".", $hostname);
         $portions = array_reverse($portions);
         if (sizeof($portions) > 2 && strlen($portions[0]) == 2 && (strlen($portions[1]) == 2 || preg_match("/^(org?|com?|net?|gov|nhs|edu|mod)\$/i", $portions[1]))) {
             $domain = $portions[2] . "." . $portions[1] . "." . $portions[0];
         } elseif (sizeof($portions) > 1) {
             $domain = $portions[1] . "." . $portions[0];
         } else {
             $domain = $portions[0];
         }
         return $domain;
         //return ( preg_match( "/[0-9]{1,3}\.[0-9]{1,3}/", $domain ) ) ? $_ip : $domain;
     }
 }