Find a default browser to use.

@return string|false
483103
protected function getDefaultBrowser()
    {
        $potential = array('xdg-open', 'open', 'start');
        /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
        $process = $this->getHelper('process');
        foreach ($potential as $browser) {
            // Check if command exists by executing help flag.

            if ($process->run($this->stdOut, "command -v $browser")->isSuccessful()) {
                return $browser;
            }
        }
        return false;
    }
504877
public function getDefault()
    {
        $sDefault  = $this->oCi->config->item('languages_default');
        $oLanguage = $this->getByCode($sDefault);

        return !empty($oLanguage) ? $oLanguage : false;
    }
1079214
public static function checkBrowserEdge()
    {
        if (stripos(self::$userAgentString, 'Edge') !== false) {
            $version = explode('Edge/', self::$userAgentString);
            if (isset($version[1])) {
                self::$browser->setVersion((float)$version[1]);
            }
            self::$browser->setName(Browser::EDGE);

            return true;
        }

        return false;
    }
708513
public function detect()
  {
    $detected = true;
    if ( empty( $this->ua ) )
    {
      $detected = false;
    }
    else
    {
      // If it's not any of the common browsers, perhaps it's something mobile.
      if ( !$this->isMSIE() && !$this->isChrome() && !$this->isFirefox() && !$this->isSafari() && !$this->isEdge() && !$this->isOpera() )
      {
        if ( !$this->isOtherMobile() )
        {
          $detected = false;
        }
      }
      else
      {
        // If it's one of the default browsers, check to see if it's the mobile version.
        if ( !$this->isChromeMobile() && !$this->isSafariMobile() && !$this->isFirefoxMobile() && !$this->isOperaMobile() )
        {
          // If not, check for other mobile conditions, otherwise mark as definitely not mobile.
          if ( !$this->isOtherMobile() )
          {
            $this->mobile = false;
            $this->touch = false;
            $this->android = false;
            $this->ios = false;
            $this->tablet = false;
            $this->phone = false;
          }
        }
      }
    }

    if ( $detected )
    {
      // Deal with Width/Height
      if ( !$this->width )
      {
        $this->width = ( $this->phone ) ? $this->defaultSize[ 'phone' ][ 'width' ] : $this->defaultSize['tablet']['width'];
        $this->height = ( $this->phone ) ? $this->defaultSize[ 'phone' ][ 'height' ] : $this->defaultSize['tablet']['height'];
      }

      // Deal with Browser
      if ( $this->isModern() )
      {
        $browser = 'modern';
      }
      elseif($this->isFallback())
      {
        $browser = 'fallback';
      }
      else
      {
        $browser = 'baseline';
      }

      // Return the array that DeviceFeatureInfo expects.
      return array(
        'hidpi'       => false,
        'width'       => $this->width,
        'height'      => $this->height,
        'low_speed'   => false,
        'low_battery' => false,
        'metered'     => $this->metered,
        'browser'     => $browser,
        'touch'       => $this->touch,
        'android'     => $this->android,
        'ios'         => $this->ios,
        'user-agent'  => $this->ua
      );
    }

    return null;
  }
1140527
public function getSearchDefaults()
    {
        $data = parent::getSearchDefaults();

        if (! isset($data[\MUtil_Model::REQUEST_ID])) {
            $data[\MUtil_Model::REQUEST_ID] = intval($this->_getIdParam());
        }

        return $data;
    }
629300
public static function get_default() {
        if ($visiblechildren = self::top()->get_children()) {
            $defcategory = reset($visiblechildren);
        } else {
            $toplevelcategories = self::get_tree(0);
            $defcategoryid = $toplevelcategories[0];
            $defcategory = self::get($defcategoryid, MUST_EXIST, true);
        }
        return $defcategory;
    }
623576
protected function checkBrowserSlurp()
    {
        if (stripos($this->_agent, 'slurp') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'Slurp'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $this->setVersion($aversion[0]);
                $this->_browser_name = self::BROWSER_SLURP;
                $this->setRobot(true);
                $this->setMobile(false);
                return true;
            }
        }
        return false;
    }
942156
public function getBrowserVersion($refresh = false)
    {
        if (empty($this->detection['browser']) || $refresh) {
            $this->detectBrowser($this->userAgent);
        }

        return $this->browserVersion;
    }
1317997
protected function checkBrowserEdge()
    {
        if (stripos($this->_agent, 'Edge/') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'Edge'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $this->setVersion($aversion[0]);
                $this->setBrowser(self::BROWSER_EDGE);
                if (stripos($this->_agent, 'Windows Phone') !== false || stripos($this->_agent, 'Android') !== false) {
                    $this->setMobile(true);
                }
                return true;
            }
        }
        return false;
    }
