ulvis.paste.net

Paste Search Dynamic
Recent pastes
check server status
  1. <?php
  2. function check_server_status($host, $port, $timeout) {
  3.   $start_time = microtime(true);
  4.   $status = fsockopen($host, $port, $errno, $errstr, $timeout);
  5.   if (!$status) {
  6.     return "Server is down.";
  7.   }
  8.    
  9.   $end_time = microtime(true);
  10.   $time_taken = $end_time - $start_time;
  11.   $time_taken = round($time_taken,5);
  12.    
  13.   return "Server responded in " . $time_taken * 1000 . " ms.";
  14. }
  15. ?>
  16. <form action="" <span id="IL_AD8" class="IL_AD">method</span>="post">
  17. Domain name: <<span id="IL_AD9" class="IL_AD">input type</span>="text" name="domain" value="<? echo $_SERVER['PHP_SELF']; ?> " />
  18. <input type="submit" value="Submit" />
  19. </form>
  20.  
  21. <strong>
  22. <?php if($_POST['domain']) echo "Status: " . check_server_status($_POST['domain'], 80, 12); ?>
  23. </strong>
Parsed in 0.034 seconds