Set actual "open_basedir" PHP ini option
@throws \Exception
@codeCoverageIgnore
543434
protected function applyOpenBaseDirSetting() {
		if($this->openBaseDirs) {
			$value = implode(PATH_SEPARATOR, $this->openBaseDirs);
			if(ini_get('open_basedir') != $value) {
				$this->forcePhpConsoleClassesAutoLoad();
				if(ini_set('open_basedir', $value) === false) {
					throw new \Exception('Unable to set "open_basedir" php.ini setting');
				}
			}
		}
	}
340722
public static function _init()
	{
		// load the file config
		\Config::load('file', true);

		// make sure the log directories exist
		try
		{
			// determine the name and location of the logfile
			$path     = \Config::get('log_path', APPPATH.'logs'.DS);
			$filename = \Config::get('log_file', null);

			if(empty($filename))
			{
				$rootpath = $path.date('Y').DS;
				$filepath = $path.date('Y/m').DS;
				$filename = $filepath.date('d').'.php';
			}
			else
			{
				$rootpath = $path;
				$filepath = $path;
				$filename = $path.$filename;
			}

			// get the required folder permissions
			$permission = \Config::get('file.chmod.folders', 0777);

			if ( ! is_dir($rootpath))
			{
				mkdir($rootpath, 0777, true);
				chmod($rootpath, $permission);
			}
			if ( ! is_dir($filepath))
			{
				mkdir($filepath, 0777, true);
				chmod($filepath, $permission);
			}

			$handle = fopen($filename, 'a');
		}
		catch (\Exception $e)
		{
			\Config::set('log_threshold', \Fuel::L_NONE);
			throw new \FuelException('Unable to create or write to the log file. Please check the permissions on '.\Config::get('log_path').'. ('.$e->getMessage().')');
		}

		if ( ! filesize($filename))
		{
			fwrite($handle, "<?php defined('COREPATH') or exit('No direct script access allowed'); ?>".PHP_EOL.PHP_EOL);
			chmod($filename, \Config::get('file.chmod.files', 0666));
		}
		fclose($handle);

		// create the monolog instance
		static::$monolog = new \Monolog\Logger('fuelphp');

		// create the streamhandler, and activate the handler
		$stream = new \Monolog\Handler\StreamHandler($filename, \Monolog\Logger::DEBUG);
		$formatter = new \Monolog\Formatter\LineFormatter("%level_name% - %datetime% --> %message%".PHP_EOL, "Y-m-d H:i:s");
		$stream->setFormatter($formatter);
		static::$monolog->pushHandler($stream);
	}
815431
private function init()
    {
        $this->os_name = php_uname('s');
        $this->os_version = php_uname('r');
        $this->os_architecture = php_uname('m');
        $this->php_version = preg_split('/\\./', phpversion());
    }
634439
private static function _initialize($keepOpen = false)
    {
        try {
            if (is_null(self::$_runtimeClient)) {
                self::$_versionEndpoint = getenv(
                    self::VERSION_ENDPOINT_ENVIRONMENT_NAME
                );

                if (self::$_versionEndpoint == false) {
                    self::$_versionEndpoint = self::VERSION_ENDPOINT_FIXED_PATH;
                }

                $kernel = RuntimeKernel::getKernel();
                $kernel->getProtocol1RuntimeGoalStateClient()->setKeepOpen(
                    $keepOpen
                );

                self::$_runtimeClient = $kernel->getRuntimeVersionManager()
                    ->getRuntimeClient(self::$_versionEndpoint);

                self::$_currentGoalState = self::$_runtimeClient
                    ->getCurrentGoalState();

                self::$_currentEnvironmentData = self::$_runtimeClient
                    ->getRoleEnvironmentData();
            } else {
                self::$_currentGoalState = self::$_runtimeClient
                    ->getCurrentGoalState();

                self::$_currentEnvironmentData = self::$_runtimeClient
                    ->getRoleEnvironmentData();
            }
        } catch (ChannelNotAvailableException $ex) {
            throw new RoleEnvironmentNotAvailableException();
        }
    }
77895
public function initCliAction()
    {
        clearstatcache();

        $app = 'app/' . Config::get('app.name') . '/';

        $assets = array(
            BASE_PATH . $app . '_session/',
            BASE_PATH . $app . '_cache/',
            BASE_PATH . $app . '_database/',
            BASE_PATH . $app . '_templates/',
        );

        echo 'Check app assets' . PHP_EOL;

        foreach ($assets as $asset) {

            if (!is_dir($asset)) {
                echo "[ Please create '$asset' directory! ]" . PHP_EOL;
            }

            if (!is_writable($asset)) {
                echo "[ Please make '$asset' writable! ]" . PHP_EOL;
            }
        }

        echo 'Secure root directory' . PHP_EOL;
        chmod(BASE_PATH, 0755);

        echo 'Secure .htaccess' . PHP_EOL;
        chmod(BASE_PATH . '.htaccess', 0644);

        echo 'Secure index.php' . PHP_EOL;
        chmod(BASE_PATH . 'index.php', 0644);

        echo 'Secure autoload.core.php' . PHP_EOL;
        chmod(BASE_PATH . 'pimf-framework/autoload.core.php', 0644);

        echo 'Create logging files' . PHP_EOL;

        $directory = Config::get('bootstrap.local_temp_directory');

        $handle = fopen($file = $directory . 'pimf-logs.txt', "at+");
        fclose($handle);
        chmod($file, 0777);
        $handle = fopen($file = $directory . 'pimf-warnings.txt', "at+");
        fclose($handle);
        chmod($file, 0777);
        $handle = fopen($file = $directory . 'pimf-errors.txt', "at+");
        fclose($handle);
        chmod($file, 0777);

        clearstatcache();
    }
628630
function tryInit(options, $that) {
            if (options.initialized === true) {
                return true;
            }

            if ($('body').width() < options.minWidth) {
                return false;
            }

            init(options, $that);

            return true;
        }
795274
public function init()
	{
		if ($this->language === null) {
			$this->language = App::$Request->getLanguage();
		}

        if ($this->targetClass === null) {
            $this->targetClass = 'wysiwyg';
        }

        if ($this->config === null || !Arr::in($this->config, ['config-small', 'config-full', 'config-medium'])) {
            $this->config = 'config-default';
        }

        $this->baseUrl = App::$Alias->scriptUrl . '/vendor/phpffcms/ffcms-ckeditor/assets';
	}
490573
protected function defineIniSettings(): void
    {
        $this->setTimezone();
        ini_set('memory_limit', '-1');

        if (extension_loaded('Zend OPcache') && ini_get('opcache.enable') && ini_get('opcache.enable_cli')) {
            if (ini_get('opcache.save_comments')) {
                ini_set('opcache.load_comments', '1');
            } else {
                ini_set('opcache.enable', '0');
            }
        }

        if (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.save_comments') === 0) {
            throw new RuntimeException('Please enable zend_optimizerplus.save_comments in php.ini.');
        }
    }
656506
public function init()
    {
        parent::init();

        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $this->windows = true;
        }

        if ($this->resource_directory) {
            if (!file_exists($this->resource_directory)) {
                throw new Exception('Invalid resource directory', 1);
            }
        }
    }
