fix: remove hardcoded Discord webhook URLs, centralize via discordmsg() helper

- Improve discordmsg() in includes/functions.php: add curl_init existence
  check, CURLOPT_TIMEOUT/CONNECTTIMEOUT, safe no-op when webhook is empty,
  correct false-return on curl_init failure
- index.php: replace hardcoded webhook URL + 15-line inline cURL block with
  discordmsg() using $settings['discord_webhook_admin']
- modules/user_admin/edit_user.php: same — role-change notification now
  uses discordmsg() + discord_webhook_admin setting
- modules/tickets/submitTicket.php: add global $settings; replace hardcoded
  webhook URL + inline cURL with discordmsg() using discord_webhook_main
- modules/billing/create_servers.php: replace $settings['webhookurl'] +
  inline cURL blocks (x2) with discordmsg() using discord_webhook_main

All modules now use the centralized discord_webhook_main / discord_webhook_admin
settings already managed in Admin > Settings. No DB migration needed.

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/e4d38343-77ed-4c7a-afac-a2a815a059fd

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-05 20:21:59 +00:00 committed by GitHub
parent 8abe2653f7
commit 4babef08eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34 additions and 112 deletions

View file

@ -9,7 +9,7 @@ require 'include/functions.php';
function exec_ogp_module()
{
global $db, $view;
global $db, $view, $settings;
$ticket = new Ticket($db);
$TicketSettings = new TicketSettings($db);
@ -94,25 +94,10 @@ function exec_ogp_module()
//WEBHOOK Discord=======================================================================================
$webhook = "https://discord.com/api/webhooks/1087807080657854484/yYtW8q63xKj3rTFYrNfW2LJk_GeC_WtuI8eJOyELxWbqTQ-uMzOO2I9qofoJCoHXFhC1";
//$webhook = "https://discord.com/api/webhooks/710275918274363412/g5Tr-EUdEnLfFryOlscxJ6FuPiSJuE6EMKRYmh9UGMiqTUxU5-y9CQrBlDJW7znr0Tol";
$msg = "Server support ticket created:\n"."ServerID: " .$_POST['ticket_service'] ."\n". "Subject: " .$_POST['ticket_subject'];
$json_data = array ('content'=>"$msg");
$make_json = json_encode($json_data);
$ch = curl_init( $webhook );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
//If you need to debug, or find out why you can't send message uncomment line below, and execute script.
//echo $response;
//end WEBHOOK Discord
//TICKET SUBMITTED, POST ON DISCORD
$msg = "Server support ticket created:\n"."ServerID: " .$_POST['ticket_service'] ."\n". "Subject: " .$_POST['ticket_subject'];
discordmsg(array('content' => $msg), $settings['discord_webhook_main'] ?? '');
//end discord