Network PC IP address view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mirainc
    New Member
    • Jul 2008
    • 34

    Network PC IP address view

    Any PHP code that can obtain and display all the IP addresses of all the PC in a network? So if this PC is running the application and the PC is connected to the LAN will i be able to view the IP addresses of all the PC in the network?

    Thanks
  • henryrhenryr
    New Member
    • Jun 2007
    • 103

    #2
    If the PC is connected to your PHP application (ie website) then you can get the IP address from $_SERVER['REMOTE_ADDR']

    So you just need to collect this value in a database or other storage medium. If you log the time against the IP then you can say at one point in time, which computers were connected.

    You could alternatively run ping with php exec() function and record the output:

    eg

    [code=php]
    for ($i=1;$i<=255;+ +$i) {
    $output=array() ;
    exec('ping -n 1 192.168.2.1.'.$ i,$output);
    if (!empty($output )) {
    echo '192.168.2.'.$i .' is connected';
    }
    }
    [/code]

    ps you would need to work on that condition - the output might be non-empty if the ping failed.

    Comment

    Working...