Files
AutoIndex-pl4/classes/MobileDeviceDetect.php

616 lines
25 KiB
PHP
Raw Permalink Normal View History

2020-12-23 03:18:48 +02:00
<?php
/**
* @package AutoIndex
*
* @copyright (c) 2002-2021 Markus Petrux, John Olson, FlorinCB aka orynider at github.com
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2
* @version $Id: MobileDeviceDetect.php, v 2.2.6 2023/11/25 23:08:08 orynider Exp $
2020-12-23 03:18:48 +02:00
* @link http://mxpcms.sourceforge.net/
* @link http://autoindex.sourceforge.net
*/
/*
AutoIndex PHP Script is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
AutoIndex PHP Script is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if (!defined('IN_AUTOINDEX') || !IN_AUTOINDEX)
{
die();
}
class MobileDeviceDetect
{
/** @var \autoindex\cache\driver\driver_interface */
protected $cache;
protected $words;
protected $request;
2024-03-18 19:50:32 +02:00
protected $language;
2020-12-23 03:18:48 +02:00
2021-04-11 17:29:47 +03:00
private $_user_agent;
private $_name;
private $_version;
private $_platform;
2020-12-23 03:18:48 +02:00
/**
* Load sessions
* @access public
*
2024-03-18 19:50:32 +02:00
*/
2021-04-11 17:29:47 +03:00
function __construct($ua = '')
2020-12-23 03:18:48 +02:00
{
global $cache;
global $request, $words;
2024-03-18 19:50:32 +02:00
$this->cache = $cache;
$this->request = $request;
$this->language = $words;
2021-04-11 17:29:47 +03:00
if(empty($ua))
{
$this->_user_agent = $request->server('HTTP_USER_AGENT');
}
else
{
$this->_user_agent = $ua;
}
//$this->_user_agent = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : '';
2020-12-23 03:18:48 +02:00
}
/**
* @package Mobile Device Detect class
* @author FlorinCB aka orynider
* @copyright (c) 2015 Sniper_E - http://www.sniper-e.com
* @copyright (c) 2015 dmzx - http://www.dmzx-web.net
* @copyright (c) 2015 martin - http://www.martins-phpbb.com
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*/
public function mobile_device_detect($iphone = true, $ipod = true, $ipad = true, $android = true, $opera = true, $blackberry = true, $palm = true, $windows = true, $lg = true)
{
$mobile_browser = false;
switch (true)
{
2021-04-11 17:29:47 +03:00
case (preg_match('/x86_64|WOW64|Win64|Iceweasel/i', $this->_user_agent));
$status = $this->language->__get('DESKTOP');
2020-12-23 03:18:48 +02:00
$mobile_browser = true;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/Bot|CFNetwork|libwww|Java|Jigsaw|SpreadTrum|httpget/i', $this->_user_agent));
2020-12-23 03:18:48 +02:00
$mobile_browser = false;
break;
case (preg_match('/ipad/i',$this->_user_agent));
$status = $this->language->__get('IPAD');
2020-12-23 03:18:48 +02:00
$mobile_browser = $ipad;
break;
case (preg_match('/ipod/i',$this->_user_agent));
$status = $this->language->__get('IPOD');
2020-12-23 03:18:48 +02:00
$mobile_browser = $ipod;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/iphone/i', $this->_user_agent));
$status = $this->language->__get('IPHONE');
2020-12-23 03:18:48 +02:00
$mobile_browser = $iphone;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/android/i', $this->_user_agent));
if (preg_match('/SM-G870A/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS5A');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-G900A|SM-G900F|SM-G900H|SM-G900M|SM-G900P|SM-G900R4|SM-G900T|SM-G900V|SM-G900W8|SM-G800F/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS5');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-G920F/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS6');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SGH-I497/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SG2T');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/GT-P5210|SM-T110|SM-T310/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGT3');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-T210/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGT3W');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-T335|SM-T530/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGT4');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-T520/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGTP');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SGH-I537/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS4A');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/GT-I9505|GT-I9500|SPH-L720T/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS4');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/GT-I9100P/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS2');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-N9005|SM-P600/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGN3');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-N7505/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGN3N');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-N910C|SM-N910F/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGN4');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-N920P/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGN5');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-G357FZ/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGA4');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-G925P/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS6E');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-G935F/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS7E');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/SM-G950F|SM-G955F/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS8');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/GT-S7582/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGSD2');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/GT-I9100P/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGS2');
2020-12-23 03:18:48 +02:00
}
else if (preg_match('/HONORPLK-L01/i',$user_agent))
{
$status = $this->language->__get('HPL01');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/EVA-L09/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('HPL09');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/VNS-L23/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('HPL23');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/IMM76B/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SGN');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/TF101/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('ATT');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/Archos 40b/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('A4TS');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/A0001/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('OPO');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/Orange Nura/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('ORN');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/XT1030/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('MDM');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/TIANYU-KTOUCH/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('TKT');
2020-12-23 03:18:48 +02:00
}
else if (preg_match('/D2005|D2105/i',$user_agent))
{
$status = $this->language->__get('SXED');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/C2005|D2303/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SXM2');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/C6906/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SXZ1');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/D5803/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('SXZ3');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/P710/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('LGOL7IT');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/LG-H850/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('LGH850');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/LG-V500/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('LGV500');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/lg/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('LG');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/ASUS_T00J/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('ATOOJ');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/Aquaris E5/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('AE5HD');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/HTC Desire|626s/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('HTCD');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/Nexus One/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('N1');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/Nexus 4|LRX22C|LVY48F|LMY47V/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('N4');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/Nexus 5|LMY48S/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('N5');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/Nexus 7|KTU84P/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('N7');
2020-12-23 03:18:48 +02:00
}
else if (preg_match('/Nexus 9|LMY47X/i',$user_agent))
{
$status = $this->language->__get('N9');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/Lenovo_K50_T5/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('LK50T5');
2020-12-23 03:18:48 +02:00
}
else
{
$status = $this->language->__get('ANDROID');
2020-12-23 03:18:48 +02:00
}
$mobile_browser = $android;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/opera mini/i', $this->_user_agent));
$status = $this->language->__get('MOBILE_DEVICE');
2020-12-23 03:18:48 +02:00
$mobile_browser = $opera;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/blackberry/i', $this->_user_agent));
2020-12-23 03:18:48 +02:00
if (preg_match('/BlackBerry9900|BlackBerry9930|BlackBerry9790|BlackBerry9780|BlackBerry9700|BlackBerry9650|BlackBerry9000|/i',$user_agent))
{
$status = 'BlackBerry Bold';
}
else if (preg_match('/BlackBerry9380|BlackBerry9370|BlackBerry9360|BlackBerry9350|BlackBerry9330|BlackBerry9320|BlackBerry9300|BlackBerry9220|BlackBerry8980|BlackBerry8900|BlackBerry8530|BlackBerry8520|BlackBerry8330|BlackBerry8320|BlackBerry8310|BlackBerry8300/i',$user_agent))
{
$status = $this->language->__get('BBCURVE');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/BlackBerry9860|BlackBerry9850|BlackBerry9810|BlackBerry9800/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('BBTORCH');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/BlackBerry9900/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('BBTOUCH');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/BlackBerry9105/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('BBPEARL');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/BlackBerry8220/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('BBPEARLF');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/BlackBerry Storm|BlackBerry Storm2/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('BBSTORM');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/BlackBerry Passport/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('BBPP');
2020-12-23 03:18:48 +02:00
}
else if (preg_match('/BlackBerry Porsche/i',$user_agent))
{
$status = $this->language->__get('BBP');
2020-12-23 03:18:48 +02:00
}
2021-04-11 17:29:47 +03:00
else if (preg_match('/BlackBerry PlayBook/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('BBPB');
2020-12-23 03:18:48 +02:00
}
else
{
$status = $this->language->__get('BLACKBERRY');
2020-12-23 03:18:48 +02:00
}
$mobile_browser = $blackberry;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i', $this->_user_agent));
$status = $this->language->__get('PALM');
2020-12-23 03:18:48 +02:00
$mobile_browser = $palm;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/(iris|3g_t|windows ce|windows Phone|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i', $this->_user_agent));
if (preg_match('/Lumia 640 XL/i', $this->_user_agent))
2020-12-23 03:18:48 +02:00
{
$status = $this->language->__get('L640XL');
2020-12-23 03:18:48 +02:00
}
else
{
$status = $this->language->__get('WSP');
2020-12-23 03:18:48 +02:00
}
$mobile_browser = $windows;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/lge vx10000/i', $this->_user_agent));
$status = $this->language->__get('VOYAGER');
2020-12-23 03:18:48 +02:00
$mobile_browser = $windows;
break;
2021-04-11 17:29:47 +03:00
case (preg_match('/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i', $this->_user_agent));
$status = $this->language->__get('MOBILE_DEVICE');
2020-12-23 03:18:48 +02:00
$mobile_browser = true;
break;
case (isset($post['HTTP_X_WAP_PROFILE']) || isset($post['HTTP_PROFILE']));
$status = $this->language->__get('MOBILE_DEVICE');
2020-12-23 03:18:48 +02:00
$mobile_browser = true;
break;
case (in_array(strtolower(substr($this->_user_agent, 0, 4)), array('1207'=>'1207','3gso'=>'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>'770s','802s'=>'802s','a wa'=>'a wa','acer'=>'acer','acs-'=>'acs-','airn'=>'airn','alav'=>'alav','asus'=>'asus','attw'=>'attw','au-m'=>'au-m','aur '=>'aur ','aus '=>'aus ','abac'=>'abac','acoo'=>'acoo','aiko'=>'aiko','alco'=>'alco','alca'=>'alca','amoi'=>'amoi','anex'=>'anex','anny'=>'anny','anyw'=>'anyw','aptu'=>'aptu','arch'=>'arch','argo'=>'argo','bell'=>'bell','bird'=>'bird','bw-n'=>'bw-n','bw-u'=>'bw-u','beck'=>'beck','benq'=>'benq','bilb'=>'bilb','blac'=>'blac','c55/'=>'c55/','cdm-'=>'cdm-','chtm'=>'chtm','capi'=>'capi','cond'=>'cond','craw'=>'craw','dall'=>'dall','dbte'=>'dbte','dc-s'=>'dc-s','dica'=>'dica','ds-d'=>'ds-d','ds12'=>'ds12','dait'=>'dait','devi'=>'devi','dmob'=>'dmob','doco'=>'doco','dopo'=>'dopo','el49'=>'el49','erk0'=>'erk0','esl8'=>'esl8','ez40'=>'ez40','ez60'=>'ez60','ez70'=>'ez70','ezos'=>'ezos','ezze'=>'ezze','elai'=>'elai','emul'=>'emul','eric'=>'eric','ezwa'=>'ezwa','fake'=>'fake','fly-'=>'fly-','fly_'=>'fly_','g-mo'=>'g-mo','g1 u'=>'g1 u','g560'=>'g560','gf-5'=>'gf-5','grun'=>'grun','gene'=>'gene','go.w'=>'go.w','good'=>'good','grad'=>'grad','hcit'=>'hcit','hd-m'=>'hd-m','hd-p'=>'hd-p','hd-t'=>'hd-t','hei-'=>'hei-','hp i'=>'hp i','hpip'=>'hpip','hs-c'=>'hs-c','htc '=>'htc ','htc-'=>'htc-','htca'=>'htca','htcg'=>'htcg','htcp'=>'htcp','htcs'=>'htcs','htct'=>'htct','htc_'=>'htc_','haie'=>'haie','hita'=>'hita','huaw'=>'huaw','hutc'=>'hutc','i-20'=>'i-20','i-go'=>'i-go','i-ma'=>'i-ma','i230'=>'i230','iac'=>'iac','iac-'=>'iac-','iac/'=>'iac/','ig01'=>'ig01','im1k'=>'im1k','inno'=>'inno','iris'=>'iris','jata'=>'jata','java'=>'java','kddi'=>'kddi','kgt'=>'kgt','kgt/'=>'kgt/','kpt '=>'kpt ','kwc-'=>'kwc-','klon'=>'klon','lexi'=>'lexi','lg g'=>'lg g','lg-a'=>'lg-a','lg-b'=>'lg-b','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-f'=>'lg-f','lg-g'=>'lg-g','lg-k'=>'lg-k','lg-l'=>'lg-l','lg-m'=>'lg-m','lg-o'=>'lg-o','lg-p'=>'lg-p','lg-s'=>'lg-s','lg-t'=>'lg-t','lg-u'=>'lg-u','lg-w'=>'lg-w','lg/k'=>'lg/k','lg/l'=>'lg/l','lg/u'=>'lg/u','lg50'=>'lg50','lg54'=>'lg54','lge-'=>'lge-','lge/'=>'lge/','lynx'=>'lynx','leno'=>'leno','m1-w'=>'m1-w','m3ga'=>'m3ga','m50/'=>'m50/','maui'=>'maui','mc01'=>'mc01','mc21'=>'mc21','mcca'=>'mcca','medi'=>'medi','meri'=>'meri','mio8'=>'mio8','mioa'=>'mioa','mo01'=>'mo01','mo02'=>'mo02','mode'=>'mode','modo'=>'modo','mot '=>'mot ','mot-'=>'mot-','mt50'=>'mt50','mtp1'=>'mtp1','mtv '=>'mtv ','mate'=>'mate','maxo'=>'maxo','merc'=>'merc','mits'=>'mits','mobi'=>'mobi','motv'=>'motv','mozz'=>'mozz','n100'=>'n100','n101'=>'n101','n102'=>'n102','n202'=>'n202','n203'=>'n203','n300'=>'n300','n302'=>'n302','n500'=>'n500','n502'=>'n502','n505'=>'n505','n700'=>'n700','n701'=>'n701','n710'=>'n710','nec-'=>'nec-','nem-'=>'nem-','newg'=>'newg','neon'=>'neon','netf'=>'netf','noki'=>'noki','nzph'=>'nzph','o2 x'=>'o2 x','o2-x'=>'o2-x','opwv'=>'opwv','owg1'=>'owg1','opti'=>'opti','oran'=>'oran','p800'=>'p800','pand'=>'pand','pg-1'=>'pg-1','pg-2'=>'pg-2','pg-3'=>'pg-3','pg-6'=>'pg-6','pg-8'=>'pg-8','pg-c'=>'pg-c','pg13'=>'pg13','phil'=>'phil','pn-2'=>'pn-2','pt-g'=>'pt-g','palm'=>'palm','pana'=>'pana','pire'=>'pire','pock'=>'pock','pose'=>'pose','psio'=>'psio','qa-a'=>'qa-a','qc-2'=>'qc-2','qc-3'=>'qc-3','qc-5'=>'qc-5','qc-7'=>'qc-7','qc07'=>'qc07','qc12'=>'qc12','qc21'=>'qc21','qc32'=>'qc32','qc60'=>'qc60','qci-'=>'qci-','qwap'=>'qwap','qtek'=>'qtek','r380'=>'r380','r600'=>'r600','raks'=>'raks','rim9'=>'rim9','rove'=>'rove','s55/'=>'s55/','sage'=>'sage','sams'=>'sams','sc01'=>'sc01','sch-'=>'sch-','scp-'=>'scp-','sdk/'=>'sdk/','se47'=>'se47','sec-'=>'sec-','sec0'=>'sec0','sec1'=>'sec1','semc'=>'semc','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','sk-0'=>'sk-0','sl45'=>'sl45','slid'=>'slid','smb3'=>'smb3','smt5'=>'smt5','sp01'=>'sp01','sph-'=>'sph-','spv '=>'spv ','spv-'=>'spv-','sy01'=>'sy01','samm'=>'samm','sany'=>'sany','sava'=>'sava','scoo'=>'scoo','send'=>'send','siem'=>'
$status = $this->language->__get('MOBILE_DEVICE');
2020-12-23 03:18:48 +02:00
$mobile_browser = true;
break;
default;
$status = $this->language->__get('DESKTOP');
2020-12-23 03:18:48 +02:00
$mobile_browser = false;
break;
}
2021-04-11 17:29:47 +03:00
//@header('Cache-Control: no-transform');
//@header('Vary: User-Agent');
if ($status == '')
2020-12-23 03:18:48 +02:00
{
return $mobile_browser;
}
2021-04-11 17:29:47 +03:00
elseif ($mobile_browser == '')
{
return $status;
}
2020-12-23 03:18:48 +02:00
else
{
return array($mobile_browser, $status);
2021-04-11 17:29:47 +03:00
}
}
private $_basic_browser = array (
'Trident\/7.0' => 'Internet Explorer 11',
'Beamrise' => 'Beamrise',
'Opera' => 'Opera',
'OPR' => 'Opera',
'Shiira' => 'Shiira',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
2021-04-11 17:29:47 +03:00
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
'iTunes' => 'iTunes',
'Silk' => 'Silk',
'Dillo' => 'Dillo',
'Maxthon' => 'Maxthon',
'Arora' => 'Arora',
'Galeon' => 'Galeon',
'Iceape' => 'Iceape',
'Iceweasel' => 'Iceweasel',
'Midori' => 'Midori',
'QupZilla' => 'QupZilla',
'Namoroka' => 'Namoroka',
'NetSurf' => 'NetSurf',
'BOLT' => 'BOLT',
'EudoraWeb' => 'EudoraWeb',
'shadowfox' => 'ShadowFox',
'Swiftfox' => 'Swiftfox',
'Uzbl' => 'Uzbl',
'UCBrowser' => 'UCBrowser',
'Kindle' => 'Kindle',
'wOSBrowser' => 'wOSBrowser',
'Epiphany' => 'Epiphany',
'SeaMonkey' => 'SeaMonkey',
'Avant Browser' => 'Avant Browser',
'Firefox' => 'Firefox',
'Chrome' => 'Google Chrome',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Safari' => 'Safari',
2021-04-11 17:29:47 +03:00
'Mozilla' => 'Mozilla'
);
private $_basic_platform = array(
'windows' => 'Windows',
'iPad' => 'iPad',
'iPod' => 'iPod',
'iPhone' => 'iPhone',
'mac' => 'Apple',
'android' => 'Android',
'linux' => 'Linux',
'Nokia' => 'Nokia',
'BlackBerry' => 'BlackBerry',
'FreeBSD' => 'FreeBSD',
'OpenBSD' => 'OpenBSD',
'NetBSD' => 'NetBSD',
'UNIX' => 'UNIX',
'DragonFly' => 'DragonFlyBSD',
'OpenSolaris' => 'OpenSolaris',
'SunOS' => 'SunOS',
'OS\/2' => 'OS/2',
'BeOS' => 'BeOS',
'win' => 'Windows',
'Dillo' => 'Linux',
'PalmOS' => 'PalmOS',
'RebelMouse' => 'RebelMouse'
);
/**
* @package Browser & Platform Detect class/functions
* @author https://stackoverflow.com/users/1060394/jay
* @ https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php
*/
function detect()
{
$this->detectBrowser();
$this->detectPlatform();
return $this;
}
/**
* @package Browser & Platform Detect class/functions
* @author https://stackoverflow.com/users/1060394/jay
* @ https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php
*/
function detectBrowser()
{
foreach($this->_basic_browser as $pattern => $name)
{
if( preg_match("/".$pattern."/i",$this->_user_agent, $match))
{
$this->_name = $name;
// finally get the correct version number
$known = array('Version', $pattern, 'other');
$pattern_version = '#(?<browser>' . join('|', $known).')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern_version, $this->_user_agent, $matches))
{
// we have no matching number just continue
}
// see how many we have
$i = count($matches['browser']);
if ($i != 1)
{
//we will have two since we are not using 'other' argument yet
//see if version is before or after the name
if (strripos($this->_user_agent,"Version") < strripos($this->_user_agent,$pattern))
{
@$this->_version = $matches['version'][0];
}
else
{
@$this->_version = $matches['version'][1];
2021-04-11 17:29:47 +03:00
}
}
else
{
$this->_version = $matches['version'][0];
}
break;
}
}
}
/**
* @package Browser & Platform Detect class/functions
* @author https://stackoverflow.com/users/1060394/jay
* @ https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php
*/
function detectPlatform()
{
foreach($this->_basic_platform as $key => $platform)
{
if (stripos($this->_user_agent, $key) !== false)
{
$this->_platform = $platform;
break;
}
}
}
/**
* @package Browser & Platform Detect class/functions
* @author https://stackoverflow.com/users/1060394/jay
* @ https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php
*/
function getBrowser()
{
if(!empty($this->_name))
{
return $this->_name;
2020-12-23 03:18:48 +02:00
}
}
2021-04-11 17:29:47 +03:00
function getVersion()
{
return $this->_version;
}
function getPlatform()
{
if(!empty($this->_platform))
{
return $this->_platform;
}
}
function getUserAgent()
{
return $this->_user_agent;
}
function getInfo()
{
// see how many we have, i.e. Array ( [0] => 1 [1] => 'Desktop)
if (is_array($this->mobile_device_detect()))
{
//we will have two since we are not using 'other' argument yet
$mobile = $this->mobile_device_detect();
//see if version is before or after the name
if (empty($mobile[1]))
{
$mobile_device = $mobile[0];
}
else
{
$mobile_device = $mobile[1];
}
}
else
{
$mobile_device = $this->mobile_device_detect();
}
return "<strong>Browsing with:</strong> {$this->getBrowser()}" .
2021-04-11 17:29:47 +03:00
"<strong> - </strong> {$this->getVersion()}" .
//"<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" .
" :: <strong>from OS:</strong> {$this->getPlatform()}" .
2024-03-18 19:50:32 +02:00
"<strong>-</strong>{$mobile_device}, on a server with PHP ". PHP_VERSION ." &amp; OS ". PHP_OS;
2021-04-11 17:29:47 +03:00
}
}
2023-08-31 22:36:52 +03:00
//end of class
?>