注意php是在服务器上执行的,不是在远程执行。所有远程信息是通过www服务器的环境变量取来的。因此完全不可读。
在不触及对方机器/操作系统本身的条件下,除访问对方的交换机,可以拿到对方的mac,其他别无它法。

解决方案 »

  1.   

    可以用系统命令exec();
    假设你是win系统。远程用户的ip为$_SERVER['REMOTE_ADDR'];
    先执行ping命令;再执行arp命令
    <?php
     $ip = $_SERVER['REMOTE_ADDR'];
     if (exec("ping $ip"))
     {
         exec("arp -a $ip",$result);
     }
    ?>
    $result 为执行 "arp -a $ip"的返回结果;用正则表达式将形如52-54-ab-52-12-d6的字符取出即可;
    这是我在win下cmd里的执行示例:
    C:\>ping 192.168.49.130Pinging 192.168.49.130 with 32 bytes of data:Reply from 192.168.49.130: bytes=32 time<10ms TTL=128
    Reply from 192.168.49.130: bytes=32 time<10ms TTL=128
    Reply from 192.168.49.130: bytes=32 time<10ms TTL=128
    Reply from 192.168.49.130: bytes=32 time<10ms TTL=128Ping statistics for 192.168.49.130:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum =  0ms, Average =  0msC:\>arp -a 192.168.49.130Interface: 192.168.50.62 on Interface 0x1000003
      Internet Address      Physical Address      Type
      192.168.49.130        52-54-ab-52-12-d6     dynamicC:\>
      

  2.   

    一个取ip地址,取网卡地址,取ip+网卡地址的函数..
    收藏的,没测试过..CODE  /*------------------------------------------------------------
    *GetClientAddr 取访问者地址
    * Parameters:$AiType -- 类型1:IP,2:MAC,3:IP+MAC
    * Return: &nbsp;地址串
    *------------------------------------------------------------*/
    function GetClientAddr($AiType=0)
    {
    $sMac = "";
    $ip= getenv("REMOTE_ADDR"); 
    $ip1 = getenv("HTTP_X_FORWARDED_FOR"); 
    $ip2 = getenv("HTTP_CLIENT_IP"); 
    ($ip1) ? $ip = $ip1 : null; 
    ($ip2) ? $ip = $ip2 : null; 
    if ($AiType > 1)
    {
     $sCmd = "nbtstat -a " . $ip;
     $sString = shell_exec($sCmd);
     $aTemp = split("=",$sString);
     $sMac = trim($aTemp[count($aTemp)-1]);
    }
    switch($AiType)
    {
    case 0:
     $sResult = "";
     break;
    case 1:
     $sResult = $ip;
     break;
    case 2:
     $sResult = $sMac;
     break;
    case 3:
     $sResult = $ip . " " . $sMac;
     break;
    default:
     $sResult = "";
     break;
    }
    return $sResult;
    }
     
      

  3.   

    楼上的兄台,可以回答我如何接到正确的MAC吗?谢谢
      

  4.   

    郑重声明:
    上面所谓的arp -a 和nbtstat 只能在局域网内使用,一旦server和client跨过了某个路由器、防火墙甚至是一个三层交换机(更不要说是代理服务器),此种命令即告失效。
      

  5.   

    <?
    @exec(" ipconfig -all >  c:\file/physicAddress.txt");
    ?>
      

  6.   

    写个ocx操作远程客户端才行访问远程用户呵呵,那你把人家硬盘格式化了怎么办?
      

  7.   

    /*------------------------------------------------------------
    *GetClientAddr 取访问者地址
    * Parameters:$AiType -- 类型1:IP,2:MAC,3:IP+MAC
    * Return: &nbsp;地址串
    *------------------------------------------------------------*/
    function GetClientAddr($AiType=0)
    {
    $sMac = "";
    $ip= getenv("REMOTE_ADDR"); 
    $ip1 = getenv("HTTP_X_FORWARDED_FOR"); 
    $ip2 = getenv("HTTP_CLIENT_IP"); 
    ($ip1) ? $ip = $ip1 : null; 
    ($ip2) ? $ip = $ip2 : null; 
    if ($AiType > 1)
    {
     $sCmd = "nbtstat -a " . $ip;
     $sString = shell_exec($sCmd);
     $aTemp = split("=",$sString);
     $sMac = trim($aTemp[count($aTemp)-1]);
    }
    switch($AiType)
    {
    case 0:
     $sResult = "";
     break;
    case 1:
     $sResult = $ip;
     break;
    case 2:
     $sResult = $sMac;
     break;
    case 3:
     $sResult = $ip . " " . $sMac;
     break;
    default:
     $sResult = "";
     break;
    }
    return $sResult;
    }
     
    ____________________________________________
    这是win下面的程序,
    linux下面的是
    ________________________________________
    /*****************************
    *function   : get ip and mac of client
    *parameter  : mode,msgString 
    *returnvalue: 
    *discribe   : shell_exec arp IP in linux sys
    *foundtime  : 
    *****************************/
    function getClientIp($AiType=0){
    $sMac = "";
    $ip= getenv("REMOTE_ADDR"); 
    $ip1 = getenv("HTTP_X_FORWARDED_FOR"); 
    $ip2 = getenv("HTTP_CLIENT_IP"); 
    ($ip1) ? $ip = $ip1 : null; 
    ($ip2) ? $ip = $ip2 : null; 
    if ($AiType > 1)
    {
    $sCmd = "arp $ip";
    $sString = shell_exec($sCmd);
    for($iCount=0;$iCount<10;$iCount++)
    $sString=str_replace("  "," ",$sString);
    $aTemp = split(" ",$sString);
    $sMac = trim($aTemp[count($aTemp)-3]);
    }
    switch($AiType)
    {
    case 0:
    $sResult = "";
    break;
    case 1:
    $sResult = $ip;
    break;
    case 2:
    $sResult = $sMac;
    break;
    case 3:
    $sResult = $ip . " " . $sMac;
    break;
    default:
    $sResult = "";
    break;
    }
    return $sResult;
    }
      

  8.   

    原理很简单,再win下面执行 netstat -a 
     再linux下面执行arp 就可以得到本网络的MAC值!
      

  9.   

    参与讨论的人有没有弄明白楼主的意思?
    远程读用户不是读本地只能通过activex来做
      

  10.   

    我想远程读用户MAC地址,然后写入数据库?
    ————————————————————
    以上的是得到访问用户的mac,而且是在远程执行!
      

  11.   

    o我明白了
    hover_online(ξ芎メ) 
    的方法
    是通过分析命令行结果得出mac地址但是有的情况下得不出来结果
      

  12.   

    呵,还真有意思?如果可以读远程用户的mac,那么用户机上的还有什么不能读呢?也就没有什么安全可言了!