Shoutbox

[PHP] Getting the online status of a computer [SOLVED] - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: [PHP] Getting the online status of a computer [SOLVED] (/showthread.php?tid=92657)

[PHP] Getting the online status of a computer [SOLVED] by ryxdp on 10-23-2009 at 09:34 AM

Well, I've Googled how to do this a bit and found no efficient way to do it. What I would like is something that pings a computer on the local network using a predefined address/name etc., and if it can be reached, return "foobar". It'll be running on a Windows-based fileserver, on a page that shows shared folders and computers on the network.

Thanks :P

EDIT: I figured out what was wrong with the ping command I already had:

PHP code:
function pingcomputer($name){
    exec('ping -n 1 '.$name.' 2>&1',$output,$result); // was -c 1 instead of -n 1 which is what windows uses
    if($result==0){
        return '<img src="online.png" title="Online" alt=""/>';
    }else{
        return '<img src="offline.png" title="Offline" alt=""/>';
    }
}


RE: [PHP] Getting the online status of a computer by John Anderton on 10-23-2009 at 10:05 AM

use file_get_contents to get a file listing from it.. run apache on the remote machine.
If you get the page, its working fine. If you can't then you're not online :)

I do something similar (but with a lot more complicated rule set+code) to handle my ISP's internet rules. :)


RE: [PHP] Getting the online status of a computer by Jarrod on 10-23-2009 at 12:26 PM

you can do it in python cgi really easily, don't think that what your after though