From ce42c091ccb0ad6ec97afd844a35b7dd3ea19298 Mon Sep 17 00:00:00 2001 From: Docker VM Date: Sun, 30 Jun 2024 23:28:04 -0400 Subject: [PATCH] Updated to use sqlite. Added /update_db.php and example.config.cfg to control sqlite db from a simple bootstrap UI --- .gitignore | 2 +- db/_ddd_db.sqlite | Bin 0 -> 12288 bytes db/ddd_db.sqlite | Bin 12288 -> 12288 bytes ddddxhs_files/ddd.css | 4 + example.config.cfg | 6 + index.php | 4 + initialize_db.php | 49 -------- update_db.php | 263 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 278 insertions(+), 50 deletions(-) create mode 100644 db/_ddd_db.sqlite create mode 100644 example.config.cfg delete mode 100755 initialize_db.php create mode 100644 update_db.php diff --git a/.gitignore b/.gitignore index 1383f39..4a780a9 100755 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/config.php \ No newline at end of file +/config.cfg \ No newline at end of file diff --git a/db/_ddd_db.sqlite b/db/_ddd_db.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..6369f7c14e47debeca8fc383950d330747908fc1 GIT binary patch literal 12288 zcmeI&O-jQ+6bJB`Mp`J?>Z;V$bJx;P1TWB}8A?o=)O=vO(pV!D+J>6CaH|(_;SoHN zM-bOeViDR>x)u39lKBX4-VDFpK>SO4vW)3Id6-2@I%h|WbJihZj47*Ec6o5w9<0V$ zm(BNu!rE6Chcc^Bd1I9?*&rYQ0SG_<0uX=z1Rwwb2tWV=I|K%WVy)HUqh)kEjnlj^Co6ll6FXd|~Vk7ltdS2mwZyi}{#`OD;|<~VtX(==}j>lN~E z)F{(NmBtg&;RNc|Dn}lG0x=B8apfD@_I8e+ZTVY# zcV0ia+gnRd(lk!jcU(JEGryZx-&yrTHV6nn00Izz00bZa0SG_<0uX=z1pbUbyHI2` z<=8ZyrqR4}Gcksir&<2MbX3Ylmg)3V@~zPJT-{aagy;FEd4Boq)fnn_C=5^Qs+8UT ndG(XY2LS;HKmY;|fB*y_009U<00Izzz&{cwbEVE#e>;2w6MlUw literal 0 HcmV?d00001 diff --git a/db/ddd_db.sqlite b/db/ddd_db.sqlite index efc2c3eb34d1478d801acdda75a9713947af16d7..c8aa2ca30696edf0ffb30255ff564e7f23df9eac 100644 GIT binary patch literal 12288 zcmeI2{ZCs}7{_nRxP757z=j*iOwL$faJdL$MS+OhEiJX9EpXdH(IFHlj;*wV!Ul7? z7Z($M(8R?pL=)rU%ryH0Ok^%GE-v_z_!13?W*Nye#>|9hG|?>TJ?AN&14lA{Hs^+x zb8o)S+vj=CDFmWDq4DVy8p}>iB&X3HsaP_Zq3`TWf1g{nN?e zbSgKQHhy6p%%vu0QkjwUw*~FGUyJ!sO!J2PXq~n?lblGYhGoqei^;OJyxjEcIQSgN zPNi}=@@`)1fjmRicC_va`cNeho{P47pY{(hvzV_m_B;Uesh#8l2IVkCfK z{zME#x{Oym6yh~e9P%IM8|%W^(R=#xW^=hzZf(RhN!2*ztn_feqHXp&_Ura@ z_Az^_-DUgUcFlIqcF5+jS*>4KFIo><_gen4d}(>xlC!i~O!E8k^KzSfOs2U+|4LUPn%__d{c?jJC)5GPf7C^PWck0r%muMI-Wk7 znlk^fVmvH9Ey+@up$ufxqlLdNONQ|6H7y+N4n|ZIi|cw{FcMIak)ai5S^PAOS+e|wxthtbgn^PcKKbEWHtHKX?UZR7>emqRJE(tN!OwAVB*C zo;;I8%hGCotBuvtShVi?BgASiQ;qh6i=8pbm#jQlE{u2AT`-^xgyd*ICBqfcxbQLy z4G%Rm#WTT0hz_0iC9pR-XmkZptJ1`(jwz(hH3Q|V2zv($&+|!6TerD_jg7UySsCNC%_qSx z|o)6Rgp5nWuexrfNuR{sKZ3t!gQ-= zV91vMo^Zg?ek)1N^PY+~p+3l&5>$pbZS@x8z@Y^23MNe%M3`OXY*5tMIsgB4{05tIX*w(jl?*dz3~%1_7RoVNbMR?tFZOcJ!7$GFUU z6ZwvV0@I_thgcQ;#Hy0%5ISK2HZaph#}ix@jiWDs20UXDP^YI4vKZ|TX%RH6MPgdu z<0i-$6tpjN2P(aMgz{T#=V_fvoYSgL4Z=)OCJ;-BaoU|(=0-U0(_8L2T zsDo2D=I#T^kO%(TyvhBGWPFKB5D)|e0YN|z5CjAPK|l}?1Ox#=KoAfF{yzkYOa
+
  • +SHA256 Checksum: 67ea139fa4721a05a26094d7bba9f3386c8473d7d7450ef762da7bf19ef921e5 +
  • +


    FEATURES DASH-DA-DASH DX diff --git a/initialize_db.php b/initialize_db.php deleted file mode 100755 index 45ba3a9..0000000 --- a/initialize_db.php +++ /dev/null @@ -1,49 +0,0 @@ -exec($createTableQuery)) { - echo "Database and table created successfully.
    "; - } else { - echo "Error creating table: " . $db->lastErrorMsg() . "
    "; - } - - // Close the database connection - $db->close(); - } catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "
    "; - } catch (Error $e) { - echo 'Caught error: ', $e->getMessage(), "
    "; - } -} else { - echo "Database already exists.
    "; -} -?> \ No newline at end of file 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.
    + + +
    + + + + +