2017-12-16 21:15:12 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
2017-12-18 14:02:24 +00:00
|
|
|
$bkup_dir = __DIR__ . '/../data/';
|
2017-12-16 21:15:12 +00:00
|
|
|
|
|
|
|
$file_list = glob($bkup_dir . '*.xml');
|
|
|
|
|
|
|
|
$hashes = array();
|
|
|
|
foreach ($file_list as $file) {
|
|
|
|
$filename = basename($file);
|
|
|
|
$file_hash = sha1_file($file);
|
|
|
|
|
|
|
|
if (isset($hashes[$file_hash])) {
|
|
|
|
$old_file = $hashes[$file_hash];
|
|
|
|
if (md5_file($file) == md5_file($bkup_dir . $old_file)) {
|
|
|
|
echo 'Duplicate file: ' . $filename . ' (first: ' . $old_file . ')' . PHP_EOL;
|
|
|
|
unlink($file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
echo 'Possible SHA1 collision?' . PHP_EOL;
|
|
|
|
}
|
|
|
|
|
|
|
|
$hashes[$file_hash] = $filename;
|
|
|
|
}
|