You are here

system_status.module in System Status 7

Drupal system status

File

system_status.module
View source
<?php

/**
 * @file
 * Drupal system status
 */

/**
 * Implements hook_help().
 *
 * Displays help and module information.
 */
function system_status_help($path, $arg) {
  switch ($path) {
    case 'admin/help#system_status':
      return '<p>' . t("A module that provides the functionality to remote check on the health of your site and modules.") . '</p>';
      break;
  }
}

/**
 * Implements hook_menu().
 */
function system_status_menu() {
  $items = array();
  $items['admin/reports/system_status'] = array(
    'title' => 'System Status',
    'description' => 'Output of the System status module',
    'access callback' => 'system_status_access_callback',
    'access arguments' => array(
      3,
    ),
    'page callback' => 'system_status_status_page',
    'file' => 'system_status_status.page.inc',
  );
  $items['admin/config/system/system_status'] = array(
    'title' => 'System Status',
    'description' => 'Configuration for System status module',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'system_status_form',
    ),
    'file' => 'system_status.admin.inc',
    'access arguments' => array(
      'administer site configuration',
    ),
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

/**
 * Access callback: Check authorized IP.
 * 
 * @see system_status_menu()
 */
function system_status_access_callback($token = FALSE) {
  if ((variable_get('system_status_need_protect_token', 0) == 1 || variable_get('system_status_service_allow_drupalstatus', 0) == 1) && $token !== variable_get('system_status_token', "")) {
    return FALSE;
  }
  $ip_address = ip_address();
  if (variable_get('system_status_service_allow_drupalstatus', 0) == 1) {
    if ($ip_address == gethostbyname("status.drupalstatus.org")) {
      return TRUE;
    }
  }
  if (variable_get('system_status_public_allow_public', 1) == 1) {

    // I took the easy way out here since i didn't want
    // to bother writing something to match v6 subnets.
    $allowed_ips = explode(',', variable_get('system_status_public_allow_ips', '127.0.0.1,::1'));
    foreach ($allowed_ips as &$address) {
      if ($ip_address === $address) {
        return TRUE;
      }
    }
  }
  return FALSE;
}

Functions

Namesort descending Description
system_status_access_callback Access callback: Check authorized IP.
system_status_help Implements hook_help().
system_status_menu Implements hook_menu().