0

I want to get user machine name or any unique code instead of IP.

Two system on same network have same IP but I want unique Code/number/name of each System.

Please tell me How can I do this with php.

Thanks

EDITED......

I am using below code. This is working on localend. But this stop working on live server. May be its getting server mac address but I want local machine Mac address from where my web app is accessing.

    ob_start();//Get the ipconfig details using system commond
    system('ipconfig /all');

    // Capture the output into a variable
    $mycom=ob_get_contents();
    // Clean (erase) the output buffer
    ob_clean();

    $findme = "Physical";
    //Search the "Physical" | Find the position of Physical text
    $pmac = strpos($mycom, $findme);

    // Get Physical Address
    $mac=substr($mycom,($pmac+36),17);
    //Display Mac Address
    echo '<h1>demo---> '.$mac.'</h1>';

Edited If this is not possible in php then javascript can be used for this? How can I use javascript to get client machine Physical Address....

Hira Singh
  • 155
  • 3
  • 25
  • Anyone can provide me solution.............? – Hira Singh Sep 20 '14 at 09:29
  • I think this has already been answered here: [http://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php][1] [1]: http://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php – Fons Sep 20 '14 at 10:31
  • I need client machine Mac Address (Physical Address) not server. – Hira Singh Sep 20 '14 at 10:34

1 Answers1

0

You should try the below code.

$ip  = $_SERVER['REMOTE_ADDR'];
// don't miss to use escapeshellarg(). Make it impossible to inject shell code
$mac1 = shell_exec('arp -a ' . escapeshellarg($ip));

// can be that the IP doesn't exist or the host isn't up (spoofed?)
// check if we found an address
if(empty($mac1)) {
    die("No mac address for $ip not found");
}

// having it
echo "mac address for $ip: $mac1";

Hope this will work for you.

Amaninder
  • 16
  • 1