Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.36 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 = "37.187.46.85"; // Link do iXat
  9. public $usuario = "zVOIP"; // Usuario BOT
  10. public $senha = ""; // Senha admin123
  11. public $sala = "Lobby"; // Sala [Nome]
  12. /* Lembre-se que a conta do BOT precisa ter everypower! */
  13. public $nome = "iXa1Bot"; // Nome do BOT
  14. public $hat = "(hat#xB#g)"; // Hat do BOT
  15. public $glow = "(glow#000222#FF0000)"; // Glow do BOT
  16. public $status = "ixa1.tk"; // Status do BOT
  17. public $statusglow = "000222#ff0000"; // Statusglow do BOT
  18. public $statuscolor = "000222#ff0000"; // Statuscolor do BOT
  19. public $textcolor = "(text#ea3422#ffffff)"; // Statuscolor do BOT
  20. public $avatar = "http://i.imgur.com/LLXYBOo.png#http://www.xatworld.com/xatimages/xatbots3.png"; // Avatar do BOT
  21. public $home = "http://ixa1.tk"; // Homepage[casinha] do BOT
  22. public $maxKicks = 4; //Number of kicks before ban
  23. public $admins = Array( 1802,1752,1763,1845 ); // IDs com acesso exemplo Array(42,100,96218942); etc...
  24. public $semacesso = "You dont allowed use commands!"; // Mensagem sem acesso..
  25. public $autoWelcome = "Welcome to ixa1 (hug#c)!"; // Mensagem de welcome para os usuarios
  26. public $automember = True; // True = ativado, False = desativado
  27. public $autoguest = False; // True = ativado, False = desativado
  28. public $censor = array("fuck","bitch","motherfucker","penis","pussy");
  29. public $censor2 = array("test","hehe","hey","hi");
  30. /* Extra */
  31. public $usuarios;
  32. public $logado;
  33. public $socket;
  34. public $chatID;
  35. public $botID;
  36. public $porta;
  37. public $ip;
  38. public $k;
  39.  
  40. /* Funcao de conectar com o ixat */
  41. public function conectar( )
  42. {
  43. $this->pegarInfos();
  44. $this->socket = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
  45. $test = socket_connect( $this->socket, $this->ip, $this->porta );
  46. echo "--> Connecting {$this->ip}:{$this->porta}...\n";
  47. If ( !$test ) {
  48. die( "<-- Failed Connection!\n" );
  49. } //!$test
  50. }
  51.  
  52. /* Funcao de desconetar [usado para debug] */
  53. public function desconectar( )
  54. {
  55. If ( isset( $this->socket ) && $this->socket == True )
  56. socket_close( $this->socket );
  57. $this->socket = False;
  58. }
  59.  
  60. /* Funcao de pegar informacoes sobre o usuario bot... */
  61. function pegarInfos( )
  62. {
  63. $curl = curl_init( $this->ixatlink . "/mobile?" . time() );
  64. curl_setopt( $curl, CURLOPT_RETURNTRANSFER, True );
  65. curl_setopt( $curl, CURLOPT_POST, True );
  66. curl_setopt( $curl, CURLOPT_POSTFIELDS, "username={$this->usuario}&password={$this->senha}&room={$this->sala}" );
  67. $url = curl_exec( $curl );
  68. $parte1 = explode( "\"id\":\"", $url );
  69. $id = explode( "\"", $parte1[ 1 ] );
  70. $this->botID = $id[ 0 ];
  71. $parte2 = explode( "\"k\":\"", $url );
  72. $k = explode( "\"", $parte2[ 1 ] );
  73. $this->k = $k[ 0 ];
  74. $parte3 = explode( "'<y r=\"", $url );
  75. $salaID = explode( "\"", $parte3[ 1 ] );
  76. $this->chatID = 1; /////////////////////////////////////////////chatid/////////////////////////////////////////
  77. $parte4 = explode( "WebSocket('ws://", $url );
  78. $ip = explode( ":", $parte4[ 1 ] );
  79. $this->ip = $ip[ 0 ];
  80. $parte5 = explode( $this->ip . ":", $url );
  81. $porta = explode( "/", $parte5[ 1 ] );
  82. $this->porta = $porta[ 0 ];
  83. If ( empty( $url ) ) {
  84. die( "<-- Falha na conexao, ou o site pode estar offlne!!\n" );
  85. } //empty( $url )
  86. If ( empty( $this->botID ) ) {
  87. die( "<-- O chat nao existe, ou os dados estao incorretos!\n" );
  88. } //empty( $this->botID )
  89. }
  90.  
  91. /* Passar codigo XML para pegar B1 e B2 */
  92. public function passarXML( $xml, $retornar = null )
  93. {
  94. $conteudo = @simplexml_load_string( trim( $xml ) );
  95. Foreach ( $conteudo->Attributes() as $i => $u )
  96. $retornar[ $i ] = (string) ( (string) $u );
  97. return $retornar;
  98. }
  99.  
  100. /* Enviar packets obvio ._. */
  101. public function enviar( $packet )
  102. {
  103. If ( $packet[ strlen( $packet ) - 1 ] != chr( 0 ) )
  104. $packet .= chr( 0 );
  105. echo "[BOT]-> {$packet}\n";
  106. return socket_write( $this->socket, $packet, strlen( $packet ) );
  107. }
  108.  
  109. /* Entrar no ixat grupo */
  110. public function entrar( )
  111. {
  112. $this->conectar();
  113. $this->enviar( "<y r=\"{$this->chatID}\" />" );
  114. $x = $this->passarXML( socket_read( $this->socket, 1204 ) );
  115. $ym1 = ((floor((2 << ($x['yi'] % 30))) % $x['yc']) + $x['yi']);
  116. $ym2 = floor(pow(2, ($x['ys'] % 32)));
  117. $j2 = "cb=\"0\" ";
  118. $j2 .= "ym1=\"{$ym1}\" ";
  119. $j2 .= "ym2=\"{$ym2}\" ";
  120. $j2 .= "y=\"{$x[ 'yi' ]}\" ";
  121. $j2 .= "k=\"{$this->k}\" ";
  122. $j2 .= "k3=\"0\" ";
  123. $j2 .= "d1=\"1416697007\" ";
  124. $j2 .= "p=\"0\" ";
  125. $j2 .= "c=\"{$this->chatID}\" ";
  126. $j2 .= "f=\"0\" ";
  127. $j2 .= "u=\"{$this->botID}\" ";
  128. $j2 .= "m6=\"131072\" ";
  129. $j2 .= "d0=\"0\" ";
  130. $j2 .= "d2=\"0\" ";
  131. $j2 .= "d4=\"2147483647\" ";
  132. $j2 .= "d5=\"2147483647\" ";
  133. $j2 .= "d6=\"2147483647\" ";
  134. $j2 .= "d7=\"2147483647\" ";
  135. $j2 .= "d8=\"2147483647\" ";
  136. $j2 .= "d9=\"2147483647\" ";
  137. $j2 .= "d10=\"2147352575\" ";
  138. $j2 .= "d11=\"2147483647\" ";
  139. $j2 .= "d12=\"2147483647\" ";
  140. $j2 .= "d13=\"2147483647\" ";
  141. $j2 .= "d14=\"2147483647\" ";
  142. $j2 .= "d15=\"7\" ";
  143. $j2 .= "N=\"{$this->usuario}\" ";
  144. $j2 .= "n=\"{$this->nome}{$this->hat}{$this->textcolor}{$this->glow}##{$this->status}#{$this->statusglow}#{$this->statuscolor}\" ";
  145. $j2 .= "a=\"{$this->avatar}\" ";
  146. $j2 .= "h=\"{$this->home}\" ";
  147. $j2 .= "v=\"0\"";
  148. $j2 = "<j2 {$j2} />";
  149. $this->enviar( $j2 );
  150. }
  151.  
  152. /* Carregar packets */
  153. public function carregar( $verIfi = True, $teste_var = True )
  154. {
  155. $x = "";
  156. try {
  157. $x = rtrim( socket_read( $this->socket, 2048 ) );
  158. $x = str_replace( "", "", $x );
  159. }
  160. catch ( Exception $e ) {
  161. return "DESLIGADO";
  162. }
  163. If ( !$x )
  164. return "DESLIGADO";
  165. If ( $x[ strlen( $x ) - 1 ] != ">" )
  166. $x .= $this->carregar( True );
  167. If ( $verIfi )
  168. $this->packets( $x, $teste_var );
  169. return $x;
  170. }
  171.  
  172. /* Mostrar packets e etc... */
  173. public function packets( $packet, $teste = True, $teste2 = False )
  174. {
  175. If ( substr_count( $packet, ">" ) > 1 ) {
  176. $packet = explode( "/>", $packet );
  177. $teste2 = True;
  178. } //substr_count( $packet, ">" ) > 1
  179. Foreach ( (Array) $packet as $p ) {
  180. If ( $teste2 )
  181. $p .= "/>";
  182. $p = trim( $p );
  183. If ( strlen( $p ) < 5 )
  184. return;
  185. echo "[IXAT]-> {$p}\n";
  186. $tipo = trim( strtolower( substr( $p, 1, strpos( $p . " ", " " ) ) ) );
  187. $p = trim( str_replace( "<" . $tipo, "", str_replace( "/>", "", $p ) ) );
  188. $p = str_replace( "\"", "", str_replace( "\" ", "&", str_replace( "&", "__38", $p ) ) );
  189. parse_str( $p, $this->packet[ $tipo ] );
  190. Foreach ( $this->packet[ $tipo ] as $x => $v )
  191. $this->packet[ $tipo ][ $x ] = str_replace( "__38", "&", str_replace( "pl_", "+", $v ) );
  192. If ( $teste )
  193. $this->tipos( $tipo, $this->packet[ $tipo ] );
  194. } //(Array) $packet as $p
  195. }
  196.  
  197. /* Algums tipos de packets e comandos podem ser adicionado aqui! */
  198. public function tipos( $tipo, $packet )
  199. {
  200. switch ( $tipo ) {
  201. /* Packets */
  202. case 'u':
  203. $u = $this->fetchUser($packet['u']);
  204. $this->users[$packet['u']]['cb'] = @$packet['cb'];
  205. $this->users[$packet['u']]['s'] = @$packet['s'];
  206. $this->users[$packet['u']]['f'] = (isset($packet['f'])) ? (int)$packet['f'] : 0;
  207. $this->users[$packet['u']]['id'] = $packet['u'];
  208. $this->users[$packet['u']]['d0'] = (isset($packet['d0'])) ? (int)$packet['d0'] : 0;
  209. $this->users[$packet['u']]['d2'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  210. $this->users[$packet['u']]['q'] = (isset($packet['q'])) ? (int)$packet['q'] : 0;
  211. $this->users[$packet['u']]['registered'] = ((key_exists('N',$packet))?$packet['N']:'Unregistered');
  212. //$this->users[$packet['u']]['name'] = (substr(@$packet['n'],0,1)=="$") ? substr(@$packet['n'],0,1) : $packet['n'];
  213. $this->users[$packet['u']]['name'] = @$packet['n'];
  214. $this->users[$packet['u']]['avatar'] = (isset($packet['a'])) ? @$packet['a'] : 'No Avatar';
  215. $this->users[$packet['u']]['home'] = (isset($packet['h'])) ? @$packet['h'] : 'No Homepage';
  216. $this->users[$packet['u']]['v'] = (@$packet['v']) ? @$packet['v'] : 0;
  217. $this->users[$packet['u']]['bride'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  218. $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]
  219. $this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1 : 0;
  220. if($this->autoWelcome!=''&&!isset($packet['s']))$this->sendPM($packet['u'], $this->autoWelcome);
  221.  
  222. if($packet['rank'] == 5)
  223. {
  224. if($this->automember){
  225. $this->member($packet['u']);
  226. }
  227. }
  228. if($packet['rank'] == 3)
  229. {
  230. if($this->autoguest){
  231. $this->guest($packet['u']);
  232. }
  233. }
  234. break;
  235.  
  236.  
  237. case "z":
  238. $this->enviarMSG( "Don't click me :( !", "PM", $packet[ "u" ] );
  239. break;
  240. case'i':
  241. $ci = explode(';=', $packet['b']);
  242. $this->chatInfo = array('background'=>$ci[0], 'tabbedChat'=>$ci[1],'tabbedChatID'=>$ci[2],'language'=>$ci[3],'radio'=>str_replace('http://','',$ci[4]),'buttons'=>$ci[5]);
  243. print_r($this->chatInfo);
  244. break;
  245.  
  246. case "m": // Mensagem
  247. if(isset($this->packet['m']['s'])) return;
  248. if(($this->packet['m']['t']) =='hey') {
  249.  
  250. $user = $this->users[ $packet[ "u" ] ];
  251. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  252. $this->enviarMSG ('Hey (hug) ['.$usuario.'] How are you?');
  253. }
  254. if(($this->packet['m']['t']) =='hi bot test') {
  255.  
  256. $user = $this->users[ $packet[ "u" ] ];
  257. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  258. $this->enviarMSG ('Okey testing.....['.$usuario.'] ');
  259. }
  260. if(($this->packet['m']['t']) =='hi') {
  261.  
  262. $user = $this->users[ $packet[ "u" ] ];
  263. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  264. $this->enviarMSG ('Hi ['.$usuario.'] (hug)');
  265. }
  266.  
  267.  
  268. if(($this->packet['m']['t']) =='hi bot') {
  269.  
  270. $user = $this->users[ $packet[ "u" ] ];
  271. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  272. $this->enviarMSG ('Hi ['.$usuario.'] (hug)');
  273. }
  274.  
  275. if(($this->packet['m']['t']) =='help') {
  276.  
  277. $user = $this->users[ $packet[ "u" ] ];
  278. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  279. $this->enviarMSG ('What is problems? ['.$usuario.'] ');
  280. }
  281. if(($this->packet['m']['t']) =='give me xats') {
  282.  
  283. $user = $this->users[ $packet[ "u" ] ];
  284. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  285. $this->enviarMSG ('Ohhhhh.... ['.$usuario.'] ');
  286. }
  287. if(($this->packet['m']['t']) =='xd') {
  288.  
  289. $user = $this->users[ $packet[ "u" ] ];
  290. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  291. $this->enviarMSG ('(xd) ['.$usuario.'] ');
  292. }
  293. if(($this->packet['m']['t']) =='everypower') {
  294.  
  295. $user = $this->users[ $packet[ "u" ] ];
  296. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  297. $this->enviarMSG ('not work!!! ['.$usuario.'] ');
  298. }
  299. if(($this->packet['m']['t']) =='how are you?') {
  300.  
  301. $user = $this->users[ $packet[ "u" ] ];
  302. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  303. $this->enviarMSG ('well thank you very much! (jolly) ['.$usuario.'] ');
  304. }
  305. if(($this->packet['m']['t']) =='bot') {
  306.  
  307. $user = $this->users[ $packet[ "u" ] ];
  308. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  309. $this->enviarMSG ('Yes ? ['.$usuario.'] ');
  310. }
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318. case "p":
  319.  
  320. if($this->censor($packet['t'])) {
  321. //$this->send('<c p="Esta palavra não é permitido aqui.(d)" u="'.$packet['u'].'" t="/k" />');
  322. $this->kick('This word is not allowed here.(d)',$packet['u']);
  323. }
  324. If ( isset( $packet[ "i" ] ) && $packet[ "i" ] > 0 )
  325. break;
  326.  
  327. $msg = $mensagem = explode( " ", $packet[ "t" ] );
  328. unset( $msg[ 0 ] );
  329. $msg = implode( " ", $msg );
  330. If ( isset( $mensagem[ 0 ] ) && $mensagem[ 0 ][ 0 ] != "!" )
  331. break;
  332. $user = $this->usuarios[ $packet[ "u" ] ];
  333. $usuario = ( $user[ "N" ] ) ? $user[ "N" ] : $user[ "u" ];
  334. switch ( substr( $mensagem[ 0 ], 1 ) ) {
  335. /* Comandos para todos */
  336. case "say":
  337. // !say [msg]
  338. $user = $this->users[ $packet[ "u" ] ];
  339. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  340. $this->enviarMSG ('['.$usuario.'] '.$msg);
  341. break;
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. case "info":
  350. // !info
  351. $this->enviarMSG( "zBot System for iXa1 (created by ADM)!", "PM", $packet[ "u" ] );
  352. break;
  353.  
  354.  
  355. case'smileyaaaaaaaaaaaaaaaaaaa':
  356. mysql_connect('localhost','root','ionutboss');
  357. mysql_select_db('ichat') or $this->sendMesage('Can\'t connect.');
  358. $message = explode(' ', $mensagem[1], 1);
  359. $power = $message[0];
  360. $db = mysql_query("SELECT * FROM `powers` WHERE name='$power'");
  361. $row = mysql_fetch_array($db);
  362. if(!$row['name']) {$this->enviarMSG('Power not found! (d)');}
  363. else {
  364. $powers = str_replace(',',' | ',$row['topsh']);
  365. if(empty($row['topsh'])) {$this->enviarMSG(ucfirst($power).' has only ('.$power.') as smilies.');}
  366. else {
  367. $this->enviarMSG('('.$power.'#) Smilies : '.$powers);}}
  368. break;
  369. case'dunceme':
  370. $message = explode(' ', $mensagem[1], 1);
  371. $users = $message[0];
  372. if(empty($users)) $users = $packet['u'];
  373. $this->enviar('<c p="You have been dunced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'. $packet['u'] .'" t="/gd3600" />');
  374.  
  375. break;
  376. case'snakeme':
  377. $message = explode(' ', $mensagem[1], 1);
  378. $users = $message[0];
  379. if(empty($users)) $users = $packet['u'];
  380. $this->enviar('<c w="134" p="You have been snaked by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unsnaked." u="'. $packet['u'] .'" t="/g3600" />');
  381.  
  382. break;
  383. case'spaceme':
  384. $message = explode(' ', $mensagem[1], 1);
  385. $users = $message[0];
  386. if(empty($users)) $users = $packet['u'];
  387. $this->enviar('<c w="136" p="You have been spaced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unspaced." u="'. $packet['u'] .'" t="/g3600" />');
  388.  
  389. break;
  390. case'matchme':
  391. $message = explode(' ', $mensagem[1], 1);
  392. $users = $message[0];
  393. if(empty($users)) $users = $packet['u'];
  394. $this->enviar('<c w="140" p="You have been match by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unmatch." u="'. $packet['u'] .'" t="/g3600" />');
  395.  
  396. break;
  397. case'mazeme':
  398. $message = explode(' ', $mensagem[1], 1);
  399. $users = $message[0];
  400. if(empty($users)) $users = $packet['u'];
  401. $this->enviar('<c w="152" p="You have been mazed by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unmazed." u="'. $packet['u'] .'" t="/g3600" />');
  402.  
  403. break;
  404. case'codeme':
  405. $message = explode(' ', $mensagem[1], 1);
  406. $users = $message[0];
  407. if(empty($users)) $users = $packet['u'];
  408. $this->enviar('<c w="162" p="You have been coded by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are uncoded." u="'. $packet['u'] .'" t="/g3600" />');
  409.  
  410. break;
  411. case'reverseme':
  412. $message = explode(' ', $mensagem[1], 1);
  413. $users = $message[0];
  414. if(empty($users)) $users = $packet['u'];
  415. $this->enviar('<c w="176" p="You have been reverse by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unreversed." u="'. $packet['u'] .'" t="/g3600" />');
  416.  
  417. break;
  418. case'zipme':
  419. $message = explode(' ', $mensagem[1], 1);
  420. $users = $message[0];
  421. if(empty($users)) $users = $packet['u'];
  422. $this->enviar('<c w="184" p="You have been zip by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unzip." u="'. $packet['u'] .'" t="/g3600" />');
  423.  
  424. break;
  425. case'soltme':
  426. $message = explode(' ', $mensagem[1], 1);
  427. $users = $message[0];
  428. if(empty($users)) $users = $packet['u'];
  429. $this->enviar('<c w="236" p="You have been solt by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unsolt." u="'. $packet['u'] .'" t="/g3600" />');
  430.  
  431. break;
  432.  
  433. case'zapme':
  434. $message = explode(' ', $mensagem[1], 1);
  435. $users = $message[0];
  436. if(empty($users)) $users = $packet['u'];
  437. $this->enviar('<c w="121" p="You have been zapped by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unzapped. #screamman#bump" u="'. $packet['u'] .'" t="/k" />');
  438.  
  439. break;
  440. case'gagme':
  441. $message = explode(' ', $mensagem[1], 1);
  442. $users = $message[0];
  443. if(empty($users)) $users = $packet['u'];
  444. $this->enviar('<c w="41" p="You have been gagged by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are ungagged." u="'. $packet['u'] .'" t="/gg3600" />');
  445.  
  446. break;
  447. case'naughtyme':
  448. $message = explode(' ', $mensagem[1], 1);
  449. $users = $message[0];
  450. if(empty($users)) $users = $packet['u'];
  451. $this->enviar('<c p="You have been naughty by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unnaughty." u="'. $packet['u'] .'" t="/gn3600" />');
  452.  
  453. break;
  454. case'yellowme':
  455. $message = explode(' ', $mensagem[1], 1);
  456. $users = $message[0];
  457. if(empty($users)) $users = $packet['u'];
  458. $this->enviar('<c p="You have been yellow by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unyellow." u="'. $packet['u'] .'" t="/gy3600" />');
  459.  
  460. break;
  461.  
  462.  
  463.  
  464.  
  465.  
  466. case 'id':
  467. $id = file_get_contents('http://xat.com/web_gear/chat/auser3.php');
  468. if(!$id) { return $this->enviarMSG('unable to connect!',($type==0)?1:$type,$packet['u']); }
  469. //$id = str_replace($id, '=', ' = ');
  470. $t = explode('&',$id);
  471. $id = array('id'=>$t[1], 'k1'=>$t[2], 'k2'=>$t[3]);
  472.  
  473. $link = 'http://xat.com/web_gear/chat/register.php?'.$id['id'].'&'.$id['k1'].'&'.$id['k2'].'&mode=1';
  474. $this->enviarMSG(implode(', ',$id),($type==0)?1:$type,$packet['u']);
  475. $this->enviarMSG($link,($type==0)?1:$type,$packet['u']);
  476.  
  477. break;
  478.  
  479. case 'youtube':
  480. case '11':
  481. $query = str_replace(' ', '%20', $msg);
  482. $x = file_get_contents('http://gdata.youtube.com/feeds/api/videos?max-results=3&q=' . str_replace(' ', '%20', urlencode($query)));
  483. $js = json_decode(json_encode(new SimpleXMLElement($x)));
  484. if (!isset($js->entry[0]->title))
  485. return $this->enviarMSG('No results from Youtube.', $type, $msg['u']);
  486. $videos = array();
  487. $i = 0;
  488. while ($i != 3) {
  489. $URL = get_object_vars($js->entry[$i]->link[0]);
  490. $link = explode('&', $URL['@attributes']->href);
  491. if (!empty($link[0]))
  492. $this->enviarMSG($js->entry[$i]->title . ' - ' . $link[0], $type, $msg['u']);
  493. $i++;
  494. sleep(3);
  495. }
  496. break;
  497. case'typing':
  498. switch(strtolower($mensagem[1])){
  499. case 'on':
  500. $this->enviar('/RTypeOn');
  501. break;
  502.  
  503. case 'off':
  504. $this->enviar('/RTypeOff');
  505. break;
  506. }
  507. break;
  508. case'price1':
  509. $message = explode(' ', $mensagem[1], 1);
  510. $powers = $message[0];
  511. mysql_connect('localhost','root','ionutboss');
  512. mysql_select_db('ichat');
  513. if(is_numeric($powers)){
  514. $db = mysql_query("SELECT * FROM `powers` WHERE id ='$powers'");}
  515. else {$db = mysql_query("SELECT * FROM `powers` WHERE name ='$powers'");}
  516. $row = mysql_fetch_array($db);
  517. if($row['name'] == true) {
  518. if(empty($row['xats'])) {$row['xats'] = '0 - 0';}
  519. if(empty($row['days'])) {$row['days'] = '0 - 0';}
  520. $this->enviarMSG(htmlentities(ucfirst($row['name'])).' custos '.$row['xats'].' xats ou '.$row['days'].' days.');
  521. } else { $this->enviarMSG('Power not found.');}
  522. break;
  523.  
  524. case'rinfo':
  525. $this->enviarMSG('ID : '.$this->sala.' | Buttons : _'.$this->chatInfo['buttons'].' | Radio : '.$this->chatInfo['radio'].' | Background : '.$this->chatInfo['background']);
  526. break;
  527. case "cmd":
  528. // !info
  529. $this->enviarMSG( "!online , !say , !price , !love , !choose , !perg , !info ,
  530. mazeme,snakeme,!att", "PM", $packet[ "u" ] );
  531. break;
  532.  
  533. case 'online':
  534. $this->enviarMSG( $users . '' . 'There ' . count( $this->users ) . ' Users Online.' );
  535. break;
  536.  
  537. case "choose":
  538. // !choose [coisa] [coisa2]
  539. $mensagem = explode( ' ou ', strtolower( $msg ) );
  540. if ( !isset( $mensagem[ 0 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  541. return $this->enviarMSG( 'It takes two choice (D)', "PM", $packet[ 'u' ] );
  542. $mensagem = array_values( $mensagem );
  543. $rand = $mensagem[ array_rand( $mensagem ) ];
  544. $this->enviarMSG( 'I prefer ' . $rand, "PM", $packet[ 'u' ] );
  545. break;
  546.  
  547. case "perg":
  548. case "8ball":
  549. // !perg/!8ball [pergunta]
  550. $respostas = array(
  551. 'Maybe',
  552. 'Sim.',
  553. 'Do Not.',
  554. 'My sources said no.',
  555. 'Ah, SIM and SIM',
  556. 'In fact I do not know',
  557. 'Outlook does not provide \'-\'',
  558. 'I think not',
  559. 'Very good',
  560. 'It was determined that yes.'
  561. );
  562. $resposta = $respostas[ array_rand( $respostas ) ];
  563. $mensagens = array( );
  564. foreach ( $mensagens as $k => $valor ) {
  565. $valor2 = strtoupper( $valor );
  566. array_push( $mensagens, $valor2 );
  567. } //$mensagens as $k => $valor
  568. $this->enviarMSG( ' [' . $usuario . ']' . $resposta, "PM", $packet[ 'u' ] );
  569. break;
  570.  
  571. case 'lovetest':
  572. // !lovetest [alguma coisa] [alguma coisa2]
  573. $gerar = rand( 0, 100 );
  574. $this->enviarMSG( $mensagem[ 1 ] . ' + ' . $mensagem[ 2 ] . ' = ' . $gerar . '%' );
  575. break;
  576.  
  577. /* Comandos para admin */
  578. case "reiniciar":
  579. // !reiniciar
  580. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  581. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  582. } //!in_Array( $packet[ "u" ], $this->admins )
  583. $this->enviarMSG( "[Server]: I'm being restarted (backoff)" );
  584. $this->reiniciar();
  585. break;
  586.  
  587.  
  588. case'userinfo':
  589. $message = explode(' ', $mensagem[1], 1);
  590. $user = $message[0];
  591.  
  592. if(!$this->users[$user]['id']){ $this->enviarMSG('I Do not NOOB.');}
  593. else{
  594. if($this->users[$user]['rel'] == 2) $this->users[$user]['rel'] = "Married";
  595. if($this->users[$user]['rel'] == 1) $this->users[$user]['rel'] = "BFF";
  596. $myNick = explode("##", $this->users[$user]['name'], 2);
  597. $myNick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($myNick[0])));
  598. $relation = $this->users[$user]['rel'].' to '.$this->users[$user]['d2'];
  599. if($relation == 'Married to 0') $relation = 'Relation not found.';
  600. $name = explode('##', $this->users[$user]['name']);
  601. $n = $name[1];
  602. $this->enviarMSG('Name : '.$myNick[0].' | Status : '.str_replace('#',' | ',$n).'| Avatar : '.$this->users[$user]['avatar'].' | Home : '.$this->users[$user]['home'].' | Relation : '.$relation);
  603. }
  604. break;
  605.  
  606. case "desligar":
  607. case "die":
  608. // !die
  609. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  610. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  611. } //!in_Array( $packet[ "u" ], $this->admins )
  612. $this->enviarMSG( "[Server]: I'm shutting down (bye)" );
  613. die( );
  614. break;
  615.  
  616. case 'automember':
  617. // !automember [on/off]
  618. if ( !in_array( $packet[ 'u' ], $this->admins ) )
  619. {
  620. return $this->enviarMSG( 'You do not have to use this command!', 'PM', $packet[ 'u' ] );
  621. } //!in_array( $packet[ 'u' ], $this->admins )
  622. switch ( $mensagem[ 1 ] )
  623. {
  624. case 'on':
  625. $this->automember = True;
  626. $this->enviarMSG( 'The automember system was activated!' );
  627. break;
  628.  
  629. case 'off':
  630. $this->automember = False;
  631. $this->enviarMSG( 'The automember system has been disabled!' );
  632. break;
  633.  
  634. default:
  635. $this->enviarMSG( 'You should choose an option [on / off].' );
  636. } //$mensagem[ 1 ]
  637. break;
  638. case 'autoguest':
  639. // !automember [on/off]
  640. if ( !in_array( $packet[ 'u' ], $this->admins ) )
  641. {
  642. return $this->enviarMSG( 'You do not have to use this command!', 'PM', $packet[ 'u' ] );
  643. } //!in_array( $packet[ 'u' ], $this->admins )
  644. switch ( $mensagem[ 1 ] )
  645. {
  646. case 'on':
  647. $this->autoguest = True;
  648. $this->enviarMSG( 'The autoguest system was activated!' );
  649. break;
  650.  
  651. case 'off':
  652. $this->autoguest = False;
  653. $this->enviarMSG( 'The autoguest system has been disabled!' );
  654. break;
  655.  
  656. default:
  657. $this->enviarMSG( 'You should choose an option [on / off].' );
  658. } //$mensagem[ 1 ]
  659. break;
  660.  
  661. case 'edit':
  662. // !edit name , status , glow , hat ,avatar
  663. if ( !in_array( $packet[ 'u' ], $this->admins ) )
  664. {
  665. return $this->enviarMSG( 'You do not have to use this command!', 'PM', $packet[ 'u' ] );
  666. } //!in_array( $packet[ 'u' ], $this->admins )
  667. switch ( $mensagem[ 1 ] )
  668. {
  669. case'name':
  670. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  671. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  672. } //!in_Array( $packet[ "u" ], $this->admins )
  673. $this->nome = $mensagem[ 2 ];
  674. $this->entrar();
  675. $this->enviarMSG('My name has been changed to : '.$this->nome);
  676.  
  677. break;
  678.  
  679. case'status':
  680. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  681. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  682. } //!in_Array( $packet[ "u" ], $this->admins )
  683. $this->status = htmlentities($mensagem[2]);
  684. $this->entrar();
  685. $this->enviarMSG('My status has been changed : '.$this->status );
  686. break;
  687.  
  688. case'glow':
  689. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  690. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  691. } //!in_Array( $packet[ "u" ], $this->admins )
  692. $mensagem = explode( ' ou ', strtolower( $msg ) );
  693. if ( !isset( $mensagem[ 1 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  694. $this->glow = $mensagem[0];
  695. $this->entrar();
  696. $this->enviarMSG('My GlowColor has been changed to [ #'.$this->glow.' ]');
  697. break;
  698.  
  699. case'hat':
  700. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  701. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  702. } //!in_Array( $packet[ "u" ], $this->admins )
  703. $mensagem = explode( ' ou ', strtolower( $msg ) );
  704. if ( !isset( $mensagem[ 1 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  705. $this->hat = $mensagem[0];
  706. $this->entrar();
  707. $this->enviarMSG('My hat was changed to Success : ' );
  708. break;
  709.  
  710. case'home':
  711. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  712. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  713. } //!in_Array( $packet[ "u" ], $this->admins )
  714. $mensagem = explode( ' ou ', strtolower( $msg ) );
  715. if ( !isset( $mensagem[ 1 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  716. $this->home = $mensagem[0];
  717. $this->entrar();
  718. $this->enviarMSG('My little house has been changed : ' );
  719. break;
  720.  
  721. case'welcome':
  722. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  723. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  724. } //!in_Array( $packet[ "u" ], $this->admins )
  725. $mensagem = explode( ' ou ', strtolower( $msg ) );
  726. if ( !isset( $mensagem[ 1 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  727. $this->autoWelcome = $mensagem[0];
  728. $this->entrar();
  729. $this->enviarMSG('My Welcome message has changed for : '.$this->autoWelcome );
  730. break;
  731.  
  732.  
  733. default:
  734. $this->enviarMSG( 'You should choose an option : !edit [name , status , glow , hat ,avatar].' );
  735. } //$mensagem[ 1 ]
  736. break;
  737.  
  738. /* Command Admin Para Bot Created Juninho & Sloom! */
  739. case "staff":
  740. // !staff
  741. $this->enviarMSG( " 1 , 4 , 7 , 2M , 1802 , 69 ", "PM", $packet[ "u" ] );
  742. break;
  743.  
  744. case'avatar':
  745. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  746. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  747. } //!in_Array( $packet[ "u" ], $this->admins )
  748. $this->avatar = $mensagem[1];
  749. $this->avatar = str_replace(' (', '(', $this->avatar);
  750. $this->avatar = str_replace(') ', ')', $this->avatar);
  751. $this->avatar = str_replace(' ', ' ', $this->avatar);
  752. $this->entrar();
  753. $this->entrar();
  754. $this->enviarMSG('My avatar has been changed : '.$this->avatar );
  755. break;
  756. case'last':
  757. $pow2 = file_get_contents('http://xat.com/web_gear/chat/pow2.php?Milk=1234');
  758. $pow2 = json_decode($pow2, true);
  759. $powername = array_search($pow2['0']['1']['id'], $pow2['5']['1']);
  760. $status = ($pow2[0][1]['text'] == '[LIMITED]') ? 'LIMITED':'UNLIMITED';
  761. $smilie = array_merge(array($powername), array_keys($pow2['3']['1'], $pow2['0']['1']['id'])); //get all smilies of the new power
  762. $smilies = array();
  763. $pawns = array();
  764. foreach($smilie as $v)
  765. array_push($smilies, $v);
  766. foreach($pow2[6][1] as $name => $value)
  767. if($name != 'time' && $value[0] == $pow2['0']['1']['id'])
  768. array_push($pawns, 'h'.$name);
  769. $smilielist = implode(", ", $smilies);
  770. $pawnlist = implode(", ", $pawns);
  771. $this->enviarMSG(ucfirst($powername).' | ID : '.$pow2['0']['1']['id'].' | Status : '.$status.' | Smilies: '.ucfirst($smilielist).' | Hats : '.$pawnlist);
  772. break;
  773. case 'calc':
  774. /* Command created by iZerang */
  775. // !calc [numero] [/ * * -] [numero 2]
  776. if ( is_numeric( $mensagem[1] ) && is_numeric( $mensagem[3] ) ) {
  777. switch ( $mensagem[2] ) {
  778.  
  779. case "*":
  780. $x = $mensagem[1] * $mensagem[3];
  781. $this->enviarMSG("{$mensagem[1]} x {$mensagem[3]} = {$x}");
  782. break;
  783.  
  784. case "/":
  785. $x = $mensagem[1] / $mensagem[3];
  786. $this->enviarMSG("{$mensagem[1]} + {$mensagem[3]} = {$x}");
  787. break;
  788.  
  789. case "+":
  790. $x = $mensagem[1] + $mensagem[3];
  791. $this->enviarMSG("{$mensagem[1]} + {$mensagem[3]} = {$x}");
  792. break;
  793.  
  794. case "-":
  795. $x = $mensagem[1] - $mensagem[3];
  796. $this->enviarMSG("{$mensagem[1]} - {$mensagem[3]} = {$x}");
  797. break;
  798. }
  799. //$mensagem[2]
  800. } //is_numeric( $mensagem[1] ) && is_numeric( $mensagem[3] )
  801. else {
  802. $this->enviarMSG( 'You must enter a valid account' , "PM", $packet[ "u" ] );
  803. }
  804. break;
  805.  
  806. case 'price':
  807. /* Command created by iZerang */
  808. $x1 = strtr(substr($mensagem[1], 0, 1), "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  809. $x2 = strtr(substr($mensagem[1], 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz");
  810. $msg = $x1.$x2;
  811. if(empty($msg)){$this->enviarMSG('The power of the name can not be empty.'); return;}
  812. $url = @file_get_contents('http://xatalert.com/fairtrade/');
  813. file_put_contents($core->lib . "prices.txt", $pricelist);
  814. if(empty($msg)){$this->enviarMSG('Failed to get price notify an administrator!'); return;}
  815. $parte1 = explode($msg.'</abbr></td><td></td><td>(', $url);
  816. $final = explode(')</td><td>',$parte1[1]);
  817. if(!$final[0]){
  818. $parte1 = explode($msg.'</abbr></td><td><img src="http://xat.com/images/apicon.png" border="0"></td><td>(', $url);
  819. $final = explode(')</td><td>',$parte1[1]);
  820. }
  821. $parte2 = explode($msg.'</abbr></td><td></td><td>('.$final[0].')</td><td>', $url);
  822. $final2 = explode('</td><td>',$parte2[1]);
  823. if(!$final2[0]){
  824. $parte2 = explode($msg.'</abbr></td><td><img src="http://xat.com/images/apicon.png" border="0"></td><td>('.$final[0].')</td><td>', $url);
  825. $final2 = explode('</td><td>',$parte2[1]);
  826. }
  827. $parte3 = explode($msg.'</abbr></td><td><img src="http://xat.com/images/apicon.png" border="0"></td><td>('.$final[0].')</td><td>'.$final2[0].'</td><td>', $url);
  828. $final3 = explode('</td><td>',$parte3[1]);
  829. if(!$final3[0]){
  830. $parte3 = explode($msg.'</abbr></td><td></td><td>('.$final[0].')</td><td>'.$final2[0].'</td><td>', $url);
  831. $final3 = explode('</td><td>',$parte3[1]);
  832. }
  833. if(!$final[0]){$this->enviarMSG('Power nonexistent, or not added yet.');}else
  834. $this->enviarMSG('The power in the '.$msg.' store costs: '.$final[0].', trade: '.$final2[0].', in days: '.$final3[0].'.');
  835. break;
  836.  
  837. case 'dx':
  838. $days = intval($message[1]);
  839. if($days < 1)
  840. return $this->sendPM($packet['u'], 'days must be 1 or more');
  841.  
  842. $tradeValue = 13;
  843. $xats = floor($days * $tradeValue);
  844. $this->enviarMSG($days.' days equals '.$xats.' xats');
  845. break;
  846.  
  847. case 'xclear11111111111111':
  848. If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  849. return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  850. } //!in_Array( $packet[ "u" ], $this->admins )
  851. return $this->enviarMSG('Sorry, but you are not allowed to do so!');;
  852. $this->clear = $mensagem[1];
  853. case 'msg11111111111111':
  854. case 'chat11111111111':
  855. case 'messages1111111111111':
  856. case 'message1111111111111111':
  857. $this->clearMsg(true,25);
  858. $this->socket->connect();
  859. $this->network->join();
  860. break;
  861.  
  862.  
  863.  
  864. } //substr( $mensagem[ 0 ], 1 )
  865. } //$tipo
  866. }
  867.  
  868. /* Reiniciar o servidor */
  869. public function reiniciar( )
  870. {
  871. $this->conectar();
  872. $this->entrar();
  873. }
  874. public function fetchUser($id) {
  875. $id = $this->parseU($id);
  876. if(isset($this->users[$id]))
  877. return $this->users[$id];
  878. else
  879. return false;
  880. }
  881. function kick($message, $id, $log=true) {
  882. if($log) {
  883. if(!empty($this->users[$id]['kicks']) ) $this->users[$id]['kicks']++;
  884. else $this->users[$id]['kicks'] = 1;
  885. }
  886. if($this->users[$id]['kicks'] > $this->maxKicks) {
  887. $this->ban($message,$id,3600);
  888. $this->users[$id]['kicks'] = 0;
  889. return;
  890. }
  891. $this->enviar('<c p="'.$message." ".$this->users[$id]['kicks'].'/'.$this->maxKicks.'" u="'.$id.'" t="/k" />');
  892. }
  893. function ban($message, $id, $time) {
  894. $this->enviar('<c p="'.ereg_replace('[^A-Za-z0-9.! ]','',$message).'" u="'.$id.'" t="/g'.$time.'" />');
  895. }
  896. public function sendPM($id=0, $packet='') {
  897. $id = $this->parseU($id);
  898. $this->enviar('<p u="'.$id.'" t="'.$packet.'" d="'.$id.'" />');
  899. }
  900.  
  901. public function parseU($id) {
  902. if(strpos($id, "_") > -1)
  903. $e = explode("_", $id);
  904. $u = (strpos($id, "_") > -1) ? $e[0] : $id;
  905. return $u;
  906. }
  907.  
  908. function member($id,$time=null) {
  909. if(!$time) $time = 0;
  910. $id = $this->parseU($id);
  911. $this->sendC($id, '/e',$time);
  912. }
  913. function guest($id,$time=null) {
  914. if(!$time) $time = 0;
  915. $id = $this->parseU($id);
  916. $this->sendC($id, '/r',$time);
  917. }
  918.  
  919. public function sendC($id=0, $com='') {//Shit always comes in handy after awhile.
  920. $this->enviar('<c u="'.$id.'" t="'.$com.'" />');
  921. }
  922. public function censor($message) {
  923. $badwords = $this->censor;
  924. $message = @preg_replace('#\((.+)\)#U','',strtolower(' '.$message.' '));
  925. foreach($badwords as $bad) {
  926. $bad = trim($bad);
  927. if(strpos($message.' ', $bad.' ')!==false) {
  928. if(strlen($bad)>=2) {
  929. return true;
  930. }
  931. }
  932.  
  933. }
  934.  
  935. }
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945. /* Enviar MSG, definido com tipo e ID */
  946. function enviarMSG( $mensagem, $tipo = "MSG", $id = 0 )
  947. {
  948. If ( !$mensagem ) {
  949. return False;
  950. } //!$mensagem
  951. switch ( $tipo ) {
  952. case "MSG": // Sample
  953. $this->enviar( "<m t=\"{$mensagem}\" u=\"{$this->botID}\" />" );
  954. break;
  955.  
  956. case "PM": // PM
  957. $this->enviar( "<p u=\"{$id}\" t=\"{$mensagem}\" d=\"{$id}\" />" );
  958. break;
  959.  
  960. case "PC": // Privado
  961. $this->enviar( "<z d=\"{$id}\" u=\"{$this->botID}\" t=\"{$mensagem}\" />" );
  962. break;
  963. } //$tipo
  964. }
  965.  
  966. }
  967.  
  968. $bot = new zBot(); // Estanciar a class
  969.  
  970. while ( 1 ) {
  971. try {
  972. If ( $bot->carregar() == "DESLIGADO" ) {
  973. $bot->desconectar();
  974. $bot->entrar();
  975. } //$bot->carregar() == "DESLIGADO"
  976. }
  977. catch ( Exception $e ) {
  978. die( $e );
  979. }
  980. } //1
  981.  
  982. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement