public static function checkConfig() { $l = \OC::$server->getL10N('lib'); // Create config in case it does not already exists $configFilePath = self::$configDir . '/config.php'; if (!file_exists($configFilePath)) { @touch($configFilePath); } // Check if config is writable $configFileWritable = is_writable($configFilePath); if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() || !$configFileWritable && \OCP\Util::needUpgrade()) { if (self::$CLI) { echo $l->t('Cannot write into "config" directory!') . "\n"; echo $l->t('This can usually be fixed by giving the webserver write access to the config directory') . "\n"; echo "\n"; echo $l->t('See %s', array(\OC_Helper::linkToDocs('admin-dir_permissions'))) . "\n"; exit; } else { OC_Template::printErrorPage($l->t('Cannot write into "config" directory!'), $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>'))); } } }
$template->assign('mail_domain', $config->getSystemValue("mail_domain", '')); $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!
/** * 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()); $urlGenerator = \OC::$server->getURLGenerator(); $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 (!OC_Helper::isReadOnlyConfigEnabled()) { 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="' . $urlGenerator->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="' . $urlGenerator->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($urlGenerator->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="' . $urlGenerator->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; }