public static function init() { if (!static::$initialized) { $sessionTimeLimit = 20 * 60; session_set_cookie_params($sessionTimeLimit); session_start(); // Verify if session already is valid $keyDiscardTime = '___discard_after___'; $now = time(); if (isset($_SESSION[$keyDiscardTime]) && $now > $_SESSION[$keyDiscardTime]) { // this session has worn out its welcome; kill it and start a brand new one session_unset(); session_destroy(); session_start(); } // either new or old, it should live at most for another hour $_SESSION[$keyDiscardTime] = $now + $sessionTimeLimit; static::$initialized = true; //Clear all old flash data foreach ($_SESSION as $k => $v) { if (Str::contains($k, ":old:")) { static::clear($k); } } //Set all new flash data as old, to be cleared on the next request foreach ($_SESSION as $k => $v) { $parts = explode(":new:", $k); if (is_array($parts) && count($parts) == 2) { $newKey = "flash:old:" . $parts[1]; static::set($newKey, $v); static::clear($k); } } } }
/** * Define internal static values. * @codeCoverageIgnore */ public static function initialize() { if (!static::$initialized) { static::$initialized = true; static::$placeholder = new \stdClass(); } }
/** * Init * * Loads in the config and sets the variables * * @access public * @return void */ public static function _init() { // Prevent multiple initializations if (static::$initialized) { return; } \Config::load('asset', true); $paths = \Config::get('asset.paths'); foreach($paths as $path) { static::add_path($path); } static::$_asset_url = \Config::get('asset.url'); static::$_folders = array( 'css' => \Config::get('asset.css_dir'), 'js' => \Config::get('asset.js_dir'), 'img' => \Config::get('asset.img_dir') ); static::$initialized = true; }
/** * Initialization function. * Here a config array must be passed with the client configuration * Sensible values are set by default, but further configuration could also * be set. * * A list of required fields is also set (with no default value set) */ public static function init($config = array()) { $default = array('base_url' => '{scheme}://{hostname}:{port}/api/{version}/{client_endpoint}', 'scheme' => 'http', 'hostname' => 'localhost', 'port' => 9292, 'version' => 'v1', 'includes_json_root' => true, 'json_root' => 'subject'); $required = array('client_endpoint', 'subclient_endpoint'); $config = Collection::fromConfig($config, $default, $required); static::$client = new Client($config->get('base_url'), $config); static::$initialized = true; }
/** * setup the wordpress environment / stack if the context is a wordpress context * * @param Context $context */ public function initializeContext(Context $context) { if (static::$initialized) { return; } static::$initialized = true; $this->prepareEnvironment(); $this->loadStack(); }
protected static function initialize() { if (static::$initialized) { return; } static::$initialized = true; static::start(); static::setCsrfToken(); }
public static function init() { if (static::$initialized) { return; } static::$profiler = new PhpQuickProfiler(FUEL_START_TIME); static::$profiler->queries = array(); static::$profiler->queryCount = 0; static::$initialized = true; }
public static function Init() { if (static::$initialized) { return; } self::$headers = array(); self::$status = self::STATUS_200; self::$headers[static::HEADER_CONTENT_TYPE] = Mimes::getExtension('html'); self::$autoHeaders = true; static::$initialized = true; }
protected function initialize() { if (\Staq::App() && \Staq::App()->isInitialized()) { static::$cacheFile = reset($this->extensions) . '/cache/autoload.php'; if (\is_file(static::$cacheFile)) { require_once static::$cacheFile; } static::$initialized = TRUE; } return $this; }
/** * Initializes properties. * * @return boolean Returns the `$initialized` property w/ a TRUE value. * * @note Sets some class properties & registers class alias. */ public static final function initialize() { if (static::$initialized) { return TRUE; } // Initialized already. if (!class_exists(stub::$core_ns_stub . '__instance')) { class_alias(__CLASS__, stub::$core_ns_stub . '__instance'); } return static::$initialized = TRUE; }
public static function configure() { if (static::$initialized === false) { // loop over all settings and set them foreach (static::$initSettings as $key => $value) { ini_set("xdebug.{$key}", $value); } } // set initialized status flag static::$initialized = true; }
protected static function Init() { if (static::$initialized) { return; } if (preg_match("#local\$#", $_SERVER['SERVER_NAME'])) { static::$current = static::DEV; } else { static::$current = static::PROD; } static::$initialized = true; }
protected static function initialize() { if (static::$initialized) { return; } static::$initialized = true; static::$parentPath = __FILE__; for ($i = substr_count(get_class(), static::$nsChar); $i >= 0; $i--) { static::$parentPath = dirname(static::$parentPath); } static::$paths = array(); static::$files = array(__FILE__); }
/** * Sets the initial Ftp filename and local data. * * @param array The settings * @return void */ public function __construct(array $config) { // Prep the hostname $this->_hostname = preg_replace('|.+?://|', '', $config['hostname']); $this->_username = $config['username']; $this->_password = $config['password']; $this->_timeout = isset($config['timeout']) ? (int) $config['timeout'] : $this->_timeout; $this->_port = isset($config['port']) ? (int) $config['port'] : $this->_port; $this->_passive = isset($config['passive']) ? (bool) $config['passive'] : $this->_passive; $this->_ssl = isset($config['ssl']) ? (bool) $config['ssl'] : $this->_ssl; $this->_debug = isset($config['debug']) ? (bool) $config['debug'] : $this->_debug; static::$initialized = true; }
protected function initialize() { if ($path = \Staq::App()->getPath('cache/', TRUE)) { static::$cacheFile = $path . '/setting.' . \Staq::App()->getPlatform() . '.php'; if (is_file(static::$cacheFile) && is_readable(static::$cacheFile)) { @(include static::$cacheFile); if (isset($cache) && is_array($cache)) { static::$cache = $cache; } } } static::$initialized = TRUE; return $this; }
/** * Static constructor. Parses all the CLI params. */ public static function _init() { if (static::$initialized === true) { return; } if (!(PHP_SAPI === 'cli' || defined('STDIN'))) { throw new \Exception('Cli class cannot be used outside of the command line.'); } self::parseCommand(); // Readline is an extension for PHP that makes interactive with PHP much more bash-like // http://www.php.net/manual/en/readline.installation.php static::$readline_support = extension_loaded('readline'); static::$initialized = true; }
protected static function initialize() { if (static::$initialized) { return; } static::$initialized = true; static::$method = $_SERVER['REQUEST_METHOD']; static::$request = $_SERVER['REQUEST_URI']; static::$script = $_SERVER['SCRIPT_NAME']; static::$original = null; static::$redirect = null; static::applyRoutes(); static::route(); }
public static function init() { if (false == static::$initialized) { /** @var ResponseInterface $response */ $response = Di::getInstance()->getShared('system.router')->loadController()->run(); list($file, $data) = $response->getTemplate(); if (isset($file) && is_file($file)) { /** @var TemplateInterface $template */ $template = Di::getInstance()->getShared('system.template'); $template->load($file); $template->render($data); } static::$initialized = true; } }
/** * Create new session. * * @return void */ public function __construct() { // Does the session need to be initialized? if (!static::$initialized) { // Get the driver name from the application config and get the // class name for us to instantiate. $driver = 'native'; $class = 'Spire\\Session\\Driver\\' . ucfirst(strtolower($driver)); // Instantiate driver. static::$driver = new $class(); // Initialize the session. if (static::driver()->initialize()) { static::$initialized = true; } } }
/** * Initialize the framework */ protected static function initialize() { // some handy constants defined('DS') or define('DS', DIRECTORY_SEPARATOR); defined('CRLF') or define('CRLF', chr(13) . chr(10)); // do we have access to mbstring? We need this in order to work with UTF-8 strings defined('MBSTRING') or define('MBSTRING', function_exists('mb_get_info')); // get the Dependency Container instance $container = static::getContainer(); // setup the autoloader if none was set yet if (!$container->isInstance('autoloader')) { // fetch the composer autoloader instance $loader = (require VENDORPATH . 'autoload.php'); // allow the framework to access the composer autoloader $container->add('autoloader', $loader); } // setup the errorhandler if none was set yet if (!$container->isInstance('errorhandler')) { $container->add('errorhandler', new Error()); } $autoloader = $container->get('autoloader'); // get all defined namespaces $prefixes = array_merge($autoloader->getPrefixes(), $autoloader->getPrefixesPsr4()); // determine the installation root if needed // TODO: find a better way to do that if (!defined('ROOTPATH')) { $path = reset($prefixes['Fuel\\Foundation\\']); if ($path = realpath(substr($path, 0, strpos($path, '/fuelphp/foundation')) . DS . '..' . DS)) { define('ROOTPATH', $path . DS); } } $fuelNamespaces = array_filter(array_keys($prefixes), function ($key) { return substr($key, 0, 5) === 'Fuel\\'; }); $nonFuelNamespaces = array_diff(array_keys($prefixes), $fuelNamespaces); // scan all fuel packages loaded for the presence of FuelServiceProviders static::loadServiceProviders($fuelNamespaces); // scan the rest of composer packages loaded for the presence of FuelServiceProviders static::loadServiceProviders($nonFuelNamespaces); // scan all fuel packages loaded for the presence of FuelLibraryProviders static::loadLibraryProviders(array_intersect_key($prefixes, array_flip($fuelNamespaces))); // scan the rest of composer packages loaded for the presence of FuelLibraryProviders static::loadLibraryProviders(array_intersect_key($prefixes, array_flip($nonFuelNamespaces))); // mark we're initialized static::$initialized = true; }
/** * @param $user Ionize\User */ public static function initialize($user) { log_message('debug', "Authority Class Initialized"); static::$initialized = TRUE; self::$ci =& get_instance(); self::$ci->load->library('session'); self::$session =& self::$ci->session; Event::register('User.logout', array(__CLASS__, 'on_logout')); Event::register('User.login', array(__CLASS__, 'on_login')); if ($user->logged_in()) { // Super Admin shortcut : Will never depend on DB. if ($user->is('super-admin')) { Authority::allow('manage', 'all'); } else { // Set Rules from DB or session self::set_rules($user); } } }
protected static function initialize() { if (static::$initialized) { return; } static::$initialized = true; if (!static::$enabled) { error_reporting(0); return; } error_reporting(-1); static::$request = array('log' => array(), 'queries' => array(), 'api_calls' => array(), 'session' => array(), 'cache' => array()); Session::start(); $_SESSION[static::$sessionKey][] =& static::$request; while (count($_SESSION[static::$sessionKey]) > static::$history) { array_shift($_SESSION[static::$sessionKey]); } static::set('start', microtime(true)); static::set('user', get_current_user()); register_shutdown_function('Debugger::end', 'abort'); }
/** * Sets the initial Ftp filename and local data. * * @param string Ftp filename * @param array array of values * @return void */ public function __construct($config = 'default') { \Config::load('ftp', true); // If it is a string we're looking at a predefined config group if (is_string($config)) { $config_arr = \Config::get('ftp.' . $config); // Check that it exists if (!is_array($config_arr) or $config_arr === array()) { throw new \Fuel_Exception('You have specified an invalid ftp connection group: ' . $config); } $config = $config_arr; } // Prep the hostname $this->_hostname = preg_replace('|.+?://|', '', $config['hostname']); $this->_username = $config['username']; $this->_password = $config['password']; $this->_port = !empty($config['port']) ? (int) $config['port'] : 21; $this->_passive = (bool) $config['passive']; $this->_ssl_mode = (bool) $config['ssl_mode']; $this->_debug = (bool) $config['debug']; static::$initialized = true; }
/** * Initialize the session handler and session itself * * @throws Exception */ private static function init() { if (!static::$initialized) { static::$initialized = true; $config = Application::getConfig('session'); if ($config === null) { throw new Exception('Missing config file for sessions'); } session_set_cookie_params($config['cookie_life'], $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); session_name($config['session_name']); if (isset($config['driver'])) { if (in_array($config['driver'], array('\\Koldy\\Session\\Driver\\File', '\\Koldy\\Session\\Driver\\Db')) && PHP_VERSION_ID < 50400) { throw new Exception('PHP 5.4 or greater is reqired to use this session driver: ' . $config['driver']); } $driverClass = $config['driver']; $handler = new $driverClass(isset($config['options']) ? $config['options'] : array()); if (!$handler instanceof \SessionHandlerInterface) { throw new Exception('Your session driver doesn\'t implement the \\SessionHandlerInterface'); } session_set_save_handler($handler); } session_start(); } }
/** * Loads route configuration * * @return void */ protected static function _loadRoutes() { static::$initialized = true; include CONFIG . 'routes.php'; }
public static function init() { static::$initialized = true; static::$ip = static::getIpAddress(); }
/** * Loads in the config and sets the variables */ public static function _init() { // Prevent multiple initializations if (static::$initialized) { return; } \Config::load('casset', true); $paths = \Config::get('casset.paths', static::$asset_paths); foreach ($paths as $key => $path) { static::add_path($key, $path); } static::$asset_url = \Config::get('casset.url', \Config::get('base_url')); static::$default_folders = array('css' => \Config::get('casset.css_dir', static::$default_folders['css']), 'js' => \Config::get('casset.js_dir', static::$default_folders['js']), 'img' => \Config::get('casset.img_dir', static::$default_folders['img'])); static::$cache_path = \Config::get('casset.cache_path', static::$cache_path); static::$min_default = \Config::get('casset.min', static::$min_default); static::$combine_default = \Config::get('casset.combine', static::$combine_default); $group_sets = \Config::get('casset.groups', array()); foreach ($group_sets as $group_type => $groups) { foreach ($groups as $group_name => $group) { $enabled = array_key_exists('enabled', $group) ? $group['enabled'] : true; $combine = array_key_exists('combine', $group) ? $group['combine'] : null; $min = array_key_exists('min', $group) ? $group['min'] : null; static::add_group($group_type, $group_name, $enabled, $combine, $min); foreach ($group['files'] as $files) { if (!is_array($files)) { $files = array($files, false); } static::add_asset($group_type, $files[0], $files[1], $group_name); } } } static::$show_files = \Config::get('casset.show_files', static::$show_files); static::$show_files_inline = \Config::get('casset.show_files_inline', static::$show_files_inline); static::$initialized = true; }
/** * Initializes the XDaRk Core autoloader. * * @return boolean Returns the `$initialized` property w/ a TRUE value. * * @note This also registers the XDaRk Core autoload handler. */ public static function initialize() { if (static::$initialized) { return TRUE; } // Initialized already. $core_ns_classes_dir = stub::n_dir_seps_up(__FILE__); static::$core_classes_dir = stub::n_dir_seps_up($core_ns_classes_dir); $core_dir = stub::n_dir_seps_up(static::$core_classes_dir); static::add_special_class(stub::$core_ns, $core_dir . '/stub.php'); static::add_special_class(stub::$core_ns_stub . '__stub', $core_dir . '/stub.php'); static::add_special_class('deps_' . stub::$core_ns, $core_ns_classes_dir . '/deps.php'); static::add_special_class(stub::$core_ns_stub . '__deps', $core_ns_classes_dir . '/deps.php'); static::add_special_class('deps_x_' . stub::$core_ns, $core_ns_classes_dir . '/deps-x.php'); static::add_special_class(stub::$core_ns_stub . '__deps_x', $core_ns_classes_dir . '/deps-x.php'); static::add_special_class(stub::$core_ns . '\\stub', $core_ns_classes_dir . '/framework.php'); static::add_special_class(stub::$core_ns . '\\deps', $core_ns_classes_dir . '/framework.php'); static::add_special_class(stub::$core_ns . '\\core', $core_ns_classes_dir . '/framework.php'); static::add_special_class(stub::$core_ns . '\\fw_constants', $core_ns_classes_dir . '/framework.php'); static::add_special_class(stub::$core_ns . '\\instance', $core_ns_classes_dir . '/framework.php'); static::add_special_class(stub::$core_ns . '\\exception_handler', $core_ns_classes_dir . '/framework.php'); static::add_special_class(stub::$core_ns_stub, $core_ns_classes_dir . '/framework.php'); static::add_classes_dir(static::$core_classes_dir); spl_autoload_register('\\' . __CLASS__ . '::load_ns_class'); if (!class_exists(stub::$core_ns_stub . '__autoloader')) { class_alias(__CLASS__, stub::$core_ns_stub . '__autoloader'); } return static::$initialized = TRUE; }
/** * Initializes the framework. * This can only be called once. * * @access public * @return void */ public static function init($config) { if (static::$initialized) { throw new \FuelException("You can't initialize Fuel more than once."); } // BC FIX FOR APPLICATIONS <= 1.6.1, makes Redis_Db available as Redis, // like it was in versions before 1.7 class_exists('Redis', false) or class_alias('Redis_Db', 'Redis'); static::$_paths = array(APPPATH, COREPATH); // Is Fuel running on the command line? static::$is_cli = (bool) defined('STDIN'); \Config::load($config); // Start up output buffering static::$is_cli or ob_start(\Config::get('ob_callback', null)); if (\Config::get('caching', false)) { \Finder::instance()->read_cache('FuelFileFinder'); } static::$profiling = \Config::get('profiling', false); static::$profiling and \Profiler::init(); // set a default timezone if one is defined try { static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get(); date_default_timezone_set(static::$timezone); } catch (\Exception $e) { date_default_timezone_set('UTC'); throw new \PHPErrorException($e->getMessage()); } static::$encoding = \Config::get('encoding', static::$encoding); MBSTRING and mb_internal_encoding(static::$encoding); static::$locale = \Config::get('locale', static::$locale); if (!static::$is_cli) { if (\Config::get('base_url') === null) { \Config::set('base_url', static::generate_base_url()); } } // Run Input Filtering \Security::clean_input(); \Event::register('fuel-shutdown', 'Fuel::finish'); // Always load classes, config & language set in always_load.php config static::always_load(); // Load in the routes \Config::load('routes', true); \Router::add(\Config::get('routes')); // Set locale, log warning when it fails if (static::$locale) { setlocale(LC_ALL, static::$locale) or logger(\Fuel::L_WARNING, 'The configured locale ' . static::$locale . ' is not installed on your system.', __METHOD__); } static::$initialized = true; // fire any app created events \Event::instance()->has_events('app_created') and \Event::instance()->trigger('app_created', '', 'none'); if (static::$profiling) { \Profiler::mark(__METHOD__ . ' End'); } }
/** * Loads route configuration * * @return void */ protected static function _loadRoutes() { static::$initialized = true; include APP . 'Config' . DS . 'routes.php'; }