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:
parent
8abe2653f7
commit
4babef08eb
5 changed files with 34 additions and 112 deletions
28
index.php
28
index.php
|
|
@ -304,30 +304,10 @@ function ogpHome()
|
|||
|
||||
//NOTIFY DISCORD WHEN ADMIN LOGS IN
|
||||
$trust_admins = array("iaregamer","dimrod","CJB","Bebiano","Syru");
|
||||
if ($userInfo['users_role'] == "admin" && in_array($userInfo['users_login'], $trust_admins) == false) {
|
||||
//WEBHOOK Discord=======================================================================================
|
||||
// Create new webhook in your Discord channel settings and copy&paste URL
|
||||
//=======================================================================================================
|
||||
$webhookurl = "https://discord.com/api/webhooks/1087810639390576650/sspI3frko8FLD6ybvzG-_BXhG4wjH7yujFBxffgtTw34uAL_AdrDxY36C-khqs--cEMu";
|
||||
//========================================================================================================
|
||||
$msg = "Admin Login :warning: \nIP:".$client_ip." \nID:".$userInfo['user_id']." \nUser:".$userInfo['users_login'];
|
||||
$json_data = array ('content'=>"$msg");
|
||||
$make_json = json_encode($json_data);
|
||||
if(!function_exists('curl_init')){
|
||||
error_log("OGP Discord webhook skipped: PHP curl extension is not loaded.");
|
||||
}else{
|
||||
$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 );
|
||||
curl_close($ch);
|
||||
}
|
||||
//end WEBHOOK Discord
|
||||
}
|
||||
if ($userInfo['users_role'] == "admin" && !in_array($userInfo['users_login'], $trust_admins)) {
|
||||
$msg = "Admin Login :warning: \nIP:".$client_ip." \nID:".$userInfo['user_id']." \nUser:".$userInfo['users_login'];
|
||||
discordmsg(array('content' => $msg), $settings['discord_webhook_admin'] ?? '');
|
||||
}
|
||||
|
||||
$_SESSION['user_id'] = $userInfo['user_id'];
|
||||
$_SESSION['users_login'] = $userInfo['users_login'];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue