HTTP_USER_AGENT Special Check
19422
protected function checkUserAgent()
	{
	    if ( \Environment::get('httpUserAgent') )  
	    {
	        $UserAgent = trim(\Environment::get('httpUserAgent'));
	    } 
	    else 
	    {
	        return false; // Ohne Absender keine Suche
	    }
	    $arrUserAgents = explode(",", $this->banner_useragent);
	    if (strlen(trim($arrUserAgents[0])) == 0) 
	    {
	        return false; // keine Angaben im Modul
	    }
	    array_walk($arrUserAgents, array('self','trimBannerArrayValue'));  // trim der array values
	    // grobe Suche
	    $CheckUserAgent = str_replace($arrUserAgents, '#', $UserAgent);
	    if ($UserAgent != $CheckUserAgent) 
	    {   // es wurde ersetzt also was gefunden
	        //DEBUG log_message('CheckUserAgent Filterung; Treffer!','Banner.log');
	        return true;
	    }
	    return false;
	}
552060
def _is_bot(user_agent):
    """"""
    bot_list = [
                'http://www.baidu.com/search/spider.html',
                'python-requests',
                'http://ltx71.com/',
                'http://drupal.org/',
                'www.sogou.com',
                'http://search.msn.com/msnbot.htm',
                'semantic-visions.com crawler',
               ]
    for bot in bot_list:
        if re.search(re.escape(bot), user_agent):
            return True
    return False
813376
def check_perm(self, request, resource):
        

        perm_name = self.get_perm_name(resource, request.method)
        if not self._has_perm(request.user, perm_name):
            raise errors.Forbidden()
126510
def _extract_info_from_useragent(user_agent):
    """"""
    parsed_string = user_agent_parser.Parse(user_agent)
    return {
        'os': parsed_string.get('os', {}).get('family'),
        'browser': parsed_string.get('user_agent', {}).get('family'),
        'browser_version': parsed_string.get('user_agent', {}).get('major'),
        'device': parsed_string.get('device', {}).get('family'),
    }
984062
def rm_special(user, cmd, special=None, identifier=None):
    '''
    
    '''
    lst = list_tab(user)
    ret = 'absent'
    rm_ = None
    for ind in range(len(lst['special'])):
        if rm_ is not None:
            break
        if _cron_matched(lst['special'][ind], cmd, identifier=identifier):
            if special is None:
                # No special param was specified
                rm_ = ind
            else:
                if lst['special'][ind]['spec'] == special:
                    rm_ = ind
    if rm_ is not None:
        lst['special'].pop(rm_)
        ret = 'removed'
    comdat = _write_cron_lines(user, _render_tab(lst))
    if comdat['retcode']:
        # Failed to commit, return the error
        return comdat['stderr']
    return ret
886800
static function checkDebugByUser()
    {
        if ( !isset( $GLOBALS['eZDebugUserIDList'] ) ||
             !is_array( $GLOBALS['eZDebugUserIDList'] ) )
        {
            return false;
        }
        else
        {
            $currentUserID = eZUser::currentUserID();

            if ( !$currentUserID )
            {
                return false;
            }
            else
            {
                $GLOBALS['eZDebugAllowedByUser'] = in_array( $currentUserID, $GLOBALS['eZDebugUserIDList'] );

                if ( $GLOBALS['eZDebugAllowed'] )
                {
                    $GLOBALS['eZDebugAllowed'] = $GLOBALS['eZDebugAllowedByUser'];
                }

                if ( $GLOBALS['eZDebugEnabled'] )
                {
                    $GLOBALS['eZDebugEnabled'] = $GLOBALS['eZDebugAllowedByUser'];
                }

                unset( $GLOBALS['eZDebugUserIDList'] );

                return true;
            }
        }
    }
483549
def set_user_agent(self, user_agent):
        """"""
        # set a default user_agent if not specified
        if user_agent is None:
            requests_ua = requests.utils.default_user_agent()
            user_agent = '%s (%s/%s)' % (requests_ua, __title__, __version__)

        # the requests module uses a case-insensitive dict for session headers
        self.session.headers['User-agent'] = user_agent
386120
public function user_agent($user_agent = NULL)
	{
		if ($user_agent !== NULL)
		{
			\Request::$user_agent = $user_agent;
			return $this;
		}
		return \Request::$user_agent;
	}
