<?php
class HardwareInfo{
	//获取MAC地址
	static function getMacAddress()
	{
	$return_arry = array();
	@exec("wmic nicconfig get macaddress", $return_arry);
	$t=array();
	foreach($return_arry as $item){
		if(trim($item)!=""){
			$t[]=$item;
		}
		
	}
	$mac_addr = '';
	if(isset($t[1])){
		$mac_addr = $t[1];
		$mac_addr = str_replace(":", "", $mac_addr);//去除字符串中的字符“:”		
	}

	
	return $mac_addr;
	}
	//获取CPU序列号
	static function getCpuSN()
	{
	$return_arry = array();
	@exec("wmic cpu get processorid", $return_arry);
	
	$cpu_sn = '';
	if(isset($return_arry[1])){
		$cpu_sn = $return_arry[1];	
	}

	return $cpu_sn;
	}
	//获取主板序列号
	static function  getBaseboardSN()
	{
	$return_arry = array();
	@exec("wmic baseboard get serialnumber", $return_arry);
	$baseboard_sn = '';
	if(isset($return_arry[1])){
		$baseboard_sn = $return_arry[1];
		$baseboard_sn = str_replace("-", "", $baseboard_sn);//去除字符串中的字符“-”		
	}

	return $baseboard_sn;
	}
	
	static function getMCode(){
		return md5(self::getBaseboardSN().self::getCpuSN().self::getMacAddress());
	}
}
