diff --git a/db/_ddd_db.sqlite b/db/_ddd_db.sqlite new file mode 100644 index 0000000..6369f7c Binary files /dev/null and b/db/_ddd_db.sqlite differ diff --git a/db/ddd_db.sqlite b/db/ddd_db.sqlite new file mode 100644 index 0000000..c8aa2ca Binary files /dev/null and b/db/ddd_db.sqlite differ diff --git a/ddd_scores.php b/ddd_scores.php index bddc96d..552ad46 100755 --- a/ddd_scores.php +++ b/ddd_scores.php @@ -1,76 +1,87 @@ "; + echo "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"; } elseif ($mode == "EX") { - echo "Top 100 EX Mode"; + echo "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($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 "
"; + echo "
"; - while ($row = $result->fetch_assoc()) { - $output = "" . $counter . " " . $row["Name"] . "" . "   " . - "" . number_format($row["Score"]) . ""; + while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + $output = "" . $counter . " " . $row["Name"] . "" . "   " . + "" . number_format($row["Score"]) . ""; - // 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 "
  • "; - echo "
    "; - echo $output; - echo "
    "; + echo "
  • "; + echo "
    "; + echo $output; + echo "
    "; - if (!empty($bosses)) { - echo "
    "; + if (!empty($bosses)) { + echo "
    "; // Display an image for each boss name foreach ($bosses as $boss) { $bossImage = trim(strtolower($boss)) . ".png"; if($bossImage != ".png"){ echo "
    "; - echo "" . $boss . ""; + echo "" . $boss . ""; echo "
    " . $boss . "
    "; echo "
    "; } } - echo "
    "; + + echo "
    "; + } + + echo "
  • "; + + $counter++; } - echo ""; - - $counter++; - } - - echo ""; + echo ""; } else { - echo "
    0 results"; + echo "
    0 results"; } -$conn->close(); +$db->close(); ?> -
    Back diff --git a/example.config.cfg b/example.config.cfg index 3c15d08..b1b42cf 100755 --- a/example.config.cfg +++ b/example.config.cfg @@ -1,13 +1,23 @@ +[options] +database="sqlite" #sqlite or mysql + [mysql] mysqlconnect_path="/var/config/mysqlconnect.php" host="localhost" -username="user" -database="database" -password="password" +username="dbUser" +database="dbName" +password="dbPassword" -#To use this file, run the following -# cp example.config.cfg config.cfg -# mkdir /var/config -# cp example.mysqlconnect.php -# Change the password, do not remove the quotes -# Access the admin page at yourwebsite.com/update_db.php \ No newline at end of file +[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.mysqlconnect.php /var/config/mysqlconnect.php +# chmod 755 /var/config/mysqlconnect.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 \ No newline at end of file diff --git a/index.php b/index.php index 41cbfe6..b278019 100755 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ - +




      @@ -7,6 +7,10 @@ DOWNLOAD DASH-DA-DASH DX
      +
    1. +SHA256 Checksum: 67ea139fa4721a05a26094d7bba9f3386c8473d7d7450ef762da7bf19ef921e5 +
    2. +


      FEATURES DASH-DA-DASH DX diff --git a/input_ddd_scoreboard.php b/input_ddd_scoreboard.php index 1f36a31..9017607 100755 --- a/input_ddd_scoreboard.php +++ b/input_ddd_scoreboard.php @@ -1,12 +1,26 @@ " . $score . "
      " . $mode . "
      "; echo "Bosses: " . $bossNames . "
      "; // 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(); ?>
      Back diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..e3bd67b --- /dev/null +++ b/setup.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Function to create config.cfg based on user input +create_config_file() { + cat < 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." diff --git a/update_db.php b/update_db.php new file mode 100644 index 0000000..6615221 --- /dev/null +++ b/update_db.php @@ -0,0 +1,263 @@ +' . $message . '
    '; +} + +// 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(); +?> + + + + + Add Score + + + +
    + + +

    Enter Password to Access

    +
    +
    + + +
    + +
    + +

    Add a New Score

    + + 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'); + } + } + } + ?> + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    + + +
    + +

    Current Scores (DX)

    + + + + + + + + + + + + + query("SELECT * FROM scores WHERE Mode = 'DX' ORDER BY Score DESC"); + + // Display the rows + while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + echo " + + + + + + + "; + } + + // 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 ''; + } + ?> + +
    IDNameScoreModeBossesActions
    {$row['ID']}{$row['Name']}{$row['Score']}{$row['Mode']}{$row['Bosses']} +
    + + + +
    +
    No scores found. Database does not exist.
    + +

    Current Scores (EX)

    + + + + + + + + + + + + + query("SELECT * FROM scores WHERE Mode = 'EX' ORDER BY Score DESC"); + + // Display the rows + while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + echo " + + + + + + + "; + } + + // 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 ''; + } + ?> + +
    IDNameScoreModeBossesActions
    {$row['ID']}{$row['Name']}{$row['Score']}{$row['Mode']}{$row['Bosses']} +
    + + + +
    +
    No scores found. Database does not exist.
    + + +
    + + + + +