Ciao,
ho visto tutte quante le discussioni su "ping" del forum... ma ho un problemino... forse potete aiutarmi...
allora come script ho usato questo (consigliato anche da freephp)
Codice PHP:
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>The WorldsEnd.NET - Free Ping Script, written in PHP</title>
</head>
<?php
// This script was writen by [email]webmaster@theworldsend.net[/email], Aug.2001
// [url]http://www.theworldsend.net[/url]
// This is my first script. Enjoy.
//
// Put it into whatever directory and call it. That's all.
// Updated to 4.2 code
// Get Variable from form via register globals on/off
//-------------------------
$max_count = 10; //maximum count for ping command
$unix = 1; //set this to 1 if you are on a *unix system
$windows = 0; //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;
//
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'];
};
// form submitted ?
If ($submit == "Ping!")
{
// over count ?
If ($count > $max_count)
{
echo 'Maximum for count is: '.$max_count;
echo '[url="'.$self.'"]Back[/url]';
}
else
{
// replace bad chars
$host= preg_replace ("/[^A-Za-z0-9.]/","",$host);
echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
echo("Ping Output:
");
echo '<pre>';
//check target IP or domain
if ($unix)
{
system ("ping -c$count -w$count $host");
system("killall ping");// kill all ping processes in case there are some stalled ones or use echo 'ping' to execute ping without shell
}
else
{
system("ping -n $count $host");
}
echo '</pre>';
}
}
else
{
echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
echo '
<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 '
[b]'.$system.'[/b]';
echo '</body></html>';
}
?>
bene... lo script credo funzioni senza particolari problemi...
il fatto è che qualunque ip "pinghi" mi viene restituito "100% lost"
qui sotto per esempio riporto il ping a "www.libero.it" cosa che, dal mio pc riesco a fare tranquillamente...ma da script no...
PING SU LIBERO.IT DA PC
C:\Users\Jonny>ping
www.libero.it
Esecuzione di Ping vs-fe.iol.it [195.210.91.83] con 32 byte di dati:
Risposta da 195.210.91.83: byte=32 durata=38ms TTL=116
Risposta da 195.210.91.83: byte=32 durata=35ms TTL=116
Risposta da 195.210.91.83: byte=32 durata=34ms TTL=116
Risposta da 195.210.91.83: byte=32 durata=40ms TTL=116
Statistiche Ping per 195.210.91.83:
Pacchetti: Trasmessi = 4, Ricevuti = 4,
Persi = 0 (0% persi),
Tempo approssimativo percorsi andata/ritorno in millisecondi:
Minimo = 34ms, Massimo = 40ms, Medio = 36ms
PING ESEGUITO DA SCRIPT PHP
PING 195.210.91.83 (195.210.91.83) 56(84) bytes of data.
--- 195.210.91.83 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3001ms
Il fatto è che il sito da cui faccio partire il ping è su Aruba... ci sta che sia per questo che nn va?
Come trovo soluzione al mio problema ?
Io, dal pannello di amministrazione del mio sito devo poter controllare se uno o più ip mi danno una risposta... tutto qui... nn mi serve altro.
devo fare solo un controllo se quella maccchina è online oppure offline...p
grazie mille.
ciao
Drummino