From dd4f143df621bb926934335c4fdf44f8267f6039 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Fri, 1 Sep 2006 08:44:53 +0000 Subject: #75002: Install-time and run-time requirements checking + status report page --- modules/system/system.install | 111 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) (limited to 'modules/system/system.install') diff --git a/modules/system/system.install b/modules/system/system.install index 1f8607224..8194241e5 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -1,6 +1,117 @@ $t('Drupal'), + 'value' => VERSION, + ); + } + + // Test web server + $requirements['webserver'] = array( + 'title' => $t('Web server'), + ); + // Use server info string, if present. + if (isset($_SERVER['SERVER_SOFTWARE'])) { + $requirements['webserver']['value'] = $_SERVER['SERVER_SOFTWARE']; + + list($server, $version) = split('[ /]', $_SERVER['SERVER_SOFTWARE']); + switch ($server) { + case 'Apache': + if (version_compare($version, DRUPAL_MINIMUM_APACHE) < 0) { + $requirements['webserver']['description'] = $t('Your Apache server is too old. Drupal requires at least Apache %version.', array('%version' => DRUPAL_MINIMUM_APACHE)); + $requirements['webserver']['severity'] = REQUIREMENT_ERROR; + } + break; + + default: + $requirements['webserver']['description'] = $t('The web server you\'re using has not been tested with Drupal and might not work properly.'); + $requirements['webserver']['severity'] = REQUIREMENT_WARNING; + break; + } + } + else { + $requirements['webserver']['value'] = $t('Unknown'); + $requirements['webserver']['description'] = $t('Unable to determine your web server type. Drupal might not work properly.'); + $requirements['webserver']['severity'] = REQUIREMENT_WARNING; + } + + // Test PHP version + $requirements['php'] = array( + 'title' => $t('PHP'), + 'value' => ($phase == 'runtime') ? l(phpversion(), 'admin/logs/status/php') : phpversion(), + ); + if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) { + $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP)); + $requirements['php']['severity'] = REQUIREMENT_ERROR; + } + + // Test DB version + global $db_type; + if (function_exists('db_status_report')) { + $requirements += db_status_report($phase); + } + + // Test settings.php file writability + if ($phase == 'runtime') { + if (!drupal_verify_install_file(conf_path() .'/settings.php', FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE)) { + $requirements['settings.php'] = array( + 'value' => $t('Not protected'), + 'severity' => REQUIREMENT_ERROR, + 'description' => $t('The file %file is not protected from modifications and poses a security risk. You must change the file\'s permissions to be non-writable.', array('%file' => conf_path() .'/settings.php')), + ); + } + else { + $requirements['settings.php'] = array( + 'value' => $t('Protected'), + ); + } + $requirements['settings.php']['title'] = $t('Configuration file'); + } + + // Report cron status + if ($phase == 'runtime') { + $cron_last = variable_get('cron_last', NULL); + + if (is_numeric($cron_last)) { + $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(time() - $cron_last))); + } + else { + $requirements['cron'] = array( + 'description' => $t('Cron has not run. It appears cron jobs have not been setup on your system. Please check the help pages for configuring cron jobs.', array('@url' => 'http://drupal.org/cron')), + 'severity' => REQUIREMENT_ERROR, + 'value' => $t('Never run'), + ); + } + + $requirements['cron']['description'] .= ' '. t('You can run cron manually.', array('@cron' => url('admin/logs/status/run-cron'))); + + $requirements['cron']['title'] = $t('Cron maintenance tasks'); + } + + // Test Unicode library + include_once './includes/unicode.inc'; + $requirements = array_merge($requirements, unicode_requirements()); + + return $requirements; +} + + /** * Implementation of hook_install(). */ -- cgit v1.2.3