<? Php // Display the browser information of the visitor Echo 'browser: '. determinebrowser ($ Agent).' <BR> '; // Display the operating system platform used to access the user Echo 'Platform: '. determineplatform ($ Agent).' <BR> '; // Parse a positive expression against the string in $ _ SERVER ['HTTP _ USER_AGENT '] to obtain information about the browser used to access the user Function determinebrowser ($ Agent ){ $ Browseragent = ""; // Browser $ Browserversion = ""; // browser version If (ereg ('msie ([0-9]. [0-9] {1, 2}) ', $ Agent, $ version )){ $ Browserversion = $ version [1]; $ Browseragent = "Internet Explorer "; } Else if (ereg ('Opera/([0-9] {1, 2}. [0-9] {1, 2}) ', $ Agent, $ version )){ $ Browserversion = $ version [1]; $ Browseragent = "Opera "; } Else if (ereg ('Firefox/([0-9.] {1, 5}) ', $ Agent, $ version )){ $ Browserversion = $ version [1]; $ Browseragent = "Firefox "; } Else if (ereg ('chrome/([0-9.] {1, 3}) ', $ Agent, $ version )){ $ Browserversion = $ version [1]; $ Browseragent = "Chrome "; } Else if (ereg ('safari/([0-9.] {1, 3}) ', $ Agent, $ version )){ $ Browseragent = "Safari "; $ Browserversion = ""; } Else { $ Browserversion = ""; $ Browseragent = "Unknown "; } Return $ browseragent. "". $ browserversion; } // Obtain the information of the browser used to access the user. Function determineplatform ($ Agent ){ $ Browserplatform = ''; If (eregi ('win', $ Agent) & strpos ($ Agent, '95 ')){ $ Browserplatform = "Windows 95 "; } Elseif (eregi ('win 9x', $ Agent) & strpos ($ Agent, '4. 90 ')){ $ Browserplatform = "Windows ME "; } Elseif (eregi ('win', $ Agent) & ereg ('98 ', $ Agent )){ $ Browserplatform = "Windows 98 "; } Elseif (eregi ('win', $ Agent) & eregi ('nt 5.0 ', $ Agent )){ $ Browserplatform = "Window 2000 "; } Elseif (eregi ('win', $ Agent) & eregi ('nt 5.1 ', $ Agent )){ $ Browserplatform = "Windows XP "; } Elseif (eregi ('win', $ Agent) & eregi ('nt 6.0 ', $ Agent )){ $ Browserplatform = "Windows Vista "; } Elseif (eregi ('win', $ Agent) & eregi ('nt 6.1 ', $ Agent )){ $ Browserplatform = "Windows 7 "; } Elseif (eregi ('win', $ Agent) & ereg ('32', $ Agent )){ $ Browserplatform = "Windows 32 "; } Elseif (eregi ('win', $ Agent) & eregi ('nt ', $ Agent )){ $ Browserplatform = "Windows NT "; } Elseif (eregi ('mac OS ', $ Agent )){ $ Browserplatform = "Mac OS "; } Elseif (eregi ('linux ', $ Agent )){ $ Browserplatform = "Linux "; } Elseif (eregi ('unix ', $ Agent )){ $ Browserplatform = "Unix "; } Elseif (eregi ('sun', $ Agent) & eregi ('OS', $ Agent )){ $ Browserplatform = "SunOS "; } Elseif (eregi ('ibm ', $ Agent) & eregi (' OS ', $ Agent )){ $ Browserplatform = "ibm OS/2 "; } Elseif (eregi ('mac', $ Agent) & eregi ('pc', $ Agent )){ $ Browserplatform = "Macintosh "; } Elseif (eregi ('powerpc', $ Agent )){ $ Browserplatform = "PowerPC "; } Elseif (eregi ('Aix ', $ Agent )){ $ Browserplatform = "AIX "; } Elseif (eregi ('hpux ', $ Agent )){ $ Browserplatform = "HPUX "; } Elseif (eregi ('netsd', $ Agent )){ $ Browserplatform = "NetBSD "; } Elseif (eregi ('bsd', $ Agent )){ $ Browserplatform = "BSD "; } Elseif (ereg ('oss1', $ Agent )){ $ Browserplatform = "OSF1 "; } Elseif (ereg ('irix ', $ Agent )){ $ Browserplatform = "IRIX "; } Elseif (eregi ('freebsd ', $ Agent )){ $ Browserplatform = "FreeBSD "; } If ($ browserplatform = '') {$ browserplatform =" Unknown ";} Return $ browserplatform; } ?> |