3 * Copyright 1999-2001 (c) VA Linux Systems
4 * http://fusionforge.org
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 unset ($BROWSER_AGENT);
24 unset ($BROWSER_PLATFORM);
26 function browser_get_agent () {
27 global $BROWSER_AGENT;
28 return $BROWSER_AGENT;
31 function browser_get_version() {
36 function browser_get_platform() {
37 global $BROWSER_PLATFORM;
38 return $BROWSER_PLATFORM;
41 function browser_is_mac() {
42 if (browser_get_platform()=='Mac') {
49 function browser_is_windows() {
50 if (browser_get_platform()=='Win') {
57 function browser_is_ie() {
58 if (browser_get_agent()=='IE') {
65 function browser_is_netscape() {
66 if (browser_get_agent()=='MOZILLA') {
75 Determine browser and version
79 if (preg_match('/MSIE ([0-9].[0-9]{1,2})/',getStringFromServer('HTTP_USER_AGENT'),$log_version)) {
80 $GLOBALS['BROWSER_VER']=$log_version[1];
81 $GLOBALS['BROWSER_AGENT']='IE';
82 } elseif (preg_match('/Opera ([0-9].[0-9]{1,2})/',getStringFromServer('HTTP_USER_AGENT'),$log_version)) {
83 $GLOBALS['BROWSER_VER']=$log_version[1];
84 $GLOBALS['BROWSER_AGENT']='OPERA';
85 } elseif (preg_match('/Mozilla\/([0-9].[0-9]{1,2})/',getStringFromServer('HTTP_USER_AGENT'),$log_version)) {
86 $GLOBALS['BROWSER_VER']=$log_version[1];
87 $GLOBALS['BROWSER_AGENT']='MOZILLA';
89 $GLOBALS['BROWSER_VER']=0;
90 $GLOBALS['BROWSER_AGENT']='OTHER';
97 if (strstr(getStringFromServer('HTTP_USER_AGENT'),'Win')) {
98 $GLOBALS['BROWSER_PLATFORM']='Win';
99 } else if (strstr(getStringFromServer('HTTP_USER_AGENT'),'Mac')) {
100 $GLOBALS['BROWSER_PLATFORM']='Mac';
101 } else if (strstr(getStringFromServer('HTTP_USER_AGENT'),'Linux')) {
102 $GLOBALS['BROWSER_PLATFORM']='Linux';
103 } else if (strstr(getStringFromServer('HTTP_USER_AGENT'),'Unix')) {
104 $GLOBALS['BROWSER_PLATFORM']='Unix';
106 $GLOBALS['BROWSER_PLATFORM']='Other';
110 echo "\n\nAgent: ".getStringFromServer('HTTP_USER_AGENT');
111 echo "\nIE: ".browser_is_ie();
112 echo "\nMac: ".browser_is_mac();
113 echo "\nWindows: ".browser_is_windows();
114 echo "\nPlatform: ".browser_get_platform();
115 echo "\nVersion: ".browser_get_version();
116 echo "\nAgent: ".browser_get_agent();