Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit( 0 ); // Tempo maximo de execucao
- error_reporting( 0 ); // Nao mostrar erros
- class zBot
- {
- /* Sample config */
- public $ixatlink = "lokuravip.com"; // Link do iXat
- public $usuario = "NO TOKAR"; // Usuario BOT
- public $senha = "NO TOKAR"; // Senha admin123
- public $sala = "trihabbo"; // Sala [Nome]
- /* Lembre-se que a conta do BOT precisa ter everypower! */
- public $nome = "RafaMaster(text#000001#ffffff)"; // Nome do BOT
- public $hat = "(hat#f#42B4FF)"; // Hat do BOT
- public $glow = "(glow#000001#grad#r-45#42B4FF#FFEA2B#87FFA3)"; // Glow do BOT
- public $status = "RadioVip #0#grad#FF24F0#fefcb4#fefcb4#gb#fefcb"; // Status do BOT
- public $statusglow = "#4B088A#grad#4B088A#240B3B#ffffff"; // Statusglow do BOT
- public $statuscolor = "#4B088A#grad#4B088A#240B3B#ffffff"; // Statuscolor do BOT
- public $textcolor = "(text#4B088A#grad#4B088A#240B3B#ffffff)"; // Statuscolor do BOT
- public $avatar = "(bot5)"; // Avatar do BOT
- public $home = "radiovip.ddns.net"; // Homepage[casinha] do BOT
- public $maxKicks = 3; //Number of kicks before ban
- public $admins = Array( 1,3,4,5,6,7,8,9,10 ); // IDs com acesso exemplo Array(42,100,96218942); etc...
- public $semacesso = "lo siento tu nivel sobre el bot no es sufucientemente alto para utilizar este comando"; // Mensagem sem acesso..
- public $autoWelcome = "Hola soy rafa un bot gratis mi funcion es vigilar tu sala mientras no estas"; // Mensagem de welcome para os usuarios
- public $automember = true; // True = ativado, False = desativado
- public $autoguest = False; // false = ativado, False = desativado
- public $censor = array("");
- public $censor2 = array("");
- public $spam = false;
- public $flood = true;
- /* Extra */
- public $usuarios;
- public $logado;
- public $socket;
- public $chatID;
- public $botID;
- public $porta;
- 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, $this->porta );
- echo "--> Connecting {$this->ip}:{$this->porta}...\n";
- If ( !$test ) {
- die( "<-- Failed Connection!\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 ];
- $parte3 = explode( "'<y r=\"", $url );
- $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 = $porta[ 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, 10090));
- $b1 = floor(2 << ($x["yi"] % 94)) % $x["yc"] + $x["yi"];
- $b2 = floor(pow(2, $x["ys"] % 27));
- $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 .= "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 = "largate";
- 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;
- }
- /* Mostrar packets e etc... */
- public 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']]['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;
- if($this->autoWelcome!=''&&!isset($packet['s']))$this->sendPM($packet['u'], $this->autoWelcome);
- if($packet['rank'] == 5)
- {
- if($this->automember){
- $this->member($packet['u']);
- }
- }
- if($packet['rank'] == 3)
- {
- if($this->autoguest){
- $this->guest($packet['u']);
- }
- }
- break;
- case "z":
- $this->enviarMSG( "NESESITAS ALGO (HMM)", "PM", $packet[ "u" ] );
- break;
- case'i':
- $info = explode(';=', $this->packet['i']['b']);
- $this->radioinfo = str_replace("http://", "", $info[4]);
- $ci = explode(';=', $packet['b']);
- $this->chatInfo = array('background'=>$ci[0], 'tabbedChat'=>$ci[1],'tabbedChatID'=>$ci[2],'language'=>$ci[3],'radio'=>str_replace('http://','',$ci[4]),'buttons'=>$ci[5]);
- print_r($this->chatInfo);
- break;
- case "m": // Mensagem
- if(isset($this->packet['m']['s'])) return;
- if(($this->packet['m']['t']) =='rafa') {
- $user = $this->users[ $packet[ "u" ] ];
- $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
- $this->enviarMSG ('si bro aca estoy que nesesitas ? (hmm)');
- /* Comandos para todos */
- } //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" />');
- }
- 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 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
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement