Merge pull request #76 from Sanqui/master

Discord reporting and minor fixes
This commit is contained in:
Xkeeper 2021-07-04 00:52:19 -07:00 committed by GitHub
commit d6d34a4b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 3 deletions

View File

@ -42,6 +42,7 @@ else if ($_POST['knockout'])
echo "Delivered IP ban to {$uinfo['lastip']}.\n"; echo "Delivered IP ban to {$uinfo['lastip']}.\n";
xk_ircsend("1|". xk(8) . $uinfo['name'] . xk(7). " (IP " . xk(8) . $uinfo['lastip'] . xk(7) .") is the latest victim of the new EZ BAN button(tm)."); xk_ircsend("1|". xk(8) . $uinfo['name'] . xk(7). " (IP " . xk(8) . $uinfo['lastip'] . xk(7) .") is the latest victim of the new EZ BAN button(tm).");
report("super", "**" . $uinfo['name'] . "** (IP " . $uinfo['lastip'] .") is the latest victim of the new EZ BAN button(tm).");
echo "\n</div>".redirect("admin-slammer.php", 'the slammer (for another go)', 2); echo "\n</div>".redirect("admin-slammer.php", 'the slammer (for another go)', 2);
die(); die();

View File

@ -9,9 +9,14 @@ require 'lib/layout.php';
$servers[3] = "irc.tcrf.net"; $servers[3] = "irc.tcrf.net";
if ($server > count($servers) || $server <= -1) $server = 0; if ($server > count($servers) || $server <= -1) $server = 0;
print "$header<br>";
print " $tblstart<tr>
$tccellh><b>Hold up, it's ". '$' ."YEAR.</b></td></tr>
<tr>$tccell1>Maybe you want to head straight for our <a href='/thread.php?id=17948'>Discord</a>?
$tblend";
print " $header<br>$tblstart<tr> print "<br><br>$tblstart<tr>
$tccellh><b>IRC Chat - BadnikZONE, #tcrf, #x</b></td></tr> $tccellh><b>IRC Chat - BadnikZONE, #tcrf, #x</b></td></tr>
<tr>$tccell1>Server List: "; <tr>$tccell1>Server List: ";

View File

