-
-
/**
- * マシンのネットワーク カードの物理 (MAC) アドレスを取得します
- * 現在 WIN/LINUX システムをサポートしています
- * 編集者: bbs.it-home.org
- **/
- class MacAddInfo {
- var $return_array = array (); // MAC アドレスを持つ文字列数集合を返します
- var $mac_addr;
-
- function MacAddInfo($os_type) {
- switch (strto lower ( $os_type )) {
- case "linux" :
- $this->forLinux ();
- 休憩;
- ケース「ソラリス」:
- ブレーク;
- case "unix" :
- ブレーク;
- case "aix" :
- ブレーク;
- デフォルト :
- $this->forWindows ();
- 休憩;
- }
$temp_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];
- 休憩;
- }
- }
- unset ( $temp_array );
- $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 MacAddInfo(PHP_OS);
- //echo $mac->mac_addr;
- ?>
-
复制代
|