Merged sqlite and mysql branches into master, supporting both options
This commit is contained in:
commit
e39415a204
Binary file not shown.
Binary file not shown.
|
@ -1,34 +1,45 @@
|
||||||
<?php
|
<?php
|
||||||
echo file_get_contents("ddd_source.html");
|
echo file_get_contents("ddd_source.html");
|
||||||
|
// Parse the config file
|
||||||
|
$config = parse_ini_file('config.cfg', true);
|
||||||
|
|
||||||
// Load the configuration file
|
// Check if the [options] section and database entry exist
|
||||||
$configFilePath = 'config.cfg';
|
if (isset($config['options']) && isset($config['options']['database'])) {
|
||||||
$config = parse_ini_file($configFilePath, true);
|
$database = $config['options']['database'];
|
||||||
|
|
||||||
// Include the MySQL connection script from the config file
|
if ($database === 'mysql') {
|
||||||
include($config['mysql']['mysqlconnect_path']);
|
include($config['mysql']['mysqlconnect_path']);
|
||||||
|
} elseif ($database === 'sqlite') {
|
||||||
|
$db_path = 'db/ddd_db.sqlite';
|
||||||
|
$db = new SQLite3($db_path);
|
||||||
|
} else {
|
||||||
|
echo "Unsupported database type specified in config.cfg\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Database configuration not found in config.cfg\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$mode = $_REQUEST['mode'];
|
$mode = $_REQUEST['mode'];
|
||||||
|
|
||||||
if ($mode == "DX") {
|
if ($mode == "DX") {
|
||||||
echo "<img src='ddddxhs_files/top100dx.png' alt='Top 100 DX Mode'>";
|
echo "<img src='/ddddxhs_files/top100dx.png' alt='Top 100 DX Mode'>";
|
||||||
$query = "SELECT * FROM ddd_db.scores WHERE ddd_db.scores.Mode = 'DX' ORDER BY ddd_db.scores.Score DESC LIMIT 100";
|
$query = "SELECT * FROM ddd_db.scores WHERE ddd_db.scores.Mode = 'DX' ORDER BY ddd_db.scores.Score DESC LIMIT 100";
|
||||||
} elseif ($mode == "EX") {
|
} elseif ($mode == "EX") {
|
||||||
echo "<img src='ddddxhs_files/top100ex.png' alt='Top 100 EX Mode'>";
|
echo "<img src='/ddddxhs_files/top100ex.png' alt='Top 100 EX Mode'>";
|
||||||
$query = "SELECT * FROM ddd_db.scores WHERE ddd_db.scores.Mode = 'EX' ORDER BY ddd_db.scores.Score DESC LIMIT 100";
|
$query = "SELECT * FROM ddd_db.scores WHERE ddd_db.scores.Mode = 'EX' ORDER BY ddd_db.scores.Score DESC LIMIT 100";
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
||||||
<?php
|
$result = $db->query($query);
|
||||||
$result = $conn->query($query);
|
|
||||||
|
|
||||||
if ($result->num_rows > 0) {
|
if ($result) {
|
||||||
// output data of each row
|
// output data of each row
|
||||||
$counter = 1;
|
$counter = 1;
|
||||||
|
|
||||||
echo "<div class='top3'>";
|
echo "<div class='top3'>";
|
||||||
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
||||||
$output = "<span id='player'>" . $counter . " " . $row["Name"] . "</span>" . " " .
|
$output = "<span id='player'>" . $counter . " " . $row["Name"] . "</span>" . " " .
|
||||||
"<span id='score'>" . number_format($row["Score"]) . "</span>";
|
"<span id='score'>" . number_format($row["Score"]) . "</span>";
|
||||||
|
|
||||||
|
@ -48,13 +59,14 @@ if ($result->num_rows > 0) {
|
||||||
$bossImage = trim(strtolower($boss)) . ".png";
|
$bossImage = trim(strtolower($boss)) . ".png";
|
||||||
if($bossImage != ".png"){
|
if($bossImage != ".png"){
|
||||||
echo "<div class='bossImageWrapper'>";
|
echo "<div class='bossImageWrapper'>";
|
||||||
echo "<img id='boss_image' src='boss_images/" . $bossImage . "' alt='" . $boss . "' title='" . $boss . "'>";
|
echo "<img id='boss_image' src='/boss_images/" . $bossImage . "' alt='" . $boss . "' title='" . $boss . "'>";
|
||||||
echo "<div class='bossLabel'>" . $boss . "</div>";
|
echo "<div class='bossLabel'>" . $boss . "</div>";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +81,7 @@ if ($result->num_rows > 0) {
|
||||||
echo "<br>0 results";
|
echo "<br>0 results";
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn->close();
|
$db->close();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<a class='ddd' href='ddd_index.php'>Back</a>
|
<a class='ddd' href='ddd_index.php'>Back</a>
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
|
[options]
|
||||||
|
database="sqlite" #sqlite or mysql
|
||||||
|
|
||||||
[mysql]
|
[mysql]
|
||||||
mysqlconnect_path="/var/config/mysqlconnect.php"
|
mysqlconnect_path="/var/config/mysqlconnect.php"
|
||||||
host="localhost"
|
host="localhost"
|
||||||
username="user"
|
username="dbUser"
|
||||||
database="database"
|
database="dbName"
|
||||||
password="password"
|
password="dbPassword"
|
||||||
|
|
||||||
#To use this file, run the following
|
[sqlite]
|
||||||
|
password="CHANGE_ME!" #This is used to manage the sqlite database from a ui at /update_db.php
|
||||||
|
|
||||||
|
# To use this file, run setup.sh with bash
|
||||||
|
# or you can use
|
||||||
|
#
|
||||||
# cp example.config.cfg config.cfg
|
# cp example.config.cfg config.cfg
|
||||||
# mkdir /var/config
|
# cp example.mysqlconnect.php /var/config/mysqlconnect.php
|
||||||
# cp example.mysqlconnect.php
|
# chmod 755 /var/config/mysqlconnect.php
|
||||||
# Change the password, do not remove the quotes
|
#
|
||||||
# Access the admin page at yourwebsite.com/update_db.php
|
# and manually enter the values into the config.cfg file
|
||||||
|
# the mysqlconnect.php is moved to /var/config to be outside the scope of the end user,
|
||||||
|
# you can place it elsewhere if you desire, be sure to update the mysqlconnect_path variable
|
|
@ -1,5 +1,5 @@
|
||||||
<!--Load Original Source Files-->
|
<!--Load Original Source Files-->
|
||||||
<?php echo file_get_contents("ddd_source.html"); ?>
|
<?php echo file_get_contents('ddd_source.html'); ?>
|
||||||
<center>
|
<center>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
<ol class='scoreList'>
|
<ol class='scoreList'>
|
||||||
|
@ -7,6 +7,10 @@
|
||||||
<img src="ddddxhs_files/download.png" alt="DOWNLOAD DASH-DA-DASH DX" title="DOWNLOAD DASH-DA-DASH DX">
|
<img src="ddddxhs_files/download.png" alt="DOWNLOAD DASH-DA-DASH DX" title="DOWNLOAD DASH-DA-DASH DX">
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
|
<li class='even ddd' id='player' style="font-size:12px">
|
||||||
|
SHA256 Checksum: 67ea139fa4721a05a26094d7bba9f3386c8473d7d7450ef762da7bf19ef921e5
|
||||||
|
</li>
|
||||||
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<img class='center' src="ddddxhs_files/features.png" alt="FEATURES DASH-DA-DASH DX" title="FEATURES DASH-DA-DASH DX">
|
<img class='center' src="ddddxhs_files/features.png" alt="FEATURES DASH-DA-DASH DX" title="FEATURES DASH-DA-DASH DX">
|
||||||
|
|
|
@ -1,12 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
echo file_get_contents("ddd_source.html");
|
echo file_get_contents("ddd_source.html");
|
||||||
|
|
||||||
// Load the configuration file
|
// Parse the config file
|
||||||
$configFilePath = 'config.cfg';
|
$config = parse_ini_file('config.cfg', true);
|
||||||
$config = parse_ini_file($configFilePath, true);
|
|
||||||
|
|
||||||
|
// Check if the [options] section and database entry exist
|
||||||
|
if (isset($config['options']) && isset($config['options']['database'])) {
|
||||||
|
$database = $config['options']['database'];
|
||||||
|
|
||||||
|
if ($database === 'mysql') {
|
||||||
// Include the MySQL connection script from the config file
|
// Include the MySQL connection script from the config file
|
||||||
include($config['mysql']['mysqlconnect_path']);
|
include($config['mysql']['mysqlconnect_path']);
|
||||||
|
} elseif ($database === 'sqlite') {
|
||||||
|
// Code for SQLite
|
||||||
|
$db_path = 'db/ddd_db.sqlite';
|
||||||
|
$db = new SQLite3($db_path);
|
||||||
|
} else {
|
||||||
|
echo "Unsupported database type specified in config.cfg\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Database configuration not found in config.cfg\n";
|
||||||
|
}
|
||||||
|
|
||||||
$b64 = $_POST["gamePass"];
|
$b64 = $_POST["gamePass"];
|
||||||
$decode = base64_decode($b64, true);
|
$decode = base64_decode($b64, true);
|
||||||
|
@ -25,18 +39,21 @@ echo $name . "<br>" . $score . "<br>" . $mode . "<br>";
|
||||||
echo "Bosses: " . $bossNames . "<br>";
|
echo "Bosses: " . $bossNames . "<br>";
|
||||||
|
|
||||||
// Prepare an SQL statement
|
// Prepare an SQL statement
|
||||||
$stmt = $conn->prepare("INSERT INTO ddd_db.scores (Name, Score, Mode, Bosses) VALUES (?, ?, ?, ?)");
|
$stmt = $db->prepare("INSERT INTO scores (Name, Score, Mode, Bosses) VALUES (?, ?, ?, ?)");
|
||||||
$stmt->bind_param("siss", $name, $score, $mode, $bossNames);
|
$stmt->bindValue(1, $name, SQLITE3_TEXT);
|
||||||
|
$stmt->bindValue(2, $score, SQLITE3_INTEGER);
|
||||||
|
$stmt->bindValue(3, $mode, SQLITE3_TEXT);
|
||||||
|
$stmt->bindValue(4, $bossNames, SQLITE3_TEXT);
|
||||||
|
|
||||||
// Execute the statement
|
// Execute the statement
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
echo "New record created successfully";
|
echo "New record created successfully";
|
||||||
} else {
|
} else {
|
||||||
echo "Error: " . $stmt->error;
|
echo "Error: " . $db->lastErrorMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
$conn->close();
|
$db->close();
|
||||||
?>
|
?>
|
||||||
<br>
|
<br>
|
||||||
<a class='ddd' href='ddd_index.php'>Back</a>
|
<a class='ddd' href='ddd_index.php'>Back</a>
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Function to create config.cfg based on user input
|
||||||
|
create_config_file() {
|
||||||
|
cat <<EOF > config.cfg
|
||||||
|
[options]
|
||||||
|
database="$1"
|
||||||
|
|
||||||
|
[mysql]
|
||||||
|
mysqlconnect_path="/var/config/mysqlconnect.php"
|
||||||
|
host="localhost"
|
||||||
|
username="dbUser"
|
||||||
|
database="dbName"
|
||||||
|
password="dbPassword"
|
||||||
|
|
||||||
|
[sqlite]
|
||||||
|
password="CHANGE_ME!"
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prompt user for database type
|
||||||
|
echo "Do you want to use sqlite or mysql? (default: sqlite)"
|
||||||
|
read -t 5 -p "Enter your choice: " db_choice
|
||||||
|
|
||||||
|
# Set default value if no input is given
|
||||||
|
db_choice=${db_choice:-sqlite}
|
||||||
|
|
||||||
|
# Create config.cfg based on user input
|
||||||
|
create_config_file $db_choice
|
||||||
|
|
||||||
|
# Create directory for mysql configuration
|
||||||
|
if [ "$db_choice" = "mysql" ]; then
|
||||||
|
mkdir -p /var/config
|
||||||
|
cp example.mysqlconnect.php /var/config/mysqlconnect.php
|
||||||
|
chmod 755 /var/config/mysqlconnect.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Setup complete. Configuration saved in config.cfg."
|
|
@ -0,0 +1,263 @@
|
||||||
|
<?php
|
||||||
|
// Path to the SQLite database file
|
||||||
|
$db_path = 'db/ddd_db.sqlite';
|
||||||
|
$config_path = 'config.cfg';
|
||||||
|
|
||||||
|
// Load password from configuration file
|
||||||
|
$password = '';
|
||||||
|
if (file_exists($config_path)) {
|
||||||
|
$config = parse_ini_file($config_path);
|
||||||
|
if (isset($config['password'])) {
|
||||||
|
$password = $config['password'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to display an alert message
|
||||||
|
function displayAlert($message, $type) {
|
||||||
|
echo '<div class="alert alert-' . $type . '">' . $message . '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the 'db' directory exists, if not, create it
|
||||||
|
if (!is_dir('db')) {
|
||||||
|
if (!mkdir('db', 0777, true)) {
|
||||||
|
die('Failed to create directories...');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle password submission
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login_password'])) {
|
||||||
|
if ($_POST['login_password'] === $password) {
|
||||||
|
session_start();
|
||||||
|
$_SESSION['logged_in'] = true;
|
||||||
|
} else {
|
||||||
|
displayAlert('Invalid password.', 'danger');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the session
|
||||||
|
session_start();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Add Score</title>
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<?php if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true): ?>
|
||||||
|
<h1 class="mt-5">Enter Password to Access</h1>
|
||||||
|
<form action="" method="post" class="mt-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="login_password">Password:</label>
|
||||||
|
<input type="password" class="form-control" id="login_password" name="login_password" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
|
</form>
|
||||||
|
<?php else: ?>
|
||||||
|
<h1 class="mt-5">Add a New Score</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Process form submission
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action'])) {
|
||||||
|
if ($_POST['action'] == 'add' && isset($_POST['name']) && isset($_POST['score']) && isset($_POST['mode'])) {
|
||||||
|
if (file_exists($db_path)) {
|
||||||
|
try {
|
||||||
|
// Open the SQLite3 database file
|
||||||
|
$db = new SQLite3($db_path);
|
||||||
|
|
||||||
|
// Prepare the insert query
|
||||||
|
$insertQuery = $db->prepare('INSERT INTO scores (Name, Score, Mode, Bosses) VALUES (:name, :score, :mode, :bosses)');
|
||||||
|
$insertQuery->bindValue(':name', $_POST['name'], SQLITE3_TEXT);
|
||||||
|
$insertQuery->bindValue(':score', $_POST['score'], SQLITE3_INTEGER);
|
||||||
|
$insertQuery->bindValue(':mode', $_POST['mode'], SQLITE3_TEXT);
|
||||||
|
$insertQuery->bindValue(':bosses', $_POST['bosses'], SQLITE3_TEXT);
|
||||||
|
|
||||||
|
// Execute the query
|
||||||
|
if ($insertQuery->execute()) {
|
||||||
|
displayAlert('Score added successfully.', 'success');
|
||||||
|
} else {
|
||||||
|
displayAlert('Error adding score: ' . $db->lastErrorMsg(), 'danger');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the database connection
|
||||||
|
$db->close();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
displayAlert('Caught exception: ' . $e->getMessage(), 'danger');
|
||||||
|
} catch (Error $e) {
|
||||||
|
displayAlert('Caught error: ' . $e->getMessage(), 'danger');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
displayAlert('Database does not exist.', 'warning');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_POST['action'] == 'delete' && isset($_POST['delete_id'])) {
|
||||||
|
if (file_exists($db_path)) {
|
||||||
|
try {
|
||||||
|
// Open the SQLite3 database file
|
||||||
|
$db = new SQLite3($db_path);
|
||||||
|
|
||||||
|
// Prepare the delete query
|
||||||
|
$deleteQuery = $db->prepare('DELETE FROM scores WHERE ID = :id');
|
||||||
|
$deleteQuery->bindValue(':id', $_POST['delete_id'], SQLITE3_INTEGER);
|
||||||
|
|
||||||
|
// Execute the query
|
||||||
|
if ($deleteQuery->execute()) {
|
||||||
|
displayAlert('Score deleted successfully.', 'success');
|
||||||
|
} else {
|
||||||
|
displayAlert('Error deleting score: ' . $db->lastErrorMsg(), 'danger');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the database connection
|
||||||
|
$db->close();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
displayAlert('Caught exception: ' . $e->getMessage(), 'danger');
|
||||||
|
} catch (Error $e) {
|
||||||
|
displayAlert('Caught error: ' . $e->getMessage(), 'danger');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
displayAlert('Database does not exist.', 'warning');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="" method="post" class="mt-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Name:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="score">Score:</label>
|
||||||
|
<input type="number" class="form-control" id="score" name="score" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="mode">Mode:</label>
|
||||||
|
<input type="text" class="form-control" id="mode" name="mode" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="bosses">Bosses:</label>
|
||||||
|
<input type="text" class="form-control" id="bosses" name="bosses">
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="action" value="add">
|
||||||
|
<button type="submit" class="btn btn-primary">Add Score</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2 class="mt-5">Current Scores (DX)</h2>
|
||||||
|
<table class="table table-bordered mt-3">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Score</th>
|
||||||
|
<th>Mode</th>
|
||||||
|
<th>Bosses</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
if (file_exists($db_path)) {
|
||||||
|
try {
|
||||||
|
// Open the SQLite3 database file
|
||||||
|
$db = new SQLite3($db_path);
|
||||||
|
|
||||||
|
// Query to fetch current scores for DX mode ordered by highest score
|
||||||
|
$result = $db->query("SELECT * FROM scores WHERE Mode = 'DX' ORDER BY Score DESC");
|
||||||
|
|
||||||
|
// Display the rows
|
||||||
|
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
||||||
|
echo "<tr>
|
||||||
|
<td>{$row['ID']}</td>
|
||||||
|
<td>{$row['Name']}</td>
|
||||||
|
<td>{$row['Score']}</td>
|
||||||
|
<td>{$row['Mode']}</td>
|
||||||
|
<td>{$row['Bosses']}</td>
|
||||||
|
<td>
|
||||||
|
<form action='' method='post' style='display:inline-block;'>
|
||||||
|
<input type='hidden' name='delete_id' value='{$row['ID']}'>
|
||||||
|
<input type='hidden' name='action' value='delete'>
|
||||||
|
<button type='submit' class='btn btn-danger btn-sm'>Delete</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the database connection
|
||||||
|
$db->close();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
displayAlert('Caught exception: ' . $e->getMessage(), 'danger');
|
||||||
|
} catch (Error $e) {
|
||||||
|
displayAlert('Caught error: ' . $e->getMessage(), 'danger');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo '<tr><td colspan="6">No scores found. Database does not exist.</td></tr>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2 class="mt-5">Current Scores (EX)</h2>
|
||||||
|
<table class="table table-bordered mt-3">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Score</th>
|
||||||
|
<th>Mode</th>
|
||||||
|
<th>Bosses</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
if (file_exists($db_path)) {
|
||||||
|
try {
|
||||||
|
// Open the SQLite3 database file
|
||||||
|
$db = new SQLite3($db_path);
|
||||||
|
|
||||||
|
// Query to fetch current scores for EX mode ordered by highest score
|
||||||
|
$result = $db->query("SELECT * FROM scores WHERE Mode = 'EX' ORDER BY Score DESC");
|
||||||
|
|
||||||
|
// Display the rows
|
||||||
|
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
||||||
|
echo "<tr>
|
||||||
|
<td>{$row['ID']}</td>
|
||||||
|
<td>{$row['Name']}</td>
|
||||||
|
<td>{$row['Score']}</td>
|
||||||
|
<td>{$row['Mode']}</td>
|
||||||
|
<td>{$row['Bosses']}</td>
|
||||||
|
<td>
|
||||||
|
<form action='' method='post' style='display:inline-block;'>
|
||||||
|
<input type='hidden' name='delete_id' value='{$row['ID']}'>
|
||||||
|
<input type='hidden' name='action' value='delete'>
|
||||||
|
<button type='submit' class='btn btn-danger btn-sm'>Delete</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the database connection
|
||||||
|
$db->close();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
displayAlert('Caught exception: ' . $e->getMessage(), 'danger');
|
||||||
|
} catch (Error $e) {
|
||||||
|
displayAlert('Caught error: ' . $e->getMessage(), 'danger');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo '<tr><td colspan="6">No scores found. Database does not exist.</td></tr>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user