You are here

function _acquia_spi_generate_hashes in Acquia Connector 6.2

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

Recursive helper function for acquia_spi_file_hashes().

2 calls to _acquia_spi_generate_hashes()
acquia_spi_file_hashes in acquia_spi/acquia_spi.module
Gather hashes of all important files, ignoring line ending and CVS Ids
acquia_spi_get_modules in acquia_spi/acquia_spi.module
Gather information about modules on the site.

File

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

Code

function _acquia_spi_generate_hashes($dir, $exclude_dirs = array(), $limit_dirs = array(), $module_break = FALSE, $orig_dir = NULL) {
  $hashes = array();
  $fileinfo = array();

  // Ensure that we have not nested into another module's dir
  if ($dir != $orig_dir && $module_break) {
    if (is_dir($dir) && ($handle = opendir($dir))) {
      while ($file = readdir($handle)) {
        if (stristr($file, '.module')) {
          return;
        }
      }
    }
  }
  if (isset($handle)) {
    closedir($handle);
  }

  // Standard nesting function
  if (is_dir($dir) && ($handle = opendir($dir))) {
    while ($file = readdir($handle)) {
      if (!in_array($file, array(
        '.',
        '..',
        'CVS',
        '.svn',
        '.git',
      ))) {
        $path = $dir == '.' ? $file : "{$dir}/{$file}";
        if (is_dir($path) && !in_array($path, $exclude_dirs) && (empty($limit_dirs) || in_array($path, $limit_dirs)) && $file != 'translations') {
          list($sub_hashes, $sub_fileinfo) = _acquia_spi_generate_hashes($path, $exclude_dirs);
          $hashes = array_merge($sub_hashes, $hashes);
          $fileinfo = array_merge($sub_fileinfo, $fileinfo);
          $hashes[$path] = acquia_spi_hash_path($path);
        }
        elseif (acquia_spi_is_manifest_type($file)) {
          $hashes[$path] = acquia_spi_hash_path($path);
          $owner = fileowner($path);
          if (function_exists('posix_getpwuid')) {
            $userinfo = posix_getpwuid($owner);
            $owner = $userinfo['name'];
          }
          $fileinfo[$path] = 'mt:' . filemtime($path) . '$p:' . substr(sprintf('%o', fileperms($path)), -4) . '$o:' . $owner . '$s:' . filesize($path);
        }
      }
    }
    closedir($handle);
  }

  //return array('hashes'=>$hashes, 'fileinfo'=>$fileinfo);
  return array(
    $hashes,
    $fileinfo,
  );
}