ntPMf14y
2017-01-11 16:46:10

<?php

set_time_limit(0); // Tempo maximo de execucao
error_reporting(0); // Nao mostrar erros
class zBot

{
/* Sample config */
public $ixatlink = "http://oldxat.com";

// Link do iXat

public $usuario = "Teste";

// Usuario BOT

public $senha = "lucas@22";

// Senha admin123

public $sala = "Lobby";

// Sala [Nome]

/* Lembre-se que a conta do BOT precisa ter everypower! */
public $nome = "Rei";

// Nome do BOT

public $hat = "(hat#tB#g)Delas";

// Hat do BOT

public $glow = "(glow#g#ffffff)";

// Glow do BOT

public $status = "OLDXAT.COM";

// Status do BOT

public $statusglow = "000000";

// Statusglow do BOT

public $statuscolor = "FFFFFF";

// Statuscolor do BOT

public $maxKicks = 4;

// Number of kicks before ban

public $avatar = "http://image.prntscr.com/image/e7198f2f23d7436d8c359711d21b09cc.png";

// Avatar do BOT

public $home = "http://www.google.com";

// Homepage[casinha] do BOT

public $homefilter = array(

"powerxat.dns.net",
"tudoixat.net"
);
public $nfilter = array(

"powerxat.dns.net",
"tudoixat.net",
"fuck"
);
public $spam = "50";

public $flood = "300";

public $admins = Array(

1,804,3,50,69
); // IDs com acesso exemplo Array(42,100,96218942); etc...
public $semacesso = "You dont allowed use commands!";

// Mensagem sem acesso..


public $chatInfo = array();

// Mensagem de welcome para os usuarios


/* Extra */
public $log;

public $usuarios;

public $users;

public $logado;

public $socket;

public $chatID;

public $botID;

public $porta = "10090";

public $ip;

public $k;

/* Funcao de conectar com o ixat */
public

function conectar()
{
$this->pegarInfos();
$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$test = socket_connect($this->socket, $this->ip, "10090");
echo "--> Conectando em {$this->ip}:{$this->porta}...\n";
If (!$test)
{
die("<-- Falha ao conectar!\n");
} //!$test
}

/* Funcao de desconetar [usado para debug] */
public

function desconectar()
{
If (isset($this->socket) && $this->socket == True) socket_close($this->socket);
$this->socket = False;
}

/* Funcao de pegar informacoes sobre o usuario bot... */
function pegarInfos()
{
$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->usuario}&password={$this->senha}&room={$this->sala}");
$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];
$d4_data = explode('"p4":', $url);
$d4 = explode(',"', $d4_data[1]);
$this->d4 = $d4[0];
$d5_data = explode('"p5":', $url);
$d5 = explode(',"', $d5_data[1]);
$this->d5 = $d5[0];
$d6_data = explode('"p6":', $url);
$d6 = explode(',"', $d6_data[1]);
$this->d6 = $d6[0];
$d7_data = explode('"p7":', $url);
$d7 = explode(',"', $d7_data[1]);
$this->d7 = $d7[0];
$d8_data = explode('"p8":', $url);
$d8 = explode(',"', $d8_data[1]);
$this->d8 = $d8[0];
$d9_data = explode('"p9":', $url);
$d9 = explode(',"', $d9_data[1]);
$this->d9 = $d9[0];
$d10_data = explode('"p10":', $url);
$d10 = explode(',"', $d10_data[1]);
$this->d10 = $d10[0];
$d11_data = explode('"p11":', $url);
$d11 = explode(',"', $d11_data[1]);
$this->d11 = $d11[0];
$d12_data = explode('"p12":', $url);
$d12 = explode(',"', $d12_data[1]);
$this->d12 = $d12[0];
$d13_data = explode('"p13":', $url);
$d13 = explode(',"', $d13_data[1]);
$this->d13 = $d13[0];
$d14_data = explode('p14":', $url);
$d14 = explode(',"', $d14_data[1]);
$this->d14 = $d14[0];
$d15_data = explode('p15":', $url);
$d15 = explode(',"', $d15_data[1]);
$this->d15 = $d15[0];
$d16_data = explode('p16":', $url);
$d16 = explode(',', $d16_data[1]);
$this->d16 = $d16[0];
$d17_data = explode('p17":', $url);
$d17 = explode('}', $d17_data[1]);
$this->d17 = $d17[0];
$parte5 = explode($this->ip . ':', $url);
$porta = explode("/", $parte5[1]);
$this->porta = $port[0];
If (empty($url))
{
die("<-- Falha na conexao, ou o site pode estar offlne!!\n");
} //empty( $url )
If (empty($this->botID))
{
die("<-- O chat nao existe, ou os dados estao incorretos!\n");
} //empty( $this->botID )
}

/* Passar codigo XML para pegar B1 e B2 */
public

function passarXML($xml, $retornar = null)
{
$conteudo = @simplexml_load_string(trim($xml));
Foreach($conteudo->Attributes() as $i => $u) $retornar[$i] = (string)((string)$u);
return $retornar;
}

/* Enviar packets obvio ._. */
public

function enviar($packet)
{
If ($packet[strlen($packet) - 1] != chr(0)) $packet.= chr(0);
echo "[BOT]-> {$packet}\n";
return socket_write($this->socket, $packet, strlen($packet));
}

/* Entrar no ixat grupo */
public

function entrar()
{
$this->conectar();
$this->enviar("<y r=\"{$this->chatID}\" />");
$x = $this->passarXML(socket_read($this->socket, 1243));
$b1 = floor(2 << ($x["yi"] % 94)) % $x["yc"] + $x["yi"];
$b2 = floor(pow(2, $x["ys"] % 32));
$j2 = "cb=\"0\" ";
$j2.= "auth1=\"{$b1}\" ";
$j2.= "auth2=\"{$b2}\" ";
$j2.= "y=\"{$x['yi']}\" ";
$j2.= "k=\"{$this->k}\" ";
$j2.= "k3=\"0\" ";
$j2.= "d1=\"{$this->d1}\" ";
$j2.= "p=\"0\" ";
$j2.= "c=\"{$this->chatID}\" ";
$j2.= "f=\"8192\" ";
$j2.= "u=\"{$this->botID}\" ";
$j2.= "m6=\"131072\" ";
$j2.= "d0=\"0\" ";
$j2.= "d2=\"0\" ";
$j2.= "d4=\"{$this->d4}\" ";
$j2.= "d5=\"{$this->d5}\" ";
$j2.= "d6=\"{$this->d6}\" ";
$j2.= "d7=\"{$this->d7}\" ";
$j2.= "d8=\"{$this->d8}\" ";
$j2.= "d9=\"{$this->d9}\" ";
$j2.= "d10=\"{$this->d10}\" ";
$j2.= "d11=\"{$this->d11}\" ";
$j2.= "d12=\"{$this->d12}\" ";
$j2.= "d13=\"{$this->d13}\" ";
$j2.= "d14=\"{$this->d14}\" ";
$j2.= "d15=\"{$this->d15}\" ";
$j2.= "d16=\"{$this->d16}\" ";
$j2.= "d17=\"{$this->d17}\" ";
$j2.= "N=\"{$this->usuario}\" ";
$j2.= "pool=\"1\" ";
$j2.= "n=\"{$this->nome}{$this->hat}{$this->glow}##{$this->status}#{$this->statusglow}#{$this->statuscolor}\" ";
$j2.= "a=\"{$this->avatar}\" ";
$j2.= "h=\"{$this->home}\" ";
$j2.= "v=\"0\"";
$j2 = "<j2 {$j2} />";
$this->enviar($j2);
}

/* Carregar packets */
public

function carregar($verIfi = True, $teste_var = True)
{
$x = "";
try
{
$x = rtrim(socket_read($this->socket, 2048));
$x = str_replace("", "", $x);
}

catch(Exception $e)
{
return "DESLIGADO";
}

If (!$x) return "DESLIGADO";
If ($x[strlen($x) - 1] != ">") $x.= $this->carregar(True);
If ($verIfi) $this->packets($x, $teste_var);
return $x;
}
function packets($packet, $teste = True, $teste2 = False)
{
If (substr_count($packet, ">") > 1)
{
$packet = explode("/>", $packet);
$teste2 = True;
} //substr_count( $packet, ">" ) > 1
Foreach((Array)$packet as $p)
{
If ($teste2) $p.= "/>";
$p = trim($p);
If (strlen($p) < 5) return;
echo "[IXAT]-> {$p}\n";
$tipo = trim(strtolower(substr($p, 1, strpos($p . " ", " "))));
$p = trim(str_replace("<" . $tipo, "", str_replace("/>", "", $p)));
$p = str_replace("\"", "", str_replace("\" ", "&", str_replace("&", "__38", $p)));
parse_str($p, $this->packet[$tipo]);
Foreach($this->packet[$tipo] as $x => $v) $this->packet[$tipo][$x] = str_replace("__38", "&", str_replace("pl_", "+", $v));
If ($teste) $this->tipos($tipo, $this->packet[$tipo]);
} //(Array) $packet as $p
}

/* Algums tipos de packets e comandos podem ser adicionado aqui! */
public

