class hackedFileHasher in Hacked! 6.2
Same name and namespace in other branches
- 7.2 includes/hackedFileHasher.inc \hackedFileHasher
Base class for the different ways that files can be hashed.
Hierarchy
- class \hackedFileHasher
Expanded class hierarchy of hackedFileHasher
File
- includes/
hacked_project.inc, line 688
View source
class hackedFileHasher {
/**
* Returns a hash of the given filename.
*
* Ignores file line endings
*/
function hash($filename) {
if (file_exists($filename)) {
if ($hash = $this
->cache_get($filename)) {
return $hash;
}
else {
$hash = $this
->perform_hash($filename);
$this
->cache_set($filename, $hash);
return $hash;
}
}
}
function cache_set($filename, $hash) {
cache_set($this
->cache_key($filename), $hash, HACKED_CACHE_TABLE, strtotime('+7 days'));
}
function cache_get($filename) {
$cache = cache_get($this
->cache_key($filename), HACKED_CACHE_TABLE);
if (!empty($cache->data)) {
return $cache->data;
}
}
function perform_hash($filename) {
return '';
}
function cache_key($filename) {
$key = array(
'filename' => $filename,
'mtime' => filemtime($filename),
'class_name' => get_class($this),
);
return sha1(serialize($key));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
hackedFileHasher:: |
function | |||
hackedFileHasher:: |
function | |||
hackedFileHasher:: |
function | |||
hackedFileHasher:: |
function | Returns a hash of the given filename. | ||
hackedFileHasher:: |
function | 2 |