Skip to content

Commit

Permalink
fix typos and reduce logging
Browse files Browse the repository at this point in the history
  • Loading branch information
cowpod committed Nov 13, 2024
1 parent 8fb515a commit 72ca83e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions functions/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
15 changes: 7 additions & 8 deletions functions/delete-mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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."}');
}
2 changes: 1 addition & 1 deletion functions/mod_extract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down

0 comments on commit 72ca83e

Please sign in to comment.