Skip to content

Commit

Permalink
Extra Error handling, + permabans
Browse files Browse the repository at this point in the history
  • Loading branch information
JABirchall committed Sep 21, 2016
1 parent 18c3ebe commit bee79c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions plugins/GlobalBan.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public function isTriggered()
$fields = [
'key' => $this->CONFIG['key'],
'uid' => $client['client_unique_identifier']->toString(),
'ip' => $client['connection_client_ip'],
'banned_by' => $this->info['invokername'],
'banned_by_uid' => $this->info['invokeruid'],
'reason' => $reason,
'ip' => $client['connection_client_ip']->toString(),
'banned_by' => $this->info['invokername']->toString(),
'banned_by_uid' => $this->info['invokeruid']->toString(),
'reason' => $reason->toString(),
'server_name' => $this->server->toString(),
'server_uid' => $this->server['virtualserver_unique_identifier'],
'h' => hash_pbkdf2('sha1', sprintf("%s-%s-%s", $this->CONFIG['key'], $client['client_unique_identifier']->toString(),$this->info['invokeruid']),$this->server['virtualserver_unique_identifier'], 1, 8),
'server_uid' => $this->server['virtualserver_unique_identifier']->toString(),
'h' => hash_pbkdf2('sha1', sprintf("%s-%s-%s", $this->CONFIG['key'], $client['client_unique_identifier']->toString(),$this->info['invokeruid']),$this->server['virtualserver_unique_identifier']->toString(), 1, 8),

];

Expand All @@ -73,14 +73,16 @@ public function isTriggered()
try {
$client->poke("[b][color=red]You are global banned by Nimda ID: #{$response->ban_id}");
$client->poke("[b][color=red]Visit [url=#]Global Ban Support[/url].");
$client->ban(1, "Global Ban ID #{$response->ban_id} ({$reason})");
$client->ban(0, "Global Ban ID #{$response->ban_id} ({$reason})");
}catch(Ts3Exception $e){
return;
}

$this->sendOutput(sprintf("[b][color=green] Client %s successfully global banned ID #%s", $client, $response->ban_id));
} elseif ($response->success === false && $response->err === 0x02) {
$this->sendOutput("[COLOR=red][b]This server is not authorized to global ban, email [email protected]");
} else {
$this->sendOutput("[COLOR=orange][b]Unexpected error");
}
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/GlobalBanList.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ public function isTriggered()

if($this->CONFIG['ban'] === true && $response->uid === $this->info['client_unique_identifier']->toString()) {
try {
$client->poke("[b][color=red]You are globally banned by Nimda ID: #{$response->id}");
$client->poke("[b][color=red]You are globally banned by Nimda ID: #{$response->ban_id}");
$client->poke("[b][color=red]Visit [url=#]Global Ban Support[/url].");
$client->ban(1, "Global Ban ID #{$response->id} ({$response->reason})");
$client->ban(0, "Global Ban ID #{$response->ban_id} ({$response->reason})");
}catch(Ts3Exception $e){
return;
}
}

if($this->CONFIG['alert'] === true) {
$message = sprintf("[ALERT] Client %s is global banned ID #%s reason: %s\n", $client, $response->ban_id, $response->reason);
$message = sprintf("[ALERT] Client %s is global banned ID #%s reason: %s issued Global Ban from: %s\n", $client, $response->ban_id, $response->reason, $response->server_name);
array_walk(array_map([$this->server, 'serverGroupGetById'], $this->CONFIG['alert_groups']), function($admin) use ($message) {
$admin->message($message);
});
Expand Down

0 comments on commit bee79c4

Please sign in to comment.