PHP Get MAC Address

Source: Internet
Author: User

/** * Get MAC Address **/classgetmacaddr{var $return _array=Array();//returns an array of strings with MAC addresses    var $mac _addr; functionGETMACADDR ($os _type){        Switch(Strtolower($os _type) ){             Case"Linux":$this-Forlinux ();  Break;  Case"Solaris": Break;  Case"UNIX": Break;  Case"Aix": Break; default:$this-forwindows ();  Break; }        $temp _array=Array(); foreach($this->return_array as $value ){            if (            Preg_match("/[0-9a-f][0-9a-f][:-]". " [0-9a-f] [0-9a-f] [:-]"." [0-9a-f] [0-9a-f] [:-]"." [0-9a-f] [0-9a-f] [:-]"." [0-9a-f] [0-9a-f] [:-]"." [0-9a-f] [0-9a-f]/i],$value,$temp _array ) ){                $this-&GT;MAC_ADDR =$temp _array[0];  Break; }        }        unset($temp _array); return $this-mac_addr; }    functionforwindows () {@exec("Ipconfig/all",$this-Return_array); if($this-Return_array)return $this-Return_array; Else{            $ipconfig=$_server["windir"]. " \system32\ipconfig.exe "; if(Is_file($ipconfig) )                @exec($ipconfig. "/all",$this-Return_array); Else                @exec($_server["windir"]. " \system\ipconfig.exe/all ",$this-Return_array); return $this-Return_array; }    }    functionForlinux () {@exec("Ifconfig-a",$this-Return_array); return $this-Return_array; }} //method uses$mac=NewGETMACADDR (Php_os);Echo $mac-mac_addr;/***IP Address Acquisition **/$a= "IP:";$b= "<<>> Enter time:";$user _ip=$_server["REMOTE_ADDR"];$user _ip= ($user _ip) ?$user _ip:$_server["REMOTE_ADDR"];d Ate_default_timezone_set ("Etc/gmt-8");$showtime=Date(' y-m-d h:i:s ');Echo"$a $user _ip";Echo"$b $showtime";

PHP get MAC address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.