I have this script
<?php
function get_reverse_dns($Ip)
{
$result = exec("nslookup -n ".escapeshellarg($Ip)." | grep 'name = '");
if(strpos($result,"name =") === false)
{
return "NO REVERSE";
}
else
{
$result = trim($result);
$ExplodedResult = explode("name =",$result);
$ExplodedResult[1] = trim($ExplodedResult[1]);
$ReverseDns = trim($ExplodedResult[1],".");
return $ReverseDns;
}
}
?>
that gives me the reverse dns, now the problem is that sometimes, an IP can have a really long delay, and i want that this script to check it the IP can be "looked up", and if 5 seconds passed and this is not happening, then return false
How can i make that?
I have tried in linux
nslookup --timeout 5 1.1.1.1 | grep 'name = '
timeout 5 nslookup 1.1.1.1 | grep 'name = '
Thanks.