Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Register our shutdown function so that no other shutdown functions run before this one.
- // This shutdown function calls exit(), immediately short-circuiting any other shutdown functions,
- // such as those registered by the devel.module for statistics.
- define('DRUPAL_ROOT', getcwd());
- register_shutdown_function('status_shutdown');
- function status_shutdown() {
- exit();
- }
- // Drupal bootstrap.
- require_once './includes/bootstrap.inc';
- drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
- // Build up our list of errors.
- $errors = array();
- // Check that the main database is active.
- $account = db_select('users','u')
- ->fields('u')
- ->condition('uid',1,'=')
- ->execute()
- ->fetchObject();
- if ($account->uid != 1) {
- $errors[] = 'Master database not responding.';
- }
- // Check that the website is online
- $mode_obj = db_select('variable', 'v')->fields('v')->condition('name', "maintenance_mode", "=")->execute()->fetchObject();
- if($mode_obj->value)
- {
- $mode = unserialize($mode_obj->value);
- if ($mode != 0) {
- $errors[] = 'Site offline';
- }
- }
- else
- {
- $errors[] = 'Could not fetch the offline status of the website.';
- }
- // Check that the files directory is operating properly. Do not use variable_get, not initialized yet.
- $files_path_obj = db_select('variable', 'v')->fields('v')->condition('name', "file_public_path", "=")->execute()->fetchObject();
- if($files_path_obj->value)
- $files_path = unserialize($files_path_obj->value);
- if ($files_path && $test = tempnam($files_path, 'status_check_')) {
- if (!unlink($test)) {
- $errors[] = 'Could not delete newly created file in the files directory.';
- }
- }
- else {
- $errors[] = 'Could not create a file in the files directory.';
- }
- // Print all errors.
- if (count($errors) > 0) {
- header('HTTP/1.1 500 Internal Server Error');
- print 'NOK' . ' 500' . '<br />';
- print implode("<br />\n", $errors);
- }
- else {
- // Split up this message, to prevent the remote chance of monitoring software
- // reading the source code if mod_php fails and then matching the string.
- print 'OK' . ' 200';
- }
- // Exit immediately, note the shutdown function registered at the top of the file.
- exit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement