Check if host is allowed to access at this environment
@return int Is allowed
@throws Server403 If host not allowed
@throws Server500 If Environment does not exist
965516
public static function hostAllowed():int
    {
        if (!in_array(self::$framework_paths["framework.env"], array("dev", "prod"))) {
            throw new Server500(new ArrayObject(array("explain" => "An error was detected on environment declaration",
                "solution" => "Please check the environment declaration.", "external" => "yes")));
        }
        $host_env = FEnv::get(("dev" === FEnv::get("framework.env"))?
            "framework.config.hosts.dev.file" : "framework.config.hosts.prod.file");
        $hosts = file_get_contents($host_env);

        if (empty(trim($hosts))) {
            self::displayError((array("explain" => "You are not allowed to access this file.", "solution" =>
                'Check '.basename(__FILE__).' for more information.', "external" => "yes")));
        } else {
            $hosts = json_decode($hosts);
            if (isset($hosts->allowed) && isset($hosts->denied)) {
                if (isset($_SERVER['HTTP_CLIENT_IP'])
                    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                    self::displayError((array("explain" => "You are not allowed to access this file.", "solution" =>
                        'Check '.basename(__FILE__).' for more information.', "external" => "yes")));
                } else {
                    $allowed = (array) $hosts->allowed;
                    $denied = (array) $hosts->denied;

                    if ((in_array("", array_map('trim', $allowed)) && in_array(
                        "",
                        array_map('trim', $denied)
                    )) || (in_array(
                        "",
                        array_map('trim', $allowed)
                    ) &&  in_array("*", $denied))) {
                        self::displayError((array("explain" => "You are not allowed to access this file.",
                            "solution" => 'Check '.basename(__FILE__).' for more information.',
                            "external" => "yes")));
                    } elseif (in_array(@$_SERVER['REMOTE_ADDR'], $denied) || (in_array("*", $denied) &&
                            !in_array(@$_SERVER['REMOTE_ADDR'], $allowed))) {
                        self::displayError((array("explain" => "You are not allowed to access this file.", "solution" =>
                            'Check '.basename(__FILE__).' for more information.', "external" => "yes")));
                    } elseif ((!in_array(@$_SERVER['REMOTE_ADDR'], $allowed) && in_array(
                        @$_SERVER['REMOTE_ADDR'],
                        $denied
                    )) || in_array(@$_SERVER['REMOTE_ADDR'], $allowed) &&
                        in_array(@$_SERVER['REMOTE_ADDR'], $denied)) {
                        self::displayError((array("explain" => "You are not allowed to access this file.", "solution" =>
                            'Check '.basename(__FILE__).' for more information.', "external" => "yes")));
                    } else {
                        return (1);
                    }
                }
            } else {
                self::displayError((array("explain" => "You are not allowed to access this file.", "solution" =>
                    'Check '.basename(__FILE__).' for more information.', "external" => "yes")));
            }
        }
        return (0);
    }
799094
protected function checkTypeAllowed()
    {
        if (!in_array($this->type, static::$ALLOWED_TYPES)) {
            throw new \Exception(
                sprintf(
                    "`%s` is not a valid environment type. Expected one of: %s",
                    $this->type,
                    implode(', ', static::$ALLOWED_TYPES)
                )
            );
        }
    }
1105286
public function isValidServerInfos()
    {
        $infos = Splash::ws()->getServerInfos();

        //====================================================================//
        // Verify Array Given
        if (!is_a($infos, 'ArrayObject')) {
            return Splash::log()->err(Splash::trans('ErrInfosNotArrayObject', get_class($infos)));
        }

        if (defined('SPLASH_DEBUG') && !empty(SPLASH_DEBUG)) {
            Splash::log()->war('Host : '.$infos['ServerHost']);
            Splash::log()->war('Path : '.$infos['ServerPath']);
        }

        //====================================================================//
        // Required Parameters are Available
        //====================================================================//
        if (!isset($infos['ServerHost']) || empty($infos['ServerHost'])) {
            Splash::log()->err(Splash::trans('ErrEmptyServerHost'));

            return Splash::log()->err(Splash::trans('ErrEmptyServerHostDesc'));
        }

        if (!isset($infos['ServerPath']) || empty($infos['ServerPath'])) {
            Splash::log()->err(Splash::trans('ErrEmptyServerPath'));

            return Splash::log()->err(Splash::trans('ErrEmptyServerPathDesc'));
        }

        //====================================================================//
        // Detect Local Installations
        //====================================================================//
        $this->isLocalInstallation($infos);

        return true;
    }
509468
public static function EnvironmentDetectByIps () {
		if (static::$environment === NULL) {
			$request = & \MvcCore\Application::GetInstance()->GetRequest();
			$serverAddress = $request->GetServerIp();
			$remoteAddress = $request->GetClientIp();
			if ($serverAddress == $remoteAddress) {
				static::$environment = static::ENVIRONMENT_DEVELOPMENT;
			} else {
				static::$environment = static::ENVIRONMENT_PRODUCTION;
			}
		}
		return static::$environment;
	}
1082547
public function isBlocked()
    {
        $ip = $this->getIp();
        $this->deleteAttempts($ip, false);

        // INET_ATON
        $query = "SELECT count(*) FROM {$this->config->table_attempts} WHERE ip = :ip";
        $query_prepared = $this->dbh->prepare($query); // INET_ATON(:ip)
        $query_prepared->execute(['ip' => $ip]);
        $attempts = $query_prepared->fetchColumn();

        if ($attempts < intval($this->config->attempts_before_verify)) {
            return "allow";
        }

        if ($attempts < intval($this->config->attempts_before_ban)) {
            return "verify";
        }

        return "block";
    }
898596
public function isBanned()
    {
        if (false !== ($banned = session('isBan', false))) {
            $this->ban();

            return $banned;
        }

        $banned = $this->model
            ->where('ip', $this->ip())
            ->whereIn('type', ['regular', 'permanent'])
            ->first(['ip', 'type']);

        if (! is_null($banned)) {
            return $banned->getAttribute('type');
        }

        return $this->isSegmentBanned();
    }
763792
public function getEnvironment()
    {
        if (!empty($this->environnement)) {
            $host      = gethostname();
            $authority = $this->request->getUri()->getAuthority();

            foreach ($this->environnement as $key => $env) {
                if (in_array($host, $env) || in_array($authority, $env)) {
                    return $key;
                }
            }
        }

        return '';
    }
959792
protected function _getEnvironment()
    {
        $environment = self::$forceEnvironment;

        // Check if the environment has been manually set (forced).
        if ($environment !== null) {
            if (!isset($this->_environments[$environment])) {
                throw new Exception('Environment configuration for "' . $environment . '" could not be found.');
            }
        }
        // If no manual setting is available, use "host:port" to decide which config to use.
        if ($environment === null && !empty($_SERVER['HTTP_HOST'])) {
            $host = (string)$_SERVER['HTTP_HOST'];
            foreach ($this->_environments as $env => $envConfig) {
                if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
                    $environment = $env;
                    break;
                }
            }
        }
        // If there is no host:port match, try "host" only.
        if ($environment === null && !empty($_SERVER['SERVER_NAME'])) {
            $host = (string)$_SERVER['SERVER_NAME'];
            foreach ($this->_environments as $env => $envConfig) {
                if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
                    $environment = $env;
                    break;
                }
            }
        }
        // If no host matched then try to use the APP path.
        if ($environment === null && ($serverPath = $this->_getRealAppPath())) {
            foreach ($this->_environments as $env => $envConfig) {
                if (isset($envConfig['path']) && in_array($serverPath, $envConfig['path'])) {
                    $environment = $env;
                    break;
                }
            }
        }
        // No environment could be identified -> we are on a dev machine.
        if (!$environment) {
            $environment = 'local';
        }

        return $environment;
    }
993573
protected function serverPort(): int
    {
        if ($this->serverPort !== null) {
            return $this->serverPort;
        }

        $iterator = $this->process->getIterator(SymfonyProcess::ITER_SKIP_ERR | SymfonyProcess::ITER_KEEP_OUTPUT);

        foreach ($iterator as $data) {
            return $this->serverPort = (int) $data;
        }

        // If the iterator didn't execute properly, then the process must have failed, we must check to be sure.
        $this->checkProcessStatus();
    }
