首页 >后端开发 >php教程 >php获取网卡MAC地址与URL中主域的代码

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

WBOY
WBOY原创
2016-07-25 09:00:34833浏览
  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. ?>
复制代码


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn