<?php
// define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$WEB = $email = $kk = $comment = $website = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["WEB"]))
{$nameErr = "WEB is required";}
else
{$WEB = test_input($_POST["WEB"]);}
if (empty($_POST["kk"]))
{$nameErr = "options is required";}
else
{$kk = test_input($_POST["kk"]);}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<p><span class="error">
</span></p><form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
WEB: <input type="text" name="WEB">Options:<input type="text" name="kk">
<input type="submit" name="submit" value="Ping"><br><br>
Options:<br>
-t Ping the specified host until stopped.<br>
To see statistics and continue<br>
>type Control-Break;<br>
To stop<br>
>type Control-C.<br>
-a Resolve addresses to hostnames.<br>
-n count Number of echo requests to send.<br>
-l size Send buffer size.<br>
-f Set Don't Fragment flag in packet (IPv4-only).<br>
-i TTL Time To Live.<br>
-v TOS Type Of Service (IPv4-only. This setting has been deprecated and has no effect on the type of service field in the IP Header).<br>
-r count Record route for count hops (IPv4-only).<br>
-s count Timestamp for count hops (IPv4-only).<br>
-j host-list Loose source route along host-list (IPv4-only).<br>
-k host-list Strict source route along host-list (IPv4-only).<br>
-w timeout Timeout in milliseconds to wait for each reply.<br>
<br><br>
</form>
<?php
echo "<h2> Result:</h2>";
echo $WEB;
echo $kk;
$ip = $WEB;
//echo shell_exec("ping $ip ");
$exe= shell_exec("ping $ip $kk 5");
print_r(nl2br($exe));
?>
<?php
// This script was writen by [email protected], Aug.2001
// http://www.theworldsend.net
// This is my first script. Enjoy.
//
// Put it into whatever directory and call it. That's all.
// Updated to 4.2 code in 2002
// Get Variable from form via register globals on/off
//-------------------------
$unix = 0; //set this to 1 if you are on a *unix system
$windows = 1; //set this to 1 if you are on a windows system
// -------------------------
// nothing more to be done.
// -------------------------
//globals on or off ?
$register_globals = (bool) ini_get('register_gobals');
$system = ini_get('system');
$unix = (bool) $unix;
$win = (bool) $windows;
//
$ip = file_get_contents('http://phihag.de/ip/');
echo ' <input type="hidden" name="submit" value="Traceroute!"></input>';
If ($register_globals)
{
$self = $PHP_SELF;
}
else
{
$submit = $_GET['testroute'];;
$host = $_GET['host'];
$self = $_SERVER['PHP_SELF'];
};
// form submitted ?
If ($submit == "Traceroute!")
{
// replace bad chars
$host= preg_replace ("/[^A-Za-z0-9.]/","",$host);
echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
echo("Trace Output:<br>");
echo '<pre>';
//check target IP or domain
if ($unix)
{
system ("traceroute $host");
system("killall -q traceroute");// kill all traceroute processes in case there are some stalled ones or use echo 'traceroute' to execute without shell
}
else
{
system("tracert $host");
}
}
else
{
echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
echo 'Traceroute server ';
echo '<p>Your IP is: '.$ip.'</p>';
echo '<form methode="post" action="'.$self.'">';
echo ' Enter IP or Host <input type="text" name="host" value="'.$host.'"></input>
<input type="hidden" name="testroute" value="Traceroute!"></input>
<input type="submit" name="submit" value="Traceroute!!!"></input>';
echo '</form>';
echo '<br><b>'.$system.'</b>';
echo '</body></html>';
}
?>
ส่วนการnslookup
Code (PHP)
<?php
// For Linux...
function gethost ($ip) {
$host = `host $ip`;
return (($host ? end ( explode (' ', $host)) : $ip));
}
// For Win32...
function nslookup ($ip) {
$host = split('Name:',`nslookup $ip`);
return ( trim (isset($host[1]) ? str_replace ("\n".'Address: '.$ip, '', $host[1]) : $ip));
}
?>