fix: billing game images - dropdown selector, auto-guess, proper URL resolution

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/28b4019a-734d-418e-8002-8c1ff0c0f564

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-03 23:03:03 +00:00 committed by GitHub
parent fa7e463895
commit 70c3ff8979
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 193 additions and 14 deletions

View file

@ -108,4 +108,35 @@ if (!isset($db) || !($db instanceof mysqli)) {
}
}
/**
* Resolve a billing_services.img_url value to a browser-safe URL.
*
* Rules:
* - Empty string '' (caller should skip the <img> tag).
* - Full URL (http:// or https://) returned as-is.
* - Bare filename (e.g. "dayz.jpg") "/images/games/{filename}".
* - Anything else treated as a bare filename for safety.
*
* Output is NOT htmlspecialchars'd here; callers must escape for HTML context.
*/
if (!function_exists('billing_image_url')) {
function billing_image_url(string $imgUrl): string
{
$imgUrl = trim($imgUrl);
if ($imgUrl === '') {
return '';
}
// Keep full external URLs intact
if (str_starts_with($imgUrl, 'http://') || str_starts_with($imgUrl, 'https://')) {
return $imgUrl;
}
// Strip any leading path separators/directories so we always get a bare filename
$filename = basename($imgUrl);
if ($filename === '') {
return '';
}
return '/images/games/' . $filename;
}
}
// End bootstrap