From 72ca83e630b5d3fe90ee0133f73069a9da76b4db Mon Sep 17 00:00:00 2001 From: Henry Gross-Hellsen <6283258+cowpod@users.noreply.github.com> Date: Wed, 13 Nov 2024 01:32:21 -0800 Subject: [PATCH] fix typos and reduce logging --- functions/db.php | 4 ++-- functions/delete-mod.php | 15 +++++++-------- functions/mod_extract.php | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/functions/db.php b/functions/db.php index 01f3934..0760f36 100644 --- a/functions/db.php +++ b/functions/db.php @@ -166,12 +166,12 @@ public function sanitize($str) { } public function insert_id() { - error_log("db.php: insert_id(): ".$this->conn->lastInsertId()); + // error_log("db.php: insert_id(): ".$this->conn->lastInsertId()); return $this->conn->lastInsertId(); } public function error() { - error_log("db.php: error(): ".$this->conn->errorInfo()); + // error_log("db.php: error(): ".$this->conn->errorInfo()); return $this->conn->errorInfo(); } } diff --git a/functions/delete-mod.php b/functions/delete-mod.php index 7945075..5096527 100644 --- a/functions/delete-mod.php +++ b/functions/delete-mod.php @@ -90,16 +90,15 @@ // remove it from db $db->execute("DELETE FROM `mods` WHERE `id` = '".$db->sanitize($_GET['id'])."'"); - if ($mod['type']=='mod' && (!isset($_GET['force']) || !$_GET['force']=='true')) { + if ($mod['type']=='mod' && !(isset($_GET['force']) && $_GET['force']=='true')) { // check if theres any other mod entries with the same file - $mod2q = $db->query("SELECT COUNT(*) AS count FROM `mods` WHERE `filename` = '".$mod['filename']."'"); - if ($mod2q && sizeof($mod2q)==1 && $mod2q[0]['count']>0) { + $mod2q = $db->query("SELECT 1 FROM `mods` WHERE `filename` = '".$mod['filename']."'"); + if ($mod2q && sizeof($mod2q)>=1) { die('{"status":"succ","message":"Mod version deleted from database, but file is still in use by other mod version."}'); // leave file on disk } - } else { - if (file_exists("../".$mod['type']."s/".$mod['filename'])) { - unlink("../".$mod['type']."s/".$mod['filename']); - } - die('{"status":"succ","message":"Mod version deleted."}'); } + if (file_exists("../".$mod['type']."s/".$mod['filename'])) { + unlink("../".$mod['type']."s/".$mod['filename']); + } + die('{"status":"succ","message":"Mod version deleted."}'); } diff --git a/functions/mod_extract.php b/functions/mod_extract.php index 3512df7..0237bdd 100644 --- a/functions/mod_extract.php +++ b/functions/mod_extract.php @@ -18,7 +18,7 @@ $filenameq = $db->query("SELECT `filename` FROM `mods` WHERE `id` = ".$db->sanitize($_GET['id'])); if ($filenameq) { - assert(sizeof($q)==1); + assert(sizeof($filenameq)==1); $filenameq=$filenameq[0]; } $fileName = $filenameq['filename'];