Geschi wrote:Are you sure you set a timeout of 1 second? Sometimes the server have lags.
Post your code, maybe we can help you then a bit better.
<?
include("funcs.inc");
set_time_limit(0);
$http_check=1;
$ftp_check=0;
$port_scan=0;
$conn_timeout=1;
print date("H:i:s")."\n";
discoverhosts();
//#######################################
function DiscoverHosts() {
//#######################################
global $http_check, $ftp_check, $port_scan;
$scanfrom="1";
$scanto="3";
$ping_hosts=0;
$my_ip=gethostbyname("holmez");
$ips=explode(".",$my_ip);
for ($i=$scanfrom; $i<=$scanto; ++$i) {
$ip="$ips[0].$ips[1].$ips[2].$i";
if ($ping_hosts) {
exec("PING $ip",$ping);
if ($ping[3]!="Request timed out.") {
print "-------------------------\n";
print "-------------------------\n";
if (!$http_check) portscan($ip);
else CheckPort($ip);
}
} else if ($http_check) CheckPort($ip,"80");
else if ($ftp_check) CheckPort($ip,"21");
else if ($port_scan) portscan($ip);
}
//#######################################
function portscan($target) {
//#######################################
global $conn_timeout;
$f=fopen("ports.txt", "r") or die("Unable to open ports.txt for read access.");
while (!feof($f)) {
$port=trim(fgets($f,4096));
$connection=fsockopen($target,$port,$errnum,$errstr,$conn_timeout);
if ($connection) {
fclose($connection);
print "Port $port on $target\tOPEN\n";
}
print "Port $port on $target\tCLOSED\n";
}
fclose($f);
print "-------------------------\n";
}
}
//#######################################
function CheckPort($target,$port) {
//#######################################
global $conn_timeout;
$connection=fsockopen($target,$port,$errnum,$errstr,$conn_timeout);
if ($connection) {
print "Port $port on $target\tALIVE\n";
fclose($connection);
} else print "Port $port on $target\tDEAD\n";
}
print date("H:i:s")."\n";
?>