Started conversion to sqlite for easier end user setup

This commit is contained in:
Docker VM 2024-06-30 22:06:39 -04:00
parent 6fb915786d
commit 0684f3eb28
40 changed files with 115 additions and 64 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
boss_images/blue.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
boss_images/bluedrac.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

0
boss_images/blueking.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

0
boss_images/bluerobo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

0
boss_images/bluespin.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

0
boss_images/bluewing.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
boss_images/krak.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

0
boss_images/krakdrac.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

0
boss_images/krakking.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

0
boss_images/krakrobo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

0
boss_images/krakspin.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

0
boss_images/krakwing.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
boss_images/raam.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
boss_images/raamdrac.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

0
boss_images/raamking.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

0
boss_images/raamrobo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

0
boss_images/raamspin.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

0
boss_images/raamwing.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
boss_images/skul.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
boss_images/skuldrac.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

0
boss_images/skulking.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

0
boss_images/skulrobo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

0
boss_images/skulspin.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

0
boss_images/skulwing.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

0
boss_images/turr.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

0
boss_images/turrdrac.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

0
boss_images/turrking.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

0
boss_images/turrrobo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
boss_images/turrspin.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

0
boss_images/turrwing.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

BIN
db/ddd_db.sqlite Normal file

Binary file not shown.

View File

@ -1,12 +1,12 @@
<!DOCTYPE html>
<body>
<a href="ddd_scores.php?mode=DX">
<img src="/ddddxhs_files/top100dx.png" alt="Top 100 DX Mode">
<img src="ddddxhs_files/top100dx.png" alt="Top 100 DX Mode">
</a>
<br>
<br>
<a href="ddd_scores.php?mode=EX">
<img src="/ddddxhs_files/top100ex.png" alt="Top 100 EX Mode">
<img src="ddddxhs_files/top100ex.png" alt="Top 100 EX Mode">
</a>
<br>
<br>

View File

