Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // THIS BOT WAS IN KTCC AND LIQ, IT IS NOW PHP FOR ANY IXAT WHO WANTS TO USE IT
- // KTommyBots was made by KTommy
- // This script was made by KTommy and recoded from KTCC to PHP by Andy, A (15) oatchats.
- set_time_limit(0);
- libxml_use_internal_errors(false);
- ini_set('display_errors', 'off');
- error_reporting(0);
- class ktommybots
- {
- public $ixatlink = "localhost";
- public $withoutaccess = "You are not a high enough rank to use this command, the minimum rank is Bot Owner.";
- public $radioinfo = 'stm5.painel.foxsolucoes.net:14702';
- public $users;
- public $logado;
- public $socket;
- public $chatID;
- public $botID;
- public $port;
- public $ip;
- public $k;
- public $filterWords;
- public $maxKicks = 4; //Number of kicks before ban
- public $members = array();
- public $spam = 5;
- public $bad = "";
- public function __construct()
- {
- $config = (object) array('db' => array(0 => 'localhost', 1 => 'root', 2 => 'KTommy2005', 3 => 'panel'));
- $this->mysql = new database($config->db[0], $config->db[1], $config->db[2], $config->db[3]);
- require_once "ixat5.php";
- $this->config->donos = @(array) json_decode($this->config->donos);
- $this->time = time();
- }
- public function connect()
- {
- $this->getinfo();
- $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- $test = socket_connect($this->socket, $this->ip, "1204");
- echo "--> Connecting to {$this->ip}:{$this->port}...\n";
- if(!$test){
- die( "<-- Error to connection!\n" );
- }
- }
- public function disconnect()
- {
- if(isset($this->socket) && $this->socket == true)
- socket_close($this->socket);
- $this->socket = false;
- }
- function getinfo()
- {
- $curl = curl_init($this->ixatlink.'/mobile?'.time());
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, "username={$this->config->username}&password={$this->config->password}&room={$this->config->room}");
- $url = curl_exec($curl);
- $parte1 = explode("\"id\":\"", $url);
- $id = explode("\"", $parte1[1]);
- $this->botID = $id[0];
- $parte2 = explode("\"k\":\"", $url);
- $k = explode("\"", $parte2[1]);
- $this->k = $k[0];
- $k3_data = explode("\"k3\":\"", $url);
- $k3 = explode("\"", $k3_data[1]);
- $this->k3 = $k3[0];
- $sala_data = explode('c="', $url);
- $salaID = explode('"', $sala_data[1]);
- $this->chatID = $salaID[0];
- $parte4 = explode("WebSocket('ws://", $url);
- $ip = explode(":", $parte4[1]);
- $this->ip = $ip[0];
- $dx_data = explode("\"xats\":\"", $url);
- $dx = explode("\"", $dx_data[1]);
- $this->dx = $dx[0];
- $d1_data = explode("\"days\":\"", $url);
- $d1 = explode("\"", $d1_data[1]);
- $this->d1 = $d1[0];
- $tesa = explode("var mypowers = JSON.parse('", $url);
- $tesa_1 = explode("');", $tesa[1]);
- $this->mypowers = json_decode($tesa_1[0], true);
- $parte5 = explode($this->ip.':', $url);
- $port = explode("/", $parte5[1]);
- $this->port = $port[0];
- if(empty($url)){
- die( "<-- Connection failed, or the website could be closed!!\n");
- }
- if(empty($this->botID)){
- die( "<-- The chat doesn't exist, or the data is incorrect!\n");
- }
- }
- public function passXML($xml, $return = null)
- {
- $content = @simplexml_load_string(trim($xml));
- foreach($content->Attributes() as $i => $u)
- $return[$i] = (string) ((string) $u);
- return $return;
- }
- public function send($packet)
- {
- if($packet[strlen($packet) - 1] != chr(0))
- $packet .= chr(0);
- echo "[BOT]-> {$packet}\n";
- return socket_write($this->socket, $packet, strlen($packet));
- }
- public function LatestPow($name){
- //Codded By ktommybots
- $Powers = @file_get_contents('http://'.$this->ixatlink.'/json/powers.php');
- $lastpow = reset(json_decode($Powers, true));
- $pow2 = @file_get_contents('http://'.$this->ixatlink.'/web_gear/chat/pow2.php');
- $lpow2 = json_decode($pow2, true);
- $PowName = array_search($lpow2['0']['1']['id'], $lpow2['6']['1']);
- $PowId = $lpow2['0']['1']['id'];
- $Price = $lastpow["x"] . PHP_EOL;
- $Status = ($lpow2[0][1]['text'] == '[LIMITED]') ? 'LIMITED':'UNLIMITED';
- $value = array("{lpname}","{lpid}","{lpprice}","{lptype}");
- $replace = array(ucfirst($PowName), $PowId, $Price, $Status);
- return str_replace($value, $replace, $name);
- }
- public function enter()
- {
- $this->connect();
- $this->send("<y r=\"{$this->chatID}\" v=\"0\" u=\"{$this->config->botid}\" />");
- $x = $this->passXML(socket_read($this->socket, $this->port));
- $bot2 = floor(pow(2, $x['ys'] % 27));
- $bot1 = floor(2 << ($x['yi'] % 94)) % $x['yc'] + $x['yi'];
- $j2 = "cb=\"0\" ";
- $j2 .= "auth1=\"{$bot1}\" ";
- $j2 .= "auth2=\"{$bot2}\" ";
- $j2 .= "y=\"{$x["yi"]}\" ";
- $j2 .= "k=\"{$this->k}\" ";
- $j2 .= "k3=\"{$this->k3}\" ";
- $j2 .= "d1=\"{$this->d1}\" ";
- $j2 .= "p=\"0\" ";
- $j2 .= "c=\"{$this->chatID}\" ";
- $j2 .= "f=\"{$this->config->botpawn}\" ";
- $j2 .= "u=\"{$this->config->botid}\" ";
- $j2 .= "d0=\"0\" ";
- foreach($this->mypowers as $i => $u){
- $j2 .= "d".substr($i, 1)."=\"{$u}\" ";
- }
- $j2 .= "dO=\"\" ";
- $j2 .= "dx=\"{$this->dx}\" ";
- $j2 .= "N=\"{$this->config->username}\" ";
- $j2 .= "n=\"{$this->LatestPow($this->config->name)}(glow#{$this->config->glow})(hat#{$this->config->hat})(text#{$this->config->tglow})##{$this->LatestPow($this->config->sta)}#{$this->config->sta2}\" ";
- $j2 .= "a=\"{$this->LatestPow($this->config->avatar)}#{$this->config->pcback}\" ";
- $j2 .= "h=\"{$this->config->homepage}\" ";
- $j2 .= "v=\"5\"";
- $j2 = "<j2 {$j2} />";
- $this->send($j2);
- }
- public function load($check = true, $test_var = true)
- {
- $x = "";
- try {
- $x = rtrim(socket_read($this->socket, 2048));
- $x = str_replace("", "", $x);
- }
- catch(Exception $e){
- return "OFF";
- }
- if(!$x)
- return "OFF";
- if($x[strlen($x) - 1] != ">")
- $x .= $this->load(true);
- if($check)
- $this->packets($x, $test_var);
- return $x;
- }
- public function packets($packet, $test = true, $test2 = false)
- {
- if(substr_count($packet, ">") > 1){
- $packet = explode("/>", $packet);
- $test2 = true;
- }
- foreach((array) $packet as $p ){
- if($test2)
- $p .= "/>";
- $p = trim($p);
- if(strlen($p) < 5)
- return;
- $type = trim(strtolower(substr($p, 1, strpos($p." ", " "))));
- $p = trim(str_replace("<".$type, "", str_replace("/>", "", $p)));
- $p = str_replace("\"", "", str_replace("\" ", "&", str_replace("&", "__38", $p)));
- parse_str($p, $this->packet[$type]);
- foreach($this->packet[$type] as $x => $v)
- $this->packet[$type][$x] = str_replace("__38", "&", str_replace("pl_", "+", $v));
- if($test)
- $this->type($type, $this->packet[$type]);
- }
- }
- public function type($type, $packet)
- {
- switch($type){
- case 'u':
- $u = $this->fetchUser($packet['u']);
- $this->users[$this->parseU($packet['u'])] = $packet;
- $this->users[$packet['u']]['cb'] = @$packet['cb'];
- $this->users[$packet['u']]['s'] = @$packet['s'];
- $this->users[$packet['u']]['f'] = (isset($packet['f'])) ? (int)$packet['f']: 0;
- $this->users[$packet['u']]['id'] = $packet['u'];
- $this->users[$packet['u']]['d0'] = (isset($packet['d0'])) ? (int)$packet['d0']: 0;
- $this->users[$packet['u']]['d2'] = (isset($packet['d2'])) ? @$packet['d2']: 0;
- $this->users[$packet['u']]['q'] = (isset($packet['q'])) ? (int)$packet['q']: 0;
- $this->users[$packet['u']]['registered'] = ((key_exists('N', $packet)) ? $packet['N']: 'Unregistered');
- $this->users[$packet['u']]['name'] = @$packet['n'];
- $this->users[$packet['u']]['avatar'] = (isset($packet['a'])) ? @$packet['a']: 'No Avatar';
- $this->users[$packet['u']]['home'] = (isset($packet['h'])) ? @$packet['h']: 'No Homepage';
- $this->users[$packet['u']]['v'] = (@$packet['v']) ? @$packet['v']: 0;
- $this->users[$packet['u']]['bride'] = (isset($packet['d2'])) ? @$packet['d2']: 0;
- $this->users[$packet['u']]['rel'] = (@$packet['d0'] & 1) ? 1: 2;
- $this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1: 0;
- $user = ( $packet['N']) ? $packet['N']: $packet['u'];
- $avatar = ( $packet['a']) ? $packet['a']: $packet['a'];
- $casinha = ( $packet['h']) ? $packet['h']: $packet['h'];
- $userid = $packet['i'];
- $uid = $packet['u'];
- $user4 = ($this->users[$packet["u"]]["n"]) ? $this->users[$packet["u"]]["n"]: $this->users[$packet["u"]]["u"];
- $hat = explode("(hat#", $user4, 2);
- $hat2 = explode(")", $hat[1], 2);
- $glow = explode("(glow#", $user4, 2);
- $glow2 = explode(")", $glow[1], 2);
- $status = explode("##", $user4, 2);
- if(!empty($this->config->autowelcome) && !isset($packet['s']))
- {
- $this->sendwelcome($this->config->autowelcome, $packet['u'], $packet['f'], $user);
- $this->mysql->query("INSERT INTO users(user, userid) SELECT '$user', $uid FROM DUAL WHERE NOT EXISTS(SELECT user FROM users WHERE user = '$user')");
- $this->mysql->query("UPDATE users SET status = '{$status[1]}', chat = '[".time().",\"{$this->config->room}\"]', home = '{$this->users[$packet['u']]['home']}', nick = '$user4', avatar = '$avatar', casinha = '$casinha' WHERE user = '$user'");
- }
- if($packet['rank'] == 5)
- {
- if($this->config->automember == 1){
- $this->member($packet['u']);
- }
- }
- if($packet['rank'] == 3)
- {
- if($this->config->autoguest == 1){
- $this->guest($packet['u']);
- }
- }
- break;
- case "i":
- $info = explode(';=', $this->packet['i']['b']);
- $this->radioinfo = str_replace("http://", "", $info[4]);
- break;
- case "z":
- $this->sendmsg("{$this->config->ticklemsg}", "PM", $packet["u"]);
- break;
- case "m":
- case "p":
- if (substr($packet['t']) && ++$this->users[$packet['u']]['messages'] >= 1 && time() - $this->users[$packet['u']]['time'] < 1)
- {
- $this->kick("Flood");
- }
- $caps = $packet['t'];
- if (ereg("^([A-Z]+)$", $caps[0]))
- {
- //$this->kick('Caps Lock', $packet['u']);
- }
- if (preg_match('/(.)\1{' . ($this->spam - 1) . ',}/', strtolower($packet['t'])) != 0)
- {
- $this->kick('Spam Detectado', $packet['u']);
- }
- $bad = explode(chr(10) , file_get_contents('bad.txt'));
- $bad = array_map('trim', $bad);
- foreach($bad as $word)
- {
- if (is_numeric(stripos($packet['t'], $word)))
- {
- $this->kick('Inappropriate Language (In Languages: English)');
- break;
- }
- }
- if (isset($packet["i"]) && $packet["i"] > 0) break;
- $msg = $message = explode(" ", $packet["t"]);
- unset($msg[0]);
- $msg = implode(" ", $msg);
- $user4 = ($this->users[$packet["u"]]["n"]) ? $this->users[$packet["u"]]["n"]: $this->users[$packet["u"]]["u"];
- foreach(unserialize($this->config->responses) as $i => $u)
- {
- if(($u[1] == True && strtolower($packet["t"]) == $i) || ($u[1] != True && is_numeric(stripos($packet["t"], $i))))
- {
- $response = str_replace(
- array("{nick}"),
- array($user4),
- $u[0]
- );
- $this->sendmsg($this->LatestPow($response));
- return True;
- }
- }
- if(isset($message[0]) && $message[0][0] != "!")
- break;
- $user = $this->users[$packet["u"]];
- $user2 = ($user["N"]) ? $user["N"]: $user["u"];
- $bot = $this->mysql->fetch_array("select * from `bots` where `id`=1;");
- switch(substr($message[0], 1)){
- case "say":
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->sendmsg("[$user2] : ".$msg);
- break;
- case "kiss":
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $message = explode(' ', $mensagem[3], 3);
- switch($mensagem[1]){
- case "Bruna":
- $this->sendmsg('<a k="Bruna" p="' . $this->senha . '" m="'. $message[0] .'" />');
- break;
- case "Foda":
- $this->sendmsg('<a k="Foda" p="' . $this->senha . '" m="FODA-SE" />');
- break;
- case "Dig":
- $this->sendmsg('<a k="Digdin" p="' . $this->senha . '" m="SOU FODA" />');
- break;
- case "Susto":
- $this->sendmsg('<a k="Susto" p="' . $this->senha . '" m="OI" />');
- break;
- case "Shark":
- $this->sendmsg('<a k="Shark" p="' . $this->senha . '" m="KISS BOT" />');
- break;
- }
- break;
- case 'ban':
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->ban($message[2], $message[1], $message[3]);
- break;
- case "glow":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET glow='{$msg}' WHERE id={$this->config->id}");
- $this->config->glow = $msg;
- $this->sendmsg('Meu NameGlow Foi Alterado Para [(glow#' . $msg . ' )] ! ');
- $this->restart();
- break;
- case "ktommybots":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET room='{$msg}' WHERE id={$this->config->id}");
- $this->config->room = $msg;
- $this->sendmsg('Eu fui mudado para o xat [' . $msg . '] ! ');
- $this->restart();
- break;
- case "nome":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET name='{$msg}' WHERE id={$this->config->id}");
- $this->config->name = $msg;
- $this->sendmsg('Meu Nome Foi Alterado Para [' . $msg . '] ! ');
- $this->restart();
- break;
- case "status":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET sta='{$msg}' WHERE id={$this->config->id}");
- $this->config->sta = $msg;
- $this->sendmsg('Meu Status Foi Alterado Para [' . $msg . '] ! ');
- $this->restart();
- break;
- case "statusglow":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET sta2='{$msg}' WHERE id={$this->config->id}");
- $this->config->sta2 = $msg;
- $this->sendmsg('Meu StatusGlow Foi Alterado Para [' . $msg . '] ! ');
- $this->restart();
- break;
- case "statuscolor":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET tglow='{$msg}' WHERE id={$this->config->id}");
- $this->config->tglow = $msg;
- $this->sendmsg('Meu StatusColor Foi Alterado Para [' . $msg . '] ! ');
- $this->restart();
- break;
- case "info":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->sendmsg('Oldbots.com Criado por ktommybots');
- break;
- case "welcome":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET autowelcome='{$msg}' WHERE id={$this->config->id}");
- $this->config->autowelcome = $msg;
- $this->sendmsg('Minha Mensagem Inicial Foi Alterado Para [' . $msg . '] ! ');
- $this->restart();
- break;
- case "casinha":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET homepage='{$msg}' WHERE id={$this->config->id}");
- $this->config->homepage = $msg;
- $this->sendmsg('Minha Casinha Foi Alterado Para [' . $msg . '] ! ');
- $this->restart();
- break;
- case "tickle":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET ticklemsg='{$msg}' WHERE id={$this->config->id}");
- $this->config->ticklemsg = $msg;
- $this->sendmsg('Meu TickleMsg Foi Alterado Para [' . $msg . '] ! ');
- $this->restart();
- break;
- case "avatar":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET avatar='{$msg}' WHERE id={$this->config->id}");
- $this->config->avatar = $msg;
- $this->sendmsg('Minha Imagem Foi Alterado Para [' . $msg . '] ! ');
- $this->restart();
- break;
- case "hat":
- if (!in_array($packet['u'], $this->config->admins)) {
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->mysql->query("UPDATE bots SET hat='{$msg}' WHERE id={$this->config->id}");
- $this->config->hat = $msg;
- $this->sendmsg('Meu Hat Foi Alterado Para [(hat#' . $msg . ' )] ! ');
- $this->restart();
- break;
- case "perg":
- case "8ball":
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- // !perg/!8ball [pergunta]
- $resposta = array(
- 'Talvez sim',
- 'Sim.',
- 'Nao.',
- 'Minhas fontes informou que nao.',
- 'Ah, sim e sim',
- 'Na verdade nao sei',
- 'Nao sei mas o Key Virou Gay \'-\'',
- 'Eu acho que nao',
- 'Muito bom',
- 'Definiu-se que sim.'
- );
- $resposta = $resposta[ array_rand( $resposta ) ];
- $message = array( );
- foreach ( $message as $k => $valus ) {
- $valus = strtoupper( $valus );
- array_push( $message, $values );
- } //$message as $k => $valus
- $this->sendmsg( '' . $resposta . $packet[ 'u' ] );
- break;
- case "testegay":
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- // !perg/!8ball [pergunta]
- $resposta = array(
- 'Ele é gay.',
- 'Ele é machao'
- );
- $resposta = $resposta[ array_rand( $resposta ) ];
- $message = array( );
- foreach ( $message as $k => $valus ) {
- $valus = strtoupper( $valus );
- array_push( $message, $values );
- } //$message as $k => $valus
- $this->sendmsg(" $resposta");
- break;
- case "online":
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->sendmsg($user2 . '' . ' Existem ' . count($this->users) . ' Usuarios Online.');
- break;
- case "smileytest":
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $user = $this->users[ $packet[ "u" ] ];
- $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
- $this->sendmsg ('('.$msg.') ');
- break;
- case "sayadm":
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->sendmsg(' '.$msg.'');
- break;
- case "restart":
- if(!in_array($packet["u"], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet["u"]);
- }
- $this->sendmsg("[Servidor]: Estou sendo reiniciado (backoff)");
- $this->restart();
- break;
- case'modme':
- $message = explode(' ', $message[1], 1);
- $users = $message[0];
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/m" />');
- break;
- case 'dx':
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $days = intval($message[1]);
- if($days < 1)
- return $this->sendPM($packet['u'], 'days must be 1 or more');
- $tradeValue = 13;
- $xats = floor($days * $tradeValue);
- $this->sendmsg($days.' days costa '.$xats.' xats cu 13 xats pe days');
- break;
- case "powers":
- $user = $this->users[$packet["u"]];
- $user2 = ($user["registered"]) ? $user["registered"]: $user["u"];
- $this->sendmsg('/!everypower '.$user2.'');
- break;
- case'ownerme':
- $message = explode(' ', $message[1], 1);
- $users = $message[0];
- if(!in_array($packet['u'], $this->config->admins)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
- }
- $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/M" />');
- break;
- case 'lastpower':
- $url = @file_get_contents('http://xat.com/json/powers.php');
- if(empty($url)){$this->sendmsg('Falha ao obter o ultimo power, avise um administrador!'); return false;}
- $conteudo = json_decode($url, true);
- $ultimo_pw = reset($conteudo);
- $this->sendmsg('Ultimo Power Adicionado : ('.$ultimo_pw['s'].'#).');
- break;
- case 'radio':
- $connection = explode(':', $this->radioinfo);
- $url = fsockopen("stm5.painel.foxsolucoes.net", 14702);
- if (!$url)
- {
- $this->enviarmsg("Connection failed.");
- return false;
- }
- else
- {
- fputs($url, "GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
- $socket = fread($url, 1000);
- $return = explode(",", $socket);
- $final = str_replace("</body></html>", "", $return[6]);
- if (!$final)
- {
- $this->sendmsg("Musica Atual:");
- return false;
- }
- else $this->sendmsg("Musica Atual: {$final}");
- }
- break;
- case'userinfo':
- $message = explode(' ', $message[1], 1);
- $user = $message[0];
- if(!$this->users[$user]['id']){
- $this->sendmsg("I'm not a noob.");
- } else {
- if($this->users[$user]['rel'] == 2) $this->users[$user]['rel'] = "Married";
- if($this->users[$user]['rel'] == 1) $this->users[$user]['rel'] = "Bff'd";
- $myNick = explode("##", $this->users[$user]['name'], 2);
- $myNick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($myNick[0])));
- $relation = $this->users[$user]['rel'].' to '.$this->users[$user]['d2'];
- if($relation == 'Married to 0') $relation = 'Relation not found.';
- $name = explode('##', $this->users[$user]['name']);
- $n = $name[1];
- $this->sendmsg('Nome : '.$myNick[0].' | Status : '.str_replace('#',' | ',$n).'| Avatar : '.$this->users[$user]['avatar'].' | Casinha : '.$this->users[$user]['home'].' | Relacao : '.$relation);
- }
- break;
- case "desligar":
- case "off":
- if(!in_array($packet["u"], $this->config->donos)){
- return $this->sendmsg($this->config->semcmd, "PM", $packet["u"]);
- }
- $this->sendmsg("{$this->config->desligar}");
- die();
- break;
- }
- }
- }
- function parseU($id){
- if(substr_count($id,'_')>=1) $id = substr($id,0,strpos($id,'_'));
- return $id;
- }
- public function restart()
- {
- require_once "ls.php";
- $this->disconnect();
- $this->enter();
- }
- function fetchUser($id)
- {
- $id = $this->parseU($id);
- if (isset($this->users[$id])) return $this->users[$id];
- else return false;
- }
- function kick($message, $id, $log = true)
- {
- if ($log)
- {
- if (!empty($this->users[$id]['kicks'])) $this->users[$id]['kicks']++;
- else $this->users[$id]['kicks'] = 1;
- }
- if ($this->users[$id]['kicks'] > $this->maxKicks)
- {
- $this->ban($message, $id, 3600);
- $this->users[$id]['kicks'] = 0;
- return;
- }
- $this->send('<c p="' . $message . " " . $this->users[$id]['kicks'] . '/' . $this->maxKicks . '" u="' . $id . '" t="/k" />');
- }
- public function ir2Rank($r)
- {
- switch($r)
- {
- case 1: return 'main'; break;
- case 2: return 'mod'; break;
- case 3: return 'member'; break;
- case 4: return 'owner'; break;
- }
- }
- function fetchID($id) {
- //Only searches users of the local chat room.
- if(!is_numeric($id)) {
- foreach($this->users as $u) {
- if(strtoupper($u['N']) == strtoupper($id)) {
- $rid = $u['u'];
- }
- }
- } else {
- foreach($this->users as $u) {
- if($u['u'] == $id) {
- $rid = $u['u'];
- } else {
- $rid = $id;
- }
- }
- }
- $rid = (is_numeric(@$rid)) ? $rid : false;
- return $rid;
- }
- function ban($message, $id, $time)
- {
- $this->send('<c p="' . ereg_replace('[^A-Za-z0-9.! ]', '', $message) . '" u="' . $id . '" t="/g' . $time . '" />');
- }
- function member($id,$time=null){
- if(!$time) $time = 0;
- $id = $this->parseU($id);
- $this->sendC($id, '/e',$time);
- }
- function guest($id,$time=null) {
- if(!$time) $time = 0;
- $id = $this->parseU($id);
- $this->sendC($id, '/r',$time);
- }
- public function sendC($id=0, $com='') {
- $this->send('<c u="'.$id.'" t="'.$com.'" />');
- }
- public function censor($message) {
- $badwords = $this->censor;
- $message = @preg_replace('#\((.+)\)#U','',strtolower(' '.$message.' '));
- foreach($badwords as $bad) {
- $bad = trim($bad);
- if(strpos($message.' ', $bad.' ')!==false) {
- if(strlen($bad)>=2) {
- return true;
- }
- }
- }
- }
- function sendwelcome($message, $id, $f, $nome)
- {
- if(!$message)
- {
- return false;
- }
- $message = str_replace('[chat]', $this->config->room, $message);
- $message = str_replace('[online]', count($this->users), $message);
- $message = str_replace('[user]', $nome, $message);
- $this->sendmsg($message, 'PM', $id);
- }
- function sendmsg($message, $type = "MSG", $id = 0)
- {
- if(!$message){
- return false;
- }
- switch($type) {
- case "MSG":
- $this->send("<m t=\"{$message}\" u=\"{$this->botID}\" />");
- break;
- case "PM":
- $this->send("<p u=\"{$id}\" t=\"{$message}\" d=\"{$id}\" />");
- break;
- case "PC":
- $this->send("<z d=\"{$id}\" u=\"{$this->botID}\" t=\"{$message}\" />");
- break;
- }
- }
- }
- $bot = new ktommybots();
- while(1){
- try{
- if($bot->load() == "OFF"){
- $bot->disconnect();
- $bot->enter();
- }
- }
- catch(Exception $e){
- die($e);
- }
- }
- class database {
- public $link, $host, $user, $pass, $name;
- public $doe = true;
- public function __construct($host = null, $user = null, $pass = null, $name = null)
- {
- if ($name != null) {
- $this->host = $host;
- $this->user = $user;
- $this->pass = $pass;
- $this->name = $name;
- }
- if (!$this->connected()) {
- $this->link = mysqli_connect($this->host, $this->user, $this->pass, $this->name);
- if (!$this->connected()){$this->error("Failed to connect to `{$this->host}`.`{$this->name}` using password [" . (empty($this->pass) ? "NO" : 'YES') . "]");}
- }
- return true;
- }
- public function connected(){return @mysqli_ping($this->link) ? true : false;}
- public function error($error)
- {
- print $error . chr(10);
- if ($this->doe == true){exit;}
- }
- public function query($query = "")
- {
- if (!is_string($query)){return false;}
- $this->__construct();
- $return = @mysqli_query($this->link, $query);
- return $return ? $return : false;
- }
- public function fetch_array($query, $return = array())
- {
- $this->__construct();
- if (!is_string($query) || !($res = $this->query($query))){return array();}
- while ($data = mysqli_fetch_assoc($res)) {$return[] = $data;}
- return !empty($return) ? $return : array();
- }
- public function sanatize($data)
- {
- if(is_array($data)){return array_map(array($this,'sanatize'), $data);}
- if(function_exists("mb_convert_encoding")) {$data = @mb_convert_encoding($data, "UTF-8", 'auto');}
- return $this->link->real_escape_string($data);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement