Compare commits
No commits in common. "master" and "sqlite-deprecated" have entirely different histories.
master
...
sqlite-dep
Binary file not shown.
|
@ -1,14 +0,0 @@
|
|||
-- Create the database
|
||||
CREATE DATABASE IF NOT EXISTS ddd_db;
|
||||
|
||||
-- Switch to the database
|
||||
USE ddd_db;
|
||||
|
||||
-- Create the scores table
|
||||
CREATE TABLE IF NOT EXISTS scores (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Name VARCHAR(255) NOT NULL,
|
||||
Score BIGINT NOT NULL,
|
||||
Mode VARCHAR(50) NOT NULL,
|
||||
Bosses TEXT
|
||||
);
|
BIN
db/ddd_db.sqlite
BIN
db/ddd_db.sqlite
Binary file not shown.
|
@ -1,74 +1,28 @@
|
|||
<?php
|
||||
echo file_get_contents("ddd_source.html");
|
||||
|
||||
// Parse the config file
|
||||
$config = parse_ini_file('config.cfg', true);
|
||||
$db_path = 'db/ddd_db.sqlite';
|
||||
$db = new SQLite3($db_path);
|
||||
|
||||
// Database connection
|
||||
$db = null;
|
||||
$mode = $_REQUEST['mode'];
|
||||
|
||||
if (isset($config['options']) && isset($config['options']['database'])) {
|
||||
$database = $config['options']['database'];
|
||||
|
||||
if ($database === 'mysql') {
|
||||
$mysql_host = $config['mysql']['host'];
|
||||
$mysql_username = $config['mysql']['username'];
|
||||
$mysql_password = $config['mysql']['password'];
|
||||
$mysql_database = $config['mysql']['database'];
|
||||
|
||||
$mysqli = new mysqli($mysql_host, $mysql_username, $mysql_password, $mysql_database);
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die("Connection failed: " . $mysqli->connect_error);
|
||||
} else {
|
||||
$db = $mysqli;
|
||||
}
|
||||
} elseif ($database === 'sqlite') {
|
||||
$db_path = 'db/ddd_db.sqlite';
|
||||
if (file_exists($db_path)) {
|
||||
try {
|
||||
$db = new SQLite3($db_path);
|
||||
} catch (Exception $e) {
|
||||
die("Failed to open the SQLite database: " . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
die("Database file does not exist: " . $db_path);
|
||||
}
|
||||
} else {
|
||||
die("Unsupported database type specified in config.cfg");
|
||||
}
|
||||
} else {
|
||||
die("Database configuration not found in config.cfg");
|
||||
}
|
||||
|
||||
// Get mode from request
|
||||
$mode = $_REQUEST['mode'] ?? 'DX';
|
||||
|
||||
// Construct query based on mode
|
||||
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 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'>";
|
||||
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";
|
||||
} else {
|
||||
die("Invalid mode specified");
|
||||
}
|
||||
|
||||
// Execute query and fetch results
|
||||
$result = null;
|
||||
|
||||
if ($db instanceof SQLite3) {
|
||||
$result = $db->query($query);
|
||||
} elseif ($db instanceof mysqli) {
|
||||
$result = $db->query($query);
|
||||
}
|
||||
$result = $db->query($query);
|
||||
|
||||
if ($result) {
|
||||
// output data of each row
|
||||
$counter = 1;
|
||||
echo "<div class='top3'><ol>";
|
||||
|
||||
while ($row = ($db instanceof SQLite3) ? $result->fetchArray(SQLITE3_ASSOC) : $result->fetch_assoc()) {
|
||||
echo "<div class='top3'>";
|
||||
|
||||
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
||||
$output = "<span id='player'>" . $counter . " " . $row["Name"] . "</span>" . " " .
|
||||
"<span id='score'>" . number_format($row["Score"]) . "</span>";
|
||||
|
||||
|
@ -88,7 +42,7 @@ if ($result) {
|
|||
$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 "<img id='boss_image' src='boss_images/" . $bossImage . "' alt='" . $boss . "' title='" . $boss . "'>";
|
||||
echo "<div class='bossLabel'>" . $boss . "</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
|
@ -102,18 +56,13 @@ if ($result) {
|
|||
$counter++;
|
||||
}
|
||||
|
||||
echo "</ol></div>";
|
||||
echo "</ol>";
|
||||
|
||||
} else {
|
||||
echo "<br>0 results";
|
||||
}
|
||||
|
||||
// Close database connection
|
||||
if ($db instanceof SQLite3) {
|
||||
$db->close();
|
||||
} elseif ($db instanceof mysqli) {
|
||||
$db->close();
|
||||
}
|
||||
$db->close();
|
||||
?>
|
||||
<br>
|
||||
<a class='ddd' href='ddd_index.php'>Back</a>
|
||||
|
|
|
@ -1,30 +1,6 @@
|
|||
[options]
|
||||
database="sqlite" #sqlite or mysql
|
||||
password="CHANGE_ME!"
|
||||
|
||||
# Connect to your existing mysql database, we will create a single "scores" table with /db/ddd_db.sql
|
||||
[mysql]
|
||||
mysqlconnect_path="/var/config/mysqlconnect.php"
|
||||
host="localhost"
|
||||
username="ddd_db_admin"
|
||||
database="ddd_db"
|
||||
password="dbd_db_password"
|
||||
|
||||
[sqlite]
|
||||
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
|
||||
#
|
||||
#To use this file, run the following
|
||||
# cp example.config.cfg config.cfg
|
||||
#
|
||||
# If using sqlite (default)
|
||||
# you can use the existing empty ddd_db.sqlite file
|
||||
# and manually enter the sqlite_password into the config.cfg file
|
||||
# for managing the database from /update_db.php
|
||||
#
|
||||
# If using mysql
|
||||
# cp example.mysqlconnect.php /var/config/mysqlconnect.php
|
||||
# chmod 755 /var/config/mysqlconnect.php
|
||||
#
|
||||
# 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
|
||||
# Change the password
|
||||
# Access the admin page at yourwebsite.com/update_db.php
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
// Load the configuration file
|
||||
$configFilePath = 'config.cfg';
|
||||
$config = parse_ini_file($configFilePath, true);
|
||||
|
||||
// Check if the mysql section exists in the config file
|
||||
if (!isset($config['mysql'])) {
|
||||
die('MySQL configuration not found in config.cfg');
|
||||
}
|
||||
|
||||
// Extract MySQL connection parameters from the config file
|
||||
$host = $config['mysql']['host'];
|
||||
$username = $config['mysql']['username'];
|
||||
$password = $config['mysql']['password'];
|
||||
$database = $config['mysql']['database'];
|
||||
|
||||
// Create a connection
|
||||
$conn = new mysqli($host, $username, $password, $database);
|
||||
|
||||
// Check the connection
|
||||
if ($conn->connect_error) {
|
||||
die('Connection failed: ' . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Optionally, close the connection when done
|
||||
// $conn->close();
|
||||
?>
|
|
@ -1,45 +0,0 @@
|
|||
<?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...');
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the database file exists
|
||||
if (!file_exists($db_path)) {
|
||||
try {
|
||||
// Create a new SQLite3 database file
|
||||
$db = new SQLite3($db_path);
|
||||
|
||||
// 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>";
|
||||
}
|
||||
?>
|
|
@ -1,26 +1,8 @@
|
|||
<?php
|
||||
echo file_get_contents("ddd_source.html");
|
||||
|
||||
// Parse the config file
|
||||
$config = parse_ini_file('config.cfg', 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($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";
|
||||
}
|
||||
$db_path = 'db/ddd_db.sqlite';
|
||||
$db = new SQLite3($db_path);
|
||||
|
||||
$b64 = $_POST["gamePass"];
|
||||
$decode = base64_decode($b64, true);
|
||||
|
|
65
readme.md
65
readme.md
|
@ -1,65 +0,0 @@
|
|||
# DASH-DA-DASH DX Fan Patch
|
||||
|
||||
This is a fan patch of DASH-DA-DASH DX that has been updated version of the source code available from [mulengine.itch.io/ddddx](https://mulengine.itch.io/ddddx). The original high score board is no longer online, so now it is hosted at [ddd.dylanbanta.com](https://ddd.dylanbanta.com/) with a functional scoreboard available [here](https://ddd.dylanbanta.com/ddd_index.php). The project can also be downloaded so that users can self-host their own copy of the site as a private scoreboard.
|
||||
|
||||
The EXE file can be found here: [ddddxhs_files/DASH-DA-DASH DX (2023 Fan Patch).exe](https://git.dylanbanta.com/Dylan/Dash-Da-Dash-DX-2023-Fan-Patch-High-Scores/raw/branch/master/ddddxhs_files/DASH-DA-DASH%20DX%20%282023%20Fan%20Patch%29.exe) (SHA256 Checksum: 67ea139fa4721a05a26094d7bba9f3386c8473d7d7450ef762da7bf19ef921e5)
|
||||
|
||||
The updated .mfa source file can be found here: [ddddxhs_files/DASH-DA-DASH DX (2023 Fan Patch).mfa](https://git.dylanbanta.com/Dylan/Dash-Da-Dash-DX-2023-Fan-Patch-High-Scores/raw/branch/master/ddddxhs_files/DASH-DA-DASH%20DX%20%282023%20Fan%20Patch%29.mfa)
|
||||
|
||||
|
||||
|
||||
## Project Overview
|
||||
|
||||
This project was made for fun, but it has been repurposed to showcase my usage of git, including creating branches from the original master branch to new sqlite and mysql branches, and then finally merging them back into the master branch. Plus it was a fun challenge to migrate the system to sqlite.
|
||||
|
||||
The php and html is not great, but when I created the project I was focused on recreating the website from way back machine with authenticity. I didn't take it too seriously since it was a project I was doing for myself. Perhaps I'll come back and clean it up one day.
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
To set up the project, you can run the `setup.sh` file or follow the manual instructions in the `example.config.cfg` file.
|
||||
|
||||
## Example Configuration File
|
||||
|
||||
```ini
|
||||
[options]
|
||||
database="sqlite" #sqlite or mysql
|
||||
|
||||
# Connect to your existing mysql database, we will create a single "scores" table with /db/ddd_db.sql
|
||||
[mysql]
|
||||
mysqlconnect_path="/var/config/mysqlconnect.php"
|
||||
host="localhost"
|
||||
username="ddd_db_admin"
|
||||
database="ddd_db"
|
||||
password="dbd_db_password"
|
||||
|
||||
[sqlite]
|
||||
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
|
||||
#
|
||||
# If using sqlite (default)
|
||||
# you can use the existing empty ddd_db.sqlite file
|
||||
# and manually enter the sqlite_password into the config.cfg file
|
||||
# for managing the database from /update_db.php
|
||||
#
|
||||
# If using mysql
|
||||
# cp example.mysqlconnect.php /var/config/mysqlconnect.php
|
||||
# chmod 755 /var/config/mysqlconnect.php
|
||||
#
|
||||
# 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
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
- [Wiki](https://lapfoxtrax.fandom.com/wiki/DASH-DA-DASH_DX)
|
||||
- [itch.io (Has version 1.14 without 2023 Fan Patch)](https://mulengine.itch.io/ddddx)
|
||||
- [DDDDX Archive](https://web.archive.org/web/20130821151756/http://renard.teknolust.org/ddd/)
|
||||
- [Scores Archive](https://web.archive.org/web/20130710170054/http://renard.teknolust.org/ddd/score/index.php)
|
||||
- [Current Website](https://halleylabs.com/)
|
||||
- [Current Website Main](https://heckscaper.com/main.html)
|
||||
- [Version 1.12 from WayBackMachine Archive](https://web.archive.org/web/20120615011611if_/http://renard.teknolust.org/ddd/dddxv12install.exe)
|
||||
- [2023 Fan Patch .mfa Source File for Clickteam Fusion 2.5](https://ddd.dylanbanta.com/ddddxhs_files/DASH-DA-DASH%20DX%20(2023%20Fan%20Patch).mfa)
|
66
setup.sh
66
setup.sh
|
@ -1,66 +0,0 @@
|
|||
#!/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="$2"
|
||||
username="$3"
|
||||
database="$4"
|
||||
password="$5"
|
||||
|
||||
[sqlite]
|
||||
sqlite_password="$6"
|
||||
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}
|
||||
|
||||
if [ "$db_choice" = "mysql" ]; then
|
||||
# Prompt user for MySQL options
|
||||
read -p "Enter MySQL host (default: localhost): " mysql_host
|
||||
mysql_host=${mysql_host:-localhost}
|
||||
read -p "Enter MySQL username (default: dbUser): " mysql_user
|
||||
mysql_user=${mysql_user:-dbUser}
|
||||
read -p "Enter MySQL database name (default: dbName): " mysql_db
|
||||
mysql_db=${mysql_db:-dbName}
|
||||
read -s -p "Enter MySQL password (default: dbPassword): " mysql_pass
|
||||
mysql_pass=${mysql_pass:-dbPassword}
|
||||
echo # Move to a new line after reading the password
|
||||
|
||||
# Create config.cfg for MySQL
|
||||
create_config_file $db_choice $mysql_host $mysql_user $mysql_db $mysql_pass ""
|
||||
|
||||
# Create directory for mysql configuration
|
||||
mkdir -p /var/config
|
||||
cp example.mysqlconnect.php /var/config/mysqlconnect.php
|
||||
chmod 755 /var/config/mysqlconnect.php
|
||||
|
||||
elif [ "$db_choice" = "sqlite" ]; then
|
||||
# Prompt user for SQLite password
|
||||
read -s -p "Enter SQLite password (default: CHANGE_ME!): " sqlite_pass
|
||||
sqlite_pass=${sqlite_pass:-CHANGE_ME!}
|
||||
echo # Move to a new line after reading the password
|
||||
|
||||
# Create config.cfg for SQLite
|
||||
create_config_file $db_choice "" "" "" "" $sqlite_pass
|
||||
|
||||
# Create empty sqlite database
|
||||
php initialize_sqlite.php
|
||||
|
||||
# Ensure the database directory and file have the correct permissions
|
||||
chmod 777 db
|
||||
chmod 777 config.cfg
|
||||
chmod 666 db/ddd_db.sqlite
|
||||
fi
|
||||
|
||||
echo "Setup complete. Configuration saved in config.cfg."
|
|
@ -7,8 +7,8 @@ $config_path = 'config.cfg';
|
|||
$password = '';
|
||||
if (file_exists($config_path)) {
|
||||
$config = parse_ini_file($config_path);
|
||||
if (isset($config['sqlite_password'])) {
|
||||
$password = $config['sqlite_password'];
|
||||
if (isset($config['password'])) {
|
||||
$password = $config['password'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user