diff --git a/wizzardRedux/admin/clean.php b/wizzardRedux/admin/clean.php new file mode 100644 index 0000000..9f02570 --- /dev/null +++ b/wizzardRedux/admin/clean.php @@ -0,0 +1,65 @@ +\n"; +} +else +{ + echo "Deleting game dupes failed!
\n".mysqli_error($link); +} + +// Delete dupes from files +$query = "DELETE files + FROM files LEFT OUTER JOIN ( + SELECT MIN(id) as id, setid, name, type, lastupdated + FROM files + GROUP BY setid, name, type, lastupdated + ) as KeepRows ON + files.id = KeepRows.id + WHERE KeepRows.id IS NULL"; +if (gettype($result) == "boolean" && $result) +{ + echo "Deleting file dupes succeeded!
\n"; +} +else +{ + echo "Deleting file dupes failed!
\n".mysqli_error($link); +} + +// Delete orphaned checksums +$query = "DELETE FROM checksums + WHERE NOT EXISTS ( + SELECT * + FROM files + WHERE checksums.file = files.id)"; + +$query = "SELECT * FROM sources"; +$result = mysqli_query($link, $query); +if (gettype($result) == "boolean" && $result) +{ + echo "Deleting checksum orphans succeeded!
\n"; +} +else +{ + echo "Deleting checksum orphans failed!
\n".mysqli_error($link); +} + +?> \ No newline at end of file diff --git a/wizzardRedux/admin/index.php b/wizzardRedux/admin/index.php index 5f1c33d..b71ea9e 100644 --- a/wizzardRedux/admin/index.php +++ b/wizzardRedux/admin/index.php @@ -44,6 +44,7 @@ Administrative Functions Homepage
  • Check for new files online
  • Generate an array of names for all MAME softlists
  • Generate an array of names for all No-Intro sources
  • +
  • Clean the database of dupes and orphans
  • "; }