From 57400aba8102fe5fe908e833ae5e856e72d0b3b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 20:23:05 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20address=20code=20review=20=E2=80=94=20lo?= =?UTF-8?q?g=20curl=5Fexec=20errors,=20update=20discordmsg=20docblock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/e4d38343-77ed-4c7a-afac-a2a815a059fd Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com> --- includes/functions.php | 44 +++++++----------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 755b1afc..2e70de2e 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -24,43 +24,10 @@ #functions go here -//discordmsg() posts a message to webhook -//can post form data. Minium is username and content -/* -$msg = json_decode(' -{ - "username":"BOTNAME", - "content":"The message the BOTNAME posts.", - "embeds": [{ - "title":"The Link Title", - "description":"The Link Description", - "url":"https://www.thelinkurl.com/", - "color":DECIMALCOLORCODE, - "author":{ - "name":"Site Name", - "url":"https://www.sitelink.com/", - "icon_url":"URLTOIMG" - }, - "fields":[ - { - "name":"LISTITEM1", - "value":"LISTVALUE1", - "inline":true - }, - { - "name":"LISTITEM2", - "value":"LISTVALUE2", - "inline":true - }, - { - "name":"LISTITEM3", - "value":"LISTVALUE3", - "inline":true - }] - }] -} -', true); -*/ +//discordmsg() posts a message to a Discord webhook. +// $msg - associative array (e.g. ['content' => '...']) to send as payload_json. +// $webhook - Discord webhook URL; no-op (returns false) when empty. +// Returns the response string on success, or false on failure / skipped. function discordmsg($msg, $webhook) { if (empty($webhook)) { return false; @@ -80,6 +47,9 @@ function discordmsg($msg, $webhook) { curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); $result = curl_exec($ch); + if ($result === false) { + error_log("GSP Discord webhook error: " . curl_error($ch)); + } curl_close($ch); return $result; }