859379
def agent_checks(consul_url=None, token=None):
    '''
    

    '''
    ret = {}
    if not consul_url:
        consul_url = _get_config()
        if not consul_url:
            log.error('No Consul URL found.')
            ret['message'] = 'No Consul URL found.'
            ret['res'] = False
            return ret

    function = 'agent/checks'
    ret = _query(consul_url=consul_url,
                 function=function,
                 token=token,
                 method='GET')
    return ret
476523
def user_agent(name, version):
    """"""

    def _interpreter():
        name = platform.python_implementation()
        version = platform.python_version()
        bitness = platform.architecture()[0]
        if name == 'PyPy':
            version = '.'.join(map(str, sys.pypy_version_info[:3]))
        full_version = [version]
        if bitness:
            full_version.append(bitness)
        return name, "-".join(full_version)

    tags = [
        (name, version),
        ("python", platform.python_version()),
        _interpreter(),
        ("machine", platform.machine() or 'unknown'),
        ("system", platform.system() or 'unknown'),
        ("platform", platform.platform() or 'unknown'),
    ]

    return ' '.join("{}/{}".format(name, version) for name, version in tags)
1134216
function checkOlderIE() {
  const ua = navigator.userAgent;
  const isIE = ua.indexOf('MSIE') !== -1 || ua.indexOf('Trident') !== -1;
  if (!isIE) {
    return false;
  }
  const version = ua.match(/(MSIE\s|Trident.*rv:)([\w.]+)/)[2];
  const versionNumber = parseFloat(version);
  if (versionNumber < 10) {
    return true;
  }
  return false;
}
497937
function formatUserAgent(userAgent) {
	var formattedUserAgent = userAgent.toLowerCase();

	// Strip the version number from robot/1.0 user agents
	var idx = formattedUserAgent.indexOf('/');
	if (idx > -1) {
		formattedUserAgent = formattedUserAgent.substr(0, idx);
	}

	return formattedUserAgent.trim();
}
440487
public static void applyUserAgent(String agent) {
    LOGGER.info("Applying agent: " + agent);
    System.setProperty("http.agent", agent);
    System.setProperty("https.agent", agent);
  }
165702
def can_fetch(self, url_info: URLInfo, user_agent: str):
        ''''''
        key = self.url_info_key(url_info)

        parser = self._parsers[key]
        return parser.is_allowed(user_agent, url_info.url)
582135
async def Prechecks(self, agent_version, name, owner_tag, uuid):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='MigrationTarget',
                   request='Prechecks',
                   version=1,
                   params=_params)
        _params['agent-version'] = agent_version
        _params['name'] = name
        _params['owner-tag'] = owner_tag
        _params['uuid'] = uuid
        reply = await self.rpc(msg)
        return reply
750576
def host_agent_available?
      @discovered ||= run_discovery

      if @discovered
        # Try default location or manually configured (if so)
        uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/")
        req = Net::HTTP::Get.new(uri)

        response = make_host_agent_request(req)

        if response && (response.code.to_i == 200)
          return true
        end
      end
      false
    rescue => e
      Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
      Instana.logger.debug e.backtrace.join("\r\n") unless ::Instana.test?
      return false
    end
213068
private function getUserAgent($url, $httpHeader = [])
    {
        $ua = $this->config['ua_browser'];

        if (!empty($httpHeader['user-agent'])) {
            $this->logger->info('Found user-agent "{user-agent}" for url "{url}" from site config', ['user-agent' => $httpHeader['user-agent'], 'url' => $url]);

            return $httpHeader['user-agent'];
        }

        $host = parse_url($url, PHP_URL_HOST);

        if ('www.' === strtolower(substr($host, 0, 4))) {
            $host = substr($host, 4);
        }

        $try = [$host];
        $split = explode('.', $host);

        if (\count($split) > 1) {
            // remove first subdomain
            array_shift($split);
            $try[] = '.' . implode('.', $split);
        }

        foreach ($try as $h) {
            if (isset($this->config['user_agents'][$h])) {
                $this->logger->info('Found user-agent "{user-agent}" for url "{url}" from config', ['user-agent' => $this->config['user_agents'][$h], 'url' => $url]);

                return $this->config['user_agents'][$h];
            }
        }

        $this->logger->info('Use default user-agent "{user-agent}" for url "{url}"', ['user-agent' => $ua, 'url' => $url]);

        return $ua;
    }