我想获取用户计算机名称或任何唯一代码而不是IP。
同一网络上的两个系统具有相同的IP,但是我想要每个系统的唯一代码/编号/名称。
请告诉我如何使用php。
谢谢
EDITED......
我正在使用下面的代码。这正在localend上进行。但是,这将停止在实时服务器上工作。可能是获取服务器的Mac地址,但是我想从中访问我的Web应用程序的本地计算机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";
希望这对您有用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句