HTTP_USER_AGENT Special Check
499876
protected function checkUserAgent()
	{
   	    if ( \Environment::get('httpUserAgent') ) 
   	    { 
	        $UserAgent = trim( \Environment::get('httpUserAgent') ); 
	    } 
	    else 
	    { 
	        return false; // Ohne Absender keine Suche
	    }
	    
	    $objUserAgent = \Database::getInstance()->prepare("SELECT 
                                                                `banner_useragent` 
                                                           FROM 
                                                                `tl_module` 
                                                           WHERE 
                                                                `banner_useragent` !=?")
                                                ->limit(1)
                                                ->execute('');
	    if (!$objUserAgent->next()) 
	    {
	    	return false; // keine Angaben im Modul
	    }   
	    $arrUserAgents = explode(",", $objUserAgent->banner_useragent);
	    if (strlen(trim($arrUserAgents[0])) == 0) 
	    {
	    	return false; // keine Angaben im Modul
	    }
	    array_walk($arrUserAgents, array('self','bannerclickTrimArrayValue'));  // trim der array values
        // grobe Suche
        $CheckUserAgent=str_replace($arrUserAgents, '#', $UserAgent);
        if ($UserAgent != $CheckUserAgent) 
        {   // es wurde ersetzt also was gefunden
        	//fuer debug log_message('CheckUserAgent Click Filterung: Treffer!','Banner.log');
            return true;
        }
        return false; 
	}
971403
public static function getUserAgent($request, $override_sideloaded_browser_ua = true)
    {
        if (!$override_sideloaded_browser_ua) {
            return $request['HTTP_USER_AGENT'];
        }

        if (isset($request[WURFL_Constants::UA])) {
            return $request[WURFL_Constants::UA];
        }
        
        foreach (self::$userAgentSearchOrder as $header) {
            if (isset($request[$header])) {
                return $request[$header];
            }
        }
        
        return '';
    }
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
764903
def check_auth(username, pwd):
    
    cfg = get_current_config()
    return username == cfg["dashboard_httpauth"].split(
        ":")[0] and pwd == cfg["dashboard_httpauth"].split(":")[1]
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();
}
1291786
function(userAgent){
		var ua = parser.setUA(userAgent).getResult();
		//console.log(ua);
		var approval = true;
		_.each(ExcludeDevices, function(a) {
			//if(typeof(a.device) != 'undefined') console.log(ua.device.type + " ?? " + a.device.type);
			if(typeof(a.browser) != 'undefined' && ua.browser.name == a.browser.name && ua.browser.major < a.browser.major) {
				// The user's browser is too old.
				console.log(ua.browser.name + " v." + ua.browser.major + " is too old major version");
				approval = false;
			} else if(typeof(a.device) != 'undefined' && ua.device.type == a.device.type) {
				// The user's devices is not allowed
				console.log(ua.device.type + " is not allowed");
				approval = false;
			} else {
				//return true;
			}
		});
		return approval;
	}
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)
440487
public static void applyUserAgent(String agent) {
    LOGGER.info("Applying agent: " + agent);
    System.setProperty("http.agent", agent);
    System.setProperty("https.agent", agent);
  }
1333774
def default_user_agent(name="python-requests"):
    """"""
    _implementation = platform.python_implementation()

    if _implementation == 'CPython':
        _implementation_version = platform.python_version()
    elif _implementation == 'PyPy':
        _implementation_version = '%s.%s.%s' % (sys.pypy_version_info.major,
                                                sys.pypy_version_info.minor,
                                                sys.pypy_version_info.micro)
        if sys.pypy_version_info.releaselevel != 'final':
            _implementation_version = ''.join([_implementation_version, sys.pypy_version_info.releaselevel])
    elif _implementation == 'Jython':
        _implementation_version = platform.python_version()  # Complete Guess
    elif _implementation == 'IronPython':
        _implementation_version = platform.python_version()  # Complete Guess
    else:
        _implementation_version = 'Unknown'

    try:
        p_system = platform.system()
        p_release = platform.release()
    except IOError:
        p_system = 'Unknown'
        p_release = 'Unknown'

    return " ".join(['%s/%s' % (name, __version__),
                     '%s/%s' % (_implementation, _implementation_version),
                     '%s/%s' % (p_system, p_release)])
54164
function operating_system_detection()
    {
        if (isset( $_SERVER )) {
            $agent = $_SERVER['HTTP_USER_AGENT'] ;
        } else {
            global $HTTP_SERVER_VARS ;
            if (isset( $HTTP_SERVER_VARS )) {
                $agent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'] ;
            } else {
                global $HTTP_USER_AGENT ;
                $agent = $HTTP_USER_AGENT ;
            }
        }
        $ros[] = array('Windows XP', 'Windows XP');
        $ros[] = array('Windows NT 5.1|Windows NT5.1)', 'Windows XP');
        $ros[] = array('Windows 2000', 'Windows 2000');
        $ros[] = array('Windows NT 5.0', 'Windows 2000');
        $ros[] = array('Windows NT 4.0|WinNT4.0', 'Windows NT');
        $ros[] = array('Windows NT 5.2', 'Windows Server 2003');
        $ros[] = array('Windows NT 6.0', 'Windows Vista');
        $ros[] = array('Windows NT 7.0', 'Windows 7');
        $ros[] = array('Windows NT 10.0', 'Windows 10');
        $ros[] = array('Windows CE', 'Windows CE');
        $ros[] = array('(media center pc).([0-9]{1,2}\.[0-9]{1,2})', 'Windows Media Center');
        $ros[] = array('(win)([0-9]{1,2}\.[0-9x]{1,2})', 'Windows');
        $ros[] = array('(win)([0-9]{2})', 'Windows');
        $ros[] = array('(windows)([0-9x]{2})', 'Windows');
    // Doesn't seem like these are necessary...not totally sure though..
    //$ros[] = array('(winnt)([0-9]{1,2}\.[0-9]{1,2}){0,1}', 'Windows NT');
    //$ros[] = array('(windows nt)(([0-9]{1,2}\.[0-9]{1,2}){0,1})', 'Windows NT'); // fix by bg
        $ros[] = array('Windows ME', 'Windows ME');
        $ros[] = array('Win 9x 4.90', 'Windows ME');
        $ros[] = array('Windows 98|Win98', 'Windows 98');
        $ros[] = array('Windows 95', 'Windows 95');
        $ros[] = array('(windows)([0-9]{1,2}\.[0-9]{1,2})', 'Windows');
        $ros[] = array('win32', 'Windows');
        $ros[] = array('(java)([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2})', 'Java');
        $ros[] = array('(Solaris)([0-9]{1,2}\.[0-9x]{1,2}){0,1}', 'Solaris');
        $ros[] = array('dos x86', 'DOS');
        $ros[] = array('unix', 'Unix');
        $ros[] = array('Mac OS X', 'Mac OS X');
        $ros[] = array('Mac_PowerPC', 'Macintosh PowerPC');
        $ros[] = array('(mac|Macintosh)', 'Mac OS');
        $ros[] = array('(sunos)([0-9]{1,2}\.[0-9]{1,2}){0,1}', 'SunOS');
        $ros[] = array('(beos)([0-9]{1,2}\.[0-9]{1,2}){0,1}', 'BeOS');
        $ros[] = array('(risc os)([0-9]{1,2}\.[0-9]{1,2})', 'RISC OS');
        $ros[] = array('os/2', 'OS/2');
        $ros[] = array('freebsd', 'FreeBSD');
        $ros[] = array('openbsd', 'OpenBSD');
        $ros[] = array('netbsd', 'NetBSD');
        $ros[] = array('irix', 'IRIX');
        $ros[] = array('plan9', 'Plan9');
        $ros[] = array('osf', 'OSF');
        $ros[] = array('aix', 'AIX');
        $ros[] = array('GNU Hurd', 'GNU Hurd');
        $ros[] = array('(fedora)', 'Linux - Fedora');
        $ros[] = array('(kubuntu)', 'Linux - Kubuntu');
        $ros[] = array('(ubuntu)', 'Linux - Ubuntu');
        $ros[] = array('(debian)', 'Linux - Debian');
        $ros[] = array('(CentOS)', 'Linux - CentOS');
        $ros[] = array('(Mandriva).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)', 'Linux - Mandriva');
        $ros[] = array('(SUSE).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)', 'Linux - SUSE');
        $ros[] = array('(Dropline)', 'Linux - Slackware (Dropline GNOME)');
        $ros[] = array('(ASPLinux)', 'Linux - ASPLinux');
        $ros[] = array('(Red Hat)', 'Linux - Red Hat');
    // Loads of Linux machines will be detected as unix.
    // Actually, all of the linux machines I've checked have the 'X11' in the User Agent.
    //$ros[] = array('X11', 'Unix');
        $ros[] = array('(linux)', 'Linux');
        $ros[] = array('(amigaos)([0-9]{1,2}\.[0-9]{1,2})', 'AmigaOS');
        $ros[] = array('amiga-aweb', 'AmigaOS');
        $ros[] = array('amiga', 'Amiga');
        $ros[] = array('AvantGo', 'PalmOS');
    //$ros[] = array('(Linux)([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,3}(rel\.[0-9]{1,2}){0,1}-([0-9]{1,2}) i([0-9]{1})86){1}', 'Linux');
    //$ros[] = array('(Linux)([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,3}(rel\.[0-9]{1,2}){0,1} i([0-9]{1}86)){1}', 'Linux');
    //$ros[] = array('(Linux)([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,3}(rel\.[0-9]{1,2}){0,1})', 'Linux');
        $ros[] = array('[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,3})', 'Linux');
        $ros[] = array('(webtv)/([0-9]{1,2}\.[0-9]{1,2})', 'WebTV');
        $ros[] = array('Dreamcast', 'Dreamcast OS');
        $ros[] = array('GetRight', 'Windows');
        $ros[] = array('go!zilla', 'Windows');
        $ros[] = array('gozilla', 'Windows');
        $ros[] = array('gulliver', 'Windows');
        $ros[] = array('ia archiver', 'Windows');
        $ros[] = array('NetPositive', 'Windows');
        $ros[] = array('mass downloader', 'Windows');
        $ros[] = array('microsoft', 'Windows');
        $ros[] = array('offline explorer', 'Windows');
        $ros[] = array('teleport', 'Windows');
        $ros[] = array('web downloader', 'Windows');
        $ros[] = array('webcapture', 'Windows');
        $ros[] = array('webcollage', 'Windows');
        $ros[] = array('webcopier', 'Windows');
        $ros[] = array('webstripper', 'Windows');
        $ros[] = array('webzip', 'Windows');
        $ros[] = array('wget', 'Windows');
        $ros[] = array('Java', 'Unknown');
        $ros[] = array('flashget', 'Windows');
    // delete next line if the script show not the right OS
    //$ros[] = array('(PHP)/([0-9]{1,2}.[0-9]{1,2})', 'PHP');
        $ros[] = array('MS FrontPage', 'Windows');
        $ros[] = array('(msproxy)/([0-9]{1,2}.[0-9]{1,2})', 'Windows');
        $ros[] = array('(msie)([0-9]{1,2}.[0-9]{1,2})', 'Windows');
        $ros[] = array('libwww-perl', 'Unix');
        $ros[] = array('UP.Browser', 'Windows CE');
        $ros[] = array('NetAnts', 'Windows');
        $file = count ( $ros );
        $os = '';
        for ($n=0; $n<$file; $n++) {
            if (preg_match('/'.$ros[$n][0].'/i', $agent, $name)) {
                $os = @$ros[$n][1].' '.@$name[2];
                break;
            }
        }
        return trim ( $os );
    }
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;
            }
        }
    }
1083887
def is_agent_listening(self, host, port):
        
        try:
            rv = False
            url = "http://%s:%s/" % (host, port)
            response = self.client.get(url, timeout=0.8)

            server_header = response.headers["Server"]
            if server_header == AGENT_HEADER:
                logger.debug("Host agent found on %s:%d" % (host, port))
                rv = True
            else:
                logger.debug("...something is listening on %s:%d but it's not the Instana Agent: %s"
                             % (host, port, server_header))
        except (requests.ConnectTimeout, requests.ConnectionError):
            logger.debug("No host agent listening on %s:%d" % (host, port))
            rv = False
        finally:
            return rv
871583
function isSafe(userAgent) {
  var consecutive = 0
    , code = 0;

  if (userAgent.length > 1000) return false;

  for (var i = 0; i < userAgent.length; i++) {
    code = userAgent.charCodeAt(i);
    // numbers between 0 and 9, letters between a and z, spaces and control
    if ((code >= 48 && code <= 57) || (code >= 97 && code <= 122) || code <= 32) {
      consecutive++;
    } else {
      consecutive = 0;
    }

    if (consecutive >= 100) {
      return false;
    }
  }

  return true
}
124269
def process_request(self, request):
        """"""
        assert hasattr(request, 'user')
        if not request.user.is_authenticated():
            path = request.path_info.lstrip('/')
            if not any(m.match(path) for m in EXEMPT_URLS):
                return HttpResponseRedirect(reverse(settings.LOGIN_URL))
67946
protected function _check($user, $request, $name, $rule, $params) {
		$message = 'You are not permitted to access this area.';

		if (is_string($rule) && isset($this->_rules[$rule])) {
			$name = $rule;
			$closure = $this->_rules[$rule];
		} elseif (is_array($rule)) {
			if (is_string($name) && isset($this->_rules[$name])) {
				$params += $rule;
				$closure = $this->_rules[$name];
			} else {
				$closure = $rule;
			}
		} elseif (is_callable($rule)) {
			$closure = $rule;
		} else {
			throw new RuntimeException("Invalid rule.");
		}

		if (!is_callable($closure)) {
			$message = isset($closure['message']) ? $closure['message'] : $message;
			$closure = isset($closure['rule']) ? $closure['rule'] : $closure;
		}

		$params += compact('message');
		if(!call_user_func($closure, $user, $request, $params)) {
			$this->_error[$name] = $params['message'];
			return false;
		}
		return true;
	}
697555
protected function _loadRequestUserAgent()
    {
        if($this->_requestUserAgent !== NULL) return;

        if(! key_exists('HTTP_USER_AGENT', $_SERVER))
            throw new Exception("No HTTP User Agent was found");

        $this->_requestUserAgent = $_SERVER['HTTP_USER_AGENT'];
    }
916857
def _build_http(http=None):
    
    if not http:
        http = httplib2.Http(
            timeout=HTTP_REQUEST_TIMEOUT, ca_certs=HTTPLIB_CA_BUNDLE)

    user_agent = 'Python-httplib2/{} (gzip), {}/{}'.format(
        httplib2.__version__,
        'custodian-gcp',
        '0.1')
    return set_user_agent(http, user_agent)