Quote:
|
Originally Posted by handyman
Is there such a thing as a script I can run on a web page that will automatically run a ping test to a ip (either manually entered or capured auto).
Basically I am trying to get as many tools into my site as possible to enable people to try diagnose faults with out having to call in to tech support.
Thanks in advance
mark
|
Try this (PHP) (taken from worldsend)
Code:
<?php
$max_count = 10;
$unix = 1;
$windows = 0;
$register_globals = (bool) ini_get('register_gobals');
$system = ini_get('system');
$unix = (bool) $unix;
$win = (bool) $windows;
//
If ($register_globals)
{
$ip = getenv(REMOTE_ADDR);
$self = $PHP_SELF;
}
else
{
$submit = $_GET['submit'];
$count = $_GET['count'];
$host = $_GET['host'];
$ip = $_SERVER['REMOTE_ADDR'];
$self = $_SERVER['PHP_SELF'];
};
If ($submit == "Ping!")
{
If ($count > $max_count)
{
echo 'Maximum for count is: '.$max_count;
echo '<a href="'.$self.'">Back</a>';
}
else
{
$host= preg_replace ("/[^A-Za-z0-9.]/","",$host);
echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
echo("Ping Output:<br>");
echo '<pre>';
if ($unix)
{
system ("ping -c$count -w$count $host");
system("killall ping");
}
else
{
system("ping -n $count $host");
}
echo '</pre>';
}
}
else
{
echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
echo '<p><font size="2">Your IP is: '.$ip.'</font></p>';
echo '<form methode="post" action="'.$self.'">';
echo ' Enter IP or Host <input type="text" name="host" value="'.$ip.'"></input>';
echo ' Enter Count <input type="text" name="count" size="2" value="4"></input>';
echo ' <input type="submit" name="submit" value="Ping!"></input>';
echo '</form>';
echo '<br><b>'.$system.'</b>';
echo '</body></html>';
}
?>