diff --git a/web/config.php.template b/web/config.php.template index af7d215e9..7e1296858 100644 --- a/web/config.php.template +++ b/web/config.php.template @@ -40,3 +40,4 @@ define('DB_CHARSET', 'utf8'); // The Database charset (Default: utf8) define('STEAMAPIKEY', ''); // Steam API Key for Shizz define('SB_EMAIL', ''); define('SB_NEW_SALT', '$5$'); //Salt for passwords +define('SB_DISCORD_WEBHOOK_URL', ''); diff --git a/web/pages/page.protest.php b/web/pages/page.protest.php index ac12a7b85..231384ef2 100644 --- a/web/pages/page.protest.php +++ b/web/pages/page.protest.php @@ -110,6 +110,62 @@ $Email, $_SERVER['REMOTE_ADDR'] )); + + if (!empty(SB_DISCORD_WEBHOOK_URL)) { + $timestamp = date('c', strtotime('now')); + + $json_data = json_encode([ + 'username' => 'SourceBans++', + 'avatar_url' => 'https://avatars0.githubusercontent.com/u/20099282', + 'tts' => false, + 'embeds' => [ + [ + 'title' => 'New Ban Protest Submitted', + 'type' => 'rich', + 'url' => 'https://github.com/sbpp', + 'timestamp' => $timestamp, + 'color' => hexdec('3366ff'), + 'footer' => [ + 'text' => 'github.com/sbpp', + 'icon_url' => 'https://avatars0.githubusercontent.com/u/20099282' + ], + 'author' => [ + 'name' => 'SourceBans++', + 'url' => 'https://github.com/sbpp' + ], + 'fields' => [ + [ + 'name' => 'Ban ID', + 'value' => $BanId, + 'inline' => false, + ], + [ + 'name' => 'Reason', + 'value' => $UnbanReason, + 'inline' => false, + ], + [ + 'name' => 'Email', + 'value' => $Email, + 'inline' => false, + ], + ], + ], + ] + ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + + $ch = curl_init(SB_DISCORD_WEBHOOK_URL); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-type: application/json']); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); + 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); + } + $protid = $GLOBALS['db']->Insert_ID(); $protadmin = $GLOBALS['db']->GetRow("SELECT ad.user FROM " . DB_PREFIX . "_protests p, " . DB_PREFIX . "_admins ad, " . DB_PREFIX . "_bans b WHERE p.pid = '" . $protid . "' AND b.bid = p.bid AND ad.aid = b.aid");