<?php
	error_reporting(0);
function ping($host, $port, $timeout) 
{ 
  $tB = microtime(true); 
  $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); 
  if (!$fP) { return "down"; } 
  $tA = microtime(true); 
  return round((($tA - $tB) * 1000), 0)." ms"; 
}


// site veya ip adresi 
$site="r10.net";

//ping fonksyionu
$ping= trim(ping($site,80,10));  // 80 portu

// down cevabı gelirse kapalı demektir.
if($ping!="down") { echo"sunucu açık";}

else{ echo"sunucu kapalı";}

?>