frtfh


SUBMITTED BY: leakage

DATE: Nov. 29, 2015, 5:18 a.m.

FORMAT: Text only

SIZE: 901 Bytes

HITS: 294

  1. <?php
  2. if( isset( $_POST[ 'submit' ] ) ) {
  3. $target = $_REQUEST["ip"];
  4. $target = stripslashes( $target );
  5. // Split the IP into 4 octects
  6. $octet = explode(".", $target);
  7. // Check IF each octet is an integer
  8. if ((is_numeric($octet[0])) && (is_numeric($octet[1])) && (is_numeric($octet[2])) && (is_numeric($octet[3])) && (sizeof($octet) == 4) ) {
  9. // If all 4 octets are int's put the IP back together.
  10. $target = $octet[0].'.'.$octet[1].'.'.$octet[2].'.'.$octet[3];
  11. // Determine OS and execute the ping command.
  12. if (stristr(php_uname('s'), 'Windows NT')) {
  13. $cmd = shell_exec( 'ping ' . $target );
  14. $html .= '<pre>'.$cmd.'</pre>';
  15. } else {
  16. $cmd = shell_exec( 'ping -c 3 ' . $target );
  17. $html .= '<pre>'.$cmd.'</pre>';
  18. }
  19. }
  20. else {
  21. $html .= '<pre>ERROR: You have entered an invalid IP</pre>';
  22. }
  23. }
  24. ?>

comments powered by Disqus