시스템 네트워크 카드의 물리적(MAC) 주소를 가져옵니다.
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-07-25 09:09:52
- /**
- 获取机器网卡的物理(MAC)地址
- **/
- class GetMacAddr
- {
- var $return_array = array(); // 返回带有MAC地址的字串数组
- var $mac_addr;
-
- function GetMacAddr($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-> mac_addr = $temp_array[0];
- break;
- }
- }
- unset($temp_array);
- return $this-> mac_addr;
- }
-
- function forWindows()
- {
- @exec( "ipconfig /all ", $this-> return_array);
- if ( $this-> return_array )
- return $this-> return_array;
- else{
- $ipconfig = $_SERVER[ "WINDIR "]. "system32ipconfig.exe ";
- if ( is_file($ipconfig) )
- @exec($ipconfig. " /all ", $this-> return_array);
- else
- @exec($_SERVER[ "WINDIR "]. "systemipconfig.exe /all ", $this-> return_array);
- return $this-> return_array;
- }
- }
-
- function forLinux()
- {
- @exec( "ifconfig -a ", $this-> return_array);
- return $this-> return_array;
- }
- }
- ?>
-
- $mac = new GetMacAddr(PHP_OS);
- echo $mac-> mac_addr;
- ?>
复制代码
|
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
저자별 최신 기사
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11
최신 이슈
-
2025-03-21 13:39:34
-
2025-03-21 13:38:34
-
2025-03-21 13:37:19
-
2025-03-21 13:35:24
-
2025-03-21 13:34:32