828442
protected function checkBrowserInternetExplorer() 
    {
        $match = '';
        
	    // Test for v1 - v1.5 IE
	    if( stripos($this->_agent,'microsoft internet explorer') !== false ) 
	    {
		    $this->setBrowser(self::BROWSER_IE);
		    $this->setVersion('1.0');
		    $aresult = stristr($this->_agent, '/');
		    if( preg_match('/308|425|426|474|0b1/i', $aresult) ) {
			    $this->setVersion('1.5');
		    }
			return true;
	    }
	    // Test for versions > 1.5
	    else if( stripos($this->_agent,'msie')     !== false 
	          && stripos($this->_agent,'opera')    === false 
	          && stripos($this->_agent,'iemobile') === false ) 
	    {
	    	/*// See if the browser is the odd MSN Explorer
	    	if( stripos($this->_agent,'msnb') !== false ) {
		    	$aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'MSN'));
			    $this->setBrowser( self::BROWSER_MSN );
			    $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
			    return true;
	    	} */
	    	$aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'msie'));
	    	$this->setBrowser( self::BROWSER_IE );
	    	$this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
	    	return true;
	    }
	    // Test for versions for Edge
	    else if ( stripos($this->_agent,'Edge')          !== false 
	    	   && stripos($this->_agent,'windows phone') === false ) 
	    {
	        $aresult = explode('/',stristr($this->_agent,'Edge'));
	        $aversion = explode('.',$aresult[1]);
	        $this->setVersion($aversion[0]);
	        $this->setBrowser(self::BROWSER_MS_EDGE);
	        return true;
	    }
	    // Test for versions for Edge mobile
	    else if ( stripos($this->_agent,'Edge')          !== false
	           && stripos($this->_agent,'windows phone') !== false )
	    {
	        $aresult = explode('/',stristr($this->_agent,'Edge'));
	        $aversion = explode('.',$aresult[1]);
	        $this->setVersion($aversion[0]);
	        $this->setBrowser(self::BROWSER_MS_EDGE_MOBILE);
	        $this->setPlatform( self::PLATFORM_WINDOWS_PHONE );
	        $this->setMobile(true);
	        return true;
	    }
	    
	    // Test for versions > 10
	    else if (  preg_match('/Trident\/[0-9\.]+/', $this->_agent) 
	            && preg_match('/rv:([0-9\.]+)/', $this->_agent, $match) )
	    {
	        $this->setBrowser( self::BROWSER_IE );
	        $this->setVersion($match[1]);
	        return true;
	    }
	    else if (stripos($this->_agent,'iemobile')      !== false
	          && stripos($this->_agent,'windows phone') !== false ) 
	    { // Windows Phones mit IEMobile
	        $this->setPlatform( self::PLATFORM_WINDOWS_PHONE );
	        $this->setBrowser( self::BROWSER_IE_MOBILE );
	        $this->setMobile(true);
	        $aresult = explode(' ',stristr(str_replace('/',' ',$this->_agent),'iemobile'));
	        $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
	        return true;
	    }
	    else if (stripos($this->_agent,'iemobile')      !== false
	          && stripos($this->_agent,'windows phone') === false )
	    { // Irgendwas mit IEMobile
    	    $this->setBrowser( self::BROWSER_IE_MOBILE );
    	    $this->setMobile(true);
    	    $aresult = explode(' ',stristr(str_replace('/',' ',$this->_agent),'iemobile'));
    	    $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
    	    return true;
	    }
	    // Test for Pocket IE
	    else if( stripos($this->_agent,'mspie') !== false || stripos($this->_agent,'pocket') !== false ) 
	    {
		    $aresult = explode(' ',stristr($this->_agent,'mspie'));
		    $this->setPlatform( self::PLATFORM_WINDOWS_CE );
		    $this->setBrowser( self::BROWSER_POCKET_IE );
		    $this->setMobile(true);

		    if( stripos($this->_agent,'mspie') !== false ) {
			    $this->setVersion($aresult[1]);
		    }
		    else {
			    $aversion = explode('/',$this->_agent);
			    $this->setVersion($aversion[1]);
		    }
		    return true;
	    }
		return false;
    }
1370533
public static function browser()
    {
        foreach (self::$_browsers as $key => $value) {
            if (preg_match($key, self::http_user_agent())) {
                self::$_arguments['browser'] = $value;

                self::$_is['browser'] = TRUE;
                self::mobile();
                break;
            }
        }
        $return = "";
        $return .= self::$_arguments['browser'];
        $return .= self::mobile();
        return $return;


    }
