PHP acquired MAC address 2004-06-30 Excerpt from: http://xjtusky.net/Article/Article.php/537
PHP gets the MAC address
PHP
// Lower the MAC address under Linux // The external Mac.exe, // Mac. EXE is required under Windows, which is the executable that returns the MAC address, you can write itself with Delphi or VC //// Hisun
IF
$ _ENV
[
"OS"
] ==
"Windows_nt"
) {Function
GetMac
(
$ nic
=
"lo"
) {
$ mac_exe_file
=
"e: /mac.exe"
; IF
$ nic
==
'Lo'
) Return
"000000000000"
; IF
$ nic
! =
'Eth0'
) {RETURN
False
}
$ S1
=
TRIM
(
Shell_exec
(
$ mac_exe_file
))); RETURN
STRTOLOWER
(
$ S1
}}} Else {function
GetMac
(
$ nic
=
"lo"
) {IF
$ nic
==
'Lo'
) Return
"000000000000"
;
$ S1
=
Shell_exec
(
"/ sbin / ifconfig"
.
Escapeeshellarg
(
$ nic
).
"| HEAD-1"
); If
Strpos
(
$ S1
,
'Hwaddr'
<=
1
) {RETURN
False
Else {
$ a
=
EXPLODE
(
'Hwaddr'
,
$ S1
);
$ S2
=
STR_REPLACE
(
":"
,
""
,
TRIM
(
$ a
[
1
])); RETURN
STRTOLOWER
(
$ S2
}}}
// echo "lo =>". getmac (). "
";
echo
"eth0 =>"
.
GetMac
(
'Eth0'
).
"
"
ECHO
"eth1 =>"
.
GetMac
(
'Eth1'
).
"
"
;
?>