From acbb850e21f47c63edd3812e39cdf61229c2e1ae Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 6 May 2026 23:45:27 +0000
Subject: [PATCH 1/2] fix: add_to_cart SQL mismatch, Browse Servers routing,
canonical game dedup, OS-aware locations, XML editor improvements
Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/aecffd5d-b644-4e4d-b13e-b392e78d4606
Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
---
modules/billing/add_to_cart.php | 2 +-
modules/billing/cart.php | 6 +-
modules/billing/module.php | 19 +-
modules/billing/order.php | 611 ++++++++++++++----------
modules/billing/serverlist.php | 101 ++--
modules/config_games/config_servers.php | 108 +++--
6 files changed, 495 insertions(+), 352 deletions(-)
diff --git a/modules/billing/add_to_cart.php b/modules/billing/add_to_cart.php
index 74313637..2a8f5679 100644
--- a/modules/billing/add_to_cart.php
+++ b/modules/billing/add_to_cart.php
@@ -204,7 +204,7 @@ $sql = "INSERT INTO {$table_prefix}billing_invoices (
billing_status, invoice_date, due_date, description, invoice_duration, rate_type, rate_per_player,
players, period_start, period_end, subtotal, total_due, payment_status, qty, coupon_id
) VALUES (
- 0, ?, ?, 0, ?, ?, ?, ?, ?, ?, ?, ?, 0.00, 'USD', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0
+ 0, ?, ?, 0, ?, ?, ?, ?, ?, ?, ?, ?, 0.00, 'USD', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0
)";
$stmt = $db->prepare($sql);
diff --git a/modules/billing/cart.php b/modules/billing/cart.php
index 93e59523..be5740cc 100644
--- a/modules/billing/cart.php
+++ b/modules/billing/cart.php
@@ -541,7 +541,7 @@ $siteBase = $protocol . $host;
@@ -640,7 +640,7 @@ $siteBase = $protocol . $host;
@@ -672,7 +672,7 @@ $siteBase = $protocol . $host;
diff --git a/modules/billing/module.php b/modules/billing/module.php
index 1c737175..dcfd5a14 100644
--- a/modules/billing/module.php
+++ b/modules/billing/module.php
@@ -24,8 +24,8 @@
// Module general information
$module_title = "billing";
-$module_version = "3.4";
-$db_version = 5;
+$module_version = "3.5";
+$db_version = 6;
$module_required = FALSE;
// Module description
$module_description = "Billing storefront / provisioning integration. Public ordering runs as a standalone site; panel pages provide provisioning and admin order management.";
@@ -386,4 +386,17 @@ $install_queries[5] = array(
}
);
-?>
+// -----------------------------------------------------------------------
+// db_version 6 — Add server_os column to remote_servers for OS-aware
+// game/service selection in the billing storefront.
+// Default 'linux' preserves existing behaviour for all current installs.
+// -----------------------------------------------------------------------
+$install_queries[6] = array(
+ function($db) {
+ $r = $db->resultQuery("SELECT COUNT(*) AS cnt FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'OGP_DB_PREFIXremote_servers' AND COLUMN_NAME = 'server_os'");
+ if ($r && isset($r[0]['cnt']) && (int)$r[0]['cnt'] > 0) return true;
+ return (bool)$db->query("ALTER TABLE `OGP_DB_PREFIXremote_servers` ADD `server_os` ENUM('linux','windows','any') NOT NULL DEFAULT 'linux' AFTER `display_public_ip`");
+ }
+);
+
+?>
\ No newline at end of file
diff --git a/modules/billing/order.php b/modules/billing/order.php
index 14b03283..596348e3 100644
--- a/modules/billing/order.php
+++ b/modules/billing/order.php
@@ -9,15 +9,13 @@
", $_POST['description']);
- $service = $_POST['service_id'];
-
- $change_description = "UPDATE {$table_prefix}billing_services
- SET description ='".$new_description."'
- WHERE service_id=".$service;
- $save = $db->query($change_description);
- }
- ?>
-
-
+if (isset($_POST['save']) && !empty($_POST['description'])) {
+ $new_description = str_replace("\\r\\n", "
", $_POST['description']);
+ $service = intval($_POST['service_id']);
+ $stmt = $db->prepare("UPDATE {$table_prefix}billing_services SET description = ? WHERE service_id = ?");
+ if ($stmt) {
+ $stmt->bind_param("si", $new_description, $service);
+ $stmt->execute();
+ $stmt->close();
+ }
+}
+/**
+ * Derive OS ('linux'|'windows'|'any') from a game_key string.
+ * Checks for _win / _windows substrings; then _linux; else 'any'.
+ */
+function order_game_key_os(string $gameKey): string
+{
+ $lk = strtolower($gameKey);
+ if (str_contains($lk, '_win')) {
+ return 'windows';
+ }
+ if (str_contains($lk, '_linux')) {
+ return 'linux';
+ }
+ return 'any';
+}
-
-
-
- query($qry_services);
-
- if ($services_result === false) {
- echo "Unable to load service information. Please try again or contact support.
";
- error_log("billing order.php: query failed - " . $db->error . " | SQL: " . $qry_services);
- billing_maybe_close_db($db);
- include(__DIR__ . '/includes/footer.php');
- echo '