167
protected function checkBrowserCustom()
    {
        foreach ($this->_customBrowserDetection as $browserName => $customBrowser) {
            $uaNameToLookFor = $customBrowser['uaNameToLookFor'];
            $isMobile = $customBrowser['isMobile'];
            $isRobot = $customBrowser['isRobot'];
            $separator = $customBrowser['separator'];
            $uaNameFindWords = $customBrowser['uaNameFindWords'];
            if ($this->checkSimpleBrowserUA($uaNameToLookFor, $this->_agent, $browserName, $isMobile, $isRobot, $separator, $uaNameFindWords)) {
                return true;
            }
        }
        return false;
    }
147042
public static function getBrowser($string = true)
    {
        if (isset($_SERVER['HTTP_USER_AGENT'])) {
            $u_agent = $_SERVER['HTTP_USER_AGENT'];
//            $bname = 'Unknown';
            $platform = 'Unknown';
//            $version = '';

            //First get the platform?
            if (preg_match('/linux/i', $u_agent)) {
                $platform = 'linux';
            } elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
                $platform = 'mac';
            } elseif (preg_match('/windows|win32/i', $u_agent)) {
                $platform = 'windows';
            }

            $bname = 'N/A';
            $ub = 'N/A';

            // Next get the name of the useragent yes seperately and for good reason
            if (preg_match('/MSIE/i', $u_agent) && !preg_match('/Opera/i', $u_agent)) {
                $bname = 'Internet Explorer';
                $ub = 'MSIE';
            } elseif (preg_match('/Firefox/i', $u_agent)) {
                $bname = 'Mozilla Firefox';
                $ub = 'Firefox';
            } elseif (preg_match('/Chrome/i', $u_agent)) {
                $bname = 'Google Chrome';
                $ub = 'Chrome';
            } elseif (preg_match('/Safari/i', $u_agent)) {
                $bname = 'Apple Safari';
                $ub = 'Safari';
            } elseif (preg_match('/Opera/i', $u_agent)) {
                $bname = 'Opera';
                $ub = 'Opera';
            } elseif (preg_match('/Netscape/i', $u_agent)) {
                $bname = 'Netscape';
                $ub = 'Netscape';
            }

            // finally get the correct version number
            $known = ['Version', $ub, 'other'];
            $pattern = '#(?<browser>'.implode('|', $known).')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
            if (!preg_match_all($pattern, $u_agent, $matches)) {
                // we have no matching number just continue
            }

            // see how many we have
            $i = count($matches['browser']);
            if (1 !== $i) {
                //we will have two since we are not using 'other' argument yet
                //see if version is before or after the name
                if (mb_strripos($u_agent, 'Version') < mb_strripos($u_agent, $ub)) {
                    $version = @$matches['version'][0];
                } else {
                    $version = @$matches['version'][1];
                }
            } else {
                $version = @$matches['version'][0];
            }

            // check if we have a number
            if (null === $version || '' === $version) {
                $version = '?';
            }

            if ($string) {
                return $bname.' '.$version.' ('.ucfirst($platform).')';
            }

            return [
                    'userAgent' => $u_agent,
                    'name' => $bname,
                    'version' => $version,
                    'platform' => $platform,
                    'pattern' => $pattern,
                ];
        }
        if ($string) {
            return null;
        }

        return [
                    'userAgent' => null,
                    'name' => null,
                    'version' => null,
                    'platform' => null,
                    'pattern' => null,
                ];
    }
148046
public function getBrowser()
    {
        foreach ($this::$browsers as $browser => $UA) {
            $is_browser = 'is'.$browser;
            if ($this->$is_browser()) {
                return $browser;
            }
        }
        return '';
    }
1030971
protected function checkBrowserChrome() {
	    if( stripos($this->_agent,'Chrome') !== false ) {
		    $aresult = explode('/',stristr($this->_agent,'Chrome'));
		    $aversion = explode(' ',$aresult[1]);
		    $this->setVersion($aversion[0]);
		    $this->setBrowser(self::BROWSER_CHROME);
		    return true;
	    }
	    return false;
    }
712270
protected function getBrowserInfo()
    {
        $browser = $this->browser->getBrowser() ?: 'Other';
        $browserVersion = $this->browser->getVersion();

        if (trim($browserVersion)) {
            return $browser . ' (' . $browserVersion . ')';
        }

        return $browser;
    }
13396
public static function checkBrowserVivaldi()
    {
        if (stripos(self::$userAgentString, 'Vivaldi') !== false) {
            $aresult = explode('/', stristr(self::$userAgentString, 'Vivaldi'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                self::$browser->setVersion($aversion[0]);
            }
            self::$browser->setName(Browser::VIVALDI);

            return true;
        }

        return false;
    }