Generate a checksum for a given filename.

Paramètres

$filename: filename

Return value

Checksum value.

2 calls to advagg_checksum()
advagg_flush_caches dans ./advagg.module
Implements hook_flush_caches().
advagg_insert_bundle_db dans ./advagg.module
Insert info into the advagg_files and advagg_bundles database.

Fichier

./advagg.module, line 1408

Code

function advagg_checksum($filename) {
    advagg_clearstatcache(TRUE, $filename);
    if (file_exists($filename)) {
        $mode = variable_get('advagg_checksum_mode', ADVAGG_CHECKSUM_MODE);
        if ($mode == 'filemtime' && function_exists('filemtime')) {
            $checksum = @filemtime($filename);
            if ($checksum === FALSE) {
                touch($filename);
                advagg_clearstatcache(TRUE, $filename);
                $checksum = @filemtime($filename);
                // Use md5 as a last option.
                if ($checksum === FALSE) {
                    $checksum = md5(file_get_contents($filename));
                }
            }
        }
        elseif ($mode = 'md5' && function_exists('md5')) {
            $checksum = md5(file_get_contents($filename));
        }
    }
    else {
        $checksum = '-1';
    }
    return $checksum;
}