Segue aí um script para resolver IP para HOST e HOST para IP...
Qualquer dúvida, tamos aê...<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br">
<head>
<title>IP para HOST para IP</title>
<style>
<!--
.caixa {
width:300px;
margin-bottom:30px;
padding:5px 5px 4px 5px;
border:1px solid #DDD;
background:#EEE;
text-align:left;
}
.titulo {
font-family:Verdana;
padding:2px 5px 2px 5px;
font-size:9pt;
font-weight:bold;
border:1px solid #DDD;
background:#FFF;
}
.conteudo {
padding:2px 5px 2px 5px;
font-size:8pt;
font-family:Verdana;
border:#DDD 1px solid;
border-top:0px;
}
input {
font-family:Verdana;
font-size:8pt;
background-color:#EEE;
border:#DDD 1px solid;
}
a {
font-family:Verdana;
font-size:8pt;
font-weight:bold;
text-decoration:none;
color:green;
//-->
</style>
</head>
<body>
<?
function Alerta($titulo,$msg){
echo "<div class=\"caixa\">
<div class=\"titulo\">".$titulo."</div>
<div class=\"conteudo\">".$msg."</div>
</div>";
}
?>
<?
$porta="80";
if ($HTTP_POST_VARS["submit_ip"] && $HTTP_POST_VARS["endereco_ip"])
{
$host=gethostbyaddr($HTTP_POST_VARS["endereco_ip"]);
if ($host==$HTTP_POST_VARS["endereco_ip"])
Alerta("Erro","O endereço IP não é valido ou o host não foi encontrado");
else
Alerta("Resultado","O host de <u>".$HTTP_POST_VARS["endereco_ip"]."</u> é: </u> <strong>".$host."</strong>");
if (!$fp1=@fsockopen($HTTP_POST_VARS["endereco_ip"],$porta,$erro_numero,$erro,30))
Alerta("Informação","Situação: <strong>Offline</strong>");
else
Alerta("Informação","Situação: <strong>Online</strong>");
echo "<a href=\"#\" onclick=\"history.go(-1);\">Voltar</a>";
exit;
}
elseif ($HTTP_POST_VARS["submit_host"] && $HTTP_POST_VARS["host"])
{
$endereco_ip=gethostbyname($HTTP_POST_VARS["host"]);
if ($endereco_ip==$HTTP_POST_VARS["host"])
Alerta("Erro","O host não é válido ou o endereço IP não foi encontrado");
else
Alerta("Resultado","O IP do domínio <u>".$HTTP_POST_VARS["host"]."</u> é: <strong>".$endereco_ip."</strong>");
if (!$fp1=@fsockopen($endereco_ip,$porta,$erro_numero,$erro,30))
Alerta("Informação","Situação: <strong>Offline</strong>");
else
Alerta("Informação","Situação: <strong>Online</strong>");
exit;
}
if ($HTTP_POST_VARS["submit_host"] || $HTTP_POST_VARS["submit_ip"])
Alerta("Erro","Digite o \"Endereço IP\" ou \"Host\".");
echo "
<form method=\"post\" action=\"$PHP_SELF\">
<div class=\"caixa\">
<div class=\"titulo\">IP para HOST</div>
<div class=\"conteudo\">
<strong>Endereço IP:</strong>
<input type=\"text\" name=\"endereco_ip\" size=\"15\">
<input type=\"submit\" name=\"submit_ip\"value=\"Resolver\">
</div>
<br />
<div class=\"titulo\">HOST para IP</div>
<div class=\"conteudo\">
<strong>Host:</strong> http://
<input type=\"text\" name=\"host\" size=\"15\">
<input type=\"submit\" name=\"submit_host\"value=\"Resolver\">
</div>
</div>
</div>
</div>
</div>
</form>
</p>";
?>
</body>
</html>
Flw's, T+V! Até mais