fix: address code review - prepared stmt, first-radio auto-select, remove unused var, clarify comment

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/4a9c8aab-3782-44a8-a5e4-01b50a813cc0

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-02 14:52:30 +00:00 committed by GitHub
parent b3d677035b
commit 7f6fe9a39a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 15 deletions

View file

@ -71,7 +71,6 @@ if (isset($_POST['save_matrix'])) {
$price_col = $period === 'daily' ? 'price_daily' : ($period === 'yearly' ? 'price_year' : 'price_monthly');
$base_esc = $db->real_escape_string($base_price);
$period_esc = $db->real_escape_string($period);
$db->query(
"UPDATE `{$table_prefix}billing_services`
@ -88,23 +87,29 @@ if (isset($_POST['save_matrix'])) {
$allServerIds[] = (int)$rsRow['remote_server_id'];
}
$stmt = $db->prepare(
"INSERT INTO `{$table_prefix}billing_service_remote_servers`
(service_id, remote_server_id, enabled, override_price)
VALUES (?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
enabled = VALUES(enabled),
override_price = VALUES(override_price)"
);
foreach ((array)$postedServices as $sid => $ignored) {
$sid = (int)$sid;
foreach ($allServerIds as $rid) {
$mapEnabled = isset($postedMappings[$sid][$rid]['enabled']) ? 1 : 0;
$ovRaw = $postedMappings[$sid][$rid]['override_price'] ?? '';
$override = (trim($ovRaw) === '') ? 'NULL' : "'" . $db->real_escape_string(number_format((float)$ovRaw, 2, '.', '')) . "'";
$db->query(
"INSERT INTO `{$table_prefix}billing_service_remote_servers`
(service_id, remote_server_id, enabled, override_price)
VALUES ({$sid}, {$rid}, {$mapEnabled}, {$override})
ON DUPLICATE KEY UPDATE
enabled = VALUES(enabled),
override_price = VALUES(override_price)"
);
$ovPrice = (trim($ovRaw) === '') ? null : number_format((float)$ovRaw, 2, '.', '');
if ($stmt) {
$stmt->bind_param('iisd', $sid, $rid, $mapEnabled, $ovPrice);
$stmt->execute();
}
}
}
if ($stmt) {
$stmt->close();
}
$flash[] = "Matrix saved successfully.";
}