785749
static function init() {

		switch( PHP_SAPI ) {
		// Ideally we want to be runnning as CLI
		case 'cli':
			break;
		// Special conditions to ensure CGI runs as CLI
		case 'cgi':
			// Ensure resource constants are defined
			if( ! defined('STDERR') ){
				define( 'STDERR', fopen('php://stderr', 'w') );
			}
			if( ! defined('STDOUT') ){
				define( 'STDOUT', fopen('php://stdout', 'w') );
			}
			break;
		default:
			echo "Command line only\n";
			exit(1);
		}
		
		// Default error logger function
		PLUG::set_error_logger( array(__CLASS__,'format_logline') );
		
		// parse command line arguments from argv global
		global $argv, $argc;
		// first cli arg is always current script. second arg will be script arg passed to shell wrapper
		for( $i = 1; $i < $argc; $i++ ){
			$arg = $argv[ $i ];
			
			// Each command line argument may take following forms:
			//  1. "Any single argument", no point parsing this unless it follows #2 below
			//  2. "-aBCD", one or more switches, parse into 'a'=>true, 'B'=>true, and so on
			//  3. "-a value", flag used with following value, parsed to 'a'=>'value'
			//  4. "--longoption", GNU style long option, parse into 'longoption'=>true
			//  5. "--longoption=value", as above, but parse into 'longoption'=>'value'
			//  6."any variable name = any value" 
			
			$pair = explode( '=', $arg, 2 );
			if( isset($pair[1]) ){
				$name = trim( $pair[0] );
				if( strpos($name,'--') === 0 ){
					// #5. trimming "--" from option, tough luck if you only used one "-"
					$name = trim( $name, '-' );
				}
				// else is #6, any pair
				$name and self::$args[$name] = trim( $pair[1] );
			}
			
			else if( strpos($arg,'--') === 0 ){
				// #4. long option, no value
				$name = trim( $arg, "-\n\r\t " );
				$name and self::$args[ $name ] = true;
			}
			
			else if( $arg && $arg{0} === '-' ){
				$flags = preg_split('//', trim($arg,"-\n\r\t "), -1, PREG_SPLIT_NO_EMPTY );
				foreach( $flags as $flag ){
					self::$args[ $flag ] = true;
				}
				// leave $flag set incase a value follows.
				continue;
			}

			// else is a standard argument. use as value only if it follows a flag, e.g "-a apple"
			else if( isset($flag) ){
				self::$args[ $flag ] = trim( $arg );
			}

			// dispose of last flag
			unset( $flag );
			// next arg 
		}
	}
970475
private function initHelper()
    {
        if (!$this->isConfigFileSet()) {
            throw new Exception("The main config file wasn't defined.");
        }
        if (!$this->isAppRootSet()) {
            throw new Exception("The application root wasn't defined.");
        }
        AppHelper::getInstance()
            ->setAppRoot($this->getAppRoot())
            ->setConfigFile($this->getConfigFile())
            ->run();
    }
591475
private function _openEnd()
    {
        if ($this->name === 'blank') {
            return;
        }

        if (!$this->inlineInner) {
            if ($this->name !== 'blank' && !$this->hasOption('inline')) {
                Config::set('tabs', '--');
            }
            Generator::tabs();
        }
        echo str_replace(':name', $this->realName, $this->brackets['end']);
    }
654496
protected static function _setPhpInit( )
		{
			$init = Module::merge( ptc_path( 'root' ) . '/app/config/init.php' );
			foreach ( $init as $k => $v )
			{
				if ( is_array( $v ) )
				{
					foreach ( $v as $key => $val )
					{
						ini_set( $k . '.' . $key , $val );
					}
				}
				else
				{
					ini_set( $k , $v );
				}
			}
			static::option( 'init' , $init );
		}
843430
protected function _init() {
        /* ############## APP ############## */

        /* ## LANG ## */
        if ($handle = opendir(APP_RESOURCE_LANG_PATH)) {
            while (false !== ($entry = readdir($handle))) {
                if (preg_match('#(' . preg_quote('.xml') . ')$#isU', $entry)) {
                    $this->_parseLang(null, str_replace('.xml', '', $entry));
                }
            }

            closedir($handle);
        }

        /* ## TEMPLATE ## */
        $this->config['template']['app'] = APP_RESOURCE_TEMPLATE_PATH;
        /* ## CSS ## */
        $this->config['css']['app'] = WEB_PATH . 'app/' . WEB_CSS_PATH;
        /* ## IMAGE ## */
        $this->config['img']['app'] = WEB_PATH . 'app/' . WEB_IMAGE_PATH;
        /* ## FILE ## */
        $this->config['file']['app'] = WEB_PATH . 'app/' . WEB_FILE_PATH;
        /* ## JS ## */
        $this->config['js']['app'] = WEB_PATH . 'app/' . WEB_JS_PATH;

        /* ############## SRC ############## */

        if ($handleSrc = opendir(SRC_PATH)) {
            while (false !== ($entrySrc = readdir($handleSrc))) {
                if (is_dir(SRC_PATH . $entrySrc) && $entrySrc != '.' && $entrySrc != '..') {
                    /* ## ROUTE ## */
                    $this->_parseRoute($entrySrc);

                    /* ## LANG ## */
                    if ($handle = opendir(SRC_PATH . $entrySrc . '/' . SRC_RESOURCE_LANG_PATH)) {
                        while (false !== ($entry = readdir($handle))) {
                            if (preg_match('#(' . preg_quote('.xml') . ')$#isU', $entry)) {
                                $lang = str_replace('.xml', '', $entry);
                                $this->_parseLang($entrySrc, $lang);
                            }
                        }

                        closedir($handle);
                    }

                    /* ## TEMPLATE ## */
                    $this->config['template']['' . $entrySrc . ''] = SRC_PATH . $entrySrc . '/' . SRC_RESOURCE_TEMPLATE_PATH;
                    /* ## CSS ## */
                    $this->config['css']['' . $entrySrc . ''] = WEB_PATH . $entrySrc . '/' . WEB_CSS_PATH;
                    /* ## IMAGE ## */
                    $this->config['img']['' . $entrySrc . ''] = WEB_PATH . $entrySrc . '/' . WEB_IMAGE_PATH;
                    /* ## FILE ## */
                    $this->config['file']['' . $entrySrc . ''] = WEB_PATH . $entrySrc . '/' . WEB_FILE_PATH;
                    /* ## JS ## */
                    $this->config['js']['' . $entrySrc . ''] = WEB_PATH . $entrySrc . '/' . WEB_JS_PATH;
                    /* ## FIREWALL ## */
                    $this->_parseFirewall($entrySrc);

                    //copy app lang in each other module lang
                    foreach ($this->config['lang'] as $key => $value) {
                        if ($key != 'app') {
                            foreach ($value as $key2 => $value2) {
                                $this->config['lang']['' . $key . '']['' . $key2 . ''] = array_merge($this->config['lang']['app']['' . $key2 . ''], $value2);
                            }
                        }
                    }

                    /* ## ANNOTATIONS ## */
                    $controllers = scandir(SRC_PATH . $entrySrc . '/' . SRC_CONTROLLER_PATH);

                    foreach ($controllers as $controller) {
                        if (strlen($controller) > 2) {
                            $annotation = Annotation::getClass('Src\\' . $entrySrc . '\\Controller\\' . basename($controller, '.php'));
                            $this->_parseAnnotationRoute($entrySrc, $controller, $annotation);
                            $this->_parseAnnotationCron($entrySrc, $controller, $annotation);
                        }
                    }

                    /* ## ENTITIES ## */
                    $entities = scandir(APP_RESOURCE_ENTITY_PATH);

                    foreach ($entities as $entity) {
                        if (strlen($entity) > 2 && strstr($entity, '.')) {
                            Annotation::getClass('\\Gcs\\App\Resource\\Entity\\' . basename($entity, '.php'));
                        }
                    }
                }
            }

            closedir($handleSrc);
        }
        else {
            throw new Exception('The directory ' . SRC_PATH . 'doesn\'t exist');
        }

        if ($this->config['user']['output']['cache']['config']) {
            $this->_cache->setContent($this->config);
            $this->_cache->setCache();
        }
    }
861756
public function boot()
    {
        if ((php_sapi_name() === 'cli' || defined('STDIN'))) {
            return;
        }

        if (session_status() == PHP_SESSION_ACTIVE) {
            throw new Exception('Session is already started');
        }

        // save path
        if ($this->app->hasProp($this->sessionPropName.'.save_path')) {
            session_save_path($this->app->getProp($this->sessionPropName.'.save_path'));
        }

        // save handler class
        if ($this->app->hasProp($this->sessionPropName.'.save_handler')) {
            session_set_save_handler($this->app->getProp($this->sessionPropName.'.save_handler'));
        }

        // name the session
        if ($this->app->hasProp($this->sessionPropName.'.name')) {
            session_name($this->app->getProp($this->sessionPropName.'.name'));
        }

        // session options
        $options = [];
        if ($this->app->hasProp($this->sessionPropName.'.options')) {
            $options = $this->app->getProp($this->sessionPropName.'.options');
        }

        // start the session
        session_start($options);
    }
950691
private static function setClient()
    {
        if (self::$client === null) {
            self::$client = new Client([
                'base_uri'  => self::$environment,
                'timeout'   => self::TIMEOUT,
                'verify'    => self::VERIFY,
            ]);
        }
    }
1316715
public static function init() {
		
		// make sure config vars exist
		if (!Config::getOption("patternExtension")) {
			Console::writeError("the pattern extension config option needs to be set...");
		}
		
		if (!Config::getOption("styleguideKit")) {
			Console::writeError("the styleguideKit config option needs to be set...");
		}
		
		// set-up config vars
		$patternExtension        = Config::getOption("patternExtension");
		$metaDir                 = Config::getOption("metaDir");
		$styleguideKit           = Config::getOption("styleguideKit");
		$styleguideKitPath       = Config::getOption("styleguideKitPath");
		
		if (!$styleguideKitPath || !is_dir($styleguideKitPath)) {
			Console::writeError("your styleguide won't render because i can't find your styleguide files. are you sure they're at <path>".Console::getHumanReadablePath($styleguideKitPath)."</path>? you can fix this in <path>./config/config.yml</path> by editing styleguideKitPath...");
		}
		
		// load pattern-lab's resources
		$partialPath             = $styleguideKitPath.DIRECTORY_SEPARATOR."views".DIRECTORY_SEPARATOR."partials";
		$generalHeaderPath       = $partialPath.DIRECTORY_SEPARATOR."general-header.".$patternExtension;
		$generalFooterPath       = $partialPath.DIRECTORY_SEPARATOR."general-footer.".$patternExtension;
		self::$htmlHead          = (file_exists($generalHeaderPath)) ? file_get_contents($generalHeaderPath) : "";
		self::$htmlFoot          = (file_exists($generalFooterPath)) ? file_get_contents($generalFooterPath) : "";
		
		// gather the user-defined header and footer information
		$patternHeadPath         = $metaDir.DIRECTORY_SEPARATOR."_00-head.".$patternExtension;
		$patternFootPath         = $metaDir.DIRECTORY_SEPARATOR."_01-foot.".$patternExtension;
		self::$patternHead       = (file_exists($patternHeadPath)) ? file_get_contents($patternHeadPath) : "";
		self::$patternFoot       = (file_exists($patternFootPath)) ? file_get_contents($patternFootPath) : "";
		
		// add the filesystemLoader
		$patternEngineBasePath   = PatternEngine::getInstance()->getBasePath();
		$filesystemLoaderClass   = $patternEngineBasePath."\Loaders\FilesystemLoader";
		
		$options                 = array();
		$options["templatePath"] = $styleguideKitPath.DIRECTORY_SEPARATOR."views";
		$options["partialsPath"] = $options["templatePath"].DIRECTORY_SEPARATOR."partials";
		
		self::$filesystemLoader  = new $filesystemLoaderClass($options);
		
		$stringLoaderClass       = $patternEngineBasePath."\Loaders\StringLoader";
		self::$stringLoader      = new $stringLoaderClass();
		
		// i can't remember why i chose to implement the pattern loader directly in classes
		// i figure i had a good reason which is why it's not showing up here
		
	}