Guest User

Untitled

a guest
Apr 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2. function pingDomain($domain){
  3. $starttime = microtime(true);
  4. $file = @fsockopen ($domain, 80, $errno, $errstr, 10);
  5. $stoptime = microtime(true);
  6. $status = 0;
  7.  
  8. if (!$file) $status = -1; // Site is down
  9. else {
  10. fclose($file);
  11. $status = ($stoptime - $starttime) * 1000;
  12. $status = floor($status);
  13. }
  14.  
  15. if ($status <> -1) {
  16. return true;
  17. }
  18.  
  19. return false;
  20.  
  21. }
  22. //llamando a la funcion
  23. if (pingDomain('www.dominio.com')) {
  24. echo 'ON';
  25. } else {
  26. echo 'OFF';
  27. }
Add Comment
Please, Sign In to add comment