cbschuld/Browser.php

UC Browser not detecting.

Closed this issue · 5 comments

Its not working for UC Browser.
I have made some changes to detect UC Browser too.

/**
* Determine if the browser is UCBrowser or not (last updated 1.7)
* @return boolean True if the browser is UCBrowser otherwise false
*/

protected function checkBrowserUCBrowser()
{
    if (stripos($this->_agent, 'UCBrowser') !== false) {
        $resultant = stristr($this->_agent, 'UCBrowser');
        if (preg_match('/\//', $resultant)) {
            $aresult = explode('/', $resultant);
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $this->setVersion($aversion[0]);
            }
        } else {
            $aversion = explode(' ', stristr($resultant, 'UCBrowser'));
            if (isset($aversion[1])) {
                $this->setVersion($aversion[1]);
            }
        }
        if (stripos($this->_agent, 'Mobile') !== false) {
            $this->setMobile(true);
        } else {
            $this->setTablet(true);
        }
        $this->setBrowser(self::BROWSER_UCBROWSER);
        return true;
    }
    return false;
}

Please, review it and add/modify if necessary.

eka7a commented

👍

The latest version (5.2.xxx.xxx) of UC browser on PC changed "UCBrowser" to "UBrowser".
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 UBrowser/5.2.3635.1033 Safari/537.36

Has anyone been able to determine this?

UCbrowse will change user agent when you visit different website

@anuj9196 @eka7a - this issue is OLD and I am finally getting time to look at it... sorry

I updated the routine to be

    protected function checkBrowserUCBrowser()
    {
        if (preg_match('/UC ?Browser\/?([\d\.]+)/', $this->_agent, $matches )) {
            if(isset($matches[1])) {
                $this->setVersion($matches[1]);
            }
            if (stripos($this->_agent, 'Mobile') !== false) {
                $this->setMobile(true);
            } else {
                $this->setTablet(true);
            }
            $this->setBrowser(self::BROWSER_UCBROWSER);
            return true;
        }
        return false;
    }

it will appear in 1.9.4 which I should be able to release this evening (GMT-7)