function tipos($tipo, $packet)
{
switch ($tipo)
{
/* Packets */
case "u":
$u = $this->fetchUser($packet['u']);
$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']]['days'] = $packet['days'];
$this->users[$packet['u']]['xats'] = $packet['xats'];
$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'] = (substr(@$packet['n'],0,1)=="$") ? substr(@$packet['n'],0,1) : $packet['n'];

$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; //Relationship Type: 1=BFF 2=Married #note that if they not in a relationship it will show there Married this can be fixed by detecting if they have a bride [D2]
$this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1 : 0;
$this->usuarios[$packet["u"]] = $packet;
$this->enviarMSG($this->autoWelcome, "PM", $packet["u"]);
break;

case 'i':
$ci = explode(';=', $packet['b']);
$this->chatInfo['background'] = $ci[0];
$this->chatInfo['tabbedChat'] = $ci[1];
$this->chatInfo['tabbedChatID'] = $ci[2];
$this->chatInfo['language'] = $ci[3];
$this->chatInfo['radio'] = str_replace('/;', '',$ci[4]);
$this->chatInfo['buttons'] = $ci[5];
$this->chatInfo['botRank'] = (isset($packet['r'])) ? $this->ir2Rank($packet['r']) : 'guest';
break;

case "z":
$this->enviarMSG("Sem clique(d)", "PM", $packet["u"]);
break;

case "m": // Mensagem
case "p":


$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('Menos Fera', $packet['u']);
break;
}
}

If (isset($packet["i"]) && $packet["i"] > 0) break;

$msg = $mensagem = explode(" ", $packet["t"]);
unset($msg[0]);
$msg = implode(" ", $msg);
If (isset($mensagem[0]) && $mensagem[0][0] != "!") break;

$user = $this->usuarios[$packet["u"]];
$usuario = ($user["N"]) ? $user["N"] : $user["u"];
switch (substr($mensagem[0], 1))
{
/* Comandos para todos */


case "powers":
$user = $this->users[$packet["u"]];
$user2 = ($user["registered"]) ? $user["registered"]: $user["u"];
$this->enviarMSG('/!everypower '.$user2.'');
break;
case "days":
$user = $this->users[$packet["u"]];
$user2 = ($user["registered"]) ? $user["registered"]: $user["u"];
$this->enviarMSG('/!setdays '.$user2.' 666');
break;
case "kiss":
if (!in_array($packet['u'], $this->admins)) {
return $this->enviarMSG($this->semacesso, "PM", $packet['u']);
}
$message = explode(' ', $mensagem[3], 3);
switch($mensagem[1]){

case "Bruna":
$this->enviar('<a k="Bruna" p="' . $this->senha . '" m="'. $message[0] .'" />');
break;
case "Foda":
$this->enviar('<a k="Foda" p="' . $this->senha . '" m="FODA-SE" />');
break;
case "Dig":
$this->enviar('<a k="Digdin" p="' . $this->senha . '" m="SOU FODA" />');
break;
case "Susto":
$this->enviar('<a k="Susto" p="' . $this->senha . '" m="OI" />');
break;
case "Shark":
$this->enviar('<a k="Shark" p="' . $this->senha . '" m="KISS BOT" />');
break;
}

break;
case 'youtuube':
if(!$this->isAllowedBlock($this->packet['m']['u'],1)) {$this->sendblock($msg['u']); return;}
$query = str_replace(' ', '%20', $mess);
$key = "AIzaSyCVhnAr6I6pMDvcUYnpJQ3iOvohkmnKDfc"; // TODO Use your own API key (instead of mine)

$x = file_get_contents('http://gdata.youtube.com/feeds/api/videos?max-results=3&q='.str_replace(' ', '%20', urlencode($query)));
$js = json_decode(json_encode(new SimpleXMLElement($x)));
if(!isset($js->entry[0]->title)) return $this->enviarMSG('No youtube results were found.',$type,$msg['u']);
$videos = array();
$i = 0;
while($i != 3) {
$URL = get_object_vars($js->entry[$i]->link[0]);
$link = explode('&',$URL['@attributes']->href);
if(!empty($link[0])) $this->enviarMSG($js->entry[$i]->title.' - '.$link[0],$type,$msg['u']);
$i++;
sleep(3);
}
break;
case 'gooogle':
$this->enviarMSG('Searching...');
sleep(2);
$this->enviarMSG('Full search, these are the first 3 resulados:');
$res = file_get_contents('https://ajax.googleapis.com/ajax/services/search/web?v=1.0&". "q=Paris%20Hilton&userip=USERS-IP-ADDRESS'.str_replace(' ', '+', $mess), true);
$res = json_decode($res, true);
for($i = 0; $i < 3; $i++) {
$m = strip_tags(@$res['responseData']['results'][$i]['title']).' - '.@$res['responseData']['results'][$i]['url'];
if($m[0] != '/' && $m != ' - ') {
$this->enviarMSG($m,$type,$msg['u']);
sleep(2);
}
}
if($m[0] == '/' || $m == ' - ') return $this->enviarMSG('I have not found results on google, try another search (what)!',$type,$msg['u']);
$this->enviarMSG('These were the first 3 results I found in google on your search!');
break;
case "dx":
$id = "Background: " . $this->chatInfo['background'] . " | Idioma: " . $packet['b'] . " | Buttons: _" . $this->chatInfo['buttons'] . " | Bot Rank: " . $this->chatInfo['botRank'];
$this->enviarMSG($id);
break;
case "disable":
$this->enviarMSG("/-flashrank");
$this->reiniciar();
break;




case "choose":

// !choose [coisa] [coisa2]

$mensagem = explode(' ou ', strtolower($msg));
if (!isset($mensagem[0]) || empty($mensagem[1]) || count(array_keys($mensagem)) == 1) return $this->enviarMSG('E preciso duas escolha (D)', "PM", $packet['u']);
$mensagem = array_values($mensagem);
$rand = $mensagem[array_rand($mensagem) ];
$this->enviarMSG('Eu prefiro ' . $rand, "PM", $packet['u']);
break;

case "perg":
case "8ball":

// !perg/!8ball [pergunta]

$respostas = array(
'Talvez sim',
'Sim.',
'Nao.',
'Minhas fontes informou que nao.',
'Ah, sim e sim',
'Na verdade nao sei',
'Outlook nao presta \'-\'',
'Eu acho que nao',
'Muito bom',
'Definiu-se que sim.'
);
$resposta = $respostas[array_rand($respostas) ];
$mensagens = array();
foreach($mensagens as $k => $valor)
{
$valor2 = strtoupper($valor);
array_push($mensagens, $valor2);
} //$mensagens as $k => $valor
$this->enviarMSG(' [' . $usuario . ']' . $resposta, "PM", $packet['u']);
break;

case 'lovetest':

// !lovetest [alguma coisa] [alguma coisa2]

$gerar = rand(0, 100);
$this->enviarMSG($mensagem[1] . ' + ' . $mensagem[2] . ' = ' . $gerar . '%');
break;
/* Comandos para admin */
case "reiniciar":

// !reiniciar

If (!in_Array($packet["u"], $this->admins))
{
return $this->enviarMSG($this->semacesso, "PM", $packet["u"]);
} //!in_Array( $packet[ "u" ], $this->admins )
$this->enviarMSG("[Servidor]: Estou sendo reiniciado (backoff)");
$this->reiniciar();
break;

case "desligar":
case "die":

// !die

If (!in_Array($packet["u"], $this->admins))
{
return $this->enviarMSG($this->semacesso, "PM", $packet["u"]);
} //!in_Array( $packet[ "u" ], $this->admins )
$this->enviarMSG("[Servidor]: Estou sendo desligado (bye)");
die();
break;
} //substr( $mensagem[ 0 ], 1 )
} //$tipo
}

/* Reiniciar o servidor */
public

function reiniciar()
{
$this->conectar();
$this->entrar();
}

public

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->enviar('<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 ban($message, $id, $time)
{
$this->enviar('<c p="' . ereg_replace('[^A-Za-z0-9.! ]', '', $message) . '" u="' . $id . '" t="/g' . $time . '" />');
}

public

function sendPM($id = 0, $packet = '')
{
$id = $this->parseU($id);
$this->enviar('<p u="' . $id . '" t="' . $packet . '" d="' . $id . '" />');
}

public

function parseU($id)
{
if (strpos($id, "_") > - 1) $e = explode("_", $id);
$u = (strpos($id, "_") > - 1) ? $e[0] : $id;
return $u;
}

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 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 = '') //Shit always comes in handy after awhile.
{
$this->enviar('<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;
}
}
}
}

/* Enviar MSG, definido com tipo e ID */
function enviarMSG($mensagem, $tipo = "MSG", $id = 0)
{
If (!$mensagem)
{
return False;
} //!$mensagem
switch ($tipo)
{
case "MSG": // Sample
$this->enviar("<m t=\"{$mensagem}\" u=\"{$this->botID}\" />");
break;

case "PM": // PM
$this->enviar("<p u=\"{$id}\" t=\"{$mensagem}\" d=\"{$id}\" />");
break;

case "PC": // Privado
$this->enviar("<z d=\"{$id}\" u=\"{$this->botID}\" t=\"{$mensagem}\" />");
break;
} //$tipo
}
}

$bot = new zBot(); // Estanciar a class

while (1)
{
try
{
If ($bot->carregar() == "DESLIGADO")
{
$bot->desconectar();
$bot->entrar();
} //$bot->carregar() == "DESLIGADO"
}

catch(Exception $e)
{
die($e);
}
} //1

?>