Use exec in PHP to obtain the unique identifier of the computer [CPU, Nic MAC address]

Source: Internet
Author: User
In PHP, exec is used to obtain the code with the unique identifier of the computer, and the CPU and Nic MAC address information can be obtained. The code is as follows:


// Obtain the CPU information of the computer

Function OnlyU (){
$ A = '';
$ B = array ();
If (function_exists ('exec ')){
If (mailto :! @ Exec (/all ", $ B )){
Return false;
}
} Elseif (function_exists ('system ')){
Ob_start ();
If (mailto :! @ System (/all ")){
Return false;
} Else {
}
$ B = ob_get_contents ();
Ob_end_clean ();
$ B = explode ("\ n", $ B); // print_r ($ B );
Array_pop ($ B );
} Else {
Return false;
}

$ All = sizeof ($ B );
For ($ I = 0; $ I <$ all; $ I ++ ){
If (strpos ($ B [$ I], "Description ")! = False ){
If (strpos ($ B [$ I + 1], "Physical Address ")! = False ){
$ C = explode (":", $ B [$ I + 1]);
$ A = trim ($ c [1]);
Break;
}
}
} // End
Return empty ($ )? False: $;
} // End function OnlyU


// Obtain the MAC address of the NIC

Function getMAC (){
@ Exec ("ipconfig/all", $ array );
For ($ Tmpa; $ Tmpa If (eregi ("Physical", $ array [$ Tmpa]) {
$ Mac = explode (":", $ array [$ Tmpa]);
Return $ mac [1];
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.