PHP gets the MAC address

zhaozj2021-02-12  152

PHP acquired MAC address 2004-06-30 Excerpt from: http://xjtusky.net/Article/Article.php/537

PHP gets the MAC address

// 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 you have any questions, please go to www.hisunweb.com message, thank you! / / Please respect the author's labor results

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'

).

"
"

;

?>

转载请注明原文地址:https://www.9cbs.com/read-7449.html

New Post(0)