-
-
Save key-moon/807e10e9128380c9b8eb26b87b85ad34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ip = $_POST["ip"]; | |
if ($ip) { | |
// super fancy regex check! | |
if (preg_match('/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/',$ip)) { | |
exec('ping -c 1 '.$ip, $cmd_result); | |
foreach($cmd_result as $str){ | |
if (strpos($str, '100% packet loss') !== false){ | |
printf("<h3>Target is NOT alive.</h3>"); | |
break; | |
} else if (strpos($str, ', 0% packet loss') !== false){ | |
printf("<h3>Target is alive.</h3>"); | |
break; | |
} | |
} | |
} else { | |
echo "Wrong IP Format."; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment