Special case that checks user on languagetoolplus.com.
972853
static UserLimits getLimitsFromUserAccount(HTTPServerConfig config, String username, String password) {
    Objects.requireNonNull(username);
    Objects.requireNonNull(password);
    String token = cache.getUnchecked(new Account(username, password));
    return getLimitsFromToken(config, token);
  }
157387
function isUserResult(item) {
  log.trace('isUserResult(%j)', item);

  if (! item) return(false);
  if (item.userPrincipalName) return(true);
  if (item.objectCategory) {
    re.isUserResult.lastIndex = 0; // Reset the regular expression
    return(re.isUserResult.test(item.objectCategory));
  }
  if ((item.objectClass) && (item.objectClass.length > 0)) {
    return(_.any(item.objectClass, function(c) { return(c.toLowerCase() === 'user'); }));
  }
  return(false);
}
757924
def get_users_indexed_by_lang():
        
        result = {}
        users = TransUser.objects.filter(active=True).select_related('user')
        for user in users:
            for lang in user.languages.all():
                if lang.code not in result:
                    result[lang.code] = set()
                result[lang.code].add(user)
        return result
1321976
def _splituser(host):
    """"""
    user, delim, host = host.rpartition('@')
    return (user if delim else None), host
782559
private function checkAdminUser($wtname, $wtuser, $wtpass, $wtemail): string
    {
        if ($wtname === '' || $wtuser === '' || $wtpass === '' || $wtemail === '') {
            return I18N::translate('You must enter all the administrator account fields.');
        }

        if (mb_strlen($wtpass) < 6) {
            return I18N::translate('The password needs to be at least six characters long.');
        }

        return '';
    }
1114254
public function check($content, $type, $additionalArgs = array(), $user = false)
    {
        if ($this->controller) {
            if (!$user) {
                $user = new User();
            }
            $wlg = $this->getWhitelistGroup();
            if ($wlg instanceof Group && $user->inGroup($wlg)) {
                // Never spam if user is in the whitelist
                return true;
            }

            /** @var \Concrete\Core\Permission\IPService $iph */
            $iph = Core::make('helper/validation/ip');
            $ip = $iph->getRequestIP();
            $args['ip_address'] = ($ip === false) ? ('') : ($ip->getIp($ip::FORMAT_IP_STRING));
            $args['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
            $args['content'] = $content;
            foreach ($additionalArgs as $key => $value) {
                $args[$key] = $value;
            }
            if (isset($args['user']) && is_object($args['user'])) {
                $u = $args['user'];
            } else {
                $u = new User();
            }
            if (!isset($args['email']) && $u->isRegistered()) {
                $ui = UserInfo::getByID($u->getUserID());
                $args['email'] = $ui->getUserEmail();
            }
            $r = $this->controller->check($args);
            if ($r) {
                return true;
            } else {
                $logText = '';
                $c = Page::getCurrentPage();
                if (is_object($c)) {
                    $logText .= t('URL: %s', Loader::helper('navigation')->getLinkToCollection($c, true));
                    $logText .= "\n";
                }
                if ($u->isRegistered()) {
                    $logText .= t('User: %s (ID %s)', $u->getUserName(), $u->getUserID());
                    $logText .= "\n";
                }
                $logText .= t('Type: %s', Loader::helper('text')->unhandle($type));
                $logText .= "\n";
                foreach ($args as $key => $value) {
                    $logText .= Loader::helper('text')->unhandle($key) . ': ' . $value . "\n";
                }

                if (Config::get('concrete.log.spam')) {
                    $logger = \Core::make('log/factory')->createLogger(Channels::CHANNEL_SPAM);
                    $logger->warning($logText);
                }
                if (Config::get('concrete.spam.notify_email') != '') {
                    $mh = Loader::helper('mail');
                    $mh->to(Config::get('concrete.spam.notify_email'));
                    $mh->addParameter('content', $logText);
                    $mh->addParameter('siteName', tc('SiteName', \Core::make('site')->getSite()->getSiteName()));
                    $mh->load('spam_detected');
                    $mh->sendMail();
                }

                return false;
            }
        } else {
            return true; // return true if it passes the test
        }
    }
1236876
protected function checkBrowserInternetExplorer()
    {
        //  Test for IE11
        if (stripos($this->_agent, 'Trident/7.0; rv:11.0') !== false) {
            $this->setBrowser(self::BROWSER_IE);
            $this->setVersion('11.0');
            return true;
        } // Test for v1 - v1.5 IE
        else 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) {
            // See if the browser is the odd MSN Explorer
            if (stripos($this->_agent, 'msnb') !== false) {
                $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'MSN'));
                if (isset($aresult[1])) {
                    $this->setBrowser(self::BROWSER_MSN);
                    $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1]));
                    return true;
                }
            }
            $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie'));
            if (isset($aresult[1])) {
                $this->setBrowser(self::BROWSER_IE);
                $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1]));
                if(preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)){
                    if($aresult[1] == '3.1'){
                        $this->setVersion('7.0');
                    }
                    else if($aresult[1] == '4.0'){
                        $this->setVersion('8.0');
                    }
                    else if($aresult[1] == '5.0'){
                        $this->setVersion('9.0');
                    }
                    else if($aresult[1] == '6.0'){
                        $this->setVersion('10.0');
                    }
                    else if($aresult[1] == '7.0'){
                        $this->setVersion('11.0');
                    }
                    else if($aresult[1] == '8.0'){
                        $this->setVersion('11.0');
                    }
                }
                if(stripos($this->_agent, 'IEMobile') !== false) {
                    $this->setBrowser(self::BROWSER_POCKET_IE);
                    $this->setMobile(true);
                }
                return true;
            }
        } // Test for versions > IE 10
        else if (stripos($this->_agent, 'trident') !== false) {
            $this->setBrowser(self::BROWSER_IE);
            $result = explode('rv:', $this->_agent);
            if (isset($result[1])) {
                $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1]));
                $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent);
            }
        } // Test for Pocket IE
        else if (stripos($this->_agent, 'mspie') !== false || stripos($this->_agent, 'pocket') !== false) {
            $aresult = explode(' ', stristr($this->_agent, 'mspie'));
            if (isset($aresult[1])) {
                $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);
                    if (isset($aversion[1])) {
                        $this->setVersion($aversion[1]);
                    }
                }
                return true;
            }
        }
        return false;
    }
143962
def check_user(self, todays_facts):
        """"""
        interval = self.conf_notify_interval
        if interval <= 0 or interval >= 121:
            return

        now = dt.datetime.now()
        message = None

        last_activity = todays_facts[-1] if todays_facts else None

        # update duration of current task
        if last_activity and not last_activity['end_time']:
            delta = now - last_activity['start_time']
            duration = delta.seconds /  60

            if duration and duration % interval == 0:
                message = _("Working on %s") % last_activity['name']
                self.notify_user(message)

        elif self.conf_notify_on_idle:
            #if we have no last activity, let's just calculate duration from 00:00
            if (now.minute + now.hour * 60) % interval == 0:
                self.notify_user(_("No activity"))
1234691
def _whoami():
    # type: () -> Tuple[Text,Text]
    """"""
    username = getuser()
    try:
        if onWindows():
            get_user_name = ctypes.windll.secur32.GetUserNameExW  # type: ignore
            size = ctypes.pointer(ctypes.c_ulong(0))
            get_user_name(3, None, size)

            name_buffer = ctypes.create_unicode_buffer(size.contents.value)
            get_user_name(3, name_buffer, size)
            fullname = str(name_buffer.value)
        else:
            fullname = pwd.getpwuid(os.getuid())[4].split(',')[0]
    except (KeyError, IndexError):
        fullname = username

    return (username, fullname)
326744
def get_user_language(user):
    
    return_value = {}
    user_language.send(sender=user, user=user, return_value=return_value)
    return return_value.get('language')
760793
private XSpellChecker GetSpellChecker(XLinguServiceManager mxLinguSvcMgr) {
    try {
      if (mxLinguSvcMgr != null) {
        return mxLinguSvcMgr.getSpellChecker();
      }
    } catch (Throwable t) {
      // If anything goes wrong, give the user a stack trace
      printMessage(t);
    }
    return null;
  }
369059
def can_view(self, user):
        """"""
        return user.is_admin or user in self.users \
            or self.project.class_ in user.admin_for
1000756
def get_abbreviation_of(self, name):
        """"""
        for language in self.user_data.languages:
            if language['language_string'] == name:
                return language['language']
        return None
52314
public static function checkBrowserNetscapeNavigator9Plus()
    {
        if (stripos(self::$userAgentString, 'Firefox') !== false &&
            preg_match('/Navigator\/([^ ]*)/i', self::$userAgentString, $matches)
        ) {
            if (isset($matches[1])) {
                self::$browser->setVersion($matches[1]);
            }
            self::$browser->setName(Browser::NETSCAPE_NAVIGATOR);

            return true;
        } elseif (stripos(self::$userAgentString, 'Firefox') === false &&
            preg_match('/Netscape6?\/([^ ]*)/i', self::$userAgentString, $matches)
        ) {
            if (isset($matches[1])) {
                self::$browser->setVersion($matches[1]);
            }
            self::$browser->setName(Browser::NETSCAPE_NAVIGATOR);

            return true;
        }

        return false;
    }
38041
def verify_keys(self):
        """"""
        verify_keys_endpoint = Template("${rest_root}/site/${public_key}")
        url = verify_keys_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
        
        data = { "clientName": "mollom_python", "clientVersion": "1.0" }

        self._client.headers["Content-Type"] = "application/x-www-form-urlencoded"

        response = self._client.post(url, data, timeout=self._timeout)
        if response.status_code != 200:
            raise MollomAuthenticationError

        return True
1295953
def checkpat(self, pattern):
        
        if pattern is None:
            return
        try:
            re.match(pattern, "")
        except re.error:
            print3("\nBad user-defined singular pattern:\n\t%s\n" % pattern)
            raise BadUserDefinedPatternError
1305184
def _current_user_override(self):
        """"""
        try:
            # threadlocals is a module, not an actual thread locals object
            request = threadlocals.request()
            if request is None:
                return False
            requesting_user = request.user
            if isinstance(requesting_user, AnonymousUser) or not requesting_user.is_authenticated:
                return False
            can_view_anyway = requesting_user and (requesting_user.is_teacher or requesting_user.is_eighthoffice or requesting_user.is_eighth_admin)
        except (AttributeError, KeyError) as e:
            logger.error("Could not check teacher/eighth override: {}".format(e))
            can_view_anyway = False
        return can_view_anyway