add invalid hash check
This commit is contained in:
parent
e2b96b37c6
commit
af520d265d
10
upload.php
10
upload.php
@ -47,15 +47,21 @@ if (!isZipFile($map["name"])) {
|
||||
die();
|
||||
}
|
||||
|
||||
$fileHash = hash_file("sha256", $file); // the hash of the file
|
||||
$fileHash = null;
|
||||
try {
|
||||
$fileHash = hash_file("sha256", $file); // the hash of the file
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
$exists = false;
|
||||
foreach (scandir($target_dir) as $file) { // scan the maps directory for a file with the same hash
|
||||
if ($fileHash != null) {
|
||||
foreach (scandir($target_dir) as $file) { // scan the maps directory for a file with the same hash
|
||||
if (hash_file("sha256", $target_dir . $file) == $fileHash) {
|
||||
$mapId = pathinfo($file, PATHINFO_FILENAME);
|
||||
$exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($exists) { // if the file already exists, redirect to the existing file
|
||||
|
Reference in New Issue
Block a user