function acquia_spi_hash_path in Acquia Connector 7
Same name and namespace in other branches
- 6.2 acquia_spi/acquia_spi.module \acquia_spi_hash_path()
- 6 acquia_spi/acquia_spi.module \acquia_spi_hash_path()
- 7.3 acquia_spi/acquia_spi.module \acquia_spi_hash_path()
- 7.2 acquia_spi/acquia_spi.module \acquia_spi_hash_path()
Calculate the sha1 hash for a path.
Parameters
$path: The name of the file or a directory.
Return value
bas64 encoded sha256 hash. 'hash' is an empty string for directories.
1 call to acquia_spi_hash_path()
- _acquia_spi_generate_hashes in acquia_spi/
acquia_spi.module - Recursive helper function for acquia_spi_file_hashes().
File
- acquia_spi/
acquia_spi.module, line 257 - Send site profile information (SPI) and system data to Acquia Network.
Code
function acquia_spi_hash_path($path = '') {
$hash = '';
if (file_exists($path)) {
if (!is_dir($path)) {
$string = file_get_contents($path);
// Remove trailing whitespace
$string = rtrim($string);
// Replace all line endings and CVS/svn Id tags
$string = preg_replace('/\\$Id[^;<>{}\\(\\)\\$]*\\$/', 'x$' . 'Id$', $string);
$string = preg_replace('/\\r\\n|\\n|\\r/', ' ', $string);
$hash = base64_encode(hash('sha256', $string, TRUE));
}
}
return $hash;
}