Initiated certain configuration variables
that depend on other factors (ie. environment, request parameters etc.)

@return Boolean: True if initiation request was execututed (ie. first call), false on later ones
358813
public function initConfig() {
		if ( $this->confInitiated ) {
			return false;
		}

		global $kgReq;
		date_default_timezone_set( 'UTC' );

		// User agent (required to get data from wmf domains)
		ini_set( 'user_agent', HttpRequest::getUserAgent() );

		// Allow request parameter to toggle debug mode
		if ( $kgReq->hasKey( 'debug' ) ) {
			$isDebug = $kgReq->getFuzzyBool( 'debug' );

			// Set cookie to remember it in the next request.
			// Also makes it easier to debug by not having to append it to every
			// individual request.
			$kgReq->setCookie( 'debug', $isDebug ? '1' : null );
		} else {
			$isDebug = $kgReq->getCookie( 'debug' ) === '1';
		}

		$this->debugMode = $isDebug;

		$this->confInitiated = true;

		return true;
	}
226449
protected function initDefault()
    {
        if ($this->isCli()) {
            return null;
        }

        $uri = (empty($_SERVER['HTTPS']) ? 'http' : 'https')
            . '://'
            . $_SERVER['HTTP_HOST']
            . $_SERVER['REQUEST_URI'];
        return  rtrim(preg_replace('/\?.*/', '', $uri), '/');
    }
331964
protected function initAllConfigs()
    {
        if ($this->isInitialized) {
            return;
        }

        $this->logger->info('Checking and initializing config files');
        foreach ($this->getEnvironments() as $environment) {
            $this->initConfig($environment);
        }

        $this->isInitialized = true;
    }
654283
public function sessionInit()
    {
        ini_set('session.auto_start', 0);
        $config = Container::get('config')->get('session');
        if ($config['adapter'] != '') {
            $class = '\\Kotori\\Http\\Session\\' . ucfirst($config['adapter']);
            if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
                throw new NotFoundException('error session handler:' . $class);
            }
        }

        session_name('KOTORI_SESSID');
        if (isset($config['auto_start']) && $config['auto_start']) {
            session_start();
            $this->hasSessionStarted = true;
        }
    }
1279745
private function startSession()
  {
    if (Config::has('session') && is_array($session = Config::get('session'))) {
      return session_start($session);
    }

    session_start([
      'name' => 'modulus_session'
    ]);
  }
92598
public function IsInternalRequest () {
		if ($this->appRequest === NULL) {
			try {
				$ctrl = $this->GetControllerName();
				$action = $this->GetActionName();
			} catch (\Exception $e) {
				$ctrl = NULL;
				$action = NULL;
			}
			if ($ctrl !== NULL && $action !== NULL) {
				$this->appRequest = FALSE;
				if ($ctrl === 'controller' && $action === 'asset')
					$this->appRequest = TRUE;
			}
		}
		return $this->appRequest;
	}
706997
public boolean isServerStarted() {

        String thisMethodName = CLASS_NAME + ".isServerStarted()";

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, thisMethodName, this);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, thisMethodName, new Boolean(_serverStarted));
        }

        return _serverStarted;
    }
669032
private function started()
    {
        if (is_null(self::$started)) {
            self::$started = (session_status() === PHP_SESSION_ACTIVE) ? true : session_start();
            if (self::$started) {
                if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
                    if (isset($_SESSION[__CLASS__]['flash']['next'])) {
                        $_SESSION[__CLASS__]['flash']['now'] = $_SESSION[__CLASS__]['flash']['next'];
                        unset($_SESSION[__CLASS__]['flash']['next']);
                    } elseif (isset($_SESSION[__CLASS__]['flash'])) {
                        unset($_SESSION[__CLASS__]);
                    }
                }
            }
        }

        return self::$started;
    }
557298
public function init()
    {
        // Avoid CLI Issues
        if (PHP_SAPI === 'cli') {
            return false;
        }
        // Cache bug // force creating first request
        elseif (!$this->requestStack->getCurrentRequest()) {
            $this->requestStack->push(Request::createFromGlobals());
        }

        // Master hostname
        $hostName = $this->requestStack->getCurrentRequest()->getHost();

        // Check config
        if (isset($this->config['enabled']) && $this->config['enabled'] === true) {
            // Fetch Host & map them
            foreach ($this->config['partners'] as $nodeName => $data) {
                // Transform Config
                $data['locals'] = $this->transformConfig($data['locals']);
                $data['globals'] = $this->transformConfig($data['globals']);

                // Get Hosts
                foreach ($data['hosts'] as $currentHostName) {
                    // Check host inexistence
                    if (!isset($this->hostConfigTable[$currentHostName])) {
                        // Get Config
                        $this->hostConfigTable[$currentHostName] = $data;
                    } else {
                        throw new WhiteLabelException(sprintf('The host "%s", in node "%s" is already defined in a previous partner node.', $currentHostName, $nodeName));
                    }
                }
            }

            // Find the partner
            if (isset($this->hostConfigTable[$hostName]) && isset($this->hostConfigTable[$hostName]['namespace'])) {
                // Write the namespace
                $partnerConfig = $this->hostConfigTable[$hostName];

                // Check if this partner is enabled
                if (!isset($partnerConfig['enabled']) || $partnerConfig['enabled'] === true) {
                    $this->context = $partnerConfig;
                    $this->locals = isset($partnerConfig['locals']) ? $partnerConfig['locals'] : [];
                }
            }
        }
    }
