In php programming, by obtaining the user's mac address, you can bind it to the customer's computer, prevent spam registration, etc.
A very simple class. When using it, just print its macAddr attribute directly after instantiation.
Code:
- class Getmac{
- var $result = array(); // Returns a string array with MAC address
- var $macAddr;
- /*Construction*/
- function __construct($osType){
- switch ( strtolower($osType) ){
- case "unix": break;
- case "solaris": break;
- case "aix": break;
$this->for_windows_os();
-
$temp_array = array(); use using with use using ‐ ‐ ‐ ‐ ‐ ‐ ‐ foreach($this->result as $value){ "."[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,
-
return $this->macAddr;
-
}
-
/*Getting method in linux system*/
-
function for_linux_os(){
-
@exec("ifconfig -a", $this->result);
-
return $this->result;
-
}
-
/*Getting method in win system*/
-
function for_windows_os(){
-
@exec("ipconfig /all", $this->result);
- H if ($ this-& gt; result) {
- Return $ This-& gt; Result;}} Else {
- $ ipconfig = $ _Server ["Windir"]. s_file ($ipconfig)) {
- @exec($ipconfig." /all", $this->result);
- e/ all", $this->result); /*1. Implementation class 2. Directly access its macAddr attribute */
- $getMac = new Getmac(PHP_OS);
- echo $getMac->macAddr;
- ?>
-
Copy code
-
-
-
-
Client, network card
-
-
-
-
|