You are here

function acquia_spi_get_platform in Acquia Connector 6.2

Same name and namespace in other branches
  1. 6 acquia_spi/acquia_spi.module \acquia_spi_get_platform()
  2. 7.3 acquia_spi/acquia_spi.module \acquia_spi_get_platform()
  3. 7 acquia_spi/acquia_spi.module \acquia_spi_get_platform()
  4. 7.2 acquia_spi/acquia_spi.module \acquia_spi_get_platform()

Gather platform specific information.

Return value

An associative array keyed by a platform information type.

2 calls to acquia_spi_get_platform()
acquia_spi_boot in acquia_spi/acquia_spi.module
Implements hook_boot().
acquia_spi_get in acquia_spi/acquia_spi.module
Gather site profile information about this site.

File

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

Code

function acquia_spi_get_platform() {
  global $db_type;
  $server = $_SERVER;
  $database_type = $db_type;

  // Webserver detection is based on name being before the slash, and
  // version being after the slash.
  preg_match('!^([^/]+)(/.+)?$!', $server['SERVER_SOFTWARE'], $webserver);
  if (isset($webserver[1]) && stristr($webserver[1], 'Apache') && function_exists('apache_get_version')) {
    $webserver[2] = apache_get_version();
    $apache_modules = apache_get_modules();
  }
  else {
    $apache_modules = '';
  }

  // Get some basic PHP vars
  $php_quantum = array(
    'memory_limit' => ini_get('memory_limit'),
    'register_globals' => ini_get('register_globals'),
    'post_max_size' => ini_get('post_max_size'),
    'max_execution_time' => ini_get('max_execution_time'),
    'upload_max_filesize' => ini_get('upload_max_filesize'),
    'error_log' => ini_get('error_log'),
    'error_reporting' => ini_get('error_reporting'),
    'display_errors' => ini_get('display_errors'),
    'log_errors' => ini_get('log_errors'),
    'session.cookie_domain' => ini_get('session.cookie_domain'),
    'session.cookie_lifetime' => ini_get('session.cookie_lifetime'),
    'newrelic.appname' => ini_get('newrelic.appname'),
    'SERVER' => $server,
    'sapi' => php_sapi_name(),
  );
  $platform = array(
    'php' => PHP_VERSION,
    'webserver_type' => isset($webserver[1]) ? $webserver[1] : '',
    'webserver_version' => isset($webserver[2]) ? $webserver[2] : '',
    'apache_modules' => $apache_modules,
    'php_extensions' => get_loaded_extensions(),
    'php_quantum' => $php_quantum,
    'database_type' => $database_type,
    'database_version' => db_version(),
    'system_type' => php_uname('s'),
    // php_uname() only accepts one character, so we need to concatenate ourselves.
    'system_version' => php_uname('r') . ' ' . php_uname('v') . ' ' . php_uname('m') . ' ' . php_uname('n'),
    'mysql' => in_array($database_type, array(
      'mysql',
      'mysqli',
    )) ? acquia_spi_get_platform_mysql_data() : array(),
  );

  // Never send NULL (or FALSE?) - that causes hmac errors.
  foreach ($platform as $key => $value) {
    if (empty($platform[$key])) {
      $platform[$key] = '';
    }
  }
  return $platform;
}