- <?php
- $path = dirname(__FILE__) . '/';
- $nickNames = array(
- "fuck",
- "noob",
- "connard",
- "fdp",
- "pute",
- "mère",
- "père",
- "abruti",
- "débile",
- "crétin",
- "idiot",
- "bite",
- "grosse",
- "fils",
- "enculé",
- "emeute"
- );
- $adminID = array(
- 2
- );
- $yatqa_ip="145.239.47.164"; // sunucu ip
- $yatqa_name="serveradmin"; // yatqa k.adı
- $yatqa_pw="xxx"; // Yatqa şifresi
- $server_id=3; // Sunucu idsi
- $maxgiris=3; // Maksimum giriş sayısı
- $fp = fsockopen($yatqa_ip, 10011, $errno, $errstr, 0.1);
- stream_set_timeout($fp, 0, 100000);
- if($fp)
- {
- send("login ".$yatqa_name." ".$yatqa_pw."");
- send("use sid=".$server_id."");
- send("clientupdate client_nickname=MyGameArea_Security");
- // Traitement des clients connectés sur le serveur TeamSpeak
- $clients = getClients();
- // Vérification des doubles connexions sur le serveur TeamSpeak (mêmes adresses IP)
- checkDoubleConnections($clients);
- send("quit");
- }
- /**
- * Fonctions du programme
- */
- function isAlreadyScan ($credit, $timeout, $data)
- {
- global $path;
- $rep = "alreadyScan";
- $f = $path . $rep . '/ip.' . $data;
- $dir = opendir($rep);
- while ($fread = readdir($dir))
- {
- if($fread != "." && $fread != "..")
- {
- if(filemtime($rep . '/' . $fread) + $timeout < time())
- {
- unlink($rep . '/' . $fread);
- }
- }
- }
- if(file_exists($f))
- {
- return true;
- }
- $fp = fopen($f, "w");
- fputs($fp, $credit);
- fclose($fp);
- return false;
- }
- function textMessage ($i)
- {
- return str_replace(array(" "), '\s', $i);
- }
- function send ($l)
- {
- global $fp;
- usleep(100000);
- fwrite($fp, $l . "\r\n");
- }
- function checkDoubleConnections ($clients)
- {
- global $fp;
- $ipList = array();
- $clidList = array();
- $collectionList = array();
- foreach ($clients as $line)
- {
- if(!empty($line['connection_client_ip']))
- {
- $ipList[] = $line['connection_client_ip'];
- $clidList[] = $line['clid'];
- $collectionList[] = array(
- "clid" => $line['clid'],
- "ip" => $line['connection_client_ip']
- );
- }
- }
- foreach (array_count_values($ipList) as $ip => $count)
- {
- if($count > 3)
- {
- foreach ($collectionList as $value)
- {
- if($value['ip'] == $ip)
- {
- kick($value['clid'], $ip, 'Bir ip adresi ile maximum 3 bağlantı yapılabilir. [MyGameArea Güvenlik Botu]', true);
- }
- }
- }
- }
- }
- function getClients ()
- {
- global $fp, $path;
- // Traitement des clients
- send("clientlist -ip -times -groups -info");
- $clientList = null;
- while ($line = fgets($fp))
- {
- $clientList .= $line;
- }
- $clientList = strstr($clientList, "error id=0 msg=ok");
- $clientList = trim(str_replace(array('error id=0 msg=ok'), "", $clientList));
- $clientsArray = explode("|", $clientList);
- $clients = array();
- foreach ($clientsArray as $line)
- {
- $lineArray = explode(" ", $line);
- $tableTemp = array();
- foreach ($lineArray as $txt)
- {
- $var = strstr($txt, '=', true);
- $value = substr(strstr($txt, '=', false), 1);
- $tableTemp[trim($var)] = trim($value);
- }
- // Récupération des informations supplémentaires sur l'utilisateur
- if(!empty($tableTemp['connection_client_ip']))
- {
- if(file_exists($path . 'alreadyScan' . '/ip.' . $tableTemp['clid'] . '.' . $tableTemp['connection_client_ip']) === FALSE)
- {
- // Récupération des données sur l'utilisateur (unique ID)
- send("clientinfo clid=" . $tableTemp['clid']);
- $infoUserList = null;
- while ($line = fgets($fp))
- {
- $infoUserList .= $line;
- }
- $infoUserListArray = explode(" ", $infoUserList);
- // Construction du tableau avec les informations utilisateurs
- foreach ($infoUserListArray as $txt)
- {
- $var = strstr($txt, '=', true);
- $value = substr(strstr($txt, '=', false), 1);
- if($var == "client_unique_identifier")
- {
- $tableTemp[trim($var)] = trim($value);
- break;
- }
- }
- // END
- }
- }
- $clients[] = $tableTemp;
- unset($tableTemp, $var, $value, $infoUserList, $infoUserListArray, $clientList);
- }
- return $clients;
- }
- function kick ($clid, $ip, $reason, $onlyKick = false)
- {
- global $fp;
- if($onlyKick === TRUE)
- {
- send("clientkick clid=" . $clid . " reasonid=5 reasonmsg=" . textMessage($reason));
- return 0;
- }
- if(AntiFlood(3, (3600 * 24), $ip) === TRUE)
- {
- send("sendtextmessage targetmode=1 target=" . $clid . " msg=" . textMessage("ATTENTION : Vous avez été banni du serveur pour récidive !"));
- send("banclient clid=" . $clid . " time=" . (60 * 60) . " banreason=" . textMessage($reason));
- } else
- {
- send("sendtextmessage targetmode=1 target=" . $clid . " msg=" . textMessage("ATTENTION : Vous avez éjecté du serveur et ceci est le *Premier avertissement* !"));
- send("clientkick clid=" . $clid . " reasonid=5 reasonmsg=" . textMessage($reason));
- }
- }
- ?>