/** * @inheritdoc */ public function initializeClasses(SymfonyRequest $symfonyRequest) { Utf8\Bootup::initAll(); // Enables the portability layer and configures PHP for UTF-8 Utf8\Bootup::filterRequestUri(); // Redirects to an UTF-8 encoded URL if it's not already the case Utf8\Bootup::filterRequestInputs(); // Normalizes HTTP inputs to UTF-8 NFC $file = $this->appPath->getCacheDir() . 'container.php'; $this->dumpContainer($symfonyRequest, $file); require_once $file; $this->container = new \ACP3ServiceContainer(); $this->container->set('core.environment.application_path', $this->appPath); $this->container->set('core.http.symfony_request', $symfonyRequest); }
/** * Application constructor. * * @param object $loader The autoloader instance. * @param array $config The custom configuration of the application. * @param string $appPath The application absolute path. * @param array $classesMap The custom classes map of the application. */ public function __construct($loader, array $config = [], $appPath = null, array $classesMap = []) { # Utilities $this->utilities = new Utilities($this); # Register start time $this->utilities->registerStartTime(); # Store application path $this->utilities->setApplicationPath($appPath); # Store classes map $this['class'] = $this->utilities->setClassesMap($classesMap); # Call container constructor parent::__construct($this->utilities->setConfiguration($config)); # Register core services providers $this->register(new FilesystemServiceProvider()); $this->register(new FinderServiceProvider()); $this->register(new HttpServiceProvider()); $this->register(new LoggerServiceProvider()); $this->register(new MessagesServiceProvider()); $this->register(new RouterServiceProvider()); $this->register(new SupportServiceProvider()); $this->register(new TemplatingServiceProvider()); $this->register(new TriggersServiceProvider()); # Enables the portablity layer and configures PHP for UTF-8 Utf8Bootup::initAll(); # Redirects to an UTF-8 encoded URL if it's not already the case Utf8Bootup::filterRequestUri(); # Normalizes HTTP inputs to UTF-8 NFC Utf8Bootup::filterRequestInputs(); # Print errors in debug mode if ($this['debug']) { $whoops = new WhoopsRun(); $whoops->pushHandler(new WhoopsHandler()); $whoops->register(); } else { ErrorHandler::register($this['phpLogger']); } # Only enable Kint in debug mode \Kint::enabled($this['debug']); }
* ---------------------------------------------------------------------------- */ use Concrete\Core\Application\Application; use Concrete\Core\Asset\AssetList; use Concrete\Core\File\Type\TypeList; use Concrete\Core\Foundation\ClassAliasList; use Concrete\Core\Foundation\Service\ProviderList; use Concrete\Core\Permission\Key\Key as PermissionKey; use Concrete\Core\Support\Facade\Facade; use Patchwork\Utf8\Bootup as PatchworkUTF8; /** * ---------------------------------------------------------------------------- * Handle text encoding. * ---------------------------------------------------------------------------- */ PatchworkUTF8::initAll(); /** * ---------------------------------------------------------------------------- * Instantiate concrete5. * ---------------------------------------------------------------------------- */ /** @var Application $cms */ $cms = (require DIR_APPLICATION . '/bootstrap/start.php'); $cms->instance('app', $cms); // Bind fully application qualified class names $cms->instance('Concrete\\Core\\Application\\Application', $cms); $cms->instance('Illuminate\\Container\\Container', $cms); /** * ---------------------------------------------------------------------------- * Bind the IOC container to our facades * Completely indebted to Taylor Otwell & Laravel for this.
/** * Check if the setlocal call does not work. This can happen if the right * local packages are not available on the server. * * @return bool */ public static function isSetLocaleWorking() { // setlocale test is pointless on Windows if (OC_Util::runningOnWindows()) { return true; } \Patchwork\Utf8\Bootup::initLocale(); if ('' === basename('§')) { return false; } return true; }
public static function init() { // calculate the root directories OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4)); // register autoloader $loaderStart = microtime(true); require_once __DIR__ . '/autoloader.php'; self::$loader = new \OC\Autoloader([OC::$SERVERROOT . '/lib', OC::$SERVERROOT . '/core', OC::$SERVERROOT . '/settings', OC::$SERVERROOT . '/ocs', OC::$SERVERROOT . '/ocs-provider', OC::$SERVERROOT . '/3rdparty']); spl_autoload_register(array(self::$loader, 'load')); $loaderEnd = microtime(true); self::$CLI = php_sapi_name() == 'cli'; try { self::initPaths(); // setup 3rdparty autoloader $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php'; if (!file_exists($vendorAutoLoad)) { throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".'); } require_once $vendorAutoLoad; } catch (\RuntimeException $e) { OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); // we can't use the template error page here, because this needs the // DI container which isn't available yet print $e->getMessage(); exit; } foreach (OC::$APPSROOTS as $appRoot) { self::$loader->addValidRoot($appRoot['path']); } // setup the basic server self::$server = new \OC\Server(\OC::$WEBROOT); \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); \OC::$server->getEventLogger()->start('boot', 'Initialize'); // Don't display errors and log them error_reporting(E_ALL | E_STRICT); @ini_set('display_errors', 0); @ini_set('log_errors', 1); date_default_timezone_set('UTC'); //try to configure php to enable big file uploads. //this doesn´t work always depending on the webserver and php configuration. //Let´s try to overwrite some defaults anyways //try to set the maximum execution time to 60min @set_time_limit(3600); @ini_set('max_execution_time', 3600); @ini_set('max_input_time', 3600); //try to set the maximum filesize to 10G @ini_set('upload_max_filesize', '10G'); @ini_set('post_max_size', '10G'); @ini_set('file_uploads', '50'); self::setRequiredIniValues(); self::handleAuthHeaders(); self::registerAutoloaderCache(); // initialize intl fallback is necessary \Patchwork\Utf8\Bootup::initIntl(); OC_Util::isSetLocaleWorking(); if (!defined('PHPUNIT_RUN')) { $logger = \OC::$server->getLogger(); OC\Log\ErrorHandler::setLogger($logger); if (\OC::$server->getConfig()->getSystemValue('debug', false)) { OC\Log\ErrorHandler::register(true); set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); } else { OC\Log\ErrorHandler::register(); } } // register the stream wrappers stream_wrapper_register('fakedir', 'OC\\Files\\Stream\\Dir'); stream_wrapper_register('static', 'OC\\Files\\Stream\\StaticStream'); stream_wrapper_register('close', 'OC\\Files\\Stream\\Close'); stream_wrapper_register('quota', 'OC\\Files\\Stream\\Quota'); stream_wrapper_register('oc', 'OC\\Files\\Stream\\OC'); \OC::$server->getEventLogger()->start('init_session', 'Initialize session'); OC_App::loadApps(array('session')); if (!self::$CLI) { self::initSession(); } \OC::$server->getEventLogger()->end('init_session'); self::initTemplateEngine(); self::checkConfig(); self::checkInstalled(); OC_Response::addSecurityHeaders(); if (self::$server->getRequest()->getServerProtocol() === 'https') { ini_set('session.cookie_secure', true); } if (!defined('OC_CONSOLE')) { $errors = OC_Util::checkServer(\OC::$server->getConfig()); if (count($errors) > 0) { if (self::$CLI) { // Convert l10n string into regular string for usage in database $staticErrors = []; foreach ($errors as $error) { echo $error['error'] . "\n"; echo $error['hint'] . "\n\n"; $staticErrors[] = ['error' => (string) $error['error'], 'hint' => (string) $error['hint']]; } try { \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); } catch (\Exception $e) { echo 'Writing to database failed'; } exit(1); } else { OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); OC_Template::printGuestPage('', 'error', array('errors' => $errors)); exit; } } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); } } //try to set the session lifetime $sessionLifeTime = self::getSessionLifeTime(); @ini_set('gc_maxlifetime', (string) $sessionLifeTime); $systemConfig = \OC::$server->getSystemConfig(); // User and Groups if (!$systemConfig->getValue("installed", false)) { self::$server->getSession()->set('user_id', ''); } OC_User::useBackend(new OC_User_Database()); OC_Group::useBackend(new OC_Group_Database()); //setup extra user backends if (!self::checkUpgrade(false)) { OC_User::setupBackends(); } self::registerCacheHooks(); self::registerFilesystemHooks(); if (\OC::$server->getSystemConfig()->getValue('enable_previews', true)) { self::registerPreviewHooks(); } self::registerShareHooks(); self::registerLogRotate(); self::registerLocalAddressBook(); self::registerEncryptionWrapper(); self::registerEncryptionHooks(); //make sure temporary files are cleaned up $tmpManager = \OC::$server->getTempManager(); register_shutdown_function(array($tmpManager, 'clean')); $lockProvider = \OC::$server->getLockingProvider(); register_shutdown_function(array($lockProvider, 'releaseAll')); if ($systemConfig->getValue('installed', false) && !self::checkUpgrade(false)) { if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { OC_Util::addScript('backgroundjobs'); } } // Check whether the sample configuration has been copied if ($systemConfig->getValue('copied_sample_config', false)) { $l = \OC::$server->getL10N('lib'); header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); OC_Template::printErrorPage($l->t('Sample configuration detected'), $l->t('It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php')); return; } $request = \OC::$server->getRequest(); $host = $request->getInsecureServerHost(); /** * if the host passed in headers isn't trusted * FIXME: Should not be in here at all :see_no_evil: */ if (!OC::$CLI && self::$server->getConfig()->getSystemValue('overwritehost') === '' && !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host) && self::$server->getConfig()->getSystemValue('installed', false)) { header('HTTP/1.1 400 Bad Request'); header('Status: 400 Bad Request'); $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); $tmpl->assign('domain', $request->server['SERVER_NAME']); $tmpl->printPage(); exit; } \OC::$server->getEventLogger()->end('boot'); }
// increase maximum execution time for php scripts // (does not work in safe mode) @set_time_limit(120); // include composer autoloader (if available) if (@file_exists(INSTALL_PATH . 'vendor/autoload.php')) { require INSTALL_PATH . 'vendor/autoload.php'; } // include Roundcube Framework require_once 'Roundcube/bootstrap.php'; // register autoloader for rcmail app classes spl_autoload_register('rcmail_autoload'); // backward compatybility (to be removed) require_once INSTALL_PATH . 'program/include/bc.php'; // load the UTF-8 portablity layer from Patchwor if (!function_exists('iconv') || !function_exists('utf8_encode') || !extension_loaded('mbstring')) { \Patchwork\Utf8\Bootup::initAll(); } /** * PHP5 autoloader routine for dynamic class loading */ function rcmail_autoload($classname) { if (strpos($classname, 'rcmail') === 0) { $filepath = INSTALL_PATH . "program/include/{$classname}.php"; if (is_readable($filepath)) { include_once $filepath; return true; } } return false; }
// Emulate PHP 5.4 feature that allows us to create/use an object without a temporary. // PHP 5.4: (new X)->y() // PHP 5.3: with(new X)->y() function with($x) { return $x; } // Use the patchwork/utf8 library to: // 1) set all PHP defaults to UTF-8 // 2) create shims for missing mb_string functions such as mb_strlen() // 3) check that requests are valid UTF-8 \Patchwork\Utf8\Bootup::initAll(); // Enables the portablity layer and configures PHP for UTF-8 \Patchwork\Utf8\Bootup::filterRequestUri(); // Redirects to an UTF-8 encoded URL if it's not already the case \Patchwork\Utf8\Bootup::filterRequestInputs(); // Normalizes HTTP inputs to UTF-8 NFC // Use the fisharebest/ext-calendar library to // 1) provide shims for the PHP ext/calendar extension, such as JewishToJD() // 2) provide calendar conversions for the Arabic and Persian calendars \Fisharebest\ExtCalendar\Shim::create(); // Split the request protocol://host:port/path/to/script.php?var=value into parts // WT_SERVER_NAME = protocol://host:port // WT_SCRIPT_PATH = /path/to/ (begins and ends with /) // WT_SCRIPT_NAME = script.php (already defined in the calling script) $https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'; define('WT_SERVER_NAME', ($https ? 'https://' : 'http://') . (empty($_SERVER['SERVER_NAME']) ? '' : $_SERVER['SERVER_NAME']) . (empty($_SERVER['SERVER_PORT']) || !$https && $_SERVER['SERVER_PORT'] == 80 || $https && $_SERVER['SERVER_PORT'] == 443 ? '' : ':' . $_SERVER['SERVER_PORT'])); // REDIRECT_URL should be set in the case of Apache following a RedirectRule // SCRIPT_NAME should always be correct, but is not always present. // PHP_SELF should always be present, but may have trailing path: /path/to/script.php/FOO/BAR if (!empty($_SERVER['REDIRECT_URL'])) {
public static function init() { // register autoloader $loaderStart = microtime(true); require_once __DIR__ . '/autoloader.php'; self::$loader = new \OC\Autoloader(); spl_autoload_register(array(self::$loader, 'load')); $loaderEnd = microtime(true); self::initPaths(); // setup 3rdparty autoloader $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php'; if (file_exists($vendorAutoLoad)) { require_once $vendorAutoLoad; } else { OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); // we can't use the template error page here, because this needs the // DI container which isn't available yet print('Composer autoloader not found, unable to continue. Check the folder "3rdparty".'); exit(); } // setup the basic server self::$server = new \OC\Server(\OC::$WEBROOT); \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); \OC::$server->getEventLogger()->start('boot', 'Initialize'); // set some stuff //ob_start(); error_reporting(E_ALL | E_STRICT); if (defined('DEBUG') && DEBUG) { ini_set('display_errors', 1); } self::$CLI = (php_sapi_name() == 'cli'); date_default_timezone_set('UTC'); ini_set('arg_separator.output', '&'); //try to configure php to enable big file uploads. //this doesn´t work always depending on the webserver and php configuration. //Let´s try to overwrite some defaults anyways //try to set the maximum execution time to 60min @set_time_limit(3600); @ini_set('max_execution_time', 3600); @ini_set('max_input_time', 3600); //try to set the maximum filesize to 10G @ini_set('upload_max_filesize', '10G'); @ini_set('post_max_size', '10G'); @ini_set('file_uploads', '50'); self::handleAuthHeaders(); self::registerAutoloaderCache(); // initialize intl fallback is necessary \Patchwork\Utf8\Bootup::initIntl(); OC_Util::isSetLocaleWorking(); if (!defined('PHPUNIT_RUN')) { OC\Log\ErrorHandler::setLogger(OC_Log::$object); if (defined('DEBUG') and DEBUG) { OC\Log\ErrorHandler::register(true); set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); } else { OC\Log\ErrorHandler::register(); } } // register the stream wrappers stream_wrapper_register('fakedir', 'OC\Files\Stream\Dir'); stream_wrapper_register('static', 'OC\Files\Stream\StaticStream'); stream_wrapper_register('close', 'OC\Files\Stream\Close'); stream_wrapper_register('quota', 'OC\Files\Stream\Quota'); stream_wrapper_register('oc', 'OC\Files\Stream\OC'); \OC::$server->getEventLogger()->start('init_session', 'Initialize session'); OC_App::loadApps(array('session')); if (!self::$CLI) { self::initSession(); } \OC::$server->getEventLogger()->end('init_session'); self::initTemplateEngine(); self::checkConfig(); self::checkInstalled(); self::checkSSL(); OC_Response::addSecurityHeaders(); $errors = OC_Util::checkServer(\OC::$server->getConfig()); if (count($errors) > 0) { if (self::$CLI) { foreach ($errors as $error) { echo $error['error'] . "\n"; echo $error['hint'] . "\n\n"; } } else { OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); OC_Template::printGuestPage('', 'error', array('errors' => $errors)); } exit; } //try to set the session lifetime $sessionLifeTime = self::getSessionLifeTime(); @ini_set('gc_maxlifetime', (string)$sessionLifeTime); $systemConfig = \OC::$server->getSystemConfig(); // User and Groups if (!$systemConfig->getValue("installed", false)) { self::$server->getSession()->set('user_id', ''); } OC_User::useBackend(new OC_User_Database()); OC_Group::useBackend(new OC_Group_Database()); //setup extra user backends if (!self::checkUpgrade(false)) { OC_User::setupBackends(); } self::registerCacheHooks(); self::registerFilesystemHooks(); self::registerPreviewHooks(); self::registerShareHooks(); self::registerLogRotate(); self::registerLocalAddressBook(); //make sure temporary files are cleaned up $tmpManager = \OC::$server->getTempManager(); register_shutdown_function(array($tmpManager, 'clean')); if ($systemConfig->getValue('installed', false) && !self::checkUpgrade(false)) { if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { OC_Util::addScript('backgroundjobs'); } } // Check whether the sample configuration has been copied if($systemConfig->getValue('copied_sample_config', false)) { $l = \OC::$server->getL10N('lib'); header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); OC_Template::printErrorPage( $l->t('Sample configuration detected'), $l->t('It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php') ); return; } $host = OC_Request::insecureServerHost(); // if the host passed in headers isn't trusted if (!OC::$CLI // overwritehost is always trusted && OC_Request::getOverwriteHost() === null && !OC_Request::isTrustedDomain($host) ) { header('HTTP/1.1 400 Bad Request'); header('Status: 400 Bad Request'); $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); $tmpl->assign('domain', $_SERVER['SERVER_NAME']); $tmpl->printPage(); exit(); } \OC::$server->getEventLogger()->end('boot'); }
<?php //------------------------------------------------------------------------------------- // autoloading //------------------------------------------------------------------------------------- require_once __DIR__ . '/vendor/autoload.php'; //------------------------------------------------------------------------------------- // initializing components //------------------------------------------------------------------------------------- \Patchwork\Utf8\Bootup::initMbstring(); //------------------------------------------------------------------------------------- // determining environment //------------------------------------------------------------------------------------- $host = gethostname(); $envs = (require_once __DIR__ . '/environment.php'); $env = in_array($host, $envs['production']) ? 'production' : in_array($host, $envs['staging']) ? 'staging' : 'development'; $mod = getenv('OITO_MODULE') ?: 'frontend'; $dir = __DIR__; //------------------------------------------------------------------------------------- // php configuration //------------------------------------------------------------------------------------- date_default_timezone_set('UTC'); ini_set('error_reporting', E_ALL); ini_set('display_errors', (int) ($env === 'development')); //------------------------------------------------------------------------------------- // include the config based on the environment //------------------------------------------------------------------------------------- $config1 = (require_once __DIR__ . '/config/production.php'); $config2 = $env !== 'production' ? require_once sprintf('%s/config/%s.php', __DIR__, $env) : []; $config3 = sprintf('%s/module/%s/config/%s.php', __DIR__, $mod, $env); $config = Zend\Stdlib\ArrayUtils::merge($config1, $config2);
*/ $list = new ProviderList($cms); $list->registerProviders($config->get('app.providers')); /** * ---------------------------------------------------------------------------- * Setup file cache directories. Has to come after we define services * because we use the file service. * ---------------------------------------------------------------------------- */ $cms->setupFilesystem(); /** * ---------------------------------------------------------------------------- * Handle text encoding. * ---------------------------------------------------------------------------- */ Bootup::initAll(); /** * ---------------------------------------------------------------------------- * Registries for theme paths, assets, routes and file types. * ---------------------------------------------------------------------------- */ $asset_list = AssetList::getInstance(); $asset_list->registerMultiple($config->get('app.assets', array())); $asset_list->registerGroupMultiple($config->get('app.asset_groups', array())); Route::registerMultiple($config->get('app.routes')); Route::setThemesByRoutes($config->get('app.theme_paths', array())); $type_list = TypeList::getInstance(); $type_list->defineMultiple($config->get('app.file_types', array())); $type_list->defineImporterAttributeMultiple($config->get('app.importer_attributes', array())); /** * ----------------------------------------------------------------------------
if (@file_exists(INSTALL_PATH . 'vendor/autoload.php')) { require INSTALL_PATH . 'vendor/autoload.php'; } // include Roundcube Framework require_once 'Roundcube/bootstrap.php'; // register autoloader for rcmail app classes spl_autoload_register('rcmail_autoload'); // backward compatybility (to be removed) require_once INSTALL_PATH . 'program/include/bc.php'; // load the UTF-8 portability layers from Patchwork // don't load mbstring layer as it conflicts with Roundcube Framework (#1490280) if (!function_exists('iconv')) { \Patchwork\Utf8\Bootup::initIconv(); } if (!function_exists('utf8_encode')) { \Patchwork\Utf8\Bootup::initUtf8Encode(); } /** * PHP5 autoloader routine for dynamic class loading */ function rcmail_autoload($classname) { if (strpos($classname, 'rcmail') === 0) { $filepath = INSTALL_PATH . "program/include/{$classname}.php"; if (is_readable($filepath)) { include_once $filepath; return true; } } return false; }
/** * {@inheritdoc} */ public function boot() { Bootup::initAll(); $this->container->addScope(new Scope(self::SCOPE_BACKEND, 'request')); $this->container->addScope(new Scope(self::SCOPE_FRONTEND, 'request')); }
/** * {@inheritdoc} */ public function boot() { Bootup::initAll(); }