Forum Moderators: coopster

Message Too Old, No Replies

PHP Ping and Tracert

         

webzila

10:35 pm on Feb 11, 2005 (gmt 0)

10+ Year Member



Does anyone know if there are any PHP scripts that will allow you to run Ping and Traceroute without utilizing the PHP system() function or use the network utilities on the server..

I understand that this wouldnt be a 'real' ping or traceroute but anything will do for me.

I used to have a script that utilized the system() command but the webhost disabled it.

Then I had a script which did something like this:

function p($target){
message("<p><b>Ping Results:</b><blockquote>"); if (! $msg .= trim(nl2br(`ping -c5 '$target'`))) #bugfix
$msg .= "Ping failed. Host may not be active."; $msg .= "</blockquote></p>"; message($msg); }

function tr($target){
message("<p><b>Traceroute Results:</b><blockquote>"); if (! $msg .= trim(nl2br(`/usr/sbin/traceroute '$target'`))) #bugfix
$msg .= "Traceroute failed. Host may not be active."; $msg .= "</blockquote></p>"; message($msg); }

That script doesnt seem to use the system() function but has also stopped working recently so I was looking for something that would not depend on the Ping and Traceroute utilities on the server but rather 'mimic' those functions and provide comparable output.

Thanks

hakre

4:27 pm on Feb 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if you don't want to use system() then you need to code it yourself. ping is icmp, you can gather all infos about icmp here: [freesoft.org...]

so for icmp you need sockets and start the communication then by yourself. this can be done with php: [php.net...]

hf