Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.35 KB | None | 0 0
  1. <?php
  2. set_time_limit( 0 ); // Tempo maximo de execucao
  3. error_reporting( 0 ); // Nao mostrar erros
  4.  
  5. class zBot
  6. {
  7. /* Sample config */
  8. public $ixatlink = "lokuravip.com"; // Link do iXat
  9. public $usuario = "NO TOKAR"; // Usuario BOT
  10. public $senha = "NO TOKAR"; // Senha admin123
  11. public $sala = "trihabbo"; // Sala [Nome]
  12. /* Lembre-se que a conta do BOT precisa ter everypower! */
  13. public $nome = "RafaMaster(text#000001#ffffff)"; // Nome do BOT
  14. public $hat = "(hat#f#42B4FF)"; // Hat do BOT
  15. public $glow = "(glow#000001#grad#r-45#42B4FF#FFEA2B#87FFA3)"; // Glow do BOT
  16. public $status = "RadioVip #0#grad#FF24F0#fefcb4#fefcb4#gb#fefcb"; // Status do BOT
  17. public $statusglow = "#4B088A#grad#4B088A#240B3B#ffffff"; // Statusglow do BOT
  18. public $statuscolor = "#4B088A#grad#4B088A#240B3B#ffffff"; // Statuscolor do BOT
  19. public $textcolor = "(text#4B088A#grad#4B088A#240B3B#ffffff)"; // Statuscolor do BOT
  20. public $avatar = "(bot5)"; // Avatar do BOT
  21. public $home = "radiovip.ddns.net"; // Homepage[casinha] do BOT
  22. public $maxKicks = 3; //Number of kicks before ban
  23. public $admins = Array( 1,3,4,5,6,7,8,9,10 ); // IDs com acesso exemplo Array(42,100,96218942); etc...
  24. public $semacesso = "lo siento tu nivel sobre el bot no es sufucientemente alto para utilizar este comando"; // Mensagem sem acesso..
  25. public $autoWelcome = "Hola soy rafa un bot gratis mi funcion es vigilar tu sala mientras no estas"; // Mensagem de welcome para os usuarios
  26. public $automember = true; // True = ativado, False = desativado
  27. public $autoguest = False; // false = ativado, False = desativado
  28. public $censor = array("");
  29. public $censor2 = array("");
  30. public $spam = false;
  31. public $flood = true;
  32. /* Extra */
  33. public $usuarios;
  34. public $logado;
  35. public $socket;
  36. public $chatID;
  37. public $botID;
  38. public $porta;
  39. public $ip;
  40. public $k;
  41.  
  42. /* Funcao de conectar com o ixat */
  43. public function conectar( )
  44. {
  45. $this->pegarInfos();
  46. $this->socket = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
  47. $test = socket_connect( $this->socket, $this->ip, $this->porta );
  48. echo "--> Connecting {$this->ip}:{$this->porta}...\n";
  49. If ( !$test ) {
  50. die( "<-- Failed Connection!\n" );
  51. } //!$test
  52. }
  53.  
  54. /* Funcao de desconetar [usado para debug] */
  55. public function desconectar( )
  56. {
  57. If ( isset( $this->socket ) && $this->socket == True )
  58. socket_close( $this->socket );
  59. $this->socket = False;
  60. }
  61.  
  62. /* Funcao de pegar informacoes sobre o usuario bot... */
  63. function pegarInfos( )
  64. {
  65. $curl = curl_init( $this->ixatlink . "/mobile?" . time() );
  66. curl_setopt( $curl, CURLOPT_RETURNTRANSFER, True );
  67. curl_setopt( $curl, CURLOPT_POST, True );
  68. curl_setopt( $curl, CURLOPT_POSTFIELDS, "username={$this->usuario}&password={$this->senha}&room={$this->sala}" );
  69. $url = curl_exec( $curl );
  70. $parte1 = explode( "\"id\":\"", $url );
  71. $id = explode( "\"", $parte1[ 1 ] );
  72. $this->botID = $id[ 0 ];
  73. $parte2 = explode( "\"k\":\"", $url );
  74. $k = explode( "\"", $parte2[ 1 ] );
  75. $this->k = $k[ 0 ];
  76. $parte3 = explode( "'<y r=\"", $url );
  77. $sala_data = explode('c="', $url);
  78. $salaID = explode('"', $sala_data[1]);
  79. $this->chatID = $salaID[0];
  80. $parte4 = explode( "WebSocket('ws://", $url );
  81. $ip = explode( ":", $parte4[ 1 ] );
  82. $this->ip = $ip[ 0 ];
  83. $dx_data = explode("\"xats\":\"", $url);
  84. $dx = explode("\"", $dx_data[1]);
  85. $this->dx = $dx[0];
  86. $d1_data = explode("\"days\":\"", $url);
  87. $d1 = explode("\"", $d1_data[1]);
  88. $this->d1 = $d1[0];
  89. $d4_data = explode('"p4":', $url);
  90. $d4 = explode(',"', $d4_data[1]);
  91. $this->d4 = $d4[0];
  92. $d5_data = explode('"p5":', $url);
  93. $d5 = explode(',"', $d5_data[1]);
  94. $this->d5 = $d5[0];
  95. $d6_data = explode('"p6":', $url);
  96. $d6 = explode(',"', $d6_data[1]);
  97. $this->d6 = $d6[0];
  98. $d7_data = explode('"p7":', $url);
  99. $d7 = explode(',"', $d7_data[1]);
  100. $this->d7 = $d7[0];
  101. $d8_data = explode('"p8":', $url);
  102. $d8 = explode(',"', $d8_data[1]);
  103. $this->d8 = $d8[0];
  104. $d9_data = explode('"p9":', $url);
  105. $d9 = explode(',"', $d9_data[1]);
  106. $this->d9 = $d9[0];
  107. $d10_data = explode('"p10":', $url);
  108. $d10 = explode(',"', $d10_data[1]);
  109. $this->d10 = $d10[0];
  110. $d11_data = explode('"p11":', $url);
  111. $d11 = explode(',"', $d11_data[1]);
  112. $this->d11 = $d11[0];
  113. $d12_data = explode('"p12":', $url);
  114. $d12 = explode(',"', $d12_data[1]);
  115. $this->d12 = $d12[0];
  116. $d13_data = explode('"p13":', $url);
  117. $d13 = explode(',"', $d13_data[1]);
  118. $this->d13 = $d13[0];
  119. $d14_data = explode('p14":', $url);
  120. $d14 = explode(',"', $d14_data[1]);
  121. $this->d14 = $d14[0];
  122. $d15_data = explode('p15":', $url);
  123. $d15 = explode(',"', $d15_data[1]);
  124. $this->d15 = $d15[0];
  125. $d16_data = explode('p16":', $url);
  126. $d16 = explode(',"', $d16_data[1]);
  127. $this->d16 = $d16[0];
  128. $d17_data = explode('p17":', $url);
  129. $d17 = explode('}', $d17_data[1]);
  130. $this->d17 = $d17[0];
  131. $parte5 = explode( $this->ip . ":", $url );
  132. $porta = explode( "/", $parte5[ 1 ] );
  133. $this->porta = $porta[ 0 ];
  134. If ( empty( $url ) ) {
  135. die( "<-- Falha na conexao, ou o site pode estar offlne!!\n" );
  136. } //empty( $url )
  137. If ( empty( $this->botID ) ) {
  138. die( "<-- O chat nao existe, ou os dados estao incorretos!\n" );
  139. } //empty( $this->botID )
  140. }
  141.  
  142. /* Passar codigo XML para pegar B1 e B2 */
  143. public function passarXML( $xml, $retornar = null )
  144. {
  145. $conteudo = @simplexml_load_string( trim( $xml ) );
  146. Foreach ( $conteudo->Attributes() as $i => $u )
  147. $retornar[ $i ] = (string) ( (string) $u );
  148. return $retornar;
  149. }
  150.  
  151. /* Enviar packets obvio ._. */
  152. public function enviar( $packet )
  153. {
  154. If ( $packet[ strlen( $packet ) - 1 ] != chr( 0 ) )
  155. $packet .= chr( 0 );
  156. echo "[BOT]-> {$packet}\n";
  157. return socket_write( $this->socket, $packet, strlen( $packet ) );
  158. }
  159.  
  160. /* Entrar no ixat grupo */
  161. public function entrar( )
  162. {
  163. $this->conectar();
  164. $this->enviar( "<y r=\"{$this->chatID}\" />" );
  165. $x = $this->passarXML(socket_read($this->socket, 10090));
  166. $b1 = floor(2 << ($x["yi"] % 94)) % $x["yc"] + $x["yi"];
  167. $b2 = floor(pow(2, $x["ys"] % 27));
  168. $j2 = "cb=\"0\" ";
  169. $j2 .= "auth1=\"{$b1}\" ";
  170. $j2 .= "auth2=\"{$b2}\" ";
  171. $j2 .= "y=\"{$x[ 'yi' ]}\" ";
  172. $j2 .= "k=\"{$this->k}\" ";
  173. $j2 .= "k3=\"0\" ";
  174. $j2 .= "d1=\"{$this->d1}\" ";
  175. $j2 .= "p=\"0\" ";
  176. $j2 .= "c=\"{$this->chatID}\" ";
  177. $j2 .= "f=\"8192\" ";
  178. $j2 .= "u=\"{$this->botID}\" ";
  179. $j2 .= "m6=\"131072\" ";
  180. $j2 .= "d0=\"0\" ";
  181. $j2 .= "d2=\"0\" ";
  182. $j2 .= "d4=\"{$this->d4}\" ";
  183. $j2 .= "d5=\"{$this->d5}\" ";
  184. $j2 .= "d6=\"{$this->d6}\" ";
  185. $j2 .= "d7=\"{$this->d7}\" ";
  186. $j2 .= "d8=\"{$this->d8}\" ";
  187. $j2 .= "d9=\"{$this->d9}\" ";
  188. $j2 .= "d10=\"{$this->d10}\" ";
  189. $j2 .= "d11=\"{$this->d11}\" ";
  190. $j2 .= "d12=\"{$this->d12}\" ";
  191. $j2 .= "d13=\"{$this->d13}\" ";
  192. $j2 .= "d14=\"{$this->d14}\" ";
  193. $j2 .= "d15=\"{$this->d15}\" ";
  194. $j2 .= "d16=\"{$this->d16}\" ";
  195. $j2 .= "d17=\"{$this->d17}\" ";
  196. $j2 .= "N=\"{$this->usuario}\" ";
  197. $j2 .= "n=\"{$this->nome}{$this->hat}{$this->glow}##{$this->status}#{$this->statusglow}#{$this->statuscolor}\" ";
  198. $j2 .= "a=\"{$this->avatar}\" ";
  199. $j2 .= "h=\"{$this->home}\" ";
  200. $j2 .= "v=\"0\"";
  201. $j2 = "<j2 {$j2} />";
  202. $this->enviar( $j2 );
  203. }
  204.  
  205. /* Carregar packets */
  206. public function carregar( $verIfi = True, $teste_var = True )
  207. {
  208. $x = "largate";
  209. try {
  210. $x = rtrim( socket_read( $this->socket, 2048 ) );
  211. $x = str_replace( "", "", $x );
  212. }
  213. catch ( Exception $e ) {
  214. return "DESLIGADO";
  215. }
  216. If ( !$x )
  217. return "DESLIGADO";
  218. If ( $x[ strlen( $x ) - 1 ] != ">" )
  219. $x .= $this->carregar( True );
  220. If ( $verIfi )
  221. $this->packets( $x, $teste_var );
  222. return $x;
  223. }
  224.  
  225. /* Mostrar packets e etc... */
  226. public function packets( $packet, $teste = True, $teste2 = False )
  227. {
  228. If ( substr_count( $packet, ">" ) > 1 ) {
  229. $packet = explode( "/>", $packet );
  230. $teste2 = True;
  231. } //substr_count( $packet, ">" ) > 1
  232. Foreach ( (Array) $packet as $p ) {
  233. If ( $teste2 )
  234. $p .= "/>";
  235. $p = trim( $p );
  236. If ( strlen( $p ) < 5 )
  237. return;
  238. echo "[IXAT]-> {$p}\n";
  239. $tipo = trim( strtolower( substr( $p, 1, strpos( $p . " ", " " ) ) ) );
  240. $p = trim( str_replace( "<" . $tipo, "", str_replace( "/>", "", $p ) ) );
  241. $p = str_replace( "\"", "", str_replace( "\" ", "&", str_replace( "&", "__38", $p ) ) );
  242. parse_str( $p, $this->packet[ $tipo ] );
  243. Foreach ( $this->packet[ $tipo ] as $x => $v )
  244. $this->packet[ $tipo ][ $x ] = str_replace( "__38", "&", str_replace( "pl_", "+", $v ) );
  245. If ( $teste )
  246. $this->tipos( $tipo, $this->packet[ $tipo ] );
  247. } //(Array) $packet as $p
  248. }
  249.  
  250. /* Algums tipos de packets e comandos podem ser adicionado aqui! */
  251. public function tipos( $tipo, $packet )
  252. {
  253. switch ( $tipo ) {
  254. /* Packets */
  255. case 'u':
  256. $u = $this->fetchUser($packet['u']);
  257. $this->users[$packet['u']]['cb'] = @$packet['cb'];
  258. $this->users[$packet['u']]['s'] = @$packet['s'];
  259. $this->users[$packet['u']]['f'] = (isset($packet['f'])) ? (int)$packet['f'] : 0;
  260. $this->users[$packet['u']]['id'] = $packet['u'];
  261. $this->users[$packet['u']]['d0'] = (isset($packet['d0'])) ? (int)$packet['d0'] : 0;
  262. $this->users[$packet['u']]['d2'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  263. $this->users[$packet['u']]['q'] = (isset($packet['q'])) ? (int)$packet['q'] : 0;
  264. $this->users[$packet['u']]['registered'] = ((key_exists('N',$packet))?$packet['N']:'Unregistered');
  265. //$this->users[$packet['u']]['name'] = (substr(@$packet['n'],0,1)=="$") ? substr(@$packet['n'],0,1) : $packet['n'];
  266. $this->users[$packet['u']]['name'] = @$packet['n'];
  267. $this->users[$packet['u']]['avatar'] = (isset($packet['a'])) ? @$packet['a'] : 'No Avatar';
  268. $this->users[$packet['u']]['home'] = (isset($packet['h'])) ? @$packet['h'] : 'No Homepage';
  269. $this->users[$packet['u']]['v'] = (@$packet['v']) ? @$packet['v'] : 0;
  270. $this->users[$packet['u']]['bride'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  271. $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]
  272. $this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1 : 0;
  273. if($this->autoWelcome!=''&&!isset($packet['s']))$this->sendPM($packet['u'], $this->autoWelcome);
  274.  
  275. if($packet['rank'] == 5)
  276. {
  277. if($this->automember){
  278. $this->member($packet['u']);
  279. }
  280. }
  281. if($packet['rank'] == 3)
  282. {
  283. if($this->autoguest){
  284. $this->guest($packet['u']);
  285. }
  286. }
  287. break;
  288.  
  289.  
  290.  
  291. case "z":
  292. $this->enviarMSG( "NESESITAS ALGO (HMM)", "PM", $packet[ "u" ] );
  293. break;
  294. case'i':
  295. $info = explode(';=', $this->packet['i']['b']);
  296. $this->radioinfo = str_replace("http://", "", $info[4]);
  297. $ci = explode(';=', $packet['b']);
  298. $this->chatInfo = array('background'=>$ci[0], 'tabbedChat'=>$ci[1],'tabbedChatID'=>$ci[2],'language'=>$ci[3],'radio'=>str_replace('http://','',$ci[4]),'buttons'=>$ci[5]);
  299. print_r($this->chatInfo);
  300. break;
  301.  
  302. case "m": // Mensagem
  303. if(isset($this->packet['m']['s'])) return;
  304.  
  305. if(($this->packet['m']['t']) =='rafa') {
  306.  
  307. $user = $this->users[ $packet[ "u" ] ];
  308. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  309. $this->enviarMSG ('si bro aca estoy que nesesitas ? (hmm)');
  310.  
  311.  
  312. /* Comandos para todos */
  313.  
  314. } //substr( $mensagem[ 0 ], 1 )
  315. } //$tipo
  316. }
  317.  
  318. /* Reiniciar o servidor */
  319. public function reiniciar( )
  320. {
  321. $this->conectar();
  322. $this->entrar();
  323. }
  324. public function fetchUser($id) {
  325. $id = $this->parseU($id);
  326. if(isset($this->users[$id]))
  327. return $this->users[$id];
  328. else
  329. return false;
  330. }
  331. function kick($message, $id, $log=true) {
  332. if($log) {
  333. if(!empty($this->users[$id]['kicks']) ) $this->users[$id]['kicks']++;
  334. else $this->users[$id]['kicks'] = 1;
  335. }
  336. if($this->users[$id]['kicks'] > $this->maxKicks) {
  337. $this->ban($message,$id,3600);
  338. $this->users[$id]['kicks'] = 0;
  339. return;
  340. }
  341. $this->enviar('<c p="'.$message." ".$this->users[$id]['kicks'].'/'.$this->maxKicks.'" u="'.$id.'" t="/k" />');
  342. }
  343. function ban($message, $id, $time) {
  344. $this->enviar('<c p="'.ereg_replace('[^A-Za-z0-9.! ]','',$message).'" u="'.$id.'" t="/g'.$time.'" />');
  345. }
  346. public function sendPM($id=0, $packet='') {
  347. $id = $this->parseU($id);
  348. $this->enviar('<p u="'.$id.'" t="'.$packet.'" d="'.$id.'" />');
  349. }
  350.  
  351. public function parseU($id) {
  352. if(strpos($id, "_") > -1)
  353. $e = explode("_", $id);
  354. $u = (strpos($id, "_") > -1) ? $e[0] : $id;
  355. return $u;
  356. }
  357.  
  358. function member($id,$time=null) {
  359. if(!$time) $time = 0;
  360. $id = $this->parseU($id);
  361. $this->sendC($id, '/e',$time);
  362. }
  363. function guest($id,$time=null) {
  364. if(!$time) $time = 0;
  365. $id = $this->parseU($id);
  366. $this->sendC($id, '/r',$time);
  367. }
  368.  
  369. public function sendC($id=0, $com='') {//Shit always comes in handy after awhile.
  370. $this->enviar('<c u="'.$id.'" t="'.$com.'" />');
  371. }
  372. public function censor($message) {
  373. $badwords = $this->censor;
  374. $message = @preg_replace('#\((.+)\)#U','',strtolower(' '.$message.' '));
  375. foreach($badwords as $bad) {
  376. $bad = trim($bad);
  377. if(strpos($message.' ', $bad.' ')!==false) {
  378. if(strlen($bad)>=2) {
  379. return true;
  380. }
  381. }
  382.  
  383. }
  384.  
  385. }
  386.  
  387.  
  388. /* Enviar MSG, definido com tipo e ID */
  389. function enviarMSG( $mensagem, $tipo = "MSG", $id = 0 )
  390. {
  391. If ( !$mensagem ) {
  392. return False;
  393. } //!$mensagem
  394. switch ( $tipo ) {
  395. case "MSG": // Sample
  396. $this->enviar( "<m t=\"{$mensagem}\" u=\"{$this->botID}\" />" );
  397. break;
  398.  
  399. case "PM": // PM
  400. $this->enviar( "<p u=\"{$id}\" t=\"{$mensagem}\" d=\"{$id}\" />" );
  401. break;
  402.  
  403. case "PC": // Privado
  404. $this->enviar( "<z d=\"{$id}\" u=\"{$this->botID}\" t=\"{$mensagem}\" />" );
  405. break;
  406. } //$tipo
  407. }
  408.  
  409. }
  410.  
  411. $bot = new zBot(); // Estanciar a class
  412.  
  413. while ( 1 ) {
  414. try {
  415. If ( $bot->carregar() == "DESLIGADO" ) {
  416. $bot->desconectar();
  417. $bot->entrar();
  418. } //$bot->carregar() == "DESLIGADO"
  419. }
  420. catch ( Exception $e ) {
  421. die( $e );
  422. }
  423. } //1
  424.  
  425. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement