Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2.  
  3. function ping($host)
  4. {
  5. exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
  6. return $rval === 0;
  7. }
  8. // random host ip example
  9. $host = '192.168.0.2';
  10. $online = ping($host);
  11.  
  12. // if site is online, send them to the site.
  13. if ($online) { echo "online"; } else { echo "offiline"; } ;
  14.  
  15.  
  16. function ping($host)
  17. {
  18. exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
  19. return $rval === 0;
  20. }
  21. // random host ip example
  22. $host = '192.168.0.1';
  23. $online = ping($host);
  24.  
  25. // if site is online, send them to the site.
  26. if ($online) { echo "online"; } else { echo "offiline"; } ;
  27.  
  28.  
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement