/    Sign up×
Community /Pin to ProfileBookmark

Does anyone know of a script that will ping an I.P. from a visitor’s PC, returning only the MS between the visitor and from the server to the visitor. It will be pinging an I.P. that I set myself within the script. I also want this to automatically ping them when they visit the site, without them having to click on any link.

Example: Texas server- 50 ms, New York server- 110 ms, and so on.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@IZZOauthorFeb 08.2007 — I don't understand this script very well. also when i try it i get socket errors

Warning: socket_create() Unable to create socket [1]: Operation not permitted in /hi.php on line 104

Warning: socket_connect() expects parameter 1 to be resource, boolean given in /hi.php on line 105

Warning: socket_send() expects parameter 1 to be resource, boolean given in /hi.php on line 110

Warning: socket_read() expects parameter 1 to be resource, boolean given in /hi.php on line 111

Warning: socket_close() expects parameter 1 to be resource, boolean given in /hi.php on line 114
Copy linkTweet thisAlerts:
@konithomimoFeb 09.2007 — well, you can do it this way:

<html><head><title>Poing!</title></head>
<body>
<table><tr>
<?php

$numberping = 1;
$ip = "192.168.1.1";
$name = gethostbyaddr($ip);

$str = exec("ping -c $numberping -w 1 $ip",$a,$a1);
$length = strlen($str);
if($length > 1) { print "<td bgcolor='green'>IP: ".$ip." (".$name.") is up</td>"; }
else { print "<td bgcolor='red'>IP: ".$ip." (".$name.") is DOWN</td>"; }

?>
</tr></table>
</body>
</html>


or even shorter, this way:

<html><head><title>Poing!</title></head>
<body>
<pre>
<?php
$ip = "192.168.1.1";
passthru("ping -c 1 $ip");
?> </pre>
</body></html>
Copy linkTweet thisAlerts:
@IZZOauthorFeb 09.2007 — i do like that second script you posted there. Is there any way possible to have it just give the average ms that was returned or is that not possible with php alone? If not what coding can do this. Javascript and php together maybe?
Copy linkTweet thisAlerts:
@yunakriFeb 11.2007 — Good thing I just did a search, I was about to make a post over this exact thing. Looks like somebody already beat me to it. I also needed a script just like the one above, but where it will also limit the results and just give me the milliseconds. Are these ping commands the same ones the command prompt uses in Windows XP? I was trying to replace the -C in the script to be -N, and it will not work for me.


----------------------------------------------------------

Pinging google.com [64.233.167.99] with 32 bytes of data:

Reply from 64.233.167.99: bytes=32 time=20ms TTL=244

Ping statistics for 64.233.167.99:

Packets: Sent = 1, Received = 1, Lost = 0 (0% lost),

Approximate round trip times in milli-seconds:

Minimum = 20ms, Maximum = 20ms, Average = 20ms


----------------------------------------------------------

These are my results using -N in the command prompt, instead of the -C.

Using these results it would seem like it would be easier (if it is possible) to pull just the last 4 or 5 characters, so that it would return just 20ms.
×

Success!

Help @IZZO spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...