Php obtains the code of the primary domain in the MAC address and URL of the NIC.
// Obtain the MAC address of the NIC
- @ Exec ("ipconfig/all", $ array );
- For ($ Tmpa; $ Tmpa If (eregi ("Physical", $ array [$ Tmpa]) {
- $ Mac = explode (":", $ array [$ Tmpa]);
- Echo $ mac [1];
- }
- }
// Obtain the url primary domain
- // By http://bbs.it-home.org
- Function GetDomain ($ url ){
- $ Pattern = "/[\ w-] + \. (com | net | org | gov | cc | biz | info | cn )(\. (cn | hk ))*/";
- Preg_match ($ pattern, $ url, $ matches );
- If (count ($ matches)> 0 ){
- Return $ matches [0];
- } Else {
- $ Rs = parse_url ($ url );
- $ Main_url = $ rs ["host"];
- If (! Strcmp (long2ip (sprintf ("% u", ip2long ($ main_url), $ main_url )){
- Return $ main_url;
- } Else {
- $ Arr = explode (".", $ main_url );
- $ Count = count ($ arr );
- $ EndArr = array ("com", "net", "org", "3322"); // com.cn net.cn
- If (in_array ($ arr [$ count-2], $ endArr )){
- $ Domain = $ arr [$ count-3]. ".". $ arr [$ count-2]. ".". $ arr [$ count-1];
- } Else {
- $ Domain = $ arr [$ count-2]. ".". $ arr [$ count-1];
- }
- Return $ domain;
- } // End if (strcmp)
- } // End if (count)
- } // End fun
- ?>
|