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

@ -147,24 +147,8 @@ function exec_ogp_module()
$db->logger( "Email FAILED - Server Renewed " . $home_id);
// END EMAIL
//WEBHOOK Discord=======================================================================================
$webhookurl = $settings['webhookurl'];
$msg = "The ". $home_name ." server ID #". $home_id . " has just been renewed.";
$json_data = array ('content'=>"$msg");
$make_json = json_encode($json_data);
$ch = curl_init( $webhookurl );
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;
//WEBHOOK Discord
discordmsg(array('content' => "The ". $home_name ." server ID #". $home_id . " has just been renewed."), $settings['discord_webhook_main'] ?? '');
//end WEBHOOK Discord
}
@ -294,28 +278,9 @@ function exec_ogp_module()
$db->logger( "Email FAILED - Server Created " . $home_id);
//WEBHOOK Discord=======================================================================================
$webhookurl = !empty($settings['webhookurl']) ? $settings['webhookurl'] : '';
if (!empty($webhookurl)) {
$msg = "A new server, ". $home_name ." ID #". $home_id . ", has just been created.";
$json_data = array ('content'=>"$msg");
$make_json = json_encode($json_data);
$ch = curl_init( $webhookurl );
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;
//WEBHOOK Discord
discordmsg(array('content' => "A new server, ". $home_name ." ID #". $home_id . ", has just been created."), $settings['discord_webhook_main'] ?? '');
//end WEBHOOK Discord
}
}
// END EMAIL