177795
public static function isAdminIP() {
        if (!isset($_SERVER['REMOTE_ADDR']))
            return false;

        static $whiteList; if (!$whiteList) {
            $ips = ['127.0.0.1', $_SERVER['SERVER_ADDR']];

            if (!self::$defaultConfig)
                return in_array($_SERVER['REMOTE_ADDR'], $ips);

            $values = self::$defaultConfig->get('admin.ip.whitelist', []);
            if (!is_array($values)) $values = [$values];
            $whiteList = \array_keys(\array_flip(\array_merge($ips, $values)));
        }
        return in_array($_SERVER['REMOTE_ADDR'], $whiteList);
    }
196547
public static function checkDomain()
	{
		$domain = Config::get('@.DOMAIN');
		return empty($domain) || !Config::get('@.FILTER_DOMAIN') || $domain === Request::server('HTTP_HOST');
	}
706337
public function checkAccess()
    {
        if (YII_ENV === 'test') {
            return true;
        }
        $ip = Yii::$app->request->getUserIP();
        foreach ($this->module->allowedIPs as $filter) {
            if ($filter === '*' || $filter === $ip || (($pos = strpos($filter, '*')) !== false && !strncmp($ip, $filter, $pos))) {
                return true;
            }
        }
        echo Yii::t('podium/view', 'Access to Podium installation is denied due to IP address restriction.');
        Yii::warning('Access to Podium installation is denied due to IP address restriction. The requested IP is ' . $ip, __METHOD__);
        return false;
    }
310387
public static function isSupportedShell()
        {
            if (isset($_ENV['TERM'])) {
                if (isset(self::$_supportedShells[$_ENV['TERM']])) {
                    return true;
                }
            } elseif (isset($_SERVER['TERM'])) {
                if (isset(self::$_supportedShells[$_SERVER['TERM']])) {
                    return true;
                }
            } elseif (isset($_SERVER['ConEmuANSI']) && $_SERVER['ConEmuANSI'] == 'ON') {
                return true;
            }

            return isAke($_SERVER, 'CLI', false);
        }
1198839
public static function getHost()
    {
        $host = '';
        if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $host = $_SERVER['HTTP_X_FORWARDED_HOST']) {
            $elements = explode(',', $host);
            $host     = trim(end($elements));
        } else {
            if (isset($_SERVER['HTTP_HOST']) && !$host = $_SERVER['HTTP_HOST']) {
                if (isset($_SERVER['SERVER_NAME']) && !$host = $_SERVER['SERVER_NAME']) {
                    $host = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '';
                }
            }
        }
        // Remove port number from host
        $host = preg_replace('/:\d+$/', '', $host);

        return trim($host);
    }
10306
public static function serverPort()
    {
        if ( empty( $GLOBALS['eZSysServerPort'] ) )
        {
            $hostname = self::hostname();
            if ( preg_match( "/.*:([0-9]+)/", $hostname, $regs ) )
            {
                $port = (int) $regs[1];
            }
            else
            {
                $port = (int) self::serverVariable( 'SERVER_PORT', true );
            }

            if ( !$port )
            {
                $port = 80;
            }

            $GLOBALS['eZSysServerPort'] = $port;
        }
        return $GLOBALS['eZSysServerPort'];
    }
305430
public function check_access() {
        global $CFG;
        $context = empty($this->context) ? context_system::instance() : $this->context;
        foreach($this->req_capability as $cap) {
            if (has_capability($cap, $context)) {
                return true;
            }
        }
        return false;
    }
1277633
public static function isSupportedShell()
        {
            $flag = false;

            if (isset($_ENV['TERM'])) {
                if (isset(self::$_supportedShells[$_ENV['TERM']])) {
                    $flag = true;
                }
            } else {
                if (isset($_SERVER['TERM'])) {
                    if (isset(self::$_supportedShells[$_SERVER['TERM']])) {
                        $flag = true;
                    }
                }
            }

            return $flag;
        }