使用php获取机器名称或任何唯一代码


Get Machine name or any unique code with php

我想获得用户机器名或任何唯一代码,而不是IP。

同一网络上的两个系统具有相同的IP,但我想要每个系统的唯一代码/编号/名称。

请告诉我如何使用php实现这一点。

感谢

EDITED......

我正在使用以下代码。这正在localend上工作。但这在实时服务器上停止工作。可能是它的获取服务器mac地址,但我想要我的网络应用程序访问的本地机器mac地址。

    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如果这在php中是不可能的,那么javascript可以用于此吗?如何使用javascript获取客户端机器的物理地址。。。。

您应该尝试以下代码。

$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";

希望这对你有用。