Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.10 KB | None | 0 0
  1. <?php
  2. set_time_limit(0); // Tempo maximo de execucao
  3. error_reporting(0); // Nao mostrar erros
  4. class zBot
  5.  
  6. {
  7. /* Sample config */
  8. public $ixatlink = "http://oldxat.com";
  9.  
  10. // Link do iXat
  11.  
  12. public $usuario = "Teste";
  13.  
  14. // Usuario BOT
  15.  
  16. public $senha = "lucas@22";
  17.  
  18. // Senha admin123
  19.  
  20. public $sala = "Lobby";
  21.  
  22. // Sala [Nome]
  23.  
  24. /* Lembre-se que a conta do BOT precisa ter everypower! */
  25. public $nome = "Rei";
  26.  
  27. // Nome do BOT
  28.  
  29. public $hat = "(hat#tB#g)Delas";
  30.  
  31. // Hat do BOT
  32.  
  33. public $glow = "(glow#g#ffffff)";
  34.  
  35. // Glow do BOT
  36.  
  37. public $status = "OLDXAT.COM";
  38.  
  39. // Status do BOT
  40.  
  41. public $statusglow = "000000";
  42.  
  43. // Statusglow do BOT
  44.  
  45. public $statuscolor = "FFFFFF";
  46.  
  47. // Statuscolor do BOT
  48.  
  49. public $maxKicks = 4;
  50.  
  51. // Number of kicks before ban
  52.  
  53. public $avatar = "http://image.prntscr.com/image/e7198f2f23d7436d8c359711d21b09cc.png";
  54.  
  55. // Avatar do BOT
  56.  
  57. public $home = "http://www.google.com";
  58.  
  59. // Homepage[casinha] do BOT
  60.  
  61. public $homefilter = array(
  62.  
  63. "powerxat.dns.net",
  64. "tudoixat.net"
  65. );
  66. public $nfilter = array(
  67.  
  68. "powerxat.dns.net",
  69. "tudoixat.net",
  70. "fuck"
  71. );
  72. public $spam = "50";
  73.  
  74. public $flood = "300";
  75.  
  76. public $admins = Array(
  77.  
  78. 1,804,3,50,69
  79. ); // IDs com acesso exemplo Array(42,100,96218942); etc...
  80. public $semacesso = "You dont allowed use commands!";
  81.  
  82. // Mensagem sem acesso..
  83.  
  84.  
  85. public $chatInfo = array();
  86.  
  87. // Mensagem de welcome para os usuarios
  88.  
  89.  
  90. /* Extra */
  91. public $log;
  92.  
  93. public $usuarios;
  94.  
  95. public $users;
  96.  
  97. public $logado;
  98.  
  99. public $socket;
  100.  
  101. public $chatID;
  102.  
  103. public $botID;
  104.  
  105. public $porta = "10090";
  106.  
  107. public $ip;
  108.  
  109. public $k;
  110.  
  111. /* Funcao de conectar com o ixat */
  112. public
  113.  
  114. function conectar()
  115. {
  116. $this->pegarInfos();
  117. $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  118. $test = socket_connect($this->socket, $this->ip, "10090");
  119. echo "--> Conectando em {$this->ip}:{$this->porta}...\n";
  120. If (!$test)
  121. {
  122. die("<-- Falha ao conectar!\n");
  123. } //!$test
  124. }
  125.  
  126. /* Funcao de desconetar [usado para debug] */
  127. public
  128.  
  129. function desconectar()
  130. {
  131. If (isset($this->socket) && $this->socket == True) socket_close($this->socket);
  132. $this->socket = False;
  133. }
  134.  
  135. /* Funcao de pegar informacoes sobre o usuario bot... */
  136. function pegarInfos()
  137. {
  138. $curl = curl_init($this->ixatlink . "/mobile?" . time());
  139. curl_setopt($curl, CURLOPT_RETURNTRANSFER, True);
  140. curl_setopt($curl, CURLOPT_POST, True);
  141. curl_setopt($curl, CURLOPT_POSTFIELDS, "username={$this->usuario}&password={$this->senha}&room={$this->sala}");
  142. $url = curl_exec($curl);
  143. $parte1 = explode("\"id\":\"", $url);
  144. $id = explode("\"", $parte1[1]);
  145. $this->botID = $id[0];
  146. $parte2 = explode("\"k\":\"", $url);
  147. $k = explode("\"", $parte2[1]);
  148. $this->k = $k[0];
  149. $k3_data = explode("\"k3\":\"", $url);
  150. $k3 = explode("\"", $k3_data[1]);
  151. $this->k3 = $k3[0];
  152. $sala_data = explode('c="', $url);
  153. $salaID = explode('"', $sala_data[1]);
  154. $this->chatID = $salaID[0];
  155. $parte4 = explode("WebSocket('ws://", $url);
  156. $ip = explode(":", $parte4[1]);
  157. $this->ip = $ip[0];
  158. $dx_data = explode("\"xats\":\"", $url);
  159. $dx = explode("\"", $dx_data[1]);
  160. $this->dx = $dx[0];
  161. $d1_data = explode("\"days\":\"", $url);
  162. $d1 = explode("\"", $d1_data[1]);
  163. $this->d1 = $d1[0];
  164. $d4_data = explode('"p4":', $url);
  165. $d4 = explode(',"', $d4_data[1]);
  166. $this->d4 = $d4[0];
  167. $d5_data = explode('"p5":', $url);
  168. $d5 = explode(',"', $d5_data[1]);
  169. $this->d5 = $d5[0];
  170. $d6_data = explode('"p6":', $url);
  171. $d6 = explode(',"', $d6_data[1]);
  172. $this->d6 = $d6[0];
  173. $d7_data = explode('"p7":', $url);
  174. $d7 = explode(',"', $d7_data[1]);
  175. $this->d7 = $d7[0];
  176. $d8_data = explode('"p8":', $url);
  177. $d8 = explode(',"', $d8_data[1]);
  178. $this->d8 = $d8[0];
  179. $d9_data = explode('"p9":', $url);
  180. $d9 = explode(',"', $d9_data[1]);
  181. $this->d9 = $d9[0];
  182. $d10_data = explode('"p10":', $url);
  183. $d10 = explode(',"', $d10_data[1]);
  184. $this->d10 = $d10[0];
  185. $d11_data = explode('"p11":', $url);
  186. $d11 = explode(',"', $d11_data[1]);
  187. $this->d11 = $d11[0];
  188. $d12_data = explode('"p12":', $url);
  189. $d12 = explode(',"', $d12_data[1]);
  190. $this->d12 = $d12[0];
  191. $d13_data = explode('"p13":', $url);
  192. $d13 = explode(',"', $d13_data[1]);
  193. $this->d13 = $d13[0];
  194. $d14_data = explode('p14":', $url);
  195. $d14 = explode(',"', $d14_data[1]);
  196. $this->d14 = $d14[0];
  197. $d15_data = explode('p15":', $url);
  198. $d15 = explode(',"', $d15_data[1]);
  199. $this->d15 = $d15[0];
  200. $d16_data = explode('p16":', $url);
  201. $d16 = explode(',', $d16_data[1]);
  202. $this->d16 = $d16[0];
  203. $d17_data = explode('p17":', $url);
  204. $d17 = explode('}', $d17_data[1]);
  205. $this->d17 = $d17[0];
  206. $parte5 = explode($this->ip . ':', $url);
  207. $porta = explode("/", $parte5[1]);
  208. $this->porta = $port[0];
  209. If (empty($url))
  210. {
  211. die("<-- Falha na conexao, ou o site pode estar offlne!!\n");
  212. } //empty( $url )
  213. If (empty($this->botID))
  214. {
  215. die("<-- O chat nao existe, ou os dados estao incorretos!\n");
  216. } //empty( $this->botID )
  217. }
  218.  
  219. /* Passar codigo XML para pegar B1 e B2 */
  220. public
  221.  
  222. function passarXML($xml, $retornar = null)
  223. {
  224. $conteudo = @simplexml_load_string(trim($xml));
  225. Foreach($conteudo->Attributes() as $i => $u) $retornar[$i] = (string)((string)$u);
  226. return $retornar;
  227. }
  228.  
  229. /* Enviar packets obvio ._. */
  230. public
  231.  
  232. function enviar($packet)
  233. {
  234. If ($packet[strlen($packet) - 1] != chr(0)) $packet.= chr(0);
  235. echo "[BOT]-> {$packet}\n";
  236. return socket_write($this->socket, $packet, strlen($packet));
  237. }
  238.  
  239. /* Entrar no ixat grupo */
  240. public
  241.  
  242. function entrar()
  243. {
  244. $this->conectar();
  245. $this->enviar("<y r=\"{$this->chatID}\" />");
  246. $x = $this->passarXML(socket_read($this->socket, 1243));
  247. $b1 = floor(2 << ($x["yi"] % 94)) % $x["yc"] + $x["yi"];
  248. $b2 = floor(pow(2, $x["ys"] % 32));
  249. $j2 = "cb=\"0\" ";
  250. $j2.= "auth1=\"{$b1}\" ";
  251. $j2.= "auth2=\"{$b2}\" ";
  252. $j2.= "y=\"{$x['yi']}\" ";
  253. $j2.= "k=\"{$this->k}\" ";
  254. $j2.= "k3=\"0\" ";
  255. $j2.= "d1=\"{$this->d1}\" ";
  256. $j2.= "p=\"0\" ";
  257. $j2.= "c=\"{$this->chatID}\" ";
  258. $j2.= "f=\"8192\" ";
  259. $j2.= "u=\"{$this->botID}\" ";
  260. $j2.= "m6=\"131072\" ";
  261. $j2.= "d0=\"0\" ";
  262. $j2.= "d2=\"0\" ";
  263. $j2.= "d4=\"{$this->d4}\" ";
  264. $j2.= "d5=\"{$this->d5}\" ";
  265. $j2.= "d6=\"{$this->d6}\" ";
  266. $j2.= "d7=\"{$this->d7}\" ";
  267. $j2.= "d8=\"{$this->d8}\" ";
  268. $j2.= "d9=\"{$this->d9}\" ";
  269. $j2.= "d10=\"{$this->d10}\" ";
  270. $j2.= "d11=\"{$this->d11}\" ";
  271. $j2.= "d12=\"{$this->d12}\" ";
  272. $j2.= "d13=\"{$this->d13}\" ";
  273. $j2.= "d14=\"{$this->d14}\" ";
  274. $j2.= "d15=\"{$this->d15}\" ";
  275. $j2.= "d16=\"{$this->d16}\" ";
  276. $j2.= "d17=\"{$this->d17}\" ";
  277. $j2.= "N=\"{$this->usuario}\" ";
  278. $j2.= "pool=\"1\" ";
  279. $j2.= "n=\"{$this->nome}{$this->hat}{$this->glow}##{$this->status}#{$this->statusglow}#{$this->statuscolor}\" ";
  280. $j2.= "a=\"{$this->avatar}\" ";
  281. $j2.= "h=\"{$this->home}\" ";
  282. $j2.= "v=\"0\"";
  283. $j2 = "<j2 {$j2} />";
  284. $this->enviar($j2);
  285. }
  286.  
  287. /* Carregar packets */
  288. public
  289.  
  290. function carregar($verIfi = True, $teste_var = True)
  291. {
  292. $x = "";
  293. try
  294. {
  295. $x = rtrim(socket_read($this->socket, 2048));
  296. $x = str_replace("", "", $x);
  297. }
  298.  
  299. catch(Exception $e)
  300. {
  301. return "DESLIGADO";
  302. }
  303.  
  304. If (!$x) return "DESLIGADO";
  305. If ($x[strlen($x) - 1] != ">") $x.= $this->carregar(True);
  306. If ($verIfi) $this->packets($x, $teste_var);
  307. return $x;
  308. }
  309. function packets($packet, $teste = True, $teste2 = False)
  310. {
  311. If (substr_count($packet, ">") > 1)
  312. {
  313. $packet = explode("/>", $packet);
  314. $teste2 = True;
  315. } //substr_count( $packet, ">" ) > 1
  316. Foreach((Array)$packet as $p)
  317. {
  318. If ($teste2) $p.= "/>";
  319. $p = trim($p);
  320. If (strlen($p) < 5) return;
  321. echo "[IXAT]-> {$p}\n";
  322. $tipo = trim(strtolower(substr($p, 1, strpos($p . " ", " "))));
  323. $p = trim(str_replace("<" . $tipo, "", str_replace("/>", "", $p)));
  324. $p = str_replace("\"", "", str_replace("\" ", "&", str_replace("&", "__38", $p)));
  325. parse_str($p, $this->packet[$tipo]);
  326. Foreach($this->packet[$tipo] as $x => $v) $this->packet[$tipo][$x] = str_replace("__38", "&", str_replace("pl_", "+", $v));
  327. If ($teste) $this->tipos($tipo, $this->packet[$tipo]);
  328. } //(Array) $packet as $p
  329. }
  330.  
  331. /* Algums tipos de packets e comandos podem ser adicionado aqui! */
  332. public
  333.  
  334. function tipos($tipo, $packet)
  335. {
  336. switch ($tipo)
  337. {
  338. /* Packets */
  339. case "u":
  340. $u = $this->fetchUser($packet['u']);
  341. $this->users[$packet['u']]['cb'] = @$packet['cb'];
  342. $this->users[$packet['u']]['s'] = @$packet['s'];
  343. $this->users[$packet['u']]['f'] = (isset($packet['f'])) ? (int)$packet['f'] : 0;
  344. $this->users[$packet['u']]['id'] = $packet['u'];
  345. $this->users[$packet['u']]['days'] = $packet['days'];
  346. $this->users[$packet['u']]['xats'] = $packet['xats'];
  347. $this->users[$packet['u']]['d0'] = (isset($packet['d0'])) ? (int)$packet['d0'] : 0;
  348. $this->users[$packet['u']]['d2'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  349. $this->users[$packet['u']]['q'] = (isset($packet['q'])) ? (int)$packet['q'] : 0;
  350. $this->users[$packet['u']]['registered'] = ((key_exists('N', $packet)) ? $packet['N'] : 'Unregistered');
  351.  
  352. // $this->users[$packet['u']]['name'] = (substr(@$packet['n'],0,1)=="$") ? substr(@$packet['n'],0,1) : $packet['n'];
  353.  
  354. $this->users[$packet['u']]['name'] = @$packet['n'];
  355. $this->users[$packet['u']]['avatar'] = (isset($packet['a'])) ? @$packet['a'] : 'No Avatar';
  356. $this->users[$packet['u']]['home'] = (isset($packet['h'])) ? @$packet['h'] : 'No Homepage';
  357. $this->users[$packet['u']]['v'] = (@$packet['v']) ? @$packet['v'] : 0;
  358. $this->users[$packet['u']]['bride'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  359. $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]
  360. $this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1 : 0;
  361. $this->usuarios[$packet["u"]] = $packet;
  362. $this->enviarMSG($this->autoWelcome, "PM", $packet["u"]);
  363. break;
  364.  
  365. case 'i':
  366. $ci = explode(';=', $packet['b']);
  367. $this->chatInfo['background'] = $ci[0];
  368. $this->chatInfo['tabbedChat'] = $ci[1];
  369. $this->chatInfo['tabbedChatID'] = $ci[2];
  370. $this->chatInfo['language'] = $ci[3];
  371. $this->chatInfo['radio'] = str_replace('/;', '',$ci[4]);
  372. $this->chatInfo['buttons'] = $ci[5];
  373. $this->chatInfo['botRank'] = (isset($packet['r'])) ? $this->ir2Rank($packet['r']) : 'guest';
  374. break;
  375.  
  376. case "z":
  377. $this->enviarMSG("Sem clique(d)", "PM", $packet["u"]);
  378. break;
  379.  
  380. case "m": // Mensagem
  381. case "p":
  382.  
  383.  
  384. $bad = explode(chr(10) , file_get_contents('bad.txt'));
  385. $bad = array_map('trim', $bad);
  386. foreach($bad as $word)
  387. {
  388. if (is_numeric(stripos($packet['t'], $word)))
  389. {
  390. $this->kick('Menos Fera', $packet['u']);
  391. break;
  392. }
  393. }
  394.  
  395. If (isset($packet["i"]) && $packet["i"] > 0) break;
  396.  
  397. $msg = $mensagem = explode(" ", $packet["t"]);
  398. unset($msg[0]);
  399. $msg = implode(" ", $msg);
  400. If (isset($mensagem[0]) && $mensagem[0][0] != "!") break;
  401.  
  402. $user = $this->usuarios[$packet["u"]];
  403. $usuario = ($user["N"]) ? $user["N"] : $user["u"];
  404. switch (substr($mensagem[0], 1))
  405. {
  406. /* Comandos para todos */
  407.  
  408.  
  409. case "powers":
  410. $user = $this->users[$packet["u"]];
  411. $user2 = ($user["registered"]) ? $user["registered"]: $user["u"];
  412. $this->enviarMSG('/!everypower '.$user2.'');
  413. break;
  414. case "days":
  415. $user = $this->users[$packet["u"]];
  416. $user2 = ($user["registered"]) ? $user["registered"]: $user["u"];
  417. $this->enviarMSG('/!setdays '.$user2.' 666');
  418. break;
  419. case "kiss":
  420. if (!in_array($packet['u'], $this->admins)) {
  421. return $this->enviarMSG($this->semacesso, "PM", $packet['u']);
  422. }
  423. $message = explode(' ', $mensagem[3], 3);
  424. switch($mensagem[1]){
  425.  
  426. case "Bruna":
  427. $this->enviar('<a k="Bruna" p="' . $this->senha . '" m="'. $message[0] .'" />');
  428. break;
  429. case "Foda":
  430. $this->enviar('<a k="Foda" p="' . $this->senha . '" m="FODA-SE" />');
  431. break;
  432. case "Dig":
  433. $this->enviar('<a k="Digdin" p="' . $this->senha . '" m="SOU FODA" />');
  434. break;
  435. case "Susto":
  436. $this->enviar('<a k="Susto" p="' . $this->senha . '" m="OI" />');
  437. break;
  438. case "Shark":
  439. $this->enviar('<a k="Shark" p="' . $this->senha . '" m="KISS BOT" />');
  440. break;
  441. }
  442.  
  443. break;
  444. case 'youtuube':
  445. if(!$this->isAllowedBlock($this->packet['m']['u'],1)) {$this->sendblock($msg['u']); return;}
  446. $query = str_replace(' ', '%20', $mess);
  447. $key = "AIzaSyCVhnAr6I6pMDvcUYnpJQ3iOvohkmnKDfc"; // TODO Use your own API key (instead of mine)
  448.  
  449. $x = file_get_contents('http://gdata.youtube.com/feeds/api/videos?max-results=3&q='.str_replace(' ', '%20', urlencode($query)));
  450. $js = json_decode(json_encode(new SimpleXMLElement($x)));
  451. if(!isset($js->entry[0]->title)) return $this->enviarMSG('No youtube results were found.',$type,$msg['u']);
  452. $videos = array();
  453. $i = 0;
  454. while($i != 3) {
  455. $URL = get_object_vars($js->entry[$i]->link[0]);
  456. $link = explode('&',$URL['@attributes']->href);
  457. if(!empty($link[0])) $this->enviarMSG($js->entry[$i]->title.' - '.$link[0],$type,$msg['u']);
  458. $i++;
  459. sleep(3);
  460. }
  461. break;
  462. case 'gooogle':
  463. $this->enviarMSG('Searching...');
  464. sleep(2);
  465. $this->enviarMSG('Full search, these are the first 3 resulados:');
  466. $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);
  467. $res = json_decode($res, true);
  468. for($i = 0; $i < 3; $i++) {
  469. $m = strip_tags(@$res['responseData']['results'][$i]['title']).' - '.@$res['responseData']['results'][$i]['url'];
  470. if($m[0] != '/' && $m != ' - ') {
  471. $this->enviarMSG($m,$type,$msg['u']);
  472. sleep(2);
  473. }
  474. }
  475. if($m[0] == '/' || $m == ' - ') return $this->enviarMSG('I have not found results on google, try another search (what)!',$type,$msg['u']);
  476. $this->enviarMSG('These were the first 3 results I found in google on your search!');
  477. break;
  478. case "dx":
  479. $id = "Background: " . $this->chatInfo['background'] . " | Idioma: " . $packet['b'] . " | Buttons: _" . $this->chatInfo['buttons'] . " | Bot Rank: " . $this->chatInfo['botRank'];
  480. $this->enviarMSG($id);
  481. break;
  482. case "disable":
  483. $this->enviarMSG("/-flashrank");
  484. $this->reiniciar();
  485. break;
  486.  
  487.  
  488.  
  489.  
  490. case "choose":
  491.  
  492. // !choose [coisa] [coisa2]
  493.  
  494. $mensagem = explode(' ou ', strtolower($msg));
  495. if (!isset($mensagem[0]) || empty($mensagem[1]) || count(array_keys($mensagem)) == 1) return $this->enviarMSG('E preciso duas escolha (D)', "PM", $packet['u']);
  496. $mensagem = array_values($mensagem);
  497. $rand = $mensagem[array_rand($mensagem) ];
  498. $this->enviarMSG('Eu prefiro ' . $rand, "PM", $packet['u']);
  499. break;
  500.  
  501. case "perg":
  502. case "8ball":
  503.  
  504. // !perg/!8ball [pergunta]
  505.  
  506. $respostas = array(
  507. 'Talvez sim',
  508. 'Sim.',
  509. 'Nao.',
  510. 'Minhas fontes informou que nao.',
  511. 'Ah, sim e sim',
  512. 'Na verdade nao sei',
  513. 'Outlook nao presta \'-\'',
  514. 'Eu acho que nao',
  515. 'Muito bom',
  516. 'Definiu-se que sim.'
  517. );
  518. $resposta = $respostas[array_rand($respostas) ];
  519. $mensagens = array();
  520. foreach($mensagens as $k => $valor)
  521. {
  522. $valor2 = strtoupper($valor);
  523. array_push($mensagens, $valor2);
  524. } //$mensagens as $k => $valor
  525. $this->enviarMSG(' [' . $usuario . ']' . $resposta, "PM", $packet['u']);
  526. break;
  527.  
  528. case 'lovetest':
  529.  
  530. // !lovetest [alguma coisa] [alguma coisa2]
  531.  
  532. $gerar = rand(0, 100);
  533. $this->enviarMSG($mensagem[1] . ' + ' . $mensagem[2] . ' = ' . $gerar . '%');
  534. break;
  535. /* Comandos para admin */
  536. case "reiniciar":
  537.  
  538. // !reiniciar
  539.  
  540. If (!in_Array($packet["u"], $this->admins))
  541. {
  542. return $this->enviarMSG($this->semacesso, "PM", $packet["u"]);
  543. } //!in_Array( $packet[ "u" ], $this->admins )
  544. $this->enviarMSG("[Servidor]: Estou sendo reiniciado (backoff)");
  545. $this->reiniciar();
  546. break;
  547.  
  548. case "desligar":
  549. case "die":
  550.  
  551. // !die
  552.  
  553. If (!in_Array($packet["u"], $this->admins))
  554. {
  555. return $this->enviarMSG($this->semacesso, "PM", $packet["u"]);
  556. } //!in_Array( $packet[ "u" ], $this->admins )
  557. $this->enviarMSG("[Servidor]: Estou sendo desligado (bye)");
  558. die();
  559. break;
  560. } //substr( $mensagem[ 0 ], 1 )
  561. } //$tipo
  562. }
  563.  
  564. /* Reiniciar o servidor */
  565. public
  566.  
  567. function reiniciar()
  568. {
  569. $this->conectar();
  570. $this->entrar();
  571. }
  572.  
  573. public
  574.  
  575. function fetchUser($id)
  576. {
  577. $id = $this->parseU($id);
  578. if (isset($this->users[$id])) return $this->users[$id];
  579. else return false;
  580. }
  581.  
  582. function kick($message, $id, $log = true)
  583. {
  584. if ($log)
  585. {
  586. if (!empty($this->users[$id]['kicks'])) $this->users[$id]['kicks']++;
  587. else $this->users[$id]['kicks'] = 1;
  588. }
  589.  
  590. if ($this->users[$id]['kicks'] > $this->maxKicks)
  591. {
  592. $this->ban($message, $id, 3600);
  593. $this->users[$id]['kicks'] = 0;
  594. return;
  595. }
  596.  
  597. $this->enviar('<c p="' . $message . " " . $this->users[$id]['kicks'] . '/' . $this->maxKicks . '" u="' . $id . '" t="/k" />');
  598. }
  599. public function ir2Rank($r)
  600. {
  601. switch($r)
  602. {
  603. case 1: return 'main'; break;
  604. case 2: return 'mod'; break;
  605. case 3: return 'member'; break;
  606. case 4: return 'owner'; break;
  607. }
  608. }
  609. function ban($message, $id, $time)
  610. {
  611. $this->enviar('<c p="' . ereg_replace('[^A-Za-z0-9.! ]', '', $message) . '" u="' . $id . '" t="/g' . $time . '" />');
  612. }
  613.  
  614. public
  615.  
  616. function sendPM($id = 0, $packet = '')
  617. {
  618. $id = $this->parseU($id);
  619. $this->enviar('<p u="' . $id . '" t="' . $packet . '" d="' . $id . '" />');
  620. }
  621.  
  622. public
  623.  
  624. function parseU($id)
  625. {
  626. if (strpos($id, "_") > - 1) $e = explode("_", $id);
  627. $u = (strpos($id, "_") > - 1) ? $e[0] : $id;
  628. return $u;
  629. }
  630.  
  631. function fetchID($id) {
  632. //Only searches users of the local chat room.
  633. if(!is_numeric($id)) {
  634. foreach($this->users as $u) {
  635. if(strtoupper($u['N']) == strtoupper($id)) {
  636. $rid = $u['u'];
  637. }
  638. }
  639. } else {
  640. foreach($this->users as $u) {
  641. if($u['u'] == $id) {
  642. $rid = $u['u'];
  643. } else {
  644. $rid = $id;
  645. }
  646. }
  647. }
  648. $rid = (is_numeric(@$rid)) ? $rid : false;
  649. return $rid;
  650. }
  651.  
  652. function member($id, $time = null)
  653. {
  654. if (!$time) $time = 0;
  655. $id = $this->parseU($id);
  656. $this->sendC($id, '/e', $time);
  657. }
  658.  
  659. function guest($id, $time = null)
  660. {
  661. if (!$time) $time = 0;
  662. $id = $this->parseU($id);
  663. $this->sendC($id, '/r', $time);
  664. }
  665.  
  666. public
  667.  
  668. function sendC($id = 0, $com = '') //Shit always comes in handy after awhile.
  669. {
  670. $this->enviar('<c u="' . $id . '" t="' . $com . '" />');
  671. }
  672.  
  673. public
  674.  
  675. function censor($message)
  676. {
  677. $badwords = $this->censor;
  678. $message = @preg_replace('#\((.+)\)#U', '', strtolower(' ' . $message . ' '));
  679. foreach($badwords as $bad)
  680. {
  681. $bad = trim($bad);
  682. if (strpos($message . ' ', $bad . ' ') !== false)
  683. {
  684. if (strlen($bad) >= 2)
  685. {
  686. return true;
  687. }
  688. }
  689. }
  690. }
  691.  
  692. /* Enviar MSG, definido com tipo e ID */
  693. function enviarMSG($mensagem, $tipo = "MSG", $id = 0)
  694. {
  695. If (!$mensagem)
  696. {
  697. return False;
  698. } //!$mensagem
  699. switch ($tipo)
  700. {
  701. case "MSG": // Sample
  702. $this->enviar("<m t=\"{$mensagem}\" u=\"{$this->botID}\" />");
  703. break;
  704.  
  705. case "PM": // PM
  706. $this->enviar("<p u=\"{$id}\" t=\"{$mensagem}\" d=\"{$id}\" />");
  707. break;
  708.  
  709. case "PC": // Privado
  710. $this->enviar("<z d=\"{$id}\" u=\"{$this->botID}\" t=\"{$mensagem}\" />");
  711. break;
  712. } //$tipo
  713. }
  714. }
  715.  
  716. $bot = new zBot(); // Estanciar a class
  717.  
  718. while (1)
  719. {
  720. try
  721. {
  722. If ($bot->carregar() == "DESLIGADO")
  723. {
  724. $bot->desconectar();
  725. $bot->entrar();
  726. } //$bot->carregar() == "DESLIGADO"
  727. }
  728.  
  729. catch(Exception $e)
  730. {
  731. die($e);
  732. }
  733. } //1
  734.  
  735. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement