You are here

function acquia_agent_site_status_access in Acquia Connector 7.3

Same name and namespace in other branches
  1. 6.2 acquia_agent/acquia_agent.module \acquia_agent_site_status_access()
  2. 7.2 acquia_agent/acquia_agent.module \acquia_agent_site_status_access()

Access callback for acquia_agent_site_status().

1 string reference to 'acquia_agent_site_status_access'
acquia_agent_menu in acquia_agent/acquia_agent.module
Implements hook_menu().

File

acquia_agent/acquia_agent.module, line 87
Acquia Agent securely sends information to Acquia Insight.

Code

function acquia_agent_site_status_access() {

  // If we don't have all the query params, leave now.
  if (!isset($_GET['key'], $_GET['nonce'])) {
    return FALSE;
  }
  $sub_data = acquia_agent_settings('acquia_subscription_data');
  $sub_uuid = _acquia_agent_get_id_from_sub($sub_data);
  if (!empty($sub_uuid)) {
    $expected_hash = hash('sha1', "{$sub_uuid}:{$_GET['nonce']}");

    // If the generated hash matches the hash from $_GET['key'], we're good.
    if ($_GET['key'] === $expected_hash) {
      return TRUE;
    }
  }

  // Log request if validation failed and debug is enabled.
  $acquia_debug = variable_get('acquia_agent_debug', FALSE);
  if ($acquia_debug) {
    $info = array(
      'sub_data' => $sub_data,
      'sub_uuid_from_data' => $sub_uuid,
      'expected_hash' => isset($expected_hash) ? $expected_hash : '',
      'get' => $_GET,
      'server' => $_SERVER,
      'request' => $_REQUEST,
    );
    watchdog('acquia_agent', 'Site status request: @data', array(
      '@data' => var_export($info, TRUE),
    ));
  }
  return FALSE;
}