fixes #56 and added tool to recalculate all hashes

This commit is contained in:
Chris
2018-06-15 20:30:00 +02:00
parent 5792bf06e2
commit eefaaf1643
2 changed files with 36 additions and 10 deletions

View File

@@ -0,0 +1,24 @@
<?php
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).DS.'..');
echo "[i] Starting recreation of hashes.csv\n";
$dir = ROOT.DS.'upload'.DS;
$dh = opendir($dir);
$fp = fopen($dir.'hashes.csv','w');
if(!$fp)
exit("[X] Can't open hashes.csv to write");
while (false !== ($hash = readdir($dh))) {
$img = $dir.$hash.DS.$hash;
if(!file_exists($img) || $hash=='.' || $hash=='..') continue;
echo " [s] Calculating $hash\n";
$sha1 = sha1_file($img);
fwrite($fp,"$sha1;$hash\n");
}
fclose($fp);
echo "[i] Finished\n";