Guest User

stallemanden

a guest
Jun 17th, 2010
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <form name='scoretable' method='post' action='test.php'>
  2.     <textarea wrap="on" class="but" rows="10" cols="20" name="toPingList"></textarea>
  3.     <input type="submit" value="Tjek PC'ere" name="B1">
  4. </form>
  5.  
  6. //Indtast PCere med komma separering. PC1,PC2,PC3 ....
  7.  
  8. <?php
  9.  
  10. $toPing = preg_split("/[\s]*[,][\s]*/", $_POST["toPingList"]);
  11.  
  12.  
  13. $pass = array();
  14. $fail = array();
  15.  
  16. // initialization
  17. $output = array();
  18. $retval = 0;
  19. foreach($toPing as $ip) {
  20.   exec("ping -w 1 " . $ip, $output, $retval);
  21.   if($retval == 0) {
  22.      $pass[] = $ip;
  23.   } else {
  24.      $fail[] = $ip;
  25.   }
  26. }
  27.  
  28. echo "Tændt: \n";
  29. print_r($pass);
  30.  
  31. echo "<br><br>";
  32.  
  33. echo "Slukket: \n";
  34. print_r($fail);
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment