当前位置:Gxlcms > PHP教程 > php获取网卡MAC地址与URL中主域的代码

php获取网卡MAC地址与URL中主域的代码

时间:2021-07-01 10:21:17 帮助过:27人阅读

  1. //获取网卡MAC地址

  2. @exec("ipconfig/all",$array);
  3. for($Tmpa;$Tmpaif(eregi("Physical",$array[$Tmpa])){
  4. $mac=explode(":",$array[$Tmpa]);
  5. echo $mac[1];
  6. }
  7. }

  8. //获取url主域

  9. //by http://bbs.it-home.org
  10. function GetDomain($url){
  11. $pattern = "/[\w-]+\.(com|net|org|gov|cc|biz|info|cn)(\.(cn|hk))*/";
  12. preg_match($pattern, $url, $matches);
  13. if(count($matches) > 0){
  14. return $matches[0];
  15. }else{
  16. $rs = parse_url($url);
  17. $main_url = $rs["host"];
  18. if(!strcmp(long2ip(sprintf("%u",ip2long($main_url))),$main_url)) {
  19. return $main_url;
  20. }else{
  21. $arr = explode(".",$main_url);
  22. $count=count($arr);
  23. $endArr = array("com","net","org","3322");//com.cn net.cn 等情况
  24. if(in_array($arr[$count-2],$endArr)){
  25. $domain = $arr[$count-3].".".$arr[$count-2].".".$arr[$count-1];
  26. }else{
  27. $domain = $arr[$count-2].".".$arr[$count-1];
  28. }
  29. return $domain;
  30. }//end if(strcmp)
  31. }//end if(count)
  32. }//end fun
  33. ?>

人气教程排行