перейдите на главную страницу монитора."; exit; } $log = "./logs/$ip-$port.log"; if (file_exists($log)) { $current_time = time(); $log_file = file($log); for ($i = 0; $i < 1; $i++) { $line = explode("|", $log_file[$i]); } $time = ($current_time - $line[0]); $old_time = ($time / 60); if ($old_time >= 10) { $fs = @fsockopen($ip, $port, $errno, $errdesc, 1); stream_set_timeout($fs, 0.3); if($fs) { fclose($fs); header ("content-type: image/png"); if (file_exists("images/status/{$id}_on.png")) $img = "images/status/{$id}_on.png"; else $img = "images/status/1_on.png"; readfile($img); logs($status = true, $ip, $port); } else { header ("content-type: image/png"); if (file_exists("images/status/{$id}_off.png")) $img = "images/status/{$id}_off.png"; else $img = "images/status/1_off.png"; readfile($img); logs($status = false, $ip, $port); } } else { if ($line[1] >= 1) { header ("content-type: image/png"); if (file_exists("images/status/{$id}_on.png")) $img = "images/status/{$id}_on.png"; else $img = "images/status/1_on.png"; readfile($img); } else { header ("content-type: image/png"); if (file_exists("images/status/{$id}_off.png")) $img = "images/status/{$id}_off.png"; else $img = "images/status/1_off.png"; readfile($img); } exit; } } else { $fs = @fsockopen($ip, $port, $errno, $errdesc, 1); stream_set_timeout($fs, 0.3); if($fs) { fclose($fs); header ("content-type: image/png"); if (file_exists("images/status/{$id}_on.png")) $img = "images/status/{$id}_on.png"; else $img = "images/status/1_on.png"; readfile($img); logs($status = true, $ip, $port); } else { header ("content-type: image/png"); if (file_exists("images/status/{$id}_off.png")) $img = "images/status/{$id}_off.png"; else $img = "images/status/1_off.png"; readfile($img); logs($status = false, $ip, $port); } } } function logs($status, $ip, $port) { $log = "./logs/servers/$ip-$port.log"; $site = $_SERVER['HTTP_REFERER']; $time = time(); $file = fopen($log, "w+"); fwrite($file, "$time|$status|$site\r\n"); fclose($file); }