❶ 识别360浏览器代码
function getbrowser()
{
global $_SERVER;
if (!isset($_SERVER['HTTP_USER_AGENT']))
{
return 'Unknow browser';
}
$agent = $_SERVER['HTTP_USER_AGENT'];
$browser = '';
$browser_ver = '';
if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs))
{
$browser = 'Internet Explorer';
$browser_ver = $regs[1];
}
elseif (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs))
{
$browser = 'FireFox';
$browser_ver = $regs[1];
}
elseif (preg_match('/Maxthon/i', $agent, $regs))
{
$browser = '(Internet Explorer ' .$browser_ver. ') Maxthon';
$browser_ver = '';
}
elseif (preg_match('/GreenBrowser/i', $agent, $regs))
{
$browser = 'GreenBrowser';
$browser_ver = '';
}
elseif (preg_match('/TheWorld/i', $agent, $regs))
{
$browser = 'TheWorld';
$browser_ver = '';
}
elseif (preg_match('/360SE/i', $agent, $regs))
{
$browser = '360SE';
$browser_ver = '';
}
elseif (preg_match('/TencentTraveler/i', $agent, $regs))
{
$browser = 'TencentTraveler';
$browser_ver = '';
}
elseif (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs))
{
$browser = 'Opera';
$browser_ver = $regs[1];
}
elseif (preg_match('/Chrome/i', $agent, $regs))
{
$browser = 'Chrome';
$browser_ver = '';
}
elseif (preg_match('/OmniWeb\/(v*)([^\s|;]+)/i', $agent, $regs))
{
$browser = 'OmniWeb';
$browser_ver = $regs[2];
}
elseif (preg_match('/Netscape([\d]*)\/([^\s]+)/i', $agent, $regs))
{
$browser = 'Netscape';
$browser_ver = $regs[2];
}
elseif (preg_match('/safari\/([^\s]+)/i', $agent, $regs))
{
$browser = 'Safari';
$browser_ver = $regs[1];
}
elseif (preg_match('/NetCaptor\s([^\s|;]+)/i', $agent, $regs))
{
$browser = '(Internet Explorer ' .$browser_ver. ') NetCaptor';
$browser_ver = $regs[1];
}
elseif (preg_match('/Lynx\/([^\s]+)/i', $agent, $regs))
{
$browser = 'Lynx';
$browser_ver = $regs[1];
}
if (!empty($browser))
{
return addslashes($browser . ' ' . $browser_ver);
}
else
{
return 'Unknow browser';
}
}
function get_os()
{
global $_SERVER;
if (!isset($_SERVER['HTTP_USER_AGENT']))
{
return 'Unknown';
}
$agent = $_SERVER['HTTP_USER_AGENT'];
$os = '';
if(eregi('win', $agent) && eregi('nt 6.1', $agent)){
$os = "Windows 7";
}
elseif(eregi('win', $agent) && eregi('nt 6.0', $agent))
{
$os = "Windows Vista";
}
elseif(eregi('win', $agent) && eregi('nt 5.2', $agent))
{
$os = "Windows 2003";
}
elseif (eregi('win', $agent) && eregi('nt 5.1', $agent))
{
$os = 'Windows XP';
}
elseif (eregi('win 9x', $agent) && strpos($agent, '4.90'))
{
$os = 'Windows ME';
}
elseif (eregi('win', $agent) && ereg('98', $agent))
{
$os = 'Windows 98';
}
elseif (eregi('win', $agent) && strpos($agent, '95'))
{
$os = 'Windows 95';
}
elseif (eregi('win', $agent) && eregi('nt 5', $agent))
{
$os = 'Windows 2000';
}
elseif (eregi('win', $agent) && eregi('nt', $agent))
{
$os = 'Windows NT';
}
elseif (eregi('win', $agent) && ereg('32', $agent))
{
$os = 'Windows 32';
}
elseif (eregi('linux', $agent))
{
$os = 'Linux';
}
elseif (eregi('unix', $agent))
{
$os = 'Unix';
}
elseif (eregi('sun', $agent) && eregi('os', $agent))
{
$os = 'SunOS';
}
elseif (eregi('ibm', $agent) && eregi('os', $agent))
{
$os = 'IBM OS/2';
}
elseif (eregi('Mac', $agent) && eregi('PC', $agent))
{
$os = 'Macintosh';
}
elseif (eregi('PowerPC', $agent))
{
$os = 'PowerPC';
}
elseif (eregi('AIX', $agent))
{
$os = 'AIX';
}
elseif (eregi('HPUX', $agent))
{
$os = 'HPUX';
}
elseif (eregi('NetBSD', $agent))
{
$os = 'NetBSD';
}
elseif (eregi('BSD', $agent))
{
$os = 'BSD';
}
elseif (ereg('OSF1', $agent))
{
$os = 'OSF1';
}
elseif (ereg('IRIX', $agent))
{
$os = 'IRIX';
}
elseif (eregi('FreeBSD', $agent))
{
$os = 'FreeBSD';
}
elseif (eregi('teleport', $agent))
{
$os = 'teleport';
}
elseif (eregi('flashget', $agent))
{
$os = 'flashget';
}
elseif (eregi('webzip', $agent))
{
$os = 'webzip';
}
elseif (eregi('offline', $agent))
{
$os = 'offline';
}
else
{
$os = 'Unknown';
}
return $os;
}
试试这个,