From 26cb9e0b8f5975f701a2f3e92f7b244084143943 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 15 Apr 2023 19:04:15 +0100 Subject: [PATCH] im silly --- upload.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/upload.php b/upload.php index 93349b8..c406e76 100644 --- a/upload.php +++ b/upload.php @@ -47,20 +47,17 @@ if (!isZipFile($map["name"])) { die(); } -$fileHash = null; -try { - $fileHash = hash_file("sha256", $file); // the hash of the file -} catch (Exception $e) { -} +$fileHash = hash_file("sha256", $file); // the hash of the file $exists = false; -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; - } +foreach (scandir($target_dir) as $file) { // scan the maps directory for a file with the same hash + if ($file == "." || $file == "..") { // ignore the . and .. files + continue; + } + if (hash_file("sha256", $target_dir . $file) == $fileHash) { + $mapId = pathinfo($file, PATHINFO_FILENAME); + $exists = true; + break; } }