phpircbot2/commands/#botted.channel.php

31 lines
714 B
PHP
Raw Normal View History

<?php
#BOT_INCLUDE "#botted" "channel" "0"
if(!function_exists("ping_ip")){
function ping_ip($ip){
$r = "";
$cmd = "ping ".escapeshellarg($ip)." -c 1 -w 1";
echo $cmd."\n";
$p = popen($cmd, "r");
while(!feof($p)) $r .= fread($p, 16384);
pclose($p);
if(preg_match("/time=/", $r)) return true;
else return false;
}
}
foreach($this -> ipcs AS $ip => $data){
if(time() - $data["lastcheck"] > 10){
$result = ping_ip($ip);
$status = ($result) ? "Online" : "Offline";
if($data["status"] != $result) $this -> call("privmsg", "#botted", "[".$ip."] Status: ".$status);
$this -> ipcs[$ip]["status"] = $result;
$this -> ipcs[$ip]["lastcheck"] = time();
}
}
?>