| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/c/o/o/coopiak/www/cj79373/libraries/regularlabs/src/Condition/ |
Upload File : |
<?php
/**
* @package Regular Labs Library
* @version 23.5.7450
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use RegularLabs\Library\Condition;
use RegularLabs\Library\MobileDetect;
use RegularLabs\Library\RegEx;
/**
* Class Agent
* @package RegularLabs\Library\Condition
*/
abstract class Agent extends Condition
{
var $agent = null;
var $device = null;
var $is_mobile = false;
/**
* isDesktop
*/
public function isDesktop()
{
return $this->getDevice() == 'desktop';
}
/**
* isMobile
*/
public function isMobile()
{
return $this->getDevice() == 'mobile';
}
/**
* isPhone
*/
public function isPhone()
{
return $this->isMobile();
}
/**
* isTablet
*/
public function isTablet()
{
return $this->getDevice() == 'tablet';
}
/**
* passBrowser
*/
public function passBrowser($browser = '')
{
if ( ! $browser)
{
return false;
}
if ($browser == 'mobile')
{
return $this->isMobile();
}
// also check for _ instead of .
$browser = RegEx::replace('\\\.([^\]])', '[\._]\1', $browser);
$browser = str_replace('\.]', '\._]', $browser);
return RegEx::match($browser, $this->getAgent(), $match, 'i');
}
/**
* getAgent
*/
private function getAgent()
{
if ( ! is_null($this->agent))
{
return $this->agent;
}
$detect = new MobileDetect;
$agent = $detect->getUserAgent();
switch (true)
{
case (stripos($agent, 'Trident') !== false):
// Add MSIE to IE11 and others missing it
$agent = RegEx::replace('(Trident/[0-9\.]+;.*rv[: ]([0-9\.]+))', '\1 MSIE \2', $agent);
break;
case (stripos($agent, 'Chrome') !== false):
// Remove Safari from Chrome
$agent = RegEx::replace('(Chrome/.*)Safari/[0-9\.]*', '\1', $agent);
// Add MSIE to IE Edge and remove Chrome from IE Edge
$agent = RegEx::replace('Chrome/.*(Edge/[0-9])', 'MSIE \1', $agent);
break;
case (stripos($agent, 'Opera') !== false):
$agent = RegEx::replace('(Opera/.*)Version/', '\1Opera/', $agent);
break;
}
$this->agent = $agent;
return $this->agent;
}
/**
* setDevice
*/
private function getDevice()
{
if ( ! is_null($this->device))
{
return $this->device;
}
$detect = new MobileDetect;
$this->is_mobile = $detect->isMobile();
switch (true)
{
case($detect->isTablet()):
$this->device = 'tablet';
break;
case ($detect->isMobile()):
$this->device = 'mobile';
break;
default:
$this->device = 'desktop';
}
return $this->device;
}
}