50 'android' =>
'android.*mobile',
51 'androidtablet' =>
'android(?!.*mobile)',
52 'blackberry' =>
'blackberry',
53 'blackberrytablet' =>
'rim tablet os',
54 'iphone' =>
'(iphone|ipod)',
56 'palm' =>
'(avantgo|blazer|elaine|hiptop|palm|plucker|xiino)',
57 'windows' =>
'windows ce; (iemobile|ppc|smartphone)',
58 'windowsphone' =>
'windows phone os',
59 'generic' =>
'(kindle|mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap|opera mini)'
71 $HTTP_USER_AGENT = $_SERVER[
'HTTP_USER_AGENT'];
75 if(preg_match(
'/MSIE ([0-9].[0-9]{1,2})/',$HTTP_USER_AGENT,$log_version))
77 $this->BROWSER_VER = $log_version[1];
78 $this->BROWSER_AGENT =
'IE';
80 elseif(preg_match(
'/Opera ([0-9].[0-9]{1,2})/',$HTTP_USER_AGENT,$log_version) ||
81 preg_match(
'/Opera\/([0-9].[0-9]{1,2})/',$HTTP_USER_AGENT,$log_version))
83 $this->BROWSER_VER = $log_version[1];
84 $this->BROWSER_AGENT =
'OPERA';
86 elseif(preg_match(
'/Safari ([0-9\/.]*)/',$HTTP_USER_AGENT,$log_version) ||
87 preg_match(
'/Safari\/([0-9\/.]*)/',$HTTP_USER_AGENT,$log_version))
89 $this->BROWSER_VER = $log_version[1];
90 $this->BROWSER_AGENT =
'Safari';
92 elseif(preg_match(
'/Firefox ([0-9\/.]*)/',$HTTP_USER_AGENT,$log_version) ||
93 preg_match(
'/Firefox\/([0-9\/.]*)/',$HTTP_USER_AGENT,$log_version))
95 $this->BROWSER_VER = $log_version[1];
96 $this->BROWSER_AGENT =
'Firefox';
98 elseif(preg_match(
'/iCab ([0-9].[0-9a-zA-Z]{1,4})/',$HTTP_USER_AGENT,$log_version) ||
99 preg_match(
'/iCab\/([0-9].[0-9a-zA-Z]{1,4})/',$HTTP_USER_AGENT,$log_version))
101 $this->BROWSER_VER = $log_version[1];
102 $this->BROWSER_AGENT =
'iCab';
104 elseif(preg_match(
'/Mozilla ([0-9].[0-9a-zA-Z]{1,4})/',$HTTP_USER_AGENT,$log_version) ||
105 preg_match(
'/Mozilla\/([0-9].[0-9a-zA-Z]{1,4})/',$HTTP_USER_AGENT,$log_version))
107 $this->BROWSER_VER = $log_version[1];
108 if (preg_match(
'/Gecko/',$HTTP_USER_AGENT,$log_version))
110 $this->BROWSER_AGENT =
'Mozilla';
114 $this->BROWSER_AGENT =
'Netscape';
117 elseif(preg_match(
'/Konqueror\/([0-9].[0-9].[0-9]{1,2})/',$HTTP_USER_AGENT,$log_version) ||
118 preg_match(
'/Konqueror\/([0-9].[0-9]{1,2})/',$HTTP_USER_AGENT,$log_version))
120 $this->BROWSER_VER=$log_version[1];
121 $this->BROWSER_AGENT=
'Konqueror';
125 $this->BROWSER_VER=0;
126 $this->BROWSER_AGENT=
'OTHER';
132 if(strstr($HTTP_USER_AGENT,
'Win'))
134 $this->BROWSER_PLATFORM=
'Win';
136 elseif(strstr($HTTP_USER_AGENT,
'Mac'))
138 $this->BROWSER_PLATFORM=
'Mac';
140 elseif(strstr($HTTP_USER_AGENT,
'Linux'))
142 $this->BROWSER_PLATFORM=
'Linux';
144 elseif(strstr($HTTP_USER_AGENT,
'Unix'))
146 $this->BROWSER_PLATFORM=
'Unix';
148 elseif(strstr($HTTP_USER_AGENT,
'Beos'))
150 $this->BROWSER_PLATFORM=
'Beos';
154 $this->BROWSER_PLATFORM=
'Other';
158 $this->userAgent = $_SERVER[
'HTTP_USER_AGENT'];
159 $this->accept = $_SERVER[
'HTTP_ACCEPT'];
161 if(isset($_SERVER[
'HTTP_X_WAP_PROFILE']) || isset($_SERVER[
'HTTP_PROFILE']))
165 else if(strpos($this->accept,
'text/vnd.wap.wml') > 0 || strpos($this->accept,
'application/vnd.wap.xhtml+xml') > 0)
171 foreach($this->devices as $device => $regexp)
205 if($this->BROWSER_AGENT ==
'IE')
222 public function __call($name, $arguments)
224 $device = substr($name, 2);
225 if($name ==
'is' . ucfirst($device) && array_key_exists(strtolower($device), $this->devices))
231 trigger_error(
'Method '.$name.
' not defined', E_USER_WARNING);
237 $var =
'is' . ucfirst($device);
238 $return = $this->$var === null ? (bool) preg_match(
'/' . $this->devices[strtolower($device)] .
'/i',
$this->userAgent) : $this->$var;
239 if($device !=
'generic' && $return ==
true)
241 $this->isGeneric =
false;
265 return explode(
'.', $this->BROWSER_VER);