samdark\webshell\Module::checkAccess PHP Method

checkAccess() protected method

protected checkAccess ( Action $action ) : boolean
$action yii\base\Action
return boolean whether the module can be accessed by the current user
    protected function checkAccess(Action $action)
    {
        $allowed = false;
        $ip = Yii::$app->getRequest()->getUserIP();
        foreach ($this->allowedIPs as $filter) {
            if ($filter === '*' || $filter === $ip || ($pos = strpos($filter, '*')) !== false && !strncmp($ip, $filter, $pos)) {
                $allowed = true;
                break;
            }
        }
        if ($allowed === false) {
            Yii::warning('Access to web shell is denied due to IP address restriction. The requested IP is ' . $ip, __METHOD__);
            return false;
        }
        if ($this->checkAccessCallback !== null && call_user_func_array($this->checkAccessCallback, [$action]) !== true) {
            Yii::warning('Access to web shell is denied due to checkAccessCallback.', __METHOD__);
            return false;
        }
        return true;
    }