문제

컴퓨터에 등록 된 소프트웨어가있는 회사의 웹 사이트를 구축하고 있으며 PC의 컴퓨터 이름과 사용자 이름을 사용하고 있습니다.사용자가 작성 해야하는 사용자 없이는 이러한 값을 어떻게 검색 할 수 있습니까?

에 도움이되는 경우 codeigniter를 사용하고 있습니다.

도움이 되었습니까?

해결책

You can't. All PHP will ever see of the user's machine is the IP address, from which you MAY be able to do a reverse lookup and get a hostname. But this hostname is not likely to be the actual machine's name. Ditto for the user's client-side username. A website has no business knowing how a user logged into their local machine.

다른 팁

If everything happens on the same local network, you could use the server machine to lookup the mac address corresponding to the IP of the visitor with something like that:

/**
 * Returns MAC-address (Ethernet 2-level in OSI model address)
 * @param string $ip Address to search MAC for. If not set, IP-address from constructor'll be used
 * @return mixed
 */
public function getMAC($ip=null)
{
    if((!$ip && !$this->sCurrentIP) || !$this->_arp_allowed())
    {
        return null;
    }
    $ip=$ip?$ip:$this->sCurrentIP;
    $rgMatches=array();
    if(PHP_OS=='WINNT')
    {
       exec("arp -a", $rgResult);
       $sMacTemplate="/[\d|A-F]{2}\-[\d|A-F]{2}\-[\d|A-F]{2}\-[\d|A-F]{2}\-[\d|A-F]{2}\-[\d|A-F]{2}/i";
       foreach($rgResult as $key=>$value)
       {
          if (strpos($value, $ip)!==FALSE)
          {
             preg_match($sMacTemplate, $value, $rgMatches);
             break;
          }
       };
    }
    else
    {
       exec("arp -a | grep $ip", $rgResult);
       if(count($rgResult))
       {
           $sMacTemplate="/[\d|A-F]{2}\:[\d|A-F]{2}\:[\d|A-F]{2}\:[\d|A-F]{2}\:[\d|A-F]{2}\:[\d|A-F]{2}/i";
           preg_match($sMacTemplate, $rgResult[0], $rgMatches);
       }
    }
    return count($rgMatches)?$rgMatches[0]:null;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top