This commit is contained in:
Lee 2023-04-15 19:04:15 +01:00
parent af520d265d
commit 26cb9e0b8f

@ -47,20 +47,17 @@ if (!isZipFile($map["name"])) {
die(); die();
} }
$fileHash = null; $fileHash = hash_file("sha256", $file); // the hash of the file
try {
$fileHash = hash_file("sha256", $file); // the hash of the file
} catch (Exception $e) {
}
$exists = false; $exists = false;
if ($fileHash != null) { foreach (scandir($target_dir) as $file) { // scan the maps directory for a file with the same hash
foreach (scandir($target_dir) as $file) { // scan the maps directory for a file with the same hash if ($file == "." || $file == "..") { // ignore the . and .. files
if (hash_file("sha256", $target_dir . $file) == $fileHash) { continue;
$mapId = pathinfo($file, PATHINFO_FILENAME); }
$exists = true; if (hash_file("sha256", $target_dir . $file) == $fileHash) {
break; $mapId = pathinfo($file, PATHINFO_FILENAME);
} $exists = true;
break;
} }
} }