22 #require_once 'Zend/Http/UserAgent/Device.php'; 109 if (is_array($userAgent)) {
115 $this->_server = $server;
130 '_aFeatures' => $this->_aFeatures,
131 '_aGroup' => $this->_aGroup,
132 '_browser' => $this->_browser,
133 '_browserVersion' => $this->_browserVersion,
134 '_userAgent' => $this->_userAgent,
135 '_images' => $this->_images,
160 foreach ($spec as $key =>
$value) {
161 if (property_exists($this, $key)) {
176 if (is_array($features)) {
177 $this->_aFeatures = array_merge($this->_aFeatures, $features);
188 abstract public function getType();
198 return (isset($this->_aFeatures[$feature]) && !is_null($this->_aFeatures[$feature]));
210 return $this->_aFeatures[$feature];
224 $this->_aFeatures[$feature] =
$value;
240 if (!isset($this->_aGroup[
$group])) {
241 $this->_aGroup[
$group] = array();
243 if (!in_array($feature, $this->_aGroup[
$group])) {
244 $this->_aGroup[
$group][] = $feature;
257 return $this->_aGroup[
$group];
293 if (is_array($uaExtract)) {
294 foreach ($uaExtract as $key =>
$info) {
299 if (isset($uaExtract[
'browser_name'])) {
300 $this->_browser = $uaExtract[
'browser_name'];
302 if (isset($uaExtract[
'browser_version'])) {
303 $this->_browserVersion = $uaExtract[
'browser_version'];
305 if (isset($uaExtract[
'device_os'])) {
306 $this->device_os = $uaExtract[
'device_os_name'];
310 $this->
setFeature(
'is_wireless_device',
false,
'product_info');
311 $this->
setFeature(
'is_mobile',
false,
'product_info');
312 $this->
setFeature(
'is_desktop',
false,
'product_info');
313 $this->
setFeature(
'is_tablet',
false,
'product_info');
314 $this->
setFeature(
'is_bot',
false,
'product_info');
315 $this->
setFeature(
'is_email',
false,
'product_info');
316 $this->
setFeature(
'is_text',
false,
'product_info');
317 $this->
setFeature(
'device_claims_web_support',
false,
'product_info');
322 if (isset($this->list) && empty($this->_browser)) {
324 foreach ($this->list as $browser_signature) {
325 if (strpos($lowerUserAgent, $browser_signature) !==
false) {
326 $this->_browser = strtolower($browser_signature);
327 $this->
setFeature(
'browser_name', $this->_browser,
'product_info');
333 if (isset($this->_server[
'remote_addr'])) {
334 $this->
setFeature(
'client_ip', $this->_server[
'remote_addr'],
'product_info');
335 }
elseif (isset($this->_server[
'http_x_forwarded_for'])) {
336 $this->
setFeature(
'client_ip', $this->_server[
'http_x_forwarded_for'],
'product_info');
337 }
elseif (isset($this->_server[
'http_client_ip'])) {
338 $this->
setFeature(
'client_ip', $this->_server[
'http_client_ip'],
'product_info');
342 if (isset($this->_server[
'server_software'])) {
343 if (strpos($this->_server[
'server_software'],
'Apache') !==
false || strpos($this->_server[
'server_software'],
'LiteSpeed') !==
false) {
344 $server[
'version'] = 1;
345 if (strpos($this->_server[
'server_software'],
'Apache/2') !==
false) {
346 $server[
'version'] = 2;
348 $server[
'server'] =
'apache';
351 if (strpos($this->_server[
'server_software'],
'Microsoft-IIS') !==
false) {
352 $server[
'server'] =
'iis';
355 if (strpos($this->_server[
'server_software'],
'Unix') !==
false) {
356 $server[
'os'] =
'unix';
357 if (isset($_ENV[
'MACHTYPE'])) {
358 if (strpos($_ENV[
'MACHTYPE'],
'linux') !==
false) {
359 $server[
'os'] =
'linux';
362 }
elseif (strpos($this->_server[
'server_software'],
'Win') !==
false) {
363 $server[
'os'] =
'windows';
366 if (preg_match(
'/Apache\/([0-9\.]*)/', $this->_server[
'server_software'], $arr)) {
368 $server[
'version'] = $arr[1];
369 $server[
'server'] =
'apache';
374 $this->
setFeature(
'php_version', phpversion(),
'server_info');
375 if (isset($server[
'server'])) {
376 $this->
setFeature(
'server_os', $server[
'server'],
'server_info');
378 if (isset($server[
'version'])) {
379 $this->
setFeature(
'server_os_version', $server[
'version'],
'server_info');
381 if (isset($this->_server[
'http_accept'])) {
382 $this->
setFeature(
'server_http_accept', $this->_server[
'http_accept'],
'server_info');
384 if (isset($this->_server[
'http_accept_language'])) {
385 $this->
setFeature(
'server_http_accept_language', $this->_server[
'http_accept_language'],
'server_info');
387 if (isset($this->_server[
'server_addr'])) {
388 $this->
setFeature(
'server_ip', $this->_server[
'server_addr'],
'server_info');
390 if (isset($this->_server[
'server_name'])) {
391 $this->
setFeature(
'server_name', $this->_server[
'server_name'],
'server_info');
403 $userAgent = trim($userAgent);
408 $pattern =
"(([^/\s]*)(/(\S*))?)(\s*\[[a-zA-Z][a-zA-Z]\])?\s*(\\((([^()]|(\\([^()]*\\)))*)\\))?\s*";
409 preg_match(
"#^$pattern#", $userAgent, $match);
412 if (isset($match[7])) {
413 $comment = explode(
';', $match[7]);
417 $end = substr($userAgent, strlen($match[0]));
419 $result[
'others'][
'full'] = $end;
423 if (isset(
$result[
'others'])) {
424 preg_match_all(
'/(([^\/\s]*)(\/)?([^\/\(\)\s]*)?)(\s\((([^\)]*)*)\))?/i',
$result[
'others'][
'full'], $match2);
426 $result[
'user_agent'] = trim($match[1]);
427 $result[
'product_name'] = isset($match[2]) ? trim($match[2]) :
'';
429 if (isset($match[4]) && trim($match[4])) {
430 $result[
'product_version'] = trim($match[4]);
431 $result[
'browser_version'] = trim($match[4]);
433 if (count($comment) && !empty($comment[0])) {
434 $result[
'comment'][
'full'] = trim($match[7]);
435 $result[
'comment'][
'detail'] = $comment;
436 $result[
'compatibility_flag'] = trim($comment[0]);
437 if (isset($comment[1])) {
438 $result[
'browser_token'] = trim($comment[1]);
440 if (isset($comment[2])) {
441 $result[
'device_os_token'] = trim($comment[2]);
444 if (empty(
$result[
'device_os_token']) && !empty(
$result[
'compatibility_flag'])) {
450 $max = count($match2[0]);
451 for (
$i = 0;
$i < $max;
$i ++) {
452 if (!empty($match2[0][
$i])) {
453 $result[
'others'][
'detail'][] = array(
464 'N' =>
'no security',
465 'U' =>
'strong security',
466 'I' =>
'weak security',
468 if (!empty(
$result[
'browser_token'])) {
469 if (isset($security[
$result[
'browser_token']])) {
471 unset(
$result[
'browser_token']);
478 $compatibleOrIe =
false;
479 if (isset(
$result[
'compatibility_flag']) && isset(
$result[
'comment'])) {
480 $compatibleOrIe = (
$result[
'compatibility_flag'] ==
'compatible' || strpos(
$result[
'comment'][
'full'],
"MSIE") !==
false);
482 if (
$product ==
'mozilla' && $compatibleOrIe) {
483 if (!empty(
$result[
'browser_token'])) {
485 preg_match_all(
'/([^\/\s].*)(\/|\s)(.*)/i',
$result[
'browser_token'], $real);
488 foreach (
$result[
'comment'][
'detail'] as $v) {
489 if (strpos($v,
'MSIE') !==
false) {
490 $real[0][1] = trim($v);
491 $result[
'browser_engine'] =
"MSIE";
492 $real[1][0] =
"Internet Explorer";
493 $temp = explode(
' ', trim($v));
494 $real[3][0] = $temp[1];
497 if (strpos($v,
'Win') !==
false) {
498 $result[
'device_os_token'] = trim($v);
503 if (!empty($real[0])) {
504 $result[
'browser_name'] = $real[1][0];
505 $result[
'browser_version'] = $real[3][0];
507 if(isset(
$result[
'browser_token'])) {
510 $result[
'browser_version'] =
'??';
513 &&
$result[
'browser_version'] < 5.0
516 $result[
'browser_name'] =
'Netscape';
520 if (
$result[
'browser_name'] ==
'MSIE') {
521 $result[
'browser_engine'] =
'MSIE';
522 $result[
'browser_name'] =
'Internet Explorer';
524 if (isset(
$result[
'device_os_token'])) {
525 if (strpos(
$result[
'device_os_token'],
'Win') !==
false) {
528 'Windows NT 6.1' =>
'Windows 7',
529 'Windows NT 6.0' =>
'Windows Vista',
530 'Windows NT 5.2' =>
'Windows Server 2003',
531 'Windows NT 5.1' =>
'Windows XP',
532 'Windows NT 5.01' =>
'Windows 2000 SP1',
533 'Windows NT 5.0' =>
'Windows 2000',
534 'Windows NT 4.0' =>
'Microsoft Windows NT 4.0',
535 'WinNT' =>
'Microsoft Windows NT 4.0',
536 'Windows 98; Win 9x 4.90' =>
'Windows Me',
537 'Windows 98' =>
'Windows 98',
538 'Win98' =>
'Windows 98',
539 'Windows 95' =>
'Windows 95',
540 'Win95' =>
'Windows 95',
541 'Windows CE' =>
'Windows CE',
543 if (isset($windows[
$result[
'device_os_token']])) {
552 $apple_device = array(
557 if (isset(
$result[
'compatibility_flag'])) {
558 if (in_array(
$result[
'compatibility_flag'], $apple_device)) {
560 $result[
'device_os_token'] =
'iPhone OS';
561 if (isset($comment[3])) {
562 $result[
'browser_language'] = trim($comment[3]);
564 if (isset(
$result[
'others'][
'detail'][1])) {
569 if (!empty(
$result[
'others'][
'detail'][2])) {
572 if (!empty(
$result[
'others'][
'detail'][3])) {
580 if (isset(
$result[
'others'])) {
581 if (
$result[
'others'][
'detail'][0][1] ==
'AppleWebKit') {
582 $result[
'browser_engine'] =
'AppleWebKit';
583 if (isset(
$result[
'others'][
'detail'][1]) &&
$result[
'others'][
'detail'][1][1] ==
'Version') {
588 if (isset($comment[3])) {
589 $result[
'browser_language'] = trim($comment[3]);
592 $last =
$result[
'others'][
'detail'][count(
$result[
'others'][
'detail']) - 1][1];
594 if (empty(
$result[
'others'][
'detail'][2][1]) ||
$result[
'others'][
'detail'][2][1] ==
'Safari') {
595 if (isset(
$result[
'others'][
'detail'][1])) {
596 $result[
'browser_name'] = (
$result[
'others'][
'detail'][1][1] &&
$result[
'others'][
'detail'][1][1] !=
'Version' ?
$result[
'others'][
'detail'][1][1] :
'Safari');
597 $result[
'browser_version'] = (
$result[
'others'][
'detail'][1][2] ?
$result[
'others'][
'detail'][1][2] :
$result[
'others'][
'detail'][0][2]);
599 $result[
'browser_name'] = (
$result[
'others'][
'detail'][0][1] &&
$result[
'others'][
'detail'][0][1] !=
'Version' ?
$result[
'others'][
'detail'][0][1] :
'Safari');
607 if (
$result[
'browser_name'] ==
'Mobile') {
609 if (
$result[
'others'][
'detail'][1][1] ==
'Version') {
616 if (strpos(
$result[
'browser_version'],
'.') > 2 || (int)
$result[
'browser_version'] > 20) {
617 $temp = explode(
'.',
$result[
'browser_version']);
618 $build = (int) $temp[0];
628 foreach ($awkVersion as $k => $v) {
630 $result[
'browser_version'] = $v;
637 if (
$result[
'others'][
'detail'][0][1] ==
'Gecko') {
639 if (!empty(
$result[
'others'][
'detail'][1][1]) && !empty(
$result[
'others'][
'detail'][count(
$result[
'others'][
'detail']) - 1][2]) || strpos(strtolower(
$result[
'others'][
'full']),
'opera') !==
false) {
645 $last = count(
$result[
'others'][
'detail']) - 1;
649 if (empty(
$result[
'others'][
'detail'][$last][2])) {
655 if (in_array(
$result[
'others'][
'detail'][$last][1], array(
662 $result[
'browser_version'] =
$result[
'others'][
'detail'][$last][2];
663 if (isset($comment[4])) {
664 $result[
'browser_build'] = trim($comment[4]);
666 if (isset($comment[3])) {
667 $result[
'browser_language'] = trim($comment[3]);
671 if (
$result[
'browser_name'] ==
'Navigator' ||
$result[
'browser_name'] ==
'Netscape6') {
672 $result[
'browser_name'] =
'Netscape';
677 $result[
'browser_name'] =
'Mozilla';
678 if (isset(
$result[
'comment'][
'detail'])) {
679 foreach (
$result[
'comment'][
'detail'] as $rv) {
680 if (strpos($rv,
'rv:') !==
false) {
681 $result[
'browser_version'] = trim(str_replace(
'rv:',
'', $rv));
689 if (
$result[
'others'][
'detail'][0][1] ==
'Netscape') {
690 $result[
'browser_name'] =
'Netscape';
696 if (
$result[
'others'][
'detail'][0][1] ==
'Presto') {
697 $result[
'browser_engine'] =
'Presto';
698 if (!empty(
$result[
'others'][
'detail'][1][2])) {
704 if (
$result[
'others'][
'detail'][0][1] ==
'Opera') {
707 if (isset(
$result[
'others'][
'detail'][1][1])) {
716 if (isset(
$result[
"browser_token"])) {
717 if (strpos(
$result[
"browser_token"],
'Opera Mini') !==
false) {
718 $result[
'browser_name'] =
'Opera Mini';
723 if (
$result[
'others'][
'detail'][0][1] ==
'SymbianOS') {
724 $result[
'device_os_token'] =
'SymbianOS';
729 if (isset(
$result[
'browser_name']) && isset(
$result[
'browser_engine'])) {
730 if (
$result[
'browser_name'] ==
'Opera' &&
$result[
'browser_engine'] ==
'Gecko' && empty(
$result[
'browser_version'])) {
736 if (isset(
$result[
'browser_version']) && isset(
$result[
'browser_build'])) {
738 unset(
$result[
'browser_build']);
743 $compatibility[
'AppleWebKit'] =
'Safari';
744 $compatibility[
'Gecko'] =
'Firefox';
745 $compatibility[
'MSIE'] =
'Internet Explorer';
746 $compatibility[
'Presto'] =
'Opera';
747 if (!empty(
$result[
'browser_engine'])) {
748 if (isset($compatibility[
$result[
'browser_engine']])) {
749 $result[
'browser_compatibility'] = $compatibility[
$result[
'browser_engine']];
767 $browserType = $this->
getType();
768 if (!isset(
$config[$browserType]) || !isset(
$config[$browserType][
'features'])) {
773 if (empty(
$config[
'classname'])) {
774 #require_once 'Zend/Http/UserAgent/Exception.php'; 783 #require_once 'Zend/Http/UserAgent/Exception.php'; 787 if (
false === include_once (
$path)) {
788 #require_once 'Zend/Http/UserAgent/Exception.php'; 949 $this->_browser = $browser;
957 $this->_browserVersion = $browserVersion;
965 $this->_userAgent = $userAgent;
986 $userAgent = strtolower($userAgent);
987 foreach ($signatures as $signature) {
988 if (!empty($signature)) {
989 if (strpos($userAgent, $signature) !==
false) {
elseif(isset( $params[ 'redirect_parent']))
__construct($userAgent=null, array $server=array(), array $config=array())
call_user_func($callable, $param)
getPhysicalScreenHeight()
_restoreFromArray(array $spec)
static _matchAgentAgainstSignatures($userAgent, $signatures)
setBrowserVersion($browserVersion)
static extractFromUserAgent($userAgent)
foreach( $_productCollection as $_product)() ?>" class $info
setGroup($group, $feature)
setFeature($feature, $value=false, $group='')