You are here

function acquia_spi_send_module_data in Acquia Connector 6.2

Same name and namespace in other branches
  1. 7.2 acquia_spi/acquia_spi.module \acquia_spi_send_module_data()

Send a file's contents to the requestor

1 string reference to 'acquia_spi_send_module_data'
acquia_spi_xmlrpc in acquia_spi/acquia_spi.module
Implementation of hook_xmlrpc().

File

acquia_spi/acquia_spi.module, line 221
Send site profile information (NSPI) and system data to Acquia Insight.

Code

function acquia_spi_send_module_data($data = array()) {

  // We only do this if we are on SSL
  $via_ssl = isset($_SERVER['HTTPS']) ? TRUE : FALSE;
  if (variable_get('acquia_spi_module_diff_data', 1) && $via_ssl && acquia_agent_has_credentials() && isset($data['body']['file']) && acquia_spi_valid_request($data, $data['body']['file'])) {

    // If our checks pass muster, then we'll provide this data.
    // If the file variable is set and if the user has allowed file diffing.
    $file = $data['body']['file'];
    $document_root = getcwd();
    $file_path = realpath($document_root . '/' . $file);

    // Be sure the file being requested is within the webroot and is not any
    // settings.php file.
    if (is_file($file_path) && strpos($file_path, $document_root) === 0 && strpos($file_path, 'settings.php') === FALSE) {
      $file_contents = file_get_contents($file_path);
      header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
      header("Content-Type:text");
      header("Cache-Control: no-cache");
      header("Pragma: no-cache");
      return $file_contents;
    }
  }
  return FALSE;
}