255 || $Octets[1] < 0 || $Octets[1] > 255 || $Octets[2] < 0 || $Octets[2] > 255 || $Octets[3] < 0 || $Octets[3] > 255 || $Octets[0] == 127 || ($Octets[0] == 192 && $Octets[1] == 168) ) { die('Invalid IP.'); } $Output = explode(' ',shell_exec('host -W 1 '.escapeshellarg($_GET['ip']))); if(count($Output) == 1 && empty($Output[0])) { //No output at all implies the command failed trigger_error("get_host() command failed with no output, ensure that the host command exists on your system and accepts the argument -W"); } if(count($Output)!=5) { die('Could not retrieve host.'); } else { die($Output[4]); }