Junichirou
Member
- Sep 22, 2015
- 4
- 0
- 56
Greetings friends, I would like to know if it is possible to create a script that assigns an icon automatically depending on the country of the person,
Following by example the lock code created by a r4p3 user
Following by example the lock code created by a r4p3 user
Code:
<?PHP
// Teamspeak config
$teamspeakInfo = array(
'username' => 'serveradmin',
'password' => 'your password',
'host' => '127.0.0.1',
'portQuery' => '10011',
'portServer' => '9987',
'displayname' => 'R4P3.NET'
);
$blacklist = array('DE'); // array('DE', 'HU');
$whitelist = array('DE'); // array('DE', 'HU');
$clientType = 2; // 1 = Everyone, 2 = Ignore Query, 3 = Ignore Clients
$listMode = 1; // 1 = blacklist, 2 = whitelist
$punishMode = 1; // 1 = kick, 2 = ban
$punishMessage = 'Your country is not allowed to join our server.'; // Message the user will see once he got kicked/banned
/*
|--------------------------------------------------------------------------------
| Do not modify anything below this area unless you know what you're doing.
|--------------------------------------------------------------------------------
*/
echo "|--------------------------------------|\n| Disallow specific countries |\n|--------------------------------------|\n";
require_once("ts3admin.class.php");
$tsAdmin = new ts3admin($teamspeakInfo['host'], $teamspeakInfo['portQuery']);
if($tsAdmin->getElement('success', $tsAdmin->connect())) {
echo "> Successfully connected to the teamspeak server\n";
$tsAdmin->login($teamspeakInfo['username'], $teamspeakInfo['password']);
echo "> Successfully logged in\n";
$tsAdmin->selectServer($teamspeakInfo['portServer']);
echo "> Successfully selected server ".$teamspeakInfo['portServer']."\n";
$tsAdmin->setName($teamspeakInfo['displayname']);
echo "> Successfully changed name to ".$teamspeakInfo['displayname']."\n";
$connectionInfo = $tsAdmin->whoAmI()['data'];
for(;;){
$clients = $tsAdmin->clientList("-country -ip");
foreach($clients['data'] as $client) {
if ($listMode == 1) {
$invalidCountry = false;
foreach($blacklist as $blacklistCountry){
if ($client['client_country'] == $blacklistCountry || $client['client_country'] == "") {
switch ($clientType) {
case '1':
$invalidCountry = true;
break;
case '2':
if ($client['client_type'] == 0) {
$invalidCountry = true;
}
break;
case '3':
if ($client['client_type'] == 1) {
$invalidCountry = true;
}
break;
}
}
}
} else if ($listMode == 2) {
$invalidCountry = true;
foreach($whitelist as $whitelistCountry){
if ($client['client_country'] == $whitelistCountry) {
switch ($clientType) {
case '1':
$invalidCountry = false;
break;
case '2':
if ($client['client_type'] == 0) {
$invalidCountry = false;
}
break;
case '3':
if ($client['client_type'] == 1) {
$invalidCountry = false;
}
break;
}
}
}
}
if ($invalidCountry && $connectionInfo['client_id'] != $client['clid']) {
if ($punishMode == 1) {
$tsAdmin->clientKick($client['clid'], "server", $punishMessage);
echo "> Successfully kicked ".$client['client_nickname']." from ".$client['client_country']." -> ".$client['connection_client_ip']."\n";
} else if ($punishMode == 2) {
$tsAdmin->banClient($client['clid'], 0, $punishMessage);
echo "> Successfully banned ".$client['client_nickname']." from ".$client['client_country']."\n";
}
}
}
}
} else {
die('Connection could not be established.');
}
?>