@ -1,71 +1,68 @@
<?php
echo file_get_contents("ddd_source.html");
include('/var/config/mysqlconnect.php');
$db_path = 'db/ddd_db.sqlite';
$db = new SQLite3($db_path);
$mode = $_REQUEST['mode'];
if ($mode == "DX") {
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";
echo "<img src='ddddxhs_files/top100dx.png' alt='Top 100 DX Mode'>";
$query = "SELECT * FROM scores WHERE Mode = 'DX' ORDER BY Score DESC LIMIT 100";
} elseif ($mode == "EX") {
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";
echo "<img src='ddddxhs_files/top100ex.png' alt='Top 100 EX Mode'>";
$query = "SELECT * FROM scores WHERE Mode = 'EX' ORDER BY Score DESC LIMIT 100";
}
?>
<?php
$result = $conn->query($query);
$result = $db->query($query);
if ($result->num_rows > 0) {
// output data of each row
$counter = 1;
if ($result) {
// output data of each row
$counter = 1;
echo "<div class='top3'>";
echo "<div class='top3'>";
while ($row = $result->fetch_assoc()) {
$output = "<span id='player'>" . $counter . " " . $row["Name"] . "</span>" . "&nbsp;&nbsp;&nbsp;" .
"<span id='score'>" . number_format($row["Score"]) . "</span>";
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$output = "<span id='player'>" . $counter . " " . $row["Name"] . "</span>" . "&nbsp;&nbsp;&nbsp;" .
"<span id='score'>" . number_format($row["Score"]) . "</span>";
// Retrieve the boss names and split them into an array
$bosses = explode(",", $row["Bosses"]);
// Retrieve the boss names and split them into an array
$bosses = explode(",", $row["Bosses"]);
echo "<li class='scoreEntry " . ($counter % 2 == 0 ? 'even' : 'odd') . "'>";
echo "<div class='scoreInfo'>";
echo $output;
echo "</div>";
echo "<li class='scoreEntry " . ($counter % 2 == 0 ? 'even' : 'odd') . "'>";
echo "<div class='scoreInfo'>";
echo $output;
echo "</div>";
if (!empty($bosses)) {
echo "<div class='bossImages'>";
if (!empty($bosses)) {
echo "<div class='bossImages'>";
// Display an image for each boss name
foreach ($bosses as $boss) {
$bossImage = trim(strtolower($boss)) . ".png";
if($bossImage != ".png"){
echo "<div class='bossImageWrapper'>";
echo "<img id='boss_image' src='/boss_images/" . $bossImage . "' alt='" . $boss . "' title='" . $boss . "'>";
echo "<div class='bossLabel'>" . $boss . "</div>";
echo "</div>";
// Display an image for each boss name
foreach ($bosses as $boss) {
$bossImage = trim(strtolower($boss)) . ".png";
if ($bossImage != ".png") {
echo "<div class='bossImageWrapper'>";
echo "<img id='boss_image' src='boss_images/" . $bossImage . "' alt='" . $boss . "' title='" . $boss . "'>";
echo "<div class='bossLabel'>" . $boss . "</div>";
echo "</div>";
}
}
echo "</div>";
}
}
echo "</li>";
echo "</div>";
$counter++;
}
echo "</li>";
$counter++;
}
echo "</ol>";
echo "</ol>";
} else {
echo "<br>0 results";
echo "<br>0 results";
}
$conn->close();
$db->close();
?>
<br>
<a class='ddd' href='/ddd_index.php'>Back</a>
<a class='ddd' href='ddd_index.php'>Back</a>

View File

@ -1,11 +1,11 @@
<!DOCTYPE html>
<head>
<link type="text/css" rel="stylesheet" href="./ddddxhs_files/ddd.css">
<link rel="stylesheet" type="text/css" href="./ddddxhs_files/banner-styles.css">
<link type="text/css" rel="stylesheet" href="ddddxhs_files/ddd.css">
<!-- <link rel="stylesheet" type="text/css" href="ddddxhs_files/banner-styles.css"> -->
</head>
<center>
<a href="./index.php">
<img src="/ddddxhs_files/title.png" alt="DASH-DA-DASH DX" title="DASH-DA-DASH DX">
<a href="index.php">
<img src="ddddxhs_files/title.png" alt="DASH-DA-DASH DX" title="DASH-DA-DASH DX">
</a>
<br>
<br>

0
ddddxhs_files/DASH-DA-DASH DX (2023 Fan Patch).exe Normal file → Executable file
View File

0
ddddxhs_files/DASH-DA-DASH DX (2023 Fan Patch).mfa Normal file → Executable file
View File

View File

@ -1,15 +1,15 @@
<!--Load Original Source Files-->
<?php echo file_get_contents("ddd_source.html"); ?>
<?php echo file_get_contents('ddd_source.html'); ?>
<center>
<br><br><br><br>
<ol class='scoreList'>
<a href='/ddddxhs_files/DASH-DA-DASH DX (2023 Fan Patch).exe'>
<img src="/ddddxhs_files/download.png" alt="DOWNLOAD DASH-DA-DASH DX" title="DOWNLOAD DASH-DA-DASH DX">
<a href='ddddxhs_files/DASH-DA-DASH DX (2023 Fan Patch).exe'>
<img src="ddddxhs_files/download.png" alt="DOWNLOAD DASH-DA-DASH DX" title="DOWNLOAD DASH-DA-DASH DX">
</a>
<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">
<br>
<br>
<br>
@ -21,8 +21,8 @@ Welcome to the fan made Dash Da Dash DX High Score Board
I created this homage as a way for my friends and I to post our high scores to an online leaderboard like back in the day.
</li>
<br>
<a href='/ddd_index.php'>
<img src="/ddddxhs_files/code.png" alt="CODE DASH-DA-DASH DX" title="CODE DASH-DA-DASH DX">
<a href='ddd_index.php'>
<img src="ddddxhs_files/code.png" alt="CODE DASH-DA-DASH DX" title="CODE DASH-DA-DASH DX">
</a>
<br><br>
<li class='even ddd' id='player'>
@ -42,7 +42,7 @@ Credits
<br>
<a href='https://web.archive.org/web/20120615011611if_/http://renard.teknolust.org/ddd/dddxv12install.exe'>Version 1.12 from WabyBackMachine Archive</a>
<br>
<a href='/ddddxhs_files/DASH-DA-DASH DX (2023 Fan Patch).mfa'>2023 Fan Patch .mfa Source File for Clickteam Fusion 2.5</a>
<a href='ddddxhs_files/DASH-DA-DASH DX (2023 Fan Patch).mfa'>2023 Fan Patch .mfa Source File for Clickteam Fusion 2.5</a>
</li>
</ol>
<br>

49
initialize_db.php Executable file
View File

@ -0,0 +1,49 @@
<?php
// Path to the SQLite database file
$db_path = 'db/ddd_db.sqlite';
// Check if the 'db' directory exists, if not, create it
if (!is_dir('db')) {
if (!mkdir('db', 0777, true)) {
die('Failed to create directories...');
}
}
echo 'test1';
// Check if the database file exists
if (!file_exists($db_path)) {
try {
// Create a new SQLite3 database file
echo 'test2';
$db = new SQLite3($db_path);
echo 'test3';
// Create the 'scores' table
$createTableQuery = "
CREATE TABLE IF NOT EXISTS scores (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Name TEXT NOT NULL,
Score INTEGER NOT NULL,
Mode TEXT NOT NULL,
Bosses TEXT NOT NULL
);
";
if ($db->exec($createTableQuery)) {
echo "Database and table created successfully.<br>";
} else {
echo "Error creating table: " . $db->lastErrorMsg() . "<br>";
}
// Close the database connection
$db->close();
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "<br>";
} catch (Error $e) {
echo 'Caught error: ', $e->getMessage(), "<br>";
}
} else {
echo "Database already exists.<br>";
}
?>

View File

@ -1,8 +1,10 @@
<?php
echo file_get_contents("ddd_source.html");
include('/var/config/mysqlconnect.php');
$b64 = $_POST["gamePass"];
$db_path = 'db/ddd_db.sqlite';
$db = new SQLite3($db_path);
$b64 = $_POST["gamePass"];
$decode = base64_decode($b64, true);
$dataArr = explode("|", $decode);
$name = $dataArr[0];
@ -19,18 +21,21 @@ echo $name . "<br>" . $score . "<br>" . $mode . "<br>";
echo "Bosses: " . $bossNames . "<br>";
// Prepare an SQL statement
$stmt = $conn->prepare("INSERT INTO ddd_db.scores (Name, Score, Mode, Bosses) VALUES (?, ?, ?, ?)");
$stmt->bind_param("siss", $name, $score, $mode, $bossNames);
$stmt = $db->prepare("INSERT INTO scores (Name, Score, Mode, Bosses) VALUES (?, ?, ?, ?)");
$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
if ($stmt->execute()) {
echo "New record created successfully";
} else {
echo "Error: " . $stmt->error;
echo "Error: " . $db->lastErrorMsg();
}
$stmt->close();
$conn->close();
$db->close();
?>
<br>
<a class='ddd' href='/ddd_index.php'>Back</a>
<a class='ddd' href='ddd_index.php'>Back</a>