/** * check if the current server configuration is suitable for ownCloud * * @param \OCP\IConfig $config * @return array arrays with error messages and hints */ public static function checkServer(\OCP\IConfig $config) { $l = \OC::$server->getL10N('lib'); $errors = array(); $CONFIG_DATADIRECTORY = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data'); if (!self::needUpgrade($config) && $config->getSystemValue('installed', false)) { // this check needs to be done every time $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); } // Assume that if checkServer() succeeded before in this session, then all is fine. if (\OC::$server->getSession()->exists('checkServer_succeeded') && \OC::$server->getSession()->get('checkServer_succeeded')) { return $errors; } $webServerRestart = false; $setup = new OC_Setup($config); $availableDatabases = $setup->getSupportedDatabases(); if (empty($availableDatabases)) { $errors[] = array( 'error' => $l->t('No database drivers (sqlite, mysql, or postgresql) installed.'), 'hint' => '' //TODO: sane hint ); $webServerRestart = true; } //common hint for all file permissions error messages $permissionsHint = $l->t('Permissions can usually be fixed by ' . '%sgiving the webserver write access to the root directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')); // Check if config folder is writable. if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { $errors[] = array( 'error' => $l->t('Cannot write into "config" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the config directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')) ); } // Check if there is a writable install folder. if ($config->getSystemValue('appstoreenabled', true)) { if (OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath()) ) { $errors[] = array( 'error' => $l->t('Cannot write into "apps" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the apps directory%s' . ' or disabling the appstore in the config file.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')) ); } } // Create root dir. if ($config->getSystemValue('installed', false)) { if (!is_dir($CONFIG_DATADIRECTORY)) { $success = @mkdir($CONFIG_DATADIRECTORY); if ($success) { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } else { $errors[] = array( 'error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)), 'hint' => $l->t('This can usually be fixed by ' . '<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.', array(OC_Helper::linkToDocs('admin-dir_permissions'))) ); } } else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { $errors[] = array( 'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud', 'hint' => $permissionsHint ); } else { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } } if (!OC_Util::isSetLocaleWorking()) { $errors[] = array( 'error' => $l->t('Setting locale to %s failed', array('en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/' . 'pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8')), 'hint' => $l->t('Please install one of these locales on your system and restart your webserver.') ); } // Contains the dependencies that should be checked against // classes = class_exists // functions = function_exists // defined = defined // If the dependency is not found the missing module name is shown to the EndUser $dependencies = array( 'classes' => array( 'ZipArchive' => 'zip', 'DOMDocument' => 'dom', 'XMLWriter' => 'XMLWriter' ), 'functions' => array( 'xml_parser_create' => 'libxml', 'mb_detect_encoding' => 'mb multibyte', 'ctype_digit' => 'ctype', 'json_encode' => 'JSON', 'gd_info' => 'GD', 'gzencode' => 'zlib', 'iconv' => 'iconv', 'simplexml_load_string' => 'SimpleXML', 'hash' => 'HASH Message Digest Framework' ), 'defined' => array( 'PDO::ATTR_DRIVER_NAME' => 'PDO' ) ); $missingDependencies = array(); $moduleHint = $l->t('Please ask your server administrator to install the module.'); foreach ($dependencies['classes'] as $class => $module) { if (!class_exists($class)) { $missingDependencies[] = $module; } } foreach ($dependencies['functions'] as $function => $module) { if (!function_exists($function)) { $missingDependencies[] = $module; } } foreach ($dependencies['defined'] as $defined => $module) { if (!defined($defined)) { $missingDependencies[] = $module; } } foreach($missingDependencies as $missingDependency) { $errors[] = array( 'error' => $l->t('PHP module %s not installed.', array($missingDependency)), 'hint' => $moduleHint ); $webServerRestart = true; } if (version_compare(phpversion(), '5.4.0', '<')) { $errors[] = array( 'error' => $l->t('PHP %s or higher is required.', '5.4.0'), 'hint' => $l->t('Please ask your server administrator to update PHP to the latest version.' . ' Your PHP version is no longer supported by ownCloud and the PHP community.') ); $webServerRestart = true; } /** * PHP 5.6 ships with a PHP setting which throws notices by default for a * lot of endpoints. Thus we need to ensure that the value is set to -1 * * FIXME: Due to https://github.com/owncloud/core/pull/13593#issuecomment-71178078 * this check is disabled for HHVM at the moment. This should get re-evaluated * at a later point. * * @link https://github.com/owncloud/core/issues/13592 */ if(version_compare(phpversion(), '5.6.0', '>=') && !self::runningOnHhvm() && \OC::$server->getIniWrapper()->getNumeric('always_populate_raw_post_data') !== -1) { $errors[] = array( 'error' => $l->t('PHP is configured to populate raw post data. Since PHP 5.6 this will lead to PHP throwing notices for perfectly valid code.'), 'hint' => $l->t('To fix this issue set <code>always_populate_raw_post_data</code> to <code>-1</code> in your php.ini') ); } if (!self::isAnnotationsWorking()) { $errors[] = array( 'error' => $l->t('PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible.'), 'hint' => $l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.') ); } if ($webServerRestart) { $errors[] = array( 'error' => $l->t('PHP modules have been installed, but they are still listed as missing?'), 'hint' => $l->t('Please ask your server administrator to restart the web server.') ); } $errors = array_merge($errors, self::checkDatabaseVersion()); // Cache the result of this function \OC::$server->getSession()->set('checkServer_succeeded', count($errors) == 0); return $errors; }
/** * check if the current server configuration is suitable for ownCloud * * @return array arrays with error messages and hints */ public static function checkServer() { $l = \OC::$server->getL10N('lib'); $errors = array(); $CONFIG_DATADIRECTORY = OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data'); if (!self::needUpgrade() && OC_Config::getValue('installed', false)) { // this check needs to be done every time $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); } // Assume that if checkServer() succeeded before in this session, then all is fine. if (\OC::$server->getSession()->exists('checkServer_succeeded') && \OC::$server->getSession()->get('checkServer_succeeded')) { return $errors; } $webServerRestart = false; //check for database drivers if (!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect') and !is_callable('oci_connect')) { $errors[] = array('error' => $l->t('No database drivers (sqlite, mysql, or postgresql) installed.'), 'hint' => ''); $webServerRestart = true; } //common hint for all file permissions error messages $permissionsHint = $l->t('Permissions can usually be fixed by ' . '%sgiving the webserver write access to the root directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')); // Check if config folder is writable. if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { $errors[] = array('error' => $l->t('Cannot write into "config" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the config directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'))); } // Check if there is a writable install folder. if (OC_Config::getValue('appstoreenabled', true)) { if (OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath())) { $errors[] = array('error' => $l->t('Cannot write into "apps" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the apps directory%s' . ' or disabling the appstore in the config file.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'))); } } // Create root dir. if (!is_dir($CONFIG_DATADIRECTORY)) { $success = @mkdir($CONFIG_DATADIRECTORY); if ($success) { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } else { $errors[] = array('error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)), 'hint' => $l->t('This can usually be fixed by ' . '<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.', array(OC_Helper::linkToDocs('admin-dir_permissions')))); } } else { if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud', 'hint' => $permissionsHint); } else { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } } if (!OC_Util::isSetLocaleWorking()) { $errors[] = array('error' => $l->t('Setting locale to %s failed', array('en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/' . 'pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8')), 'hint' => $l->t('Please install one of these locales on your system and restart your webserver.')); } // Contains the dependencies that should be checked against // classes = class_exists // functions = function_exists // defined = defined // If the dependency is not found the missing module name is shown to the EndUser $dependencies = array('classes' => array('ZipArchive' => 'zip', 'DOMDocument' => 'dom'), 'functions' => array('xml_parser_create' => 'libxml', 'mb_detect_encoding' => 'mb multibyte', 'ctype_digit' => 'ctype', 'json_encode' => 'JSON', 'gd_info' => 'GD', 'gzencode' => 'zlib', 'iconv' => 'iconv', 'simplexml_load_string' => 'SimpleXML'), 'defined' => array('PDO::ATTR_DRIVER_NAME' => 'PDO')); $missingDependencies = array(); $moduleHint = $l->t('Please ask your server administrator to install the module.'); foreach ($dependencies['classes'] as $class => $module) { if (!class_exists($class)) { $missingDependencies[] = $module; } } foreach ($dependencies['functions'] as $function => $module) { if (!function_exists($function)) { $missingDependencies[] = $module; } } foreach ($dependencies['defined'] as $defined => $module) { if (!defined($defined)) { $missingDependencies[] = $module; } } foreach ($missingDependencies as $missingDependency) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array($missingDependency)), 'hint' => $moduleHint); $webServerRestart = true; } if (version_compare(phpversion(), '5.3.3', '<')) { $errors[] = array('error' => $l->t('PHP %s or higher is required.', '5.3.3'), 'hint' => $l->t('Please ask your server administrator to update PHP to the latest version.' . ' Your PHP version is no longer supported by ownCloud and the PHP community.')); $webServerRestart = true; } if (strtolower(@ini_get('safe_mode')) == 'on' || strtolower(@ini_get('safe_mode')) == 'yes' || strtolower(@ini_get('safe_mode')) == 'true' || ini_get("safe_mode") == 1) { $errors[] = array('error' => $l->t('PHP Safe Mode is enabled. ownCloud requires that it is disabled to work properly.'), 'hint' => $l->t('PHP Safe Mode is a deprecated and mostly useless setting that should be disabled. ' . 'Please ask your server administrator to disable it in php.ini or in your webserver config.')); $webServerRestart = true; } if (get_magic_quotes_gpc() == 1) { $errors[] = array('error' => $l->t('Magic Quotes is enabled. ownCloud requires that it is disabled to work properly.'), 'hint' => $l->t('Magic Quotes is a deprecated and mostly useless setting that should be disabled. ' . 'Please ask your server administrator to disable it in php.ini or in your webserver config.')); $webServerRestart = true; } if (!self::isAnnotationsWorking()) { $errors[] = array('error' => 'PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible.', 'hint' => 'This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.'); } if ($webServerRestart) { $errors[] = array('error' => $l->t('PHP modules have been installed, but they are still listed as missing?'), 'hint' => $l->t('Please ask your server administrator to restart the web server.')); } $errors = array_merge($errors, self::checkDatabaseVersion()); // Cache the result of this function \OC::$server->getSession()->set('checkServer_succeeded', count($errors) == 0); return $errors; }
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'); }
// warn if Windows is used $template->assign('WindowsWarning', OC_Util::runningOnWindows()); // warn if outdated version of a memcache module is used $caches = ['apcu' => ['name' => $l->t('APCu'), 'version' => '4.0.6'], 'redis' => ['name' => $l->t('Redis'), 'version' => '2.2.5']]; $outdatedCaches = []; foreach ($caches as $php_module => $data) { $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); if ($isOutdated) { $outdatedCaches[$php_module] = $data; } } $template->assign('OutdatedCacheWarning', $outdatedCaches); // add hardcoded forms from the template $forms = OC_App::getForms('admin'); $formsAndMore = array(); if ($request->getServerProtocol() !== 'https' || !OC_Util::isAnnotationsWorking() || $suggestedOverwriteCliUrl || !OC_Util::isSetLocaleWorking() || !OC_Util::fileInfoLoaded() || $databaseOverload) { $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & setup warnings')); } $formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing')); $formsAndMore[] = ['anchor' => 'encryptionAPI', 'section-name' => $l->t('Server-side encryption')]; // Prioritize fileSharingSettings and files_external and move updater to the version $fileSharingSettings = $filesExternal = $updaterAppPanel = $ocDefaultEncryptionModulePanel = ''; foreach ($forms as $index => $form) { if (strpos($form, 'id="fileSharingSettings"')) { $fileSharingSettings = $form; unset($forms[$index]); continue; } if (strpos($form, 'id="files_external"')) { $filesExternal = $form; unset($forms[$index]);
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'); }
/** * check if the current server configuration is suitable for ownCloud * * @param \OCP\IConfig $config * @return array arrays with error messages and hints */ public static function checkServer(\OCP\IConfig $config) { $l = \OC::$server->getL10N('lib'); $errors = array(); $CONFIG_DATADIRECTORY = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data'); if (!self::needUpgrade($config) && $config->getSystemValue('installed', false)) { // this check needs to be done every time $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); } // Assume that if checkServer() succeeded before in this session, then all is fine. if (\OC::$server->getSession()->exists('checkServer_succeeded') && \OC::$server->getSession()->get('checkServer_succeeded')) { return $errors; } $webServerRestart = false; $setup = new \OC\Setup($config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); $availableDatabases = $setup->getSupportedDatabases(); if (empty($availableDatabases)) { $errors[] = array('error' => $l->t('No database drivers (sqlite, mysql, or postgresql) installed.'), 'hint' => ''); $webServerRestart = true; } // Check if server running on Windows platform if (OC_Util::runningOnWindows()) { $errors[] = ['error' => $l->t('Microsoft Windows Platform is not supported'), 'hint' => $l->t('Running ownCloud Server on the Microsoft Windows platform is not supported. We suggest you ' . 'use a Linux server in a virtual machine if you have no option for migrating the server itself. ' . 'Find Linux packages as well as easy to deploy virtual machine images on <a href="%s">%s</a>. ' . 'For migrating existing installations to Linux you can find some tips and a migration script ' . 'in <a href="%s">our documentation</a>.', ['https://owncloud.org/install/', 'owncloud.org/install/', 'https://owncloud.org/?p=8045'])]; } // Check if config folder is writable. if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { $errors[] = array('error' => $l->t('Cannot write into "config" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the config directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'))); } // Check if there is a writable install folder. if ($config->getSystemValue('appstoreenabled', true)) { if (OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath())) { $errors[] = array('error' => $l->t('Cannot write into "apps" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the apps directory%s' . ' or disabling the appstore in the config file.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>'))); } } // Create root dir. if ($config->getSystemValue('installed', false)) { if (!is_dir($CONFIG_DATADIRECTORY)) { $success = @mkdir($CONFIG_DATADIRECTORY); if ($success) { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } else { $errors[] = array('error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)), 'hint' => $l->t('This can usually be fixed by ' . '<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.', array(OC_Helper::linkToDocs('admin-dir_permissions')))); } } else { if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { //common hint for all file permissions error messages $permissionsHint = $l->t('Permissions can usually be fixed by ' . '%sgiving the webserver write access to the root directory%s.', array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')); $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud', 'hint' => $permissionsHint); } else { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } } } if (!OC_Util::isSetLocaleWorking()) { $errors[] = array('error' => $l->t('Setting locale to %s failed', array('en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/' . 'pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8')), 'hint' => $l->t('Please install one of these locales on your system and restart your webserver.')); } // Contains the dependencies that should be checked against // classes = class_exists // functions = function_exists // defined = defined // ini = ini_get // If the dependency is not found the missing module name is shown to the EndUser // When adding new checks always verify that they pass on Travis as well // for ini settings, see https://github.com/owncloud/administration/blob/master/travis-ci/custom.ini $dependencies = array('classes' => array('ZipArchive' => 'zip', 'DOMDocument' => 'dom', 'XMLWriter' => 'XMLWriter'), 'functions' => ['xml_parser_create' => 'libxml', 'mb_detect_encoding' => 'mb multibyte', 'ctype_digit' => 'ctype', 'json_encode' => 'JSON', 'gd_info' => 'GD', 'gzencode' => 'zlib', 'iconv' => 'iconv', 'simplexml_load_string' => 'SimpleXML', 'hash' => 'HASH Message Digest Framework', 'curl_init' => 'cURL'], 'defined' => array('PDO::ATTR_DRIVER_NAME' => 'PDO'), 'ini' => ['default_charset' => 'UTF-8']); $missingDependencies = array(); $invalidIniSettings = []; $moduleHint = $l->t('Please ask your server administrator to install the module.'); /** * FIXME: The dependency check does not work properly on HHVM on the moment * and prevents installation. Once HHVM is more compatible with our * approach to check for these values we should re-enable those * checks. */ $iniWrapper = \OC::$server->getIniWrapper(); if (!self::runningOnHhvm()) { foreach ($dependencies['classes'] as $class => $module) { if (!class_exists($class)) { $missingDependencies[] = $module; } } foreach ($dependencies['functions'] as $function => $module) { if (!function_exists($function)) { $missingDependencies[] = $module; } } foreach ($dependencies['defined'] as $defined => $module) { if (!defined($defined)) { $missingDependencies[] = $module; } } foreach ($dependencies['ini'] as $setting => $expected) { if (is_bool($expected)) { if ($iniWrapper->getBool($setting) !== $expected) { $invalidIniSettings[] = [$setting, $expected]; } } if (is_int($expected)) { if ($iniWrapper->getNumeric($setting) !== $expected) { $invalidIniSettings[] = [$setting, $expected]; } } if (is_string($expected)) { if (strtolower($iniWrapper->getString($setting)) !== strtolower($expected)) { $invalidIniSettings[] = [$setting, $expected]; } } } } foreach ($missingDependencies as $missingDependency) { $errors[] = array('error' => $l->t('PHP module %s not installed.', array($missingDependency)), 'hint' => $moduleHint); $webServerRestart = true; } foreach ($invalidIniSettings as $setting) { if (is_bool($setting[1])) { $setting[1] = $setting[1] ? 'on' : 'off'; } $errors[] = ['error' => $l->t('PHP setting "%s" is not set to "%s".', [$setting[0], var_export($setting[1], true)]), 'hint' => $l->t('Adjusting this setting in php.ini will make ownCloud run again')]; $webServerRestart = true; } /** * The mbstring.func_overload check can only be performed if the mbstring * module is installed as it will return null if the checking setting is * not available and thus a check on the boolean value fails. * * TODO: Should probably be implemented in the above generic dependency * check somehow in the long-term. */ if ($iniWrapper->getBool('mbstring.func_overload') !== null && $iniWrapper->getBool('mbstring.func_overload') === true) { $errors[] = array('error' => $l->t('mbstring.func_overload is set to "%s" instead of the expected value "0"', [$iniWrapper->getString('mbstring.func_overload')]), 'hint' => $l->t('To fix this issue set <code>mbstring.func_overload</code> to <code>0</code> in your php.ini')); } if (!self::isAnnotationsWorking()) { $errors[] = array('error' => $l->t('PHP is apparently set up to strip inline doc blocks. This will make several core apps inaccessible.'), 'hint' => $l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.')); } if (!\OC::$CLI && $webServerRestart) { $errors[] = array('error' => $l->t('PHP modules have been installed, but they are still listed as missing?'), 'hint' => $l->t('Please ask your server administrator to restart the web server.')); } $errors = array_merge($errors, self::checkDatabaseVersion()); // Cache the result of this function \OC::$server->getSession()->set('checkServer_succeeded', count($errors) == 0); return $errors; }
public static function init() { // register autoloader require_once __DIR__ . '/autoloader.php'; self::$loader = new \OC\Autoloader(); self::$loader->registerPrefix('Doctrine\\Common', 'doctrine/common/lib'); self::$loader->registerPrefix('Doctrine\\DBAL', 'doctrine/dbal/lib'); self::$loader->registerPrefix('Symfony\\Component\\Routing', 'symfony/routing'); self::$loader->registerPrefix('Symfony\\Component\\Console', 'symfony/console'); self::$loader->registerPrefix('Patchwork', '3rdparty'); self::$loader->registerPrefix('Pimple', '3rdparty/Pimple'); spl_autoload_register(array(self::$loader, 'load')); // make a dummy session available as early as possible since error pages need it self::$session = new \OC\Session\Memory(''); // 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 switch magic quotes off. if (get_magic_quotes_gpc() == 1) { ini_set('magic_quotes_runtime', 0); } //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::initPaths(); self::registerAutoloaderCache(); OC_Util::isSetLocaleWorking(); // setup 3rdparty autoloader $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php'; if (file_exists($vendorAutoLoad)) { require_once $vendorAutoLoad; } 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'); // setup the basic server self::$server = new \OC\Server(); self::initTemplateEngine(); OC_App::loadApps(array('session')); if (!self::$CLI) { self::initSession(); } else { self::$session = new \OC\Session\Memory(''); } 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); // User and Groups if (!OC_Config::getValue("installed", false)) { self::$session->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 register_shutdown_function(array('OC_Helper', 'cleanTmp')); if (OC_Config::getValue('installed', false) && !self::checkUpgrade(false)) { if (OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { OC_Util::addScript('backgroundjobs'); } } $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(); } }
/** * @brief check if the current server configuration is suitable for ownCloud * @return array arrays with error messages and hints */ public static function checkServer() { $errors = array(); $CONFIG_DATADIRECTORY = OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data'); if (!\OC::needUpgrade() && OC_Config::getValue('installed', false)) { // this check needs to be done every time $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); } // Assume that if checkServer() succeeded before in this session, then all is fine. if (\OC::$session->exists('checkServer_suceeded') && \OC::$session->get('checkServer_suceeded')) { return $errors; } $defaults = new \OC_Defaults(); $webServerRestart = false; //check for database drivers if (!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect') and !is_callable('oci_connect')) { $errors[] = array('error' => 'No database drivers (sqlite, mysql, or postgresql) installed.', 'hint' => ''); $webServerRestart = true; } //common hint for all file permissions error messages $permissionsHint = 'Permissions can usually be fixed by ' . '<a href="' . OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the root directory</a>.'; // Check if config folder is writable. if (!is_writable(OC::$SERVERROOT . "/config/") or !is_readable(OC::$SERVERROOT . "/config/")) { $errors[] = array('error' => "Can't write into config directory", 'hint' => 'This can usually be fixed by ' . '<a href="' . OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the config directory</a>.'); } // Check if there is a writable install folder. if (OC_Config::getValue('appstoreenabled', true)) { if (OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath())) { $errors[] = array('error' => "Can't write into apps directory", 'hint' => 'This can usually be fixed by ' . '<a href="' . OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the apps directory</a> ' . 'or disabling the appstore in the config file.'); } } // Create root dir. if (!is_dir($CONFIG_DATADIRECTORY)) { $success = @mkdir($CONFIG_DATADIRECTORY); if ($success) { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } else { $errors[] = array('error' => "Can't create data directory (" . $CONFIG_DATADIRECTORY . ")", 'hint' => 'This can usually be fixed by ' . '<a href="' . OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the root directory</a>.'); } } else { if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { $errors[] = array('error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud', 'hint' => $permissionsHint); } else { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } } if (!OC_Util::isSetLocaleWorking()) { $errors[] = array('error' => 'Setting locale to en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8 failed', 'hint' => 'Please install one of theses locales on your system and restart your webserver.'); } $moduleHint = "Please ask your server administrator to install the module."; // check if all required php modules are present if (!class_exists('ZipArchive')) { $errors[] = array('error' => 'PHP module zip not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!class_exists('DOMDocument')) { $errors[] = array('error' => 'PHP module dom not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('xml_parser_create')) { $errors[] = array('error' => 'PHP module libxml not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('mb_detect_encoding')) { $errors[] = array('error' => 'PHP module mb multibyte not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('ctype_digit')) { $errors[] = array('error' => 'PHP module ctype is not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('json_encode')) { $errors[] = array('error' => 'PHP module JSON is not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!extension_loaded('gd') || !function_exists('gd_info')) { $errors[] = array('error' => 'PHP module GD is not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('gzencode')) { $errors[] = array('error' => 'PHP module zlib is not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('iconv')) { $errors[] = array('error' => 'PHP module iconv is not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (!function_exists('simplexml_load_string')) { $errors[] = array('error' => 'PHP module SimpleXML is not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (version_compare(phpversion(), '5.3.3', '<')) { $errors[] = array('error' => 'PHP 5.3.3 or higher is required.', 'hint' => 'Please ask your server administrator to update PHP to the latest version.' . ' Your PHP version is no longer supported by ownCloud and the PHP community.'); $webServerRestart = true; } if (!defined('PDO::ATTR_DRIVER_NAME')) { $errors[] = array('error' => 'PHP PDO module is not installed.', 'hint' => $moduleHint); $webServerRestart = true; } if (strtolower(@ini_get('safe_mode')) == 'on' || strtolower(@ini_get('safe_mode')) == 'yes' || strtolower(@ini_get('safe_mode')) == 'true' || ini_get("safe_mode") == 1) { $errors[] = array('error' => 'PHP Safe Mode is enabled. ownCloud requires that it is disabled to work properly.', 'hint' => 'PHP Safe Mode is a deprecated and mostly useless setting that should be disabled. ' . 'Please ask your server administrator to disable it in php.ini or in your webserver config.'); $webServerRestart = true; } if (get_magic_quotes_gpc() == 1) { $errors[] = array('error' => 'Magic Quotes is enabled. ownCloud requires that it is disabled to work properly.', 'hint' => 'Magic Quotes is a deprecated and mostly useless setting that should be disabled. ' . 'Please ask your server administrator to disable it in php.ini or in your webserver config.'); $webServerRestart = true; } if ($webServerRestart) { $errors[] = array('error' => 'PHP modules have been installed, but they are still listed as missing?', 'hint' => 'Please ask your server administrator to restart the web server.'); } $errors = array_merge($errors, self::checkDatabaseVersion()); // Cache the result of this function \OC::$session->set('checkServer_suceeded', count($errors) == 0); return $errors; }
$tmpl->assign('loglevel', OC_Config::getValue("loglevel", 2)); $tmpl->assign('mail_domain', OC_Config::getValue("mail_domain", '')); $tmpl->assign('mail_from_address', OC_Config::getValue("mail_from_address", '')); $tmpl->assign('mail_smtpmode', OC_Config::getValue("mail_smtpmode", '')); $tmpl->assign('mail_smtpsecure', OC_Config::getValue("mail_smtpsecure", '')); $tmpl->assign('mail_smtphost', OC_Config::getValue("mail_smtphost", '')); $tmpl->assign('mail_smtpport', OC_Config::getValue("mail_smtpport", '')); $tmpl->assign('mail_smtpauthtype', OC_Config::getValue("mail_smtpauthtype", '')); $tmpl->assign('mail_smtpauth', OC_Config::getValue("mail_smtpauth", false)); $tmpl->assign('mail_smtpname', OC_Config::getValue("mail_smtpname", '')); $tmpl->assign('mail_smtppassword', OC_Config::getValue("mail_smtppassword", '')); $tmpl->assign('entries', $entries); $tmpl->assign('entriesremain', $entriesremain); $tmpl->assign('htaccessworking', $htaccessworking); $tmpl->assign('readOnlyConfigEnabled', OC_Helper::isReadOnlyConfigEnabled()); $tmpl->assign('isLocaleWorking', OC_Util::isSetLocaleWorking()); $tmpl->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking()); $tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded()); $tmpl->assign('old_php', OC_Util::isPHPoutdated()); $tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax')); $tmpl->assign('cron_log', OC_Config::getValue('cron_log', true)); $tmpl->assign('lastcron', OC_Appconfig::getValue('core', 'lastcron', false)); $tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes')); $tmpl->assign('shareDefaultExpireDateSet', OC_Appconfig::getValue('core', 'shareapi_default_expire_date', 'no')); $tmpl->assign('shareExpireAfterNDays', OC_Appconfig::getValue('core', 'shareapi_expire_after_n_days', '7')); $tmpl->assign('shareEnforceExpireDate', OC_Appconfig::getValue('core', 'shareapi_enforce_expire_date', 'no')); $excludeGroups = OC_Appconfig::getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false; $tmpl->assign('shareExcludeGroups', $excludeGroups); $excludedGroupsList = OC_Appconfig::getValue('core', 'shareapi_exclude_groups_list', ''); $excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON!
$template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes')); $template->assign('allowPublicMailNotification', $appConfig->getValue('core', 'shareapi_allow_public_notification', 'no')); $template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no')); $template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly()); $databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false); $template->assign('databaseOverload', $databaseOverload); // warn if Windows is used $template->assign('WindowsWarning', OC_Util::runningOnWindows()); // add hardcoded forms from the template $forms = OC_App::getForms('admin'); $l = OC_L10N::get('settings'); $formsAndMore = array(); if (OC_Request::serverProtocol() !== 'https' || !OC_Util::isAnnotationsWorking() || $suggestedOverwriteCliUrl || !OC_Util::isSetLocaleWorking() || !OC_Util::isPhpCharSetUtf8() || !OC_Util::fileInfoLoaded() || $databaseOverload ) { $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & Setup Warnings')); } $formsMap = array_map(function ($form) { if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) { $sectionName = str_replace('<h2>', '', $regs[0]); $sectionName = str_replace('</h2>', '', $sectionName); $anchor = strtolower($sectionName); $anchor = str_replace(' ', '-', $anchor); return array( 'anchor' => 'goto-' . $anchor, 'section-name' => $sectionName,
public static function init() { // register autoloader require_once __DIR__ . '/autoloader.php'; self::$loader = new \OC\Autoloader(); self::$loader->registerPrefix('Doctrine\\Common', 'doctrine/common/lib'); self::$loader->registerPrefix('Doctrine\\DBAL', 'doctrine/dbal/lib'); self::$loader->registerPrefix('Symfony\\Component\\Routing', 'symfony/routing'); self::$loader->registerPrefix('Symfony\\Component\\Console', 'symfony/console'); self::$loader->registerPrefix('Sabre\\VObject', '3rdparty'); self::$loader->registerPrefix('Sabre_', '3rdparty'); self::$loader->registerPrefix('Patchwork', '3rdparty'); spl_autoload_register(array(self::$loader, 'load')); // 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 switch magic quotes off. if (get_magic_quotes_gpc() == 1) { ini_set('magic_quotes_runtime', 0); } //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'); //copy http auth headers for apache+php-fcgid work around if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) { $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION']; } //set http auth headers for apache+php-cgi work around if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) { list($name, $password) = explode(':', base64_decode($matches[1]), 2); $_SERVER['PHP_AUTH_USER'] = strip_tags($name); $_SERVER['PHP_AUTH_PW'] = strip_tags($password); } //set http auth headers for apache+php-cgi work around if variable gets renamed by apache if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) { list($name, $password) = explode(':', base64_decode($matches[1]), 2); $_SERVER['PHP_AUTH_USER'] = strip_tags($name); $_SERVER['PHP_AUTH_PW'] = strip_tags($password); } self::initPaths(); if (OC_Config::getValue('instanceid', false)) { // \OC\Memcache\Cache has a hidden dependency on // OC_Util::getInstanceId() for namespacing. See #5409. try { self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader')); } catch (\Exception $ex) { } } OC_Util::isSetLocaleWorking(); // set debug mode if an xdebug session is active if (!defined('DEBUG') || !DEBUG) { if (isset($_COOKIE['XDEBUG_SESSION'])) { define('DEBUG', true); } } if (!defined('PHPUNIT_RUN')) { if (defined('DEBUG') and DEBUG) { OC\Log\ErrorHandler::register(true); set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); } else { OC\Log\ErrorHandler::register(); } OC\Log\ErrorHandler::setLogger(OC_Log::$object); } // 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'); // setup the basic server self::$server = new \OC\Server(); self::initTemplateEngine(); OC_App::loadApps(array('session')); if (!self::$CLI) { self::initSession(); } else { self::$session = new \OC\Session\Memory(''); } self::checkConfig(); self::checkInstalled(); self::checkSSL(); self::addSecurityHeaders(); $errors = OC_Util::checkServer(); 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); // User and Groups if (!OC_Config::getValue("installed", false)) { self::$session->set('user_id', ''); } OC_User::useBackend(new OC_User_Database()); OC_Group::useBackend(new OC_Group_Database()); if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('loginname') && $_SERVER['PHP_AUTH_USER'] !== self::$session->get('loginname')) { $sessionUser = self::$session->get('loginname'); $serverUser = $_SERVER['PHP_AUTH_USER']; OC_Log::write('core', "Session loginname ({$sessionUser}) doesn't match SERVER[PHP_AUTH_USER] ({$serverUser}).", OC_Log::WARN); OC_User::logout(); } // Load Apps // This includes plugins for users and filesystems as well global $RUNTIME_NOAPPS; global $RUNTIME_APPTYPES; if (!$RUNTIME_NOAPPS && !self::checkUpgrade(false)) { if ($RUNTIME_APPTYPES) { OC_App::loadApps($RUNTIME_APPTYPES); } else { OC_App::loadApps(); } } //setup extra user backends OC_User::setupBackends(); self::registerCacheHooks(); self::registerFilesystemHooks(); self::registerPreviewHooks(); self::registerShareHooks(); self::registerLogRotate(); //make sure temporary files are cleaned up register_shutdown_function(array('OC_Helper', 'cleanTmp')); //parse the given parameters self::$REQUESTEDAPP = isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app']) ? OC_App::cleanAppId(strip_tags($_GET['app'])) : OC_Config::getValue('defaultapp', 'files'); if (substr_count(self::$REQUESTEDAPP, '?') != 0) { $app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?')); $param = substr($_GET['app'], strpos($_GET['app'], '?') + 1); parse_str($param, $get); $_GET = array_merge($_GET, $get); self::$REQUESTEDAPP = $app; $_GET['app'] = $app; } self::$REQUESTEDFILE = isset($_GET['getfile']) ? $_GET['getfile'] : null; if (substr_count(self::$REQUESTEDFILE, '?') != 0) { $file = substr(self::$REQUESTEDFILE, 0, strpos(self::$REQUESTEDFILE, '?')); $param = substr(self::$REQUESTEDFILE, strpos(self::$REQUESTEDFILE, '?') + 1); parse_str($param, $get); $_GET = array_merge($_GET, $get); self::$REQUESTEDFILE = $file; $_GET['getfile'] = $file; } if (!is_null(self::$REQUESTEDFILE)) { $subdir = OC_App::getAppPath(OC::$REQUESTEDAPP) . '/' . self::$REQUESTEDFILE; $parent = OC_App::getAppPath(OC::$REQUESTEDAPP); if (!OC_Helper::issubdirectory($subdir, $parent)) { self::$REQUESTEDFILE = null; header('HTTP/1.0 404 Not Found'); exit; } } if (OC_Config::getValue('installed', false) && !self::checkUpgrade(false)) { if (OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { OC_Util::addScript('backgroundjobs'); } } }
public static function init() { // register autoloader require_once __DIR__ . '/autoloader.php'; self::$loader = new \OC\Autoloader(); self::$loader->registerPrefix('Doctrine\\Common', 'doctrine/common/lib'); self::$loader->registerPrefix('Doctrine\\DBAL', 'doctrine/dbal/lib'); self::$loader->registerPrefix('Symfony\\Component\\Routing', 'symfony/routing'); self::$loader->registerPrefix('Symfony\\Component\\Console', 'symfony/console'); self::$loader->registerPrefix('Patchwork', '3rdparty'); self::$loader->registerPrefix('Pimple', '3rdparty/Pimple'); spl_autoload_register(array(self::$loader, 'load')); // make a dummy session available as early as possible since error pages need it self::$session = new \OC\Session\Memory(''); // 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 switch magic quotes off. if (get_magic_quotes_gpc() == 1) { ini_set('magic_quotes_runtime', 0); } //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'); //copy http auth headers for apache+php-fcgid work around if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) { $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION']; } //set http auth headers for apache+php-cgi work around if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) { list($name, $password) = explode(':', base64_decode($matches[1]), 2); $_SERVER['PHP_AUTH_USER'] = strip_tags($name); $_SERVER['PHP_AUTH_PW'] = strip_tags($password); } //set http auth headers for apache+php-cgi work around if variable gets renamed by apache if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) { list($name, $password) = explode(':', base64_decode($matches[1]), 2); $_SERVER['PHP_AUTH_USER'] = strip_tags($name); $_SERVER['PHP_AUTH_PW'] = strip_tags($password); } self::initPaths(); if (OC_Config::getValue('instanceid', false)) { // \OC\Memcache\Cache has a hidden dependency on // OC_Util::getInstanceId() for namespacing. See #5409. try { self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader')); } catch (\Exception $ex) { } } OC_Util::isSetLocaleWorking(); // setup 3rdparty autoloader $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php'; if (file_exists($vendorAutoLoad)) { require_once $vendorAutoLoad; } // set debug mode if an xdebug session is active if (!defined('DEBUG') || !DEBUG) { if (isset($_COOKIE['XDEBUG_SESSION'])) { define('DEBUG', true); } } 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'); // setup the basic server self::$server = new \OC\Server(); self::initTemplateEngine(); OC_App::loadApps(array('session')); if (!self::$CLI) { self::initSession(); } else { self::$session = new \OC\Session\Memory(''); } self::checkConfig(); self::checkInstalled(); self::checkSSL(); OC_Response::addSecurityHeaders(); $errors = OC_Util::checkServer(); 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); // User and Groups if (!OC_Config::getValue("installed", false)) { self::$session->set('user_id', ''); } OC_User::useBackend(new OC_User_Database()); OC_Group::useBackend(new OC_Group_Database()); //setup extra user backends OC_User::setupBackends(); self::registerCacheHooks(); self::registerFilesystemHooks(); self::registerPreviewHooks(); self::registerShareHooks(); self::registerLogRotate(); //make sure temporary files are cleaned up register_shutdown_function(array('OC_Helper', 'cleanTmp')); if (OC_Config::getValue('installed', false) && !self::checkUpgrade(false)) { if (OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { OC_Util::addScript('backgroundjobs'); } } }
$suggestedOverwriteCliUrl = $shouldSuggestOverwriteCliUrl ? \OC::$WEBROOT : ''; $template->assign('suggestedOverwriteCliUrl', $suggestedOverwriteCliUrl); $template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_links', 'yes')); $template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired()); $template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes')); $template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes')); $template->assign('allowPublicMailNotification', $appConfig->getValue('core', 'shareapi_allow_public_notification', 'no')); $template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no')); $template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly()); $databaseOverload = strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false; $template->assign('databaseOverload', $databaseOverload); // add hardcoded forms from the template $forms = OC_App::getForms('admin'); $l = OC_L10N::get('settings'); $formsAndMore = array(); if (OC_Request::serverProtocol() !== 'https' || !OC_Util::isAnnotationsWorking() || $suggestedOverwriteWebRoot || !OC_Util::isSetLocaleWorking() || !OC_Util::isPhpCharSetUtf8() || !OC_Util::fileInfoLoaded() || $databaseOverload) { $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & Setup Warnings')); } $formsMap = array_map(function ($form) { if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) { $sectionName = str_replace('<h2>', '', $regs[0]); $sectionName = str_replace('</h2>', '', $sectionName); $anchor = strtolower($sectionName); $anchor = str_replace(' ', '-', $anchor); return array('anchor' => 'goto-' . $anchor, 'section-name' => $sectionName, 'form' => $form); } return array('form' => $form); }, $forms); $formsAndMore = array_merge($formsAndMore, $formsMap); // add bottom hardcoded forms from the template $formsAndMore[] = array('anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron'));
]; $outdatedCaches = []; foreach ($caches as $php_module => $data) { $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); if ($isOutdated) { $outdatedCaches[$php_module] = $data; } } $template->assign('OutdatedCacheWarning', $outdatedCaches); // add hardcoded forms from the template $forms = OC_App::getForms('admin'); $formsAndMore = array(); if ($request->getServerProtocol() !== 'https' || !OC_Util::isAnnotationsWorking() || $suggestedOverwriteCliUrl || !OC_Util::isSetLocaleWorking() || !OC_Util::fileInfoLoaded() || $databaseOverload ) { $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & setup warnings')); } $formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing')); $formsAndMore[] = ['anchor' => 'encryptionAPI', 'section-name' => $l->t('Server-side encryption')]; // Prioritize fileSharingSettings and files_external and move updater to the version $fileSharingSettings = $filesExternal = $updaterAppPanel = $ocDefaultEncryptionModulePanel = ''; foreach ($forms as $index => $form) { if (strpos($form, 'id="fileSharingSettings"')) { $fileSharingSettings = $form; unset($forms[$index]); continue; }
$template->assign('mail_from_address', $config->getSystemValue("mail_from_address", '')); $template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", '')); $template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", '')); $template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", '')); $template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", '')); $template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", '')); $template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false)); $template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", '')); $template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", '')); $template->assign('entries', $entries); $template->assign('entriesremain', $entriesRemaining); $template->assign('logFileSize', $logFileSize); $template->assign('doesLogFileExist', $doesLogFileExist); $template->assign('showLog', $showLog); $template->assign('readOnlyConfigEnabled', OC_Helper::isReadOnlyConfigEnabled()); $template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking()); $template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking()); $template->assign('has_fileinfo', OC_Util::fileInfoLoaded()); $template->assign('backgroundjobs_mode', $appConfig->getValue('core', 'backgroundjobs_mode', 'ajax')); $template->assign('cron_log', $config->getSystemValue('cron_log', true)); $template->assign('lastcron', $appConfig->getValue('core', 'lastcron', false)); $template->assign('shareAPIEnabled', $appConfig->getValue('core', 'shareapi_enabled', 'yes')); $template->assign('shareDefaultExpireDateSet', $appConfig->getValue('core', 'shareapi_default_expire_date', 'no')); $template->assign('shareExpireAfterNDays', $appConfig->getValue('core', 'shareapi_expire_after_n_days', '7')); $template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'shareapi_enforce_expire_date', 'no')); $excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false; $template->assign('shareExcludeGroups', $excludeGroups); $excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', ''); $excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON! $template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));