Hello!
Can I with PHP code ping a domain and use the "reply data" (if its up or not, and the ping time)
Thanks,
Sure!
If you use a backend program like ping.exe in Windows and ping in Linux....
you need to execute the ping program form the php code, using a execute function: http://dk.php.net/exec
i will recoment you to use:
exec(); http://dk.php.net/manual/en/function.exec.php
Remember to turn safe mode off, if it's on then you are not allowed to run system commands!
use set_ini(); to solve the proglem (if it is there!)
or change it in httpd.conf (if it's on Apache, and you are the administrator)
If you don't want to ping the other server, just check if it is online - whats the best way to do that?
function isURL($Value) { $parsed = parse_url($Value); if($parsed['scheme'] != 'http' || $parsed['host'] == '') { $parsed['scheme'] = 'http'; $parsed['host'] = BASEURL; } elseif(!checkdnsrr($parsed['host'],'A')) {return 0;} $fp = fsockopen ($parsed['host'], 80); fputs($fp,"GET $Value HTTP/1.0\n\n"); $line = fgets($fp, 1024); if (stristr($line, '200 OK')) {$end = 1;} else{$end = 0;} fclose($fp); return $end; } //end isURL
????????: Ping are made to fill thise needs out! Sooo... Not relly... drawmack make some good code, but it only works if there stands a web server in the end of the domain! Not if it's a FTP server, telnet osv..
Truti, you can easily modify the code to allow for that as well by making ports into an array and having it check each one. Heck you could even have it give back stats on which ports are open and which are closed.