@ -1336,6 +1336,17 @@ function addslashes_array($data) {
} }
function report($type, $msg) {
if (!function_exists('get_discord_webhook')) return;
$wh_url = get_discord_webhook($type, null);
if (!$wh_url) return;
discord_send($wh_url, $outdiscord);
}
// general purpose report function, now with discord!
function xk_ircout($type, $user, $in) { function xk_ircout($type, $user, $in) {
// gone // gone
@ -1357,18 +1368,33 @@ function addslashes_array($data) {
if ($in['pmatch'] >= 3) $color = array(7, 4); if ($in['pmatch'] >= 3) $color = array(7, 4);
elseif ($in['pmatch'] >= 5) $color = array(4, 5); elseif ($in['pmatch'] >= 5) $color = array(4, 5);
$extra = " (". xk($color[1]) ."Password matches: ". xk($color[0]) . $in['pmatch'] . xk() .")"; $extra = " (". xk($color[1]) ."Password matches: ". xk($color[0]) . $in['pmatch'] . xk() .")";
$extradiscord = " (**Password matches**: " . $in['pmatch'] . ")";
} }
$out = "1|New user: #". xk(12) . $in['id'] . xk(11) ." $user ". xk() ."(IP: ". xk(12) . $in['ip'] . xk() .")$extra: https://jul.rustedlogic.net/?u=". $in['id']; $out = "1|New user: #". xk(12) . $in['id'] . xk(11) ." $user ". xk() ."(IP: ". xk(12) . $in['ip'] . xk() .")$extra: https://jul.rustedlogic.net/?u=". $in['id'];
$outdiscord = "New user: **#" . $in['id'] . "** (IP: " . $in['ip'] . ")$extra: <https://jul.rustedlogic.net/?u=" . $in['id'] . ">";
} else { } else {
// global $sql; // global $sql;
// $res = $sql -> resultq("SELECT COUNT(`id`) FROM `posts`"); // $res = $sql -> resultq("SELECT COUNT(`id`) FROM `posts`");
$out = "$dest|New $type by ". xk(11) . $user . xk() ." (". xk(12) . $in['forum'] .": ". xk(11) . $in['thread'] . xk() ."): https://jul.rustedlogic.net/?p=". $in['pid']; $out = "$dest|New $type by ". xk(11) . $user . xk() ." (". xk(12) . $in['forum'] .": ". xk(11) . $in['thread'] . xk() ."): https://jul.rustedlogic.net/?p=". $in['pid'];
$outdiscord = "New $type by **" . $user . "** (" . $in['forum'] . ": **" . $in['thread'] . "**): <https://jul.rustedlogic.net/?p=". $in['pid'] . ">";
} }
xk_ircsend($out); xk_ircsend($out);
// discord part
// logic to decide where the message goes based on info provided
if (!function_exists('get_discord_webhook')) return;
$wh_url = get_discord_webhook($type, $in);
if (!$wh_url) return;
discord_send($wh_url, $outdiscord);
} }
function xk_ircsend($str) { function xk_ircsend($str) {
@ -1387,6 +1413,28 @@ function addslashes_array($data) {
return true; return true;
} }
function discord_send($url, $msg) {
// stripped down from https://gist.github.com/Mo45/cb0813cb8a6ebcd6524f6a36d4f8862c
$json_data = json_encode([
"content" => $msg
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('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);
// echo $response;
curl_close($ch);
return true;
}
function xk($n = -1) { function xk($n = -1) {
if ($n == -1) $k = ""; if ($n == -1) $k = "";
else $k = str_pad($n, 2, 0, STR_PAD_LEFT); else $k = str_pad($n, 2, 0, STR_PAD_LEFT);

View File

@ -40,11 +40,14 @@
//if ($fails > 1) //if ($fails > 1)
@xk_ircsend("102|". xk(14) ."Failed attempt". xk(8) ." #$fails ". xk(14) ."to log in as ". xk(8) . $username . xk(14) ." by IP ". xk(8) . $_SERVER['REMOTE_ADDR'] . xk(14) ."."); @xk_ircsend("102|". xk(14) ."Failed attempt". xk(8) ." #$fails ". xk(14) ."to log in as ". xk(8) . $username . xk(14) ." by IP ". xk(8) . $_SERVER['REMOTE_ADDR'] . xk(14) .".");
report("mod", "Failed attempt **#$fails** to log in as **$username** by IP " . $_SERVER['REMOTE_ADDR'] . ".");
if ($fails >= 5) { if ($fails >= 5) {
$sql->query("INSERT INTO `ipbans` SET `ip` = '". $_SERVER['REMOTE_ADDR'] ."', `date` = '". ctime() ."', `reason` = 'Send e-mail for password recovery'"); $sql->query("INSERT INTO `ipbans` SET `ip` = '". $_SERVER['REMOTE_ADDR'] ."', `date` = '". ctime() ."', `reason` = 'Send e-mail for password recovery'");
@xk_ircsend("102|". xk(7) ."Auto-IP banned ". xk(8) . $_SERVER['REMOTE_ADDR'] . xk(7) ." for this."); @xk_ircsend("102|". xk(7) ."Auto-IP banned ". xk(8) . $_SERVER['REMOTE_ADDR'] . xk(7) ." for this.");
report("mod", "Auto-IP banned " . $_SERVER['REMOTE_ADDR'] . "for this.");
@xk_ircsend("1|". xk(7) ."Auto-IP banned ". xk(8) . $_SERVER['REMOTE_ADDR'] . xk(7) ." for repeated failed logins."); @xk_ircsend("1|". xk(7) ."Auto-IP banned ". xk(8) . $_SERVER['REMOTE_ADDR'] . xk(7) ." for repeated failed logins.");
report("super", "Auto-IP banned " . $_SERVER['REMOTE_ADDR'] . "for repeated failed logins.");
} }
$msg = "Couldn't login. Either you didn't enter an existing username, or you haven't entered the right password for the username."; $msg = "Couldn't login. Either you didn't enter an existing username, or you haven't entered the right password for the username.";

View File

@ -25,7 +25,7 @@
$linkcolor4 = 'CCE8FF'; # Hover $linkcolor4 = 'CCE8FF'; # Hover
$tableborder = '000011'; # Border color for tables $tableborder = '000011'; # Border color for tables
$tableheadtext = '002549'; # Table header text color $tableheadtext = 'bdd8f1'; # Table header text color
$tableheadbg = '000921'; # Table header background (you can use images) $tableheadbg = '000921'; # Table header background (you can use images)
$categorybg = '002864'; # Category BG $categorybg = '002864'; # Category BG
$tablebg1 = '001E4B'; # Table cell 1 background $tablebg1 = '001E4B'; # Table cell 1 background

View File

@ -4,7 +4,8 @@
$formcss=1; $formcss=1;
$inputborder='000000'; $inputborder='000000';
$bgcolor='010'; $bgcolor='010 linear-gradient(45deg, #001100 40%, #001600 40%, #001600 50%, #001100 50%, #001100 90%, #001600 90%, #001600 100%); background-size: 35.36px 35.36px';
$bgimage="";
$textcolor='DDDDDD'; $textcolor='DDDDDD';
$linkcolor ='BEFEBA'; $linkcolor ='BEFEBA';