From d3acae2ed78698141b7fac8bf8a835242c184dd7 Mon Sep 17 00:00:00 2001
From: Matt Nadareski
Date: Thu, 28 Jul 2016 11:02:20 -0700
Subject: [PATCH] Cleanup
This is a bulk cleanup of all of the functions that have since been
surpassed by their desktop counterparts. A lot of effort went into these
original features but the effort that was expended to make the desktop
better far exceeded this. I thank the efforts of everyone who helped to
make the web version a reality in the first place since it provided the
strong base that SabreTools has become. This will still be maintained
purely as a way of checking files online as will be required when the
WoD DATs are properly recreated.
---
admin/clean.php | 124 ----
admin/deheader.php | 144 -----
admin/edit.php | 874 ---------------------------
admin/import.php | 564 ------------------
admin/index.php | 7 -
admin/parenting.php | 5 -
admin/parenting/add_parent_db.php | 24 -
admin/parenting/index.php | 115 ----
admin/parenting/list_parents.php | 98 ---
admin/parenting/list_sets.php | 131 ----
admin/parenting/rem_parent_db.php | 3 -
admin/parenting/set_parent.php | 25 -
admin/reset.php | 43 --
headers/a7800.xml | 17 -
headers/fds.xml | 25 -
headers/lynx.xml | 17 -
headers/mega.xml | 87 ---
headers/n64.xml | 24 -
headers/nes.xml | 13 -
headers/snes.xml | 24 -
includes/functions.php | 153 -----
includes/remapping.php | 956 ------------------------------
index.php | 9 -
pages/generate.php | 723 ----------------------
pages/view.php | 279 ---------
sites/CPC-Power.php | 8 +-
26 files changed, 5 insertions(+), 4487 deletions(-)
delete mode 100644 admin/clean.php
delete mode 100644 admin/deheader.php
delete mode 100644 admin/edit.php
delete mode 100644 admin/import.php
delete mode 100644 admin/parenting.php
delete mode 100644 admin/parenting/add_parent_db.php
delete mode 100644 admin/parenting/index.php
delete mode 100644 admin/parenting/list_parents.php
delete mode 100644 admin/parenting/list_sets.php
delete mode 100644 admin/parenting/rem_parent_db.php
delete mode 100644 admin/parenting/set_parent.php
delete mode 100644 admin/reset.php
delete mode 100644 headers/a7800.xml
delete mode 100644 headers/fds.xml
delete mode 100644 headers/lynx.xml
delete mode 100644 headers/mega.xml
delete mode 100644 headers/n64.xml
delete mode 100644 headers/nes.xml
delete mode 100644 headers/snes.xml
delete mode 100644 includes/remapping.php
delete mode 100644 pages/generate.php
delete mode 100644 pages/view.php
diff --git a/admin/clean.php b/admin/clean.php
deleted file mode 100644
index 9d453a3..0000000
--- a/admin/clean.php
+++ /dev/null
@@ -1,124 +0,0 @@
-\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 files
-$query = "DELETE FROM files
- WHERE NOT EXISTS (
- SELECT *
- FROM games
- WHERE files.setid = games.id)";
-$result = mysqli_query($link, $query);
-if (gettype($result) == "boolean" && $result)
-{
- echo "Deleting file orphans succeeded! \n";
-}
-else
-{
- echo "Deleting file orphans failed! \n".mysqli_error($link);
-}
-
-// Delete orphaned checksums
-$query = "DELETE FROM checksums
- WHERE NOT EXISTS (
- SELECT *
- FROM files
- WHERE checksums.file = files.id)";
-$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);
-}
-
-// Fix the names of games that have spacing issues
-$query = "SELECT * FROM games
- WHERE name LIKE ' %'
- ORDER BY name ASC";
-$result = mysqli_query($link, $query);
-
-while ($line = mysqli_fetch_assoc($result))
-{
- $query = "UPDATE games
- SET name='".trim($line["name"])."'
- WHERE id=".$line["id"];
- $result2 = mysqli_query($link, $query);
- if (gettype($result2) == "boolean" && $result2)
- {
- echo "Trimming game names succeeded! \n";
- }
- else
- {
- echo "Trimming game names failed! \n".mysqli_error($link);
- }
-}
-
-// Fix the names of files that have spacing issues
-$query = "SELECT * FROM files
- WHERE name LIKE ' %'
- ORDER BY name ASC";
-$result = mysqli_query($link, $query);
-
-while ($line = mysqli_fetch_assoc($result))
-{
- $query = "UPDATE files
- SET name='".trim($line["name"])."'
- WHERE id=".$line["id"];
- $result2 = mysqli_query($link, $query);
- if (gettype($result2) == "boolean" && $result2)
- {
- echo "Trimming file names succeeded! \n";
- }
- else
- {
- echo "Trimming file names failed! \n".mysqli_error($link);
- }
-}
-
-?>
\ No newline at end of file
diff --git a/admin/deheader.php b/admin/deheader.php
deleted file mode 100644
index 9035b02..0000000
--- a/admin/deheader.php
+++ /dev/null
@@ -1,144 +0,0 @@
- 128,
- "fds" => 16,
- "lynx" => 64,
- "nes" => 16,
- "snes" => 512,
-);
-
-$dir = (isset($_GET["dir"]) ? urldecode($_GET["dir"]) : "");
-$type = (isset($_GET["type"]) ? $_GET["type"] : "");
-
-echo "
Remove File Headers
";
-
-// If the directory isn't set or it's not a directory, prompt the user to enter a directory and set which type it is
-if (trim($dir) == "" || !is_dir($dir))
-{
- echo <<
-
- Enter a directory name:
- Select rom type:
-EOL;
-
- foreach ($types as $typename => $val)
- {
- echo "\t".$typename." \n";
- }
-
- echo <<
-
-
-EOL;
-}
-
-// If a directory is given but the type isn't defined or it's incorrect, give the options for file type
-elseif (trim($type) == "" || !$types[$type] === "")
-{
- echo <<
-
-
- Select rom type:
-EOL;
-
- foreach ($types as $typename => $val)
- {
- echo "\t".$typename." \n";
- }
-
- echo <<
-
-
-EOL;
-}
-
-// Otherwise, process the folder
-else
-{
- $dir = $dir."/";
- $roms = scandir($dir);
- echo "
\n";
-}
-
-?>
\ No newline at end of file
diff --git a/admin/edit.php b/admin/edit.php
deleted file mode 100644
index 822194e..0000000
--- a/admin/edit.php
+++ /dev/null
@@ -1,874 +0,0 @@
-";
-
- $query = "UPDATE games SET system=0 WHERE system=".$system;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "Files altered successfully! No further action required. ";
- }
- else
- {
- echo "Something has gone wrong, please manually alter all files with system '".$system."' to have value 0 ";
- }
- }
- else
- {
- echo "System could not be deleted. Try again later. ";
- }
- }
- // If a source is being removed (can't remove default)
- elseif ($remove == "source" && $source != "" && $source != "0")
- {
- $query = "DELETE FROM source where id=".$system;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "Source deleted successfully! Altering all related files. ";
-
- $query = "UPDATE games SET source=0 WHERE source=".$source;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "Files altered successfully! No further action required. ";
- }
- else
- {
- echo "Something has gone wrong, please manually alter all files with source '".$source."' to have value 0 ";
- }
- }
- else
- {
- echo "System could not be deleted. Try again later. ";
- }
- }
- // If a game is being removed
- elseif ($remove == "game" && $game != "")
- {
- $query = "DELETE FROM games
- JOIN files
- ON games.id=files.setid
- JOIN checksums
- ON files.id=checksums.file
- WHERE games.id=".$game;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "Game and dependent files deleted successfully! ";
- }
- else
- {
- echo "Could not delete game or dependent files. Please try again ";;
- }
- }
- // If a file is being removed
- elseif ($remove == "file" && $file != "")
- {
- $query = "DELETE FROM files
- JOIN checksums
- ON files.id=checksums.file
- WHERE files.id=".$file;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "File deleted successfully! ";
- }
- else
- {
- echo "Could not delete file. Please try again ";;
- }
- }
-}
-// Handle the POST cases. They do not have to be mutually exclusive
-else
-{
- // If a system is being edited or added via POST
- if ($system != "" && $manufacturer != "" && $systemname != "")
- {
- // If the system is new and being added
- if ($system == "-1")
- {
- // Always check if this exact combination is already there. This might have been in error
- $query = "SELECT * FROM systems WHERE manufacturer='".$manufacturer." AND system='".$systemname."'";
- $result = mysqli_query($link, $query);
-
- // If we find this system, tell the user and don't move forward
- if (gettype($result) != "boolean" && mysqli_num_rows($result) > 0)
- {
- echo "This system has been found. No further action is required ";
- }
- // If the system is not found, add it
- else
- {
- $query = "INSERT INTO systems (manufacturer, system) VALUES ('".$manufacturer."', '".$systemname."')";
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The system '".$manufacturer." - ".$systemname."' has been added successfully! ";
- }
- else
- {
- echo "The system '".$manufacturer." - ".$systemname."' could not be added, try again later ";
- }
- }
- }
- // If the system is being edited
- else
- {
- // Check if the system exists first
- $query = "SELECT * FROM systems WHERE id=".$system;
- $result = mysqli_query($link, $query);
-
- // If we don't find the system, don't add it. This might have been in error
- if (gettype($result) == "boolean" && !$result)
- {
- echo "The system with id '".$system."' could not be found, try again later ";
- }
- // If we find the system, update with the new information, if not a duplicate of another
- else
- {
- $query = "SELECT * FROM systems WHERE manufacturer='".$manufacturer." AND system='".$systemname."'";
- $result = mysqli_query($link, $query);
-
- // If the system is found or unchanged, don't readd it
- if (gettype($result) != "boolean" && mysqli_num_rows($result) > 0)
- {
- echo "This system has been found. No further action is required ";
- }
- // If the system really has changed or is not a duplicate, add it
- else
- {
- $query = "UPDATE systems SET manufacturer='".$manufacturer."', system='".$systemname."' WHERE id=".$system;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The system '".$manufacturer." - ".$systemname."' has been updated successfully! ";
- }
- else
- {
- echo "The system '".$manufacturer." - ".$systemname."' could not be updated, try again later ";
- }
- }
- }
- }
- }
- // If a source is being edited or added via POST
- if ($source != "" && $sourcename != "" && $url != "")
- {
- // If the source is new and being added
- if ($source == "-1")
- {
- // Always check if this exact combination is already there. This might have been in error
- $query = "SELECT * FROM sources WHERE name='".$sourcename."'";
- $result = mysqli_query($link, $query);
-
- // If we find this source, tell the user and don't move forward
- if (gettype($result) != "boolean" && mysqli_num_rows($result) > 0)
- {
- echo "This source has been found. No further action is required ";
- }
- // If the source is not found, add it
- else
- {
- $query = "INSERT INTO sources (name, url) VALUES ('".$sourcename."', '".$url."')";
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The source '".$sourcename."' has been added successfully! ";
- }
- else
- {
- echo "The source '".$sourcename."' could not be added, try again later ";
- }
- }
- }
- // If the source is being edited
- else
- {
- // Check if the source exists first
- $query = "SELECT * FROM sources WHERE id=".$system;
- $result = mysqli_query($link, $query);
-
- // If we don't find the source, don't add it. This might have been in error
- if (gettype($result) == "boolean" && !$result)
- {
- echo "The source with id '".$source."' could not be found, try again later ";
- }
- // If we find the source, update with the new information, if not a duplicate of another
- else
- {
- $query = "SELECT * FROM sources WHERE name='".$sourcename."'";
- $result = mysqli_query($link, $query);
-
- // If the source is found or unchanged, don't readd it
- if (gettype($result) != "boolean" && mysqli_num_rows($result) > 0)
- {
- echo "This source has been found. No further action is required ";
- }
- // If the source really has changed or is not a duplicate, add it
- else
- {
- $query = "UPDATE sources SET name='".$sourcename."', url='".$url."' WHERE id=".$source;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The source '".$sourcename."' has been updated successfully! ";
- }
- else
- {
- echo "The source '".$sourcename."' could not be updated, try again later ";
- }
- }
- }
- }
- }
- // If a game is being edited or added via POST
- if ($game != "" && $gamename != "" && $system != "" && $source != "")
- {
- // If the game is new and being added
- if ($game == "-1")
- {
- // Always check if this exact combination is already there. This might have been in error
- $query = "SELECT * FROM games WHERE name='".$gamename."' AND system=".$system." AND source=".$source;
- $result = mysqli_query($link, $query);
-
- // If we find this game, tell the user and don't move forward
- if (gettype($result) != "boolean" && mysqli_num_rows($result) > 0)
- {
- echo "This game has been found. No further action is required ";
- }
- // If the game is not found, add it
- else
- {
- $query = "INSERT INTO games (name, system, source) VALUES ('".$gamename."', ".$system.", ".$source.")";
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The game '".$gamename."' has been added successfully! ";
- }
- else
- {
- echo "The game '".$gamename."' could not be added, try again later ";
- }
- }
- }
- // If the game is being edited
- else
- {
- // Check if the game exists first
- $query = "SELECT * FROM games WHERE id=".$game;
- $result = mysqli_query($link, $query);
-
- // If we don't find the game, don't add it. This might have been in error
- if (gettype($result) == "boolean" && !$result)
- {
- echo "The game with id '".$game."' could not be found, try again later ";
- }
- // If we find the game, update with the new information, if not a duplicate of another
- else
- {
- $query = "SELECT * FROM games WHERE name='".$gamename."' AND system=".$system." AND source=".$source;
- $result = mysqli_query($link, $query);
-
- // If the game is found elsewhere or unchanged, don't readd it
- if (gettype($result) != "boolean" && mysqli_num_rows($result) > 0)
- {
- echo "This source has been found. No further action is required ";
- }
- // If the game really has changed or is not a duplicate, add it
- else
- {
- $query = "UPDATE game SET name='".$gamename."', system=".$system.", source=".$source." WHERE id=".$game;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The game '".$gamename."' has been updated successfully! ";
- }
- else
- {
- echo "The game '".$gamename."' could not be updated, try again later ";
- }
- }
- }
- }
- }
- // If a file is being edited or added via POST
- if ($file != "" && $filename != "" && $game != "" && $type != "" &&
- (($type == "rom" && $size != "" && ($crc != "" || $md5 != "" || $sha1 != "")) ||
- ($type == "disk" && ($md5 != "" || $sha1 != ""))))
- {
- // If the file is new and being added
- if ($file == "-1")
- {
- // Always check if this exact combination is already there. This might have been in error
- $query = "SELECT * FROM files
- JOIN checksums ON files.id=checksums.file
- WHERE files.name='".$filename.
- "' AND files.setid=".$game.
- " AND files.type='".$type.
- "' AND checksums.size=".$size.
- "' AND checksums.crc='".$crc.
- "' AND checksums.md5='".$md5.
- "' AND checksums.sha1='".$sha1;
- $result = mysqli_query($link, $query);
-
- // If we find this file, tell the user and don't move forward
- if (gettype($result) != "boolean" && mysqli_num_rows($result) > 0)
- {
- echo "This file has been found. No further action is required ";
- }
- // If the file is not found, add it
- else
- {
- $query = "INSERT INTO files (name, game, type)
- VALUES ('".$filename."', ".$game.", ".$type.")";
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The file '".$filename."' has been added successfully! Adding checksums. ";
-
- $file = mysqli_insert_id($link);
- $query = "INSERT INTO checksums (game, size, crc, md5, sha1)
- VALUES (".$game.", ".$size.", '".$crc."', '".$md5."', '".$sha1."')";
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The checksums have been added! ";
- }
- else
- {
- echo "The checksums could not be added, please try again later ";
- }
- }
- else
- {
- echo "The file '".$filename."' could not be added, try again later ";
- }
- }
- }
- // If the file is being edited
- else
- {
- // Check if the file exists first
- $query = "SELECT * FROM files WHERE id=".$file;
- $result = mysqli_query($link, $query);
-
- // If we don't find the file, don't add it. This might have been in error
- if (gettype($result) == "boolean" && !$result)
- {
- echo "The game with id '".$file."' could not be found, try again later ";
- }
- // If we find the file, update with the new information, if not a duplicate of another
- else
- {
- $query = "SELECT * FROM files
- JOIN checksums ON files.id=checksums.file
- WHERE files.name='".$filename.
- "' AND files.setid=".$game.
- " AND files.type='".$type.
- "' AND checksums.size=".$size.
- "' AND checksums.crc='".$crc.
- "' AND checksums.md5='".$md5.
- "' AND checksums.sha1='".$sha1;
- $result = mysqli_query($link, $query);
-
- // If the file is found elsewhere or unchanged, don't readd it
- if (gettype($result) != "boolean" && mysqli_num_rows($result) > 0)
- {
- echo "This file has been found. No further action is required ";
- }
- // If the source really has changed or is not a duplicate, add it
- else
- {
- $query = "UPDATE file
- JOIN checksums ON files.id=checksums.file
- SET files.name='".$filename.
- "' AND files.setid=".$game.
- " AND files.type='".$type.
- "' AND checksums.size=".$size.
- "' AND checksums.crc='".$crc.
- "' AND checksums.md5='".$md5.
- "' AND checksums.sha1='".$sha1;
- $result = mysqli_query($link, $query);
-
- if (gettype($result) == "boolean" && $result)
- {
- echo "The file '".$filename."' has been updated successfully! ";
- }
- else
- {
- echo "The file '".$filename."' could not be updated, try again later ";
- }
- }
- }
- }
- }
-}
-
-// Assuming there are no relevent params (or processing POST is done), show the basic page
-if ($system == "" && $source == "" && $game == "" && $file == "")
-{
- show_default($link);
-}
-// First and foremost, capture file edit mode. It's exclusive above all others.
-elseif ($file != "")
-{
- // Retrieve the file info
- $query = "SELECT files.id AS file,
- files.name AS name,
- files.type AS type,
- checksums.size AS size,
- checksums.crc AS crc,
- checksums.md5 AS md5,
- checksums.sha1 AS sha1
- FROM files
- JOIN checksums
- ON files.id=checksums.file
- WHERE files.id=".$file;
- $result = mysqli_query($link, $query);
- $rom = mysqli_fetch_assoc($result);
-
- // Now output the editable information
- echo " ";
-
-}
-// Then capture game edit mode, it also takes precidence over the others.
-elseif ($game != "")
-{
- // Retrieve the system listing
- $query = "SELECT id, manufacturer, system FROM systems
- ORDER BY manufacturer ASC,
- system ASC";
- $result = mysqli_query($link, $query);
- $systems = array();
- while ($row = mysqli_fetch_assoc($result))
- {
- array_push($systems, $row);
- }
-
- // Retrieve the sources listing
- $query = "SELECT id, name FROM sources
- ORDER BY name ASC";
- $result = mysqli_query($link, $query);
- $sources = array();
- while ($row = mysqli_fetch_assoc($result))
- {
- array_push($sources, $row);
- }
-
- // Get the total count in the case that it needs limiting
- $query = "SELECT COUNT(*) as count
- FROM systems
- JOIN games
- ON systems.id=games.system
- JOIN sources
- ON games.source=sources.id
- JOIN files
- ON games.id=files.setid
- JOIN checksums
- ON files.id=checksums.file
- WHERE games.id=".$game;
- $count = mysqli_query($link, $query);
- $count = mysqli_fetch_assoc($count);
- $count = $count["count"];
- settype($count, "integer");
-
- // Retrieve the game info
- $query = "SELECT systems.manufacturer AS manufacturer,
- systems.system AS system,
- systems.id AS systemid,
- sources.name AS source,
- sources.id AS sourceid,
- games.name AS game,
- files.id AS file,
- files.name AS name,
- files.type AS type,
- checksums.size AS size,
- checksums.crc AS crc,
- checksums.md5 AS md5,
- checksums.sha1 AS sha1
- FROM systems
- JOIN games
- ON systems.id=games.system
- JOIN sources
- ON games.source=sources.id
- JOIN files
- ON games.id=files.setid
- JOIN checksums
- ON files.id=checksums.file
- WHERE games.id=".$game.
- " LIMIT 50 OFFSET ".($offset == "" ? "0" : ($offset*5)."0");
- $result = mysqli_query($link, $query);
- if (gettype($result) == "boolean" || mysqli_num_rows($result) == 0)
- {
- echo "No game info could be retrieved! There might be an error. ";
- exit;
- }
- $roms = mysqli_fetch_all($result);
- $game_info = $roms[0];
-
- echo " ";
-
- echo " ";
- if ($offset != "" && $offset > 0)
- {
- echo "Last 50 ";
- }
- if ($count > (mysqli_num_rows($result) + ($offset == "" ? 0 : $offset*50)))
- {
- echo "Next 50";
- }
- echo " ";
-
- echo "Back to previous page \n";
-
-}
-else
-{
- // Retrieve source info only so it's not duplicated
- if ($source_set)
- {
- $query = "SELECT name, url FROM sources WHERE id='".$source."'";
- $source_result = mysqli_query($link, $query);
- $source_info = mysqli_fetch_assoc($source_result);
- }
- // Retrieve system info only so it's not duplicated
- if ($system_set)
- {
- $query = "SELECT manufacturer, system FROM systems WHERE id='".$system."'";
- $system_result = mysqli_query($link, $query);
- $system_info = mysqli_fetch_assoc($system_result);
- }
-
- // Get the total count in the case that it needs limiting
- $query = "SELECT COUNT(*) as count
- FROM systems
- JOIN games
- ON systems.id=games.system
- JOIN sources
- ON games.source=sources.id
- WHERE ".
- ($source_set ? "sources.id=".$source : "").
- ($source_set && $system_set ? " AND " : "").
- ($system_set ? "systems.id=".$system : "");
- $count = mysqli_query($link, $query);
- $count = mysqli_fetch_assoc($count);
- $count = $count["count"];
- settype($count, "integer");
-
- // Then get all games assocated
- $query = "SELECT games.name AS name,
- games.id AS id,
- systems.manufacturer AS manufacturer,
- systems.system AS system,
- sources.name AS source
- FROM systems
- JOIN games
- ON systems.id=games.system
- JOIN sources
- ON games.source=sources.id
- WHERE ".
- ($source_set ? "sources.id=".$source : "").
- ($source_set && $system_set ? " AND " : "").
- ($system_set ? "systems.id=".$system : "").
- " ORDER BY games.name ASC
- LIMIT 50 OFFSET ".($offset == "" ? "0" : ($offset*5)."0");
- $games_result = mysqli_query($link, $query);
-
- echo " \n";
-
- echo "
Games With This ".
- ($source_set ? "Source" : "").
- ($source_set && $system_set ? " And " : "").
- ($system_set ? "System" : "")."
\n";
- if (gettype($games_result) != "boolean")
- {
- while ($game = mysqli_fetch_assoc($games_result))
- {
- echo "".$game["name"];
- if ($source_set && !$system_set)
- {
- echo " (".$game["manufacturer"]." - ".$game["system"].")";
- }
- if (!$source_set && $system_set)
- {
- echo " (".$game["source"].")";
- }
- echo " \n";
- }
- echo " ";
- if ($offset != "" && $offset > 0)
- {
- echo "Last 50 ";
- }
- if ($count > (mysqli_num_rows($games_result) + ($offset == "" ? 0 : $offset*50)))
- {
- echo "Next 50";
- }
- echo " ";
- }
- else
- {
- echo "No games could be found!";
- }
- echo " ";
-}
-
-// Requires the mysqli link
-function show_default($link)
-{
- // Retrieve the system listing
- $query = "SELECT id, manufacturer, system FROM systems
- ORDER BY manufacturer ASC,
- system ASC";
- $result = mysqli_query($link, $query);
- $systems = array();
- while ($row = mysqli_fetch_assoc($result))
- {
- array_push($systems, $row);
- }
-
- // Retrieve the sources listing
- $query = "SELECT id, name FROM sources
- ORDER BY name ASC";
- $result = mysqli_query($link, $query);
- $sources = array();
- while ($row = mysqli_fetch_assoc($result))
- {
- array_push($sources, $row);
- }
-
- // Output the input selection form
- echo <<
-
-
Select a System or Source
-
-
-
-
-
Or Add a New One
-\n";
-}
-
-?>
\ No newline at end of file
diff --git a/admin/import.php b/admin/import.php
deleted file mode 100644
index f4e07ab..0000000
--- a/admin/import.php
+++ /dev/null
@@ -1,564 +0,0 @@
-Import From Datfile";
-
-ini_set('max_execution_time', 0); // Set the execution time to infinite. This is a bad idea in production.
-
-// Verify GET variables
-$auto = isset($_GET["auto"]) && $_GET["auto"] == "1";
-$size = isset($_GET["size"]) && $_GET["size"] == "1";
-
-// Set import path
-$importroot = "../temp/import/";
-
-if (!isset($_GET["filename"]))
-{
- // List all files, auto-generate links to proper pages
- echo "
";
}
diff --git a/pages/generate.php b/pages/generate.php
deleted file mode 100644
index d47c14f..0000000
--- a/pages/generate.php
+++ /dev/null
@@ -1,723 +0,0 @@
- "a7800.xml",
- "228" => "fds.xml",
- "31" => "lynx.xml",
- "0" => "mega.xml", // Merged version of all other headers
- "234" => "n64.xml",
- "238" => "nes.xml",
- "241" => "snes.xml", // Self-created to deal with various headers
-);
-
-ini_set('max_execution_time', 0); // Set the execution time to infinite. This is a bad idea in production.
-ini_set("memory_limit", "-1"); // Set the maximum memory to infinite. This is a bad idea in production.
-
-//Get the values for all parameters
-foreach ($getvars as $var)
-{
- $$var = (isset($_GET[$var]) ? trim($_GET[$var]) : "");
-}
-
-//Get the values for all parameters
-foreach ($postvars as $var)
-{
- $$var = (isset($_POST[$var]) ? trim($_POST[$var]) : "");
-}
-
-// Specifically deal with MEGA being set
-if ($mega == "1")
-{
- $system = "";
- $source = "";
-}
-
-// If not generating or creating MEGAMERGED, show the list of all available DATs
-if ($generate != "1" && $mega != "1" && $auto != "1")
-{
- echo <<Export to Datfile
-
-
System
Source
-
-
-
-
";
-
- // If the system is set, it takes precidence in DAT creation
- if ($system != "")
- {
- echo <<
-
-
-
Sources:
-All sources OR Select a source below:\n
-
-EOL;
-
- $query = "SELECT DISTINCT sources.id, sources.name
- FROM systems
- JOIN games
- ON systems.id=games.system
- JOIN sources
- ON games.source=sources.id
- WHERE systems.id=".$system.
- " ORDER BY sources.name";
- $result = mysqli_query($link, $query);
-
- while($src = mysqli_fetch_assoc($result))
- {
- echo "".$src["name"]." ";
- }
- }
-
- // If the source is set, show all values for the source
- else if ($source != "")
- {
- echo <<
-
-
-
Systems:
-All systems OR Select a system below:\n
-
-EOL;
-
- $query = "SELECT DISTINCT systems.id, systems.manufacturer, systems.system
- FROM sources
- JOIN games
- ON sources.id=games.source
- JOIN systems
- ON games.system=systems.id
- WHERE sources.id=".$source.
- " ORDER BY systems.manufacturer, systems.system";
- $result = mysqli_query($link, $query);
-
- while($sys = mysqli_fetch_assoc($result))
- {
- echo "".$sys["manufacturer"]." - ".$sys["system"]." ";
- }
- }
-
- echo "
Datfile format:
-XML Format
-Old Format
-
-
-Create DAT of all available files ";
-}
-
-// If auto is set, create all DATs and zip for distribution
-elseif ($auto == "1")
-{
- echo "
Generate All DATs
";
-
- $query = "SELECT DISTINCT systems.id, systems.manufacturer, systems.system
- FROM systems
- JOIN games
- ON systems.id=games.system
- ORDER BY systems.manufacturer, systems.system";
- $result = mysqli_query($link, $query);
-
- // Generate system-merged and custom DATs
- while($sys = mysqli_fetch_assoc($result))
- {
- echo "Beginning generate ".$sys["manufacturer"]." - ".$sys["system"]." (merged) \n";
- generate_dat($sys["id"], "");
- sleep(2);
-
- $squery = "SELECT DISTINCT sources.id, sources.name
- FROM systems
- JOIN games
- ON systems.id=games.system
- JOIN sources
- ON games.source=sources.id
- WHERE systems.id=".$sys["id"]."
- ORDER BY sources.name";
- $sresult = mysqli_query($link, $squery);
-
- while($src = mysqli_fetch_assoc($sresult))
- {
- // If the source is not one of the import-only ones
- if ((int) $src["id"] > 14)
- {
- echo "Beginning generate ".$sys["manufacturer"]." - ".$sys["system"]." (".$src["name"].") \n";
- generate_dat($sys["id"], $src["id"]);
- sleep(2);
- }
- }
-
- // Free up some memory if possible
- unset($sresult);
- }
-
- // Free up some memory if possible
- unset($result);
-
- // Generate source-merged DATs
- $query = "SELECT DISTINCT sources.id, sources.name
- FROM sources
- JOIN games
- ON sources.id=games.source
- ORDER BY sources.name";
- $result = mysqli_query($link, $query);
-
- while($src = mysqli_fetch_assoc($result))
- {
- echo "Beginning generate ALL (".$src["name"].") \n";
- generate_dat("", $src["id"]);
- sleep(2);
- }
-
- // Free up some memory if possible
- unset($result);
-
- // Create the MEGAMERGED as part of the generation process
- echo "Beginning generate ALL (merged) \n";
- generate_dat("", "");
-
- //echo "Creating new zipfile... \n";
- $zip = new ZipArchive();
- $zip->open("temp/dats-".date("Ymd").".zip", ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
-
- // Seems unnecessary, but helps make sure the zipfile is populated correctly
- $zip->addEmptyDir("merged-system");
- $zip->addEmptyDir("merged-source");
- $zip->addEmptyDir("custom");
-
- //echo "Zipfile created successfully! \n";
- foreach (scandir("temp/output") as $item)
- {
- if (strpos($item, ".xml") !== FALSE || strpos($item, ".dat") !== FALSE)
- {
- //echo "Adding ".$item." \n";
- $zip->addFile("temp/output/".$item,
- (strpos($item, "ALL (merged") !== FALSE ? $item :
- (strpos($item, "merged") !== FALSE ? "merged-system/".$item :
- (strpos($item, "ALL") !== FALSE ? "merged-source/".$item : "custom/".$item))));
- }
- }
-
- $zip->close();
-
- // http://php.net/manual/en/function.unlink.php#109971
- array_map("unlink", glob("temp/output/*.*"));
-}
-
-// If we are generating an individual DAT
-elseif ($generate == "1" || $mega == "1")
-{
- $systems = array();
- $sources = array();
-
- // If we have a source, treat all POST vars as systems
- if ($system == "" && $source != "")
- {
- $sources = $source;
-
- if ($all == "1")
- {
- $systems = "";
- }
- else
- {
- foreach ($_POST as $key => $value)
- {
- if (!in_array($key, $postvars) && $value == "1")
- {
- $systems[] = $key;
- }
- }
-
- $systems = implode(", ", $systems);
- }
- }
- // If we have a system, treat all POST vars as sources
- elseif ($system != "" && $source == "")
- {
- $systems = $system;
-
- if ($all == "1")
- {
- $sources = "";
- }
- else
- {
- foreach ($_POST as $key => $value)
- {
- if (!in_array($key, $postvars) && $value == "1")
- {
- $sources[] = $key;
- }
- }
-
- $sources = implode(", ", $sources);
- }
- }
- // If we have neither, then it's MEGA
- else
- {
- $systems = "";
- $sources = "";
- }
-
- // If the source is not one of the import-only ones
- if (!($sources != "" && sizeof(explode(", ", $sources)) == 1 && (int) $sources <= 14))
- {
- generate_dat($systems, $sources, true);
- }
- exit();
-}
-
-/*
- If just the source is set, create a DAT that has each game suffixed by system and merged
- If just the system is set, create a DAT that has each game suffixed by source and merged (merged)
- If both system and source are set, create a DAT that has each rom unsuffixed and unmerged (custom)
- */
-function generate_dat ($systems, $sources, $lone = false)
-{
- global $link, $headers;
-
- // Get the systems and sources names for the given inputs
- $querysy = "SELECT manufacturer, system FROM systems WHERE id IN (".$systems.")";
- $resultsy = mysqli_query($link, $querysy);
-
- $syslist = "";
- // If the result has data, populate the srclist
- if (gettype($resultsy) != "boolean" && mysqli_num_rows($resultsy) > 0)
- {
- $syslist = array();
- while ($sys = mysqli_fetch_assoc($resultsy))
- {
- $syslist[] = $sys["manufacturer"]." - ".$sys["system"];
- }
- $syslist = implode("; ", (sizeof($syslist) > 3 ? array($syslist[0], $syslist[1], "etc.") : $syslist));
- }
-
- // Free up some memory if possible
- unset($resultsy);
-
- $queryso = "SELECT name FROM sources WHERE id IN (".$sources.")";
- $resultso = mysqli_query($link, $queryso);
-
- $srclist = "";
- // If the result has data, populate the srclist
- if (gettype($resultso) != "boolean" && mysqli_num_rows($resultso) > 0)
- {
- $srclist = array();
- while ($src = mysqli_fetch_assoc($resultso))
- {
- $srclist[] = $src["name"];
- }
- $srclist = implode("; ", (sizeof($srclist) > 3 ? array($srclist[0], $srclist[1], "etc.") : $srclist));
- }
-
- // Free up some memory if possible
- unset($resultso);
-
- // Retrieve the roms in a preprocessed order
- $roms = process_roms($systems, $sources);
-
- $version = date("YmdHis");
-
- // Create a name for the file based on the retrieved information
- $datname = ($syslist != "" ? $syslist : "ALL")." (".($srclist != "" ? $srclist : "merged")." ".$version.")";
-
- // Create and open an output file for writing (currently uses current time, change to "last updated time"
- if ($lone)
- {
- ob_end_clean();
-
- //First thing first, push the http headers
- header('content-type: application/x-gzip');
- header('Content-Disposition: attachment; filename="'.$datname.($old == "1" ? ".dat" : ".xml").'.gz"');
- }
- else
- {
- echo "Opening file for writing: temp/output/".$datname.($old == "1" ? ".dat" : ".xml")." \n";
- $handle = fopen("temp/output/".$datname.($old == "1" ? ".dat" : ".xml"), "w");
- }
-
- // Temporarilly set $system if we're in MEGAMERGED mode to get the right header skip XML
- if ($systems == "" && $sources == "")
- {
- $systems = "0";
- }
-
- $header_old = "clrmamepro (
- name \"".htmlspecialchars($datname)."\"
- description \"".htmlspecialchars($datname)."\"
- version \"".$version."\"
- ".($system != "" && array_key_exists($systems, $headers) ? " header \"".$headers[$systems]."\"" : "")."
- comment \"\"
- author \"The Wizard of DATz\"
-)\n";
-
- $header = "
-
-
-
-
- ".htmlspecialchars($datname)."
- ".htmlspecialchars($datname)."
- The Wizard of DATz
- ".$version."
- ".$version."
- The Wizard of DATz
-
- \n";
-
- $footer = "\n";
-
- // Unset $system again if we're in MEGAMERGED mode
- if ($system == "0" && $source == "")
- {
- $system = "";
- }
-
- if (!$lone)
- {
- echo "Writing data to file \n";
- }
- $lastgame = "";
- if ($old == "1")
- {
- // Write the header out
- if ($lone)
- {
- echo gzencode($header_old, 9);
- }
- else
- {
- fwrite($handle, $header_old);
- }
-
- // Write out each of the machines and roms
- foreach ($roms as $rom)
- {
- $state = "";
- if ($lastgame != "" && $lastgame != $rom["game"])
- {
- $state = $state.")\n";
- }
- if ($lastgame != $rom["game"])
- {
- $state = $state."game (\n".
- "\tname \"".$rom["game"]."\"\n".
- "\tdescription \"".$rom["game"]."\"\n";
- }
- $state = $state."\t".$rom["type"]." ( name \"".$rom["name"]."\"".
- ($rom["size"] != "0" ? " size ".$rom["size"] : "").
- ($rom["crc"] != "" ? " crc ".$rom["crc"] : "").
- ($rom["md5"] != "" ? " md5 ".$rom["md5"] : "").
- ($rom["sha1"] != "" ? " sha1 ".$rom["sha1"] : "").
- " )\n";
-
- $lastgame = $rom["game"];
-
- if ($lone)
- {
- echo gzencode($state, 9);
- }
- else
- {
- fwrite($handle, $state);
- }
- }
-
- if ($lone)
- {
- echo gzencode(")", 9);
- }
- else
- {
- fwrite($handle, ")");
- }
- }
- else
- {
- // Write the header out
- if ($lone)
- {
- echo gzencode($header, 9);
- }
- else
- {
- fwrite($handle, $header);
- }
-
- // Write out each of the machines and roms
- foreach ($roms as $rom)
- {
- // Preprocess each game and rom name for safety
- $rom["game"] = htmlspecialchars(utf8_encode($rom["game"]));
- $rom["name"] = htmlspecialchars(utf8_encode($rom["name"]));
-
- $state = "";
-
- if ($lastgame != "" && $lastgame != $rom["game"])
- {
- $state = $state."\t\n";
- }
- if ($lastgame != $rom["game"])
- {
- $state = $state."\t\n".
- "\t\t".$rom["game"]."\n";
- }
- $state = $state."\t\t<".$rom["type"]." name=\"".$rom["name"]."\"".
- ($rom["size"] != "" ? " size=\"".$rom["size"]."\"" : "").
- ($rom["crc"] != "" ? " crc=\"".$rom["crc"]."\"" : "").
- ($rom["md5"] != "" ? " md5=\"".$rom["md5"]."\"" : "").
- ($rom["sha1"] != "" ? " sha1=\"".$rom["sha1"]."\"" : "").
- " />\n";
-
- $lastgame = $rom["game"];
-
- if ($lone)
- {
- echo gzencode($state, 9);
- }
- else
- {
- fwrite($handle, $state);
- }
- }
-
- if ($lone)
- {
- echo gzencode("\t", 9);
- echo gzencode($footer, 9);
- }
- else
- {
- fwrite($handle, "\t");
- fwrite($handle, $footer);
- }
- }
-
- if (!$lone)
- {
- fclose($handle);
- echo "File written! \n";
- }
-}
-
-// Change duplicate names and remove duplicates (merged only)
-function process_roms($systems, $sources)
-{
- global $link;
-
- // Check if we're in a merged mode
- $sysmerged = $systems == "" || sizeof(explode(", ", $systems)) > 1;
- $srcmerged = $sources == "" || sizeof(explode(", ", $sources)) > 1;
- $merged = $sysmerged || $srcmerged;
-
- // Since the source and/or system are valid, retrive all files
- $query = "SELECT DISTINCT systems.manufacturer AS manufacturer, systems.system AS system, systems.id AS systemid,
- sources.name AS source, sources.url AS url, sources.id AS sourceid,
- games.name AS game, files.name AS name, files.type AS type, checksums.size AS size, checksums.crc AS crc,
- checksums.md5 AS md5, checksums.sha1 AS sha1
-FROM systems
-JOIN games
- ON systems.id=games.system
-JOIN sources
- ON games.source=sources.id
-JOIN files
- ON games.id=files.setid
-JOIN checksums
- ON files.id=checksums.file".
- (!$sysmerged || !$srcmerged ? "\nWHERE" : "").
- (!$srcmerged ? " sources.id IN (".$sources.")" : "").
- (!$srcmerged && !$sysmerged ? " AND" : "").
- (!$sysmerged ? " systems.id IN (".$systems.")" : "")."
-ORDER BY ".
- ($merged ? "checksums.size, checksums.crc, checksums.md5, checksums.sha1"
- : "systems.id, sources.id, games.name, files.name");
- $result = mysqli_query($link, $query);
-
- // If there are no games for this set of parameters, tell the user
- if (gettype($result) == "boolean" || mysqli_num_rows($result) == 0)
- {
- echo "No games could be found with those inputs. Please check and try again. ";
- echo "Go Back";
- exit;
- }
-
- // Retrieve the array from the sql result
- $roms = mysqli_fetch_all($result, MYSQLI_ASSOC);
-
- // If we're in merged mode, take care of merging before renaming
- if ($merged)
- {
- // First, dedupe the set
- $lastgood = 0;
- for ($i = 0; $i < sizeof($roms); $i++)
- {
- $rom = $roms[$i];
- $last = $roms[$lastgood];
-
- // Check if the rom is a duplicate
- $dupe = false;
- if ($rom["type"] == "rom" && $last["type"] == "rom")
- {
- $dupe = (($rom["size"] != -1 && $rom["size"] == $last["size"]) && (
- ($rom["crc"] != "" && $last["crc"] != "" && $rom["crc"] == $last["crc"]) ||
- ($rom["md5"] != "" && $last["md5"] != "" && $rom["md5"] == $last["md5"]) ||
- ($rom["sha1"] != "" && $last["sha1"] != "" && $rom["sha1"] == $last["sha1"])
- )
- );
- }
- else if ($rom["type"] == "disk" && $lasttype == "disk")
- {
- $dupe = (($rom["md5"] != "" && $last["md5"] != "" && $rom["md5"] == $last["md5"]) ||
- ($rom["sha1"] != "" && $last["sha1"] != "" && $rom["sha1"] == $last["sha1"])
- );
- }
-
- // If it's a duplicate, unset it so it's not in the output, but add the info to the previous item
- if ($dupe)
- {
- $last["crc"] = ($last["crc"] == "" && $rom["crc"] != "" ? $rom["crc"] : $last["crc"]);
- $last["md5"] = ($last["md5"] == "" && $rom["md5"] != "" ? $rom["md5"] : $last["md5"]);
- $last["sha1"] = ($last["sha1"] == "" && $rom["sha1"] != "" ? $rom["sha1"] : $last["sha1"]);
- $roms[$lastgood] = $last;
-
- unset($roms[$i]);
- }
- // Otherwise, set the last unset rom
- else
- {
- $lastgood = $i;
- }
- }
-
- // Then we put it in the right order
- usort($roms, function ($a, $b)
- {
- if ($a["systemid"] == $b["systemid"])
- {
- if ($a["sourceid"] == $b["sourceid"])
- {
- if ($a["game"] == $b["game"])
- {
- return strcmp($a["name"], $b["name"]);
- }
- return strcmp($a["game"], $b["game"]);
- }
- return (int) $a["sourceid"] - (int) $b["sourceid"];
- }
- return (int) $a["systemid"] - (int) $b["systemid"];
- });
- }
-
- // Rename the games and roms if necessary
- $lastname = ""; $lastgame = "";
- foreach ($roms as &$rom)
- {
- // If we're in merged mode, rename the game associated
- if ($merged)
- {
- $rom["game"] = $rom["game"].
- ($sysmerged ? " [".$rom["manufacturer"]." - ".$rom["system"]."]" : "").
- ($srcmerged ? " [".$rom["source"]."]" : "");
- }
-
- // Now relable any roms that have the same name inside of the same game
- $samename = false; $samegame = false;
- if ($rom["name"] != "")
- {
- $samename = ($lastname == $rom["name"]);
- }
- if ($rom["game"] != "")
- {
- $samegame = ($lastgame == $rom["game"]);
- }
-
- $lastname = $rom["name"];
- $lastgame = $rom["game"];
-
- // If the name and set are the same, rename it with whatever is different
- if ($samename && $samegame)
- {
- $rom["name"] = preg_replace("/^(.*)(\..*)/", "$1 (".
- ($rom["crc"] != "" ? $rom["crc"] :
- ($rom["md5"] != "" ? $rom["md5"] :
- ($rom["sha1"] != "" ? $rom["sha1"] : "Alt"))).
- ")$2", $rom["name"]);
- }
- }
-
- // Return the sorted list of roms
- return $roms;
-}
-
-?>
\ No newline at end of file
diff --git a/pages/view.php b/pages/view.php
deleted file mode 100644
index a27e062..0000000
--- a/pages/view.php
+++ /dev/null
@@ -1,279 +0,0 @@
-";
- exit;
- }
- $roms = mysqli_fetch_all($result);
- $game_info = $roms[0];
-
- echo "
View the Game Information Below
-
-
-
-
System
-
".$game_info[0]." - ".$game_info[1]."
-
-
-
Source
-
".$game_info[3]."
-
-
-
Name
-
".$game_info[5]."
-
-
-
-
-
-
Name
Type
Size
CRC
MD5
SHA-1
-
";
-
- foreach ($roms as $rom)
- {
- echo "
\n";
- for ($i = 7; $i < 13; $i++)
- {
- echo "\t
".$rom[$i]."
\n";
- }
- echo "
\n";
- }
-
- echo "
";
-
- echo " ";
- if ($offset != "" && $offset > 0)
- {
- echo "Last 50 ";
- }
- if ($count > (mysqli_num_rows($result) + ($offset == "" ? 0 : $offset*50)))
- {
- echo "Next 50";
- }
- echo " ";
-
- echo "Back to previous page \n";
-
-}
-else
-{
- // Retrieve source info only so it's not duplicated
- if ($source != "")
- {
- $query = "SELECT name, url FROM sources WHERE id='".$source."'";
- $source_result = mysqli_query($link, $query);
- $source_info = mysqli_fetch_assoc($source_result);
- }
- // Retrieve system info only so it's not duplicated
- if ($system != "")
- {
- $query = "SELECT manufacturer, system FROM systems WHERE id='".$system."'";
- $system_result = mysqli_query($link, $query);
- $system_info = mysqli_fetch_assoc($system_result);
- }
-
- // Get the total count in the case that it needs limiting
- $query = "SELECT COUNT(*) as count
- FROM systems
- JOIN games
- ON systems.id=games.system
- JOIN sources
- ON games.source=sources.id
- WHERE ".
- ($source != "" ? "sources.id=".$source : "").
- ($source != "" && $system != "" ? " AND " : "").
- ($system != "" ? "systems.id=".$system : "");
- $count = mysqli_query($link, $query);
- $count = mysqli_fetch_assoc($count);
- $count = $count["count"];
- settype($count, "integer");
-
- // Then get all games assocated
- $query = "SELECT games.name AS name,
- games.id AS id,
- systems.manufacturer AS manufacturer,
- systems.system AS system,
- sources.name AS source
- FROM systems
- JOIN games
- ON systems.id=games.system
- JOIN sources
- ON games.source=sources.id
- WHERE ".
- ($source != "" ? "sources.id=".$source : "").
- ($source != "" && $system != "" ? " AND " : "").
- ($system != "" ? "systems.id=".$system : "").
- " ORDER BY games.name ASC
- LIMIT 50 OFFSET ".($offset == "" ? "0" : ($offset*5)."0");
- $games_result = mysqli_query($link, $query);
-
- echo "
Games With This ".
- ($source != "" ? "Source" : "").
- ($source != "" && $system != "" ? " And " : "").
- ($system != "" ? "System" : "")."
\n";
- if (gettype($games_result) != "boolean")
- {
- while ($game = mysqli_fetch_assoc($games_result))
- {
- echo "".$game["name"];
- if ($source != "" && !$system != "")
- {
- echo " (".$game["manufacturer"]." - ".$game["system"].")";
- }
- if (!$source != "" && $system != "")
- {
- echo " (".$game["source"].")";
- }
- echo " \n";
- }
- echo " ";
- if ($offset != "" && $offset > 0)
- {
- echo "Last 50 ";
- }
- if ($count > (mysqli_num_rows($games_result) + ($offset == "" ? 0 : $offset*50)))
- {
- echo "Next 50";
- }
- echo " ";
- }
- else
- {
- echo "No games could be found!";
- }
- echo " ";
-}
-
-// Requires the mysqli link
-function show_default($link)
-{
- // Retrieve the system listing
- $query = "SELECT id, manufacturer, system FROM systems
- ORDER BY manufacturer ASC,
- system ASC";
- $result = mysqli_query($link, $query);
- $systems = mysqli_fetch_all($result, MYSQLI_ASSOC);
-
- // Retrieve the sources listing
- $query = "SELECT id, name FROM sources
- ORDER BY name ASC";
- $result = mysqli_query($link, $query);
- $sources = mysqli_fetch_all($result, MYSQLI_ASSOC);
-
- // Output the input selection form
- echo <<
-
-
Select a System or Source
-
-
-
-
\n";
-
- // Retieve the last 30 games to be updated, based on lastupdated time
- $query = "SELECT games.name as name, files.lastupdated as lu, systems.manufacturer as manufacturer, systems.system as system
- FROM files
- JOIN games ON files.setid=games.id
- JOIN systems ON games.system=systems.id
- ORDER BY files.lastupdated DESC
- LIMIT 30";
- $result = mysqli_query($link, $query);
- echo "