查看: 6010|回复: 0
打印 上一主题 下一主题

获得游客的操作系统和浏览器的信息的PHP代码

[复制链接]
跳转到指定楼层
1#
发表于 2007-9-30 13:44:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
// Return visitor's OS
function return_os()
{
   $agent = $_SERVER["HTTP_USER_AGENT"];

   if(preg_match('/Win/i', $agent) && preg_match('/NT 5.2/i', $agent)) {// Windows 2003
       $os = "Win2003";
   } elseif (preg_match('/Win/i', $agent) && preg_match('/NT 5.1/i', $agent)) {// Windows XP
       $os = "WinXP";
   } elseif (preg_match('/Win/i', $agent) && preg_match('/NT 5.0/i', $agent)) {// Windows 2000
       $os = "Win2000";
   } elseif (preg_match('/Win/i', $agent) && preg_match('/NT/i', $agent)) {// Windows NT
       $os = "Win2000";
   } elseif (preg_match('/Win/i', $agent) && preg_match('/4.90/i', $agent)) {// Windows ME
       $os = "Win9X";
   } elseif (preg_match('/Win/i', $agent) && preg_match('/98/i', $agent)) {// Windows 98
       $os = "Win9X";
   } elseif (preg_match('/Win/i', $agent) && preg_match('/95/i', $agent)) {// Windows 95
       $os = "Win9X";
   } elseif (preg_match('/Win/i', $agent) && preg_match('/32/i', $agent)) {// Windows 32
       $os = "Win9X";
   } elseif (preg_match('/Linux/i', $agent)) {// linux
       $os = "Linux";
   } elseif (preg_match('/BSD/i', $agent)) {// *BSD
       $os = "Unix";
   } elseif (preg_match('/Unix/i', $agent)) {// Unix
       $os = "Unix";
   } elseif (preg_match('/Sun/i', $agent)) {// SunOS
       $os = "SunOS";
   } elseif (preg_match('/Mac/i', $agent)) {// Macintosh
       $os = "Macintosh";
   } elseif (preg_match('/IBM/i', $agent)) {// IBMOS
       $os = "IBMOS";
   } else {// Other
       $os = "Other";
   }

   return trim($os);
}

// Return visitor's browser
function return_browser()
{
   $agent = $_SERVER["HTTP_USER_AGENT"];

   if(preg_match('/Firefox/i',$agent)) {
       $browser="Firefox";
   } elseif (preg_match('/Netscape/i',$agent)) {
       $browser="Netscape";
   } elseif (preg_match('/NetCaptor/i',$agent)) {// has MSIE
       $browser="NetCaptor";
   } elseif (preg_match('/MSN/i',$agent)) {// has MSIE
       $browser="MSN Explorer";
   } elseif (preg_match('/Opera/i',$agent)) {// has MSIE
       $browser="Opera";
   } elseif (preg_match('/AOL/i',$agent)) {
       $browser="AOL";
   } elseif (preg_match('/JAVA/i',$agent)) {
       $browser="JAVA";
   } elseif (preg_match('/MacWeb/i',$agent)) {
       $browser="MacWeb";
   } elseif (preg_match("/MSIE/i", $agent)) {
       $str = explode(";",$agent);
       $str = $str['1'];
       $str = explode(" ",$str);
       $browser_ver = $str['2'];
       if($browser_ver == "6.0") {
           $browser = "IE6";
       } else {
           $browser = "IE5";
       }
   } else {
       $browser = "Other";
   }

   return trim($browser);
}
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表