1006776
public function GettingStarted() {
      $this->Permission('Garden.Settings.Manage');
      
      $this->SetData('Title', T('Getting Started'));
      $this->AddSideMenu('dashboard/settings/gettingstarted');
      $this->TextEnterEmails = T('TextEnterEmails', 'Type email addresses separated by commas here');
      
      if ($this->Form->AuthenticatedPostBack()) {
         // Do invitations to new members.
         $Message = $this->Form->GetFormValue('InvitationMessage');
         $Message .= "\n\n".Gdn::Request()->Url('/', TRUE);
         $Message = trim($Message);
         $Recipients = $this->Form->GetFormValue('Recipients');
         if ($Recipients == $this->TextEnterEmails)
            $Recipients = '';
            
         $Recipients = explode(',', $Recipients);
         $CountRecipients = 0;
         foreach ($Recipients as $Recipient) {
            if (trim($Recipient) != '') {
               $CountRecipients++;
               if (!ValidateEmail($Recipient))
                  $this->Form->AddError(sprintf(T('%s is not a valid email address'), $Recipient));
            }
         }
         if ($CountRecipients == 0)
            $this->Form->AddError(T('You must provide at least one recipient'));
         if ($this->Form->ErrorCount() == 0) {
            $Email = new Gdn_Email();
            $Email->Subject(T('Check out my new community!'));
            $Email->Message($Message);
            foreach ($Recipients as $Recipient) {
               if (trim($Recipient) != '') {
                  $Email->To($Recipient);
                  try {
                     $Email->Send();
                  } catch (Exception $ex) {
                     $this->Form->AddError($ex);
                  }
               }
            }
         }
         if ($this->Form->ErrorCount() == 0)
            $this->InformMessage(T('Your invitations were sent successfully.'));
      }
      
      $this->Render();
   }
69130
protected function init(): bool
    {
        if (!isset($_SESSION[$this->name])) {
            $_SESSION[$this->name] = [];
        }
        return true;
    }
448220
public function isStarted()
    {
        $started = false;
        if (version_compare(phpversion(), '5.4.0', '>=')) {
            $started = session_status() === PHP_SESSION_ACTIVE ? true : false;
        } else {
            $started = session_id() === '' ? false : true;
        }

        return $started;
    }
355748
public static function startup()
    {
        global $PPHP;

        $sessionSeconds = $PPHP['config']['session']['gc_maxlifetime'] * 60;
        // Start a PHP-handled session and bind it to the current remote IP address as
        // a precaution per https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet
        // We'll go one step further in _magic() and throw in User Agent details.
        ini_set('session.gc_probability', 1);
        ini_set('session.gc_gc_divisor', 1000);
        ini_set('session.gc_maxlifetime', $sessionSeconds);
        session_save_path($PPHP['dir'] . '/var/sessions');
        ini_set('session.cookie_lifetime', 0);  // Session
        ini_set('session.cookie_httponly', true);
        session_start();
        if (isset($_SESSION['magic'])) {
            if ($_SESSION['magic'] !== self::_magic()) {
                self::reset();
            };
        } else {
            self::_init();
        };
    }
1048925
protected function initialiseSession()
    {
        $session = $this->session ?: new Session();

        if ( ! $session->isStarted()) {
            $session->start();
        }

        return $this->session = $session;
    }
1195971
public function startup()
    {
        if (!$this->getConfig('requireIdentity')) {
            return;
        }

        $request = $this->getController()->request;
        $action = $request->getParam('action');
        if (in_array($action, $this->unauthenticatedActions)) {
            return;
        }

        $identity = $request->getAttribute($this->getConfig('identityAttribute'));
        if (!$identity) {
            throw new UnauthenticatedException();
        }
    }
1234901
public function onConfigUpdated()
    {
        parent::onConfigUpdated();

        if (($order = ini_get('request_order')) || ($order = ini_get('variables_order'))) {
            $this->variablesOrder = $order;
        } else {
            $this->variablesOrder = null;
        }
    }
724382
private boolean isFirstRequestProcessed()
    {
        FacesContext context = FacesContext.getCurrentInstance();
        
        //if firstRequestProcessed is not set, check the application map
        if(!_firstRequestProcessed && context != null 
                && Boolean.TRUE.equals(context.getExternalContext().getApplicationMap()
                        .containsKey(LifecycleImpl.FIRST_REQUEST_PROCESSED_PARAM)))
        {
            _firstRequestProcessed = true;
        }
        return _firstRequestProcessed;
    }