login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Snippets > Ping-script

Ping-script

Auteur: Dolfje - 18 september 2005 - 15:34 - Gekeurd door: nemesiskoen - Hits: 3600 - Aantal punten: 2.00 (3 stemmen)



Deze script pingt naar de opgegeven ip of domeinnaam.

Je moet alleen if( 0 /*unix*/ ) veranderen.
Verander 0 naar 1 als je op linux of unix zit,
als je op windows zit, laat je het zo.

Code:
  1. <?
  2. $host = "www.google.com";
  3. $host = "";
  4. if( 0 /*unix*/ )
  5. {
  6. system ("ping -c5 -w5 $host");
  7. system("killall ping");// kill all ping processes in case there are some stalled ones or use echo 'ping' to execute ping without shell
  8. }
  9. else
  10. {
  11. system("ping -n 5 $host");
  12. }
  13. ?>


met een check erbij:

  1. <?
  2. $host = "www.google.com";
  3.  
  4. $host = "";
  5. if( strpos($url, "http://") !== FALSE AND strpos($url, "http://") == 0 AND strpos(substr($url, 7), "/") === FALSE )
  6. {
  7. $host = substr($url,7);
  8. }
  9. elseif( ereg("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $url) )
  10. {
  11. $host = $url;
  12. }
  13.  
  14. if( !empty($host) )
  15. {
  16.  
  17. if( 0 /*unix*/ )
  18. {
  19. system ("ping -c5 -w5 $host");
  20. system("killall ping");
  21. }
  22. else
  23. {
  24. system("ping -n 5 $host");
  25. }
  26. }
  27. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (2)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.028s