From dfe1d0d2db478839cb6c8c768ad487abe98f807f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 22 Oct 2025 01:35:14 +0000 Subject: [PATCH] Remove db.php and add navigation menu to all pages Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com> --- _website/adminserverlist.php | 45 ++++++++++++++++----------- _website/cart.php | 28 +++++++++++++++-- _website/db.php | 39 ----------------------- _website/includes/menu.php | 55 +++++++++++++++++++++++++++++++++ _website/index.php | 28 +---------------- _website/login.php | 21 +++++++++++-- _website/logout.php | 6 ++-- _website/order.php | 27 +++++++++++++++- _website/serverlist.php | 29 ++++++++++++++--- _website/test_db_connection.php | 10 ++++-- 10 files changed, 190 insertions(+), 98 deletions(-) delete mode 100644 _website/db.php create mode 100644 _website/includes/menu.php diff --git a/_website/adminserverlist.php b/_website/adminserverlist.php index 37df8609..1126a8a9 100644 --- a/_website/adminserverlist.php +++ b/_website/adminserverlist.php @@ -1,29 +1,32 @@ + + + + + + Admin Server List - GameServers.World + + - Admin panel error: $db must be a mysqli connection (check panel/_db.php). - '; - return; +// Create database connection +$db = mysqli_connect($db_host, $db_user, $db_pass, $db_name); +if (!$db) { + die("Connection failed: " . mysqli_connect_error()); } + +// Include menu +include(__DIR__ . '/includes/menu.php'); + +/* show errors during setup */ +@ini_set('display_errors','1'); +error_reporting(E_ALL); function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } function esc_mysqli($db, $v){ return $db->real_escape_string($v); } function fetch_all_assoc($db, $sql){ @@ -318,3 +321,9 @@ document.querySelectorAll('.locs-box').forEach(function(box){ }); + + + diff --git a/_website/cart.php b/_website/cart.php index e7acf3df..7737519b 100644 --- a/_website/cart.php +++ b/_website/cart.php @@ -1,17 +1,35 @@ + + + + + + Shopping Cart - GameServers.World + +

Please login to view your cart

"; + mysqli_close($db); + echo ""; return; } @@ -256,3 +274,9 @@ $apiBase = '/paypal/api'; + + + diff --git a/_website/db.php b/_website/db.php deleted file mode 100644 index 95c92b42..00000000 --- a/_website/db.php +++ /dev/null @@ -1,39 +0,0 @@ - -text/x-generic _db.php ( PHP script, ASCII text, with CRLF line terminators ) -query("SELECT 'users_role' FROM ogp_users WHERE userID = $userID"); - if($adminField == "admin"){ - $adminStatus = true; - }else{ - $adminStatus = false; - } - return $adminStatus; -} - -function logger($logtext){ - file_put_contents("logfile.txt",$logtext . PHP_EOL,FILE_APPEND); - -} -?> diff --git a/_website/includes/menu.php b/_website/includes/menu.php new file mode 100644 index 00000000..d1c4f8fc --- /dev/null +++ b/_website/includes/menu.php @@ -0,0 +1,55 @@ + + + +
+
+ GameServers.World +
+ +
+ + + Logout + + Login + +
+
diff --git a/_website/index.php b/_website/index.php index 3bdcb47a..f11efd68 100644 --- a/_website/index.php +++ b/_website/index.php @@ -1,12 +1,3 @@ - @@ -40,28 +31,11 @@ $username = $is_logged_in ? htmlspecialchars($_SESSION['website_username']) : '' .gsw-btn{border:1px solid;border-radius:8px;padding:10px 14px;text-decoration:none;display:inline-block;font-weight:600} .gsw-fine{font-size:.92rem;opacity:.9;text-align:center;margin-top:10px} - - .gsw-header{display:flex;justify-content:space-between;align-items:center;padding:16px 24px;background:rgba(255,255,255,0.1);backdrop-filter:blur(10px);margin-bottom:20px} - .gsw-header-left{font-weight:700;font-size:1.2rem;color:#fff} - .gsw-header-right{display:flex;gap:12px;align-items:center} - .gsw-user-info{color:#fff;font-size:0.95rem} - .gsw-header-btn{padding:8px 16px;background:#fff;color:#667eea;border-radius:6px;text-decoration:none;font-weight:600;transition:transform 0.2s} - .gsw-header-btn:hover{transform:translateY(-2px)} -
-
GameServers.World
-
- - - Logout - - Login - -
-
+
diff --git a/_website/login.php b/_website/login.php index 2fb56773..dfba9dcc 100644 --- a/_website/login.php +++ b/_website/login.php @@ -3,8 +3,19 @@ session_name("gameservers_website"); session_start(); -// Include database connection -require_once('db.php'); +// Include database configuration +require_once(__DIR__ . '/includes/config.inc.php'); + +// Create database connection +$db = mysqli_connect($db_host, $db_user, $db_pass, $db_name); +if (!$db) { + die("Connection failed: " . mysqli_connect_error()); +} + +// Logger function +function logger($logtext){ + file_put_contents(__DIR__ . "/logfile.txt", $logtext . PHP_EOL, FILE_APPEND); +} // Check if user is already logged in if (isset($_SESSION['website_user_id']) && !empty($_SESSION['website_user_id'])) { @@ -61,6 +72,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['login'])) { } } } + +// Close database connection +mysqli_close($db); ?> @@ -68,7 +82,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['login'])) { Login - GameServers.World - +