Advertisement
Guest User

Zbot.php att

a guest
Mar 28th, 2015
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.74 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. error_reporting(0);
  4.  
  5. class iBot
  6. {
  7. public $ixatlink = "http://ixaat12.zapto.org:8090";
  8. public $withoutaccess = "You aren't allowed to use commands!";
  9. public $radioinfo = 'semnome';
  10. public $users;
  11. public $logado;
  12. public $socket;
  13. public $chatID;
  14. public $botID;
  15. public $port;
  16. public $ip;
  17. public $k;
  18. public $filterWords;
  19. public $maxKicks = 4; //Number of kicks before ban
  20. public $members = array();
  21. public $censor = array("porra","fdp","caralho","buceta","pinto","anal","cu","fuck","bitch","vai tomar no cu","viado","gay");
  22. public function __construct()
  23. {
  24. $config = (object) array('db' => array(0 => 'localhost', 1 => 'root', 2 => '', 3 => 'pulse'));
  25. $this->mysql = new database($config->db[0], $config->db[1], $config->db[2], $config->db[3]);
  26. $this->config = $this->mysql->fetch_array("select * from `bots` limit 0, 1;");
  27. $this->config = (object) $this->config[0];
  28.  
  29. $this->config->admins = @(array) json_decode($this->config->admins);
  30. $this->time = time();
  31. }
  32.  
  33. public function connect()
  34. {
  35. $this->getinfo();
  36. $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  37. $test = socket_connect($this->socket, $this->ip, $this->port);
  38. echo "--> Connecting to {$this->ip}:{$this->port}...\n";
  39. if(!$test){
  40. die( "<-- Error to connection!\n" );
  41. }
  42. }
  43.  
  44. public function disconnect()
  45. {
  46. if(isset($this->socket) && $this->socket == true)
  47. socket_close($this->socket);
  48. $this->socket = false;
  49. }
  50.  
  51. function getinfo()
  52. {
  53. $curl = curl_init($this->ixatlink.'/mobile?'.time());
  54. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  55. curl_setopt($curl, CURLOPT_POST, true);
  56. curl_setopt($curl, CURLOPT_POSTFIELDS, "username={$this->config->username}&password={$this->config->password}&room={$this->config->room}");
  57. $url = curl_exec($curl);
  58. $parte1 = explode("\"id\":\"", $url);
  59. $id = explode("\"", $parte1[1]);
  60. $this->botID = $id[0];
  61. $parte2 = explode("\"k\":\"", $url);
  62. $k = explode("\"", $parte2[1]);
  63. $this->k = $k[0];
  64. $k3_data = explode("\"k3\":\"", $url);
  65. $k3 = explode("\"", $k3_data[1]);
  66. $this->k3 = $k3[0];
  67. $sala_data = explode('c="', $url);
  68. $salaID = explode('"', $sala_data[1]);
  69. $this->chatID = $salaID[0];
  70. $parte4 = explode("WebSocket('ws://", $url);
  71. $ip = explode(":", $parte4[1]);
  72. $this->ip = $ip[0];
  73. $dx_data = explode("\"xats\":\"", $url);
  74. $dx = explode("\"", $dx_data[1]);
  75. $this->dx = $dx[0];
  76. $d1_data = explode("\"days\":\"", $url);
  77. $d1 = explode("\"", $d1_data[1]);
  78. $this->d1 = $d1[0];
  79. $d4_data = explode('"p4":', $url);
  80. $d4 = explode(',"', $d4_data[1]);
  81. $this->d4 = $d4[0];
  82. $d5_data = explode('"p5":', $url);
  83. $d5 = explode(',"', $d5_data[1]);
  84. $this->d5 = $d5[0];
  85. $d6_data = explode('"p6":', $url);
  86. $d6 = explode(',"', $d6_data[1]);
  87. $this->d6 = $d6[0];
  88. $d7_data = explode('"p7":', $url);
  89. $d7 = explode(',"', $d7_data[1]);
  90. $this->d7 = $d7[0];
  91. $d8_data = explode('"p8":', $url);
  92. $d8 = explode(',"', $d8_data[1]);
  93. $this->d8 = $d8[0];
  94. $d9_data = explode('"p9":', $url);
  95. $d9 = explode(',"', $d9_data[1]);
  96. $this->d9 = $d9[0];
  97. $d10_data = explode('"p10":', $url);
  98. $d10 = explode(',"', $d10_data[1]);
  99. $this->d10 = $d10[0];
  100. $d11_data = explode('"p11":', $url);
  101. $d11 = explode(',"', $d11_data[1]);
  102. $this->d11 = $d11[0];
  103. $d12_data = explode('"p12":', $url);
  104. $d12 = explode(',"', $d12_data[1]);
  105. $this->d12 = $d12[0];
  106. $d13_data = explode('"p13":', $url);
  107. $d13 = explode(',"', $d13_data[1]);
  108. $this->d13 = $d13[0];
  109. $d14_data = explode('p14":', $url);
  110. $d14 = explode(',"', $d14_data[1]);
  111. $this->d14 = $d14[0];
  112. $d15_data = explode('p15":', $url);
  113. $d15 = explode('}', $d15_data[1]);
  114. $this->d15 = $d15[0];
  115. $parte5 = explode($this->ip.':', $url);
  116. $port = explode("/", $parte5[1]);
  117. $this->port = $port[0];
  118. if(empty($url)){
  119. die( "<-- Connection failed, or the website could be closed!!\n");
  120. }
  121. if(empty($this->botID)){
  122. die( "<-- The chat doesn't exist, or the data is incorrect!\n");
  123. }
  124. }
  125.  
  126. public function passXML($xml, $return = null)
  127. {
  128. $content = @simplexml_load_string(trim($xml));
  129. foreach($content->Attributes() as $i => $u)
  130. $return[$i] = (string) ((string) $u);
  131. return $return;
  132. }
  133.  
  134. public function send($packet)
  135. {
  136. if($packet[strlen($packet) - 1] != chr(0))
  137. $packet .= chr(0);
  138. echo "[BOT]-> {$packet}\n";
  139. return socket_write($this->socket, $packet, strlen($packet));
  140. }
  141.  
  142. public function enter()
  143. {
  144. $this->connect();
  145. $this->send("<y r=\"{$this->chatID}\" v=\"0\" u=\"{$this->config->id}\" />");
  146. $x = $this->passXML(socket_read($this->socket, $this->port));
  147. $bot2 = floor(pow(2, $x['ys'] % 27));
  148. $bot1 = floor(2 << ($x['yi'] % 94)) % $x['yc'] + $x['yi'];
  149. $j2 = "cb=\"0\" ";
  150. $j2 .= "auth1=\"{$bot1}\" ";
  151. $j2 .= "auth2=\"{$bot2}\" ";
  152. $j2 .= "y=\"{$x["yi"]}\" ";
  153. $j2 .= "k=\"{$this->k}\" ";
  154. $j2 .= "k3=\"{$this->k3}\" ";
  155. $j2 .= "d1=\"{$this->d1}\" ";
  156. $j2 .= "p=\"0\" ";
  157. $j2 .= "c=\"{$this->chatID}\" ";
  158. if($this->config->botpion == 1){ $j2 .= "f=\"8192\" "; } else { $j2 .= "f=\"0\" "; }
  159. $j2 .= "u=\"{$this->config->id}\" ";
  160. $j2 .= "d0=\"0\" ";
  161. $j2 .= "d4=\"{$this->d4}\" ";
  162. $j2 .= "d5=\"{$this->d5}\" ";
  163. $j2 .= "d6=\"{$this->d6}\" ";
  164. $j2 .= "d7=\"{$this->d7}\" ";
  165. $j2 .= "d8=\"{$this->d8}\" ";
  166. $j2 .= "d9=\"{$this->d9}\" ";
  167. $j2 .= "d10=\"{$this->d10}\" ";
  168. $j2 .= "d11=\"{$this->d11}\" ";
  169. $j2 .= "d12=\"{$this->d12}\" ";
  170. $j2 .= "d13=\"{$this->d13}\" ";
  171. $j2 .= "d14=\"{$this->d14}\" ";
  172. $j2 .= "d15=\"{$this->d15}\" ";
  173. $j2 .= "dO=\"\" ";
  174. $j2 .= "dx=\"{$this->dx}\" ";
  175. $j2 .= "N=\"{$this->config->username}\" ";
  176. $j2 .= "n=\"{$this->config->name}\" ";
  177. $j2 .= "a=\"{$this->config->avatar}\" ";
  178. $j2 .= "h=\"{$this->config->homepage}\" ";
  179. $j2 .= "v=\"5\"";
  180. $j2 = "<j2 {$j2} />";
  181. $this->send($j2);
  182. }
  183.  
  184. public function load($check = true, $test_var = true)
  185. {
  186. $x = "";
  187. try {
  188. $x = rtrim(socket_read($this->socket, 2048));
  189. $x = str_replace("", "", $x);
  190. }
  191. catch(Exception $e){
  192. return "OFF";
  193. }
  194. if(!$x)
  195. return "OFF";
  196. if($x[strlen($x) - 1] != ">")
  197. $x .= $this->load(true);
  198. if($check)
  199. $this->packets($x, $test_var);
  200. return $x;
  201. }
  202.  
  203. public function packets($packet, $test = true, $test2 = false)
  204. {
  205. if(substr_count($packet, ">") > 1){
  206. $packet = explode("/>", $packet);
  207. $test2 = true;
  208. }
  209. foreach((array) $packet as $p ){
  210. if($test2)
  211. $p .= "/>";
  212. $p = trim($p);
  213. if(strlen($p) < 5)
  214. return;
  215. echo "[XAT]-> {$p}\n";
  216. $type = trim(strtolower(substr($p, 1, strpos($p." ", " "))));
  217. $p = trim(str_replace("<".$type, "", str_replace("/>", "", $p)));
  218. $p = str_replace("\"", "", str_replace("\" ", "&", str_replace("&", "__38", $p)));
  219. parse_str($p, $this->packet[$type]);
  220. foreach($this->packet[$type] as $x => $v)
  221. $this->packet[$type][$x] = str_replace("__38", "&", str_replace("pl_", "+", $v));
  222. if($test)
  223. $this->type($type, $this->packet[$type]);
  224. }
  225. }
  226.  
  227. public function type($type, $packet)
  228. {
  229. switch($type){
  230. case 'u':
  231. $u = $this->fetchUser($packet['u']);
  232. $this->users[$this->parseU($packet['u'])] = $packet;
  233. $this->users[$packet['u']]['cb'] = @$packet['cb'];
  234. $this->users[$packet['u']]['s'] = @$packet['s'];
  235. $this->users[$packet['u']]['f'] = (isset($packet['f'])) ? (int)$packet['f']: 0;
  236. $this->users[$packet['u']]['id'] = $packet['u'];
  237. $this->users[$packet['u']]['d0'] = (isset($packet['d0'])) ? (int)$packet['d0']: 0;
  238. $this->users[$packet['u']]['d2'] = (isset($packet['d2'])) ? @$packet['d2']: 0;
  239. $this->users[$packet['u']]['q'] = (isset($packet['q'])) ? (int)$packet['q']: 0;
  240. $this->users[$packet['u']]['registered'] = ((key_exists('N', $packet)) ? $packet['N']: 'Unregistered');
  241. $this->users[$packet['u']]['name'] = @$packet['n'];
  242. $this->users[$packet['u']]['avatar'] = (isset($packet['a'])) ? @$packet['a']: 'No Avatar';
  243. $this->users[$packet['u']]['home'] = (isset($packet['h'])) ? @$packet['h']: 'No Homepage';
  244. $this->users[$packet['u']]['v'] = (@$packet['v']) ? @$packet['v']: 0;
  245. $this->users[$packet['u']]['bride'] = (isset($packet['d2'])) ? @$packet['d2']: 0;
  246. $this->users[$packet['u']]['rel'] = (@$packet['d0'] & 1) ? 1: 2;
  247. $this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1: 0;
  248. $user = ( $packet['N']) ? $packet['N']: $packet['u'];
  249. $userid = $packet['i'];
  250.  
  251.  
  252. if(!empty($this->config->autowelcome) && !isset($packet['s']))
  253. {
  254. $this->sendwelcome($this->config->autowelcome, $packet['u'], $packet['f'], $user);
  255. }
  256.  
  257. if($packet['rank'] == 5)
  258. {
  259. if($this->config->automember == 1){
  260. $this->member($packet['u']);
  261. }
  262. }
  263.  
  264. if($packet['rank'] == 3)
  265. {
  266. if($this->config->autoguest == 1){
  267. $this->guest($packet['u']);
  268. }
  269. }
  270. break;
  271.  
  272.  
  273.  
  274.  
  275. case "i":
  276. $info = explode(';=', $this->packet['i']['b']);
  277. $this->radioinfo = str_replace("http://", "", $info[4]);
  278. break;
  279.  
  280. case "z":
  281. $this->sendmsg("{$this->config->ticklemsg}", "PM", $packet["u"]);
  282. break;
  283.  
  284. case "m":
  285. case "p":
  286. if($this->censor($packet['t'])) {
  287. $this->send('<c p="Sem inapp (d)" u="'.$packet['u'].'" t="/k" />');
  288. }
  289. if(isset($packet["i"]) && $packet["i"] > 0)
  290. break;
  291.  
  292. $msg = $message = explode(" ", $packet["t"]);
  293. unset($msg[0]);
  294. $msg = implode(" ", $msg);
  295. $user4 = ($this->users[$packet["u"]]["n"]) ? $this->users[$packet["u"]]["n"]: $this->users[$packet["u"]]["u"];
  296. $response = $this->mysql->fetch_array("select * from `response` where `question`='{$this->mysql->sanatize($message[0])}';");
  297. if($message[0] == "{$response[0]['question']}" || $msg == "{$response[0]['question']}"){
  298.  
  299. $hat = explode("(hat#", $user4, 2);
  300. $hat2 = explode(")", $hat[1], 2);
  301. $glow = explode("(glow#", $user4, 2);
  302. $glow2 = explode(")", $glow[1], 2);
  303. $status = explode("##", $user4, 2);
  304. $this->sendmsg(str_replace("$", "", str_replace("##{$status[1]}", "", str_replace("(glow#{$glow2[0]})", "", str_replace("(hat#{$hat2[0]})", "", str_replace("[user]", $user4, $response[0]['answer']))))));
  305. }
  306. if(isset($message[0]) && $message[0][0] != "!")
  307. break;
  308. $user = $this->users[$packet["u"]];
  309. $user2 = ($user["N"]) ? $user["N"]: $user["u"];
  310. $bot = $this->mysql->fetch_array("select * from `bots` limit 0, 1;");
  311. switch(substr($message[0], 1)){
  312.  
  313. case "say":
  314. $this->sendmsg("[$user2] : ".$msg);
  315. break;
  316.  
  317. case 'insultar':
  318. if(is_numeric(strpos(strtolower($message[1]), 'Key'))) return $this->respond("Nao posso chingar ele :(");
  319. $insulto = array("$message[1] FDP", "$message[1] lixo", "$message[1] arrombado", "$message[1] noob", "$message[1] tueburroe");
  320. $this->sendmsg($insulto[array_rand($insulto)]);
  321.  
  322. break;
  323.  
  324. case "perg":
  325. case "8ball":
  326. // !perg/!8ball [pergunta]
  327. $resposta = array(
  328. 'Talvez sim',
  329. 'Sim.',
  330. 'Nao.',
  331. 'Minhas fontes informou que nao.',
  332. 'Ah, sim e sim',
  333. 'Na verdade nao sei',
  334. 'Outlook nao presta \'-\'',
  335. 'Eu acho que nao',
  336. 'Muito bom',
  337. 'Definiu-se que sim.'
  338. );
  339. $resposta = $resposta[ array_rand( $resposta ) ];
  340. $message = array( );
  341. foreach ( $message as $k => $valus ) {
  342. $valus = strtoupper( $valus );
  343. array_push( $message, $values );
  344. } //$message as $k => $valus
  345. $this->sendmsg( '' . $resposta . $packet[ 'u' ] );
  346. break;
  347.  
  348.  
  349.  
  350.  
  351. case "test":
  352. // !say [msg]
  353. $user = $this->users[ $packet[ "u" ] ];
  354. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  355. $this->sendmsg ('('.$msg.') ');
  356. break;
  357.  
  358.  
  359. case "sayadm":
  360. if(!in_array($packet['u'], $this->config->admins)){
  361. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  362. }
  363.  
  364. $this->sendmsg($msg);
  365. break;
  366.  
  367. case 'botpion':
  368. if(!in_array($packet['u'], $this->config->admins)){
  369. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  370. }
  371. if($this->config->botpion == 1)
  372. {
  373. $this->mysql->query("UPDATE bots SET botpion='0'");
  374. $this->sendmsg('Bot pion has been disabled!');
  375. return $this->restart();
  376. }
  377. else
  378. {
  379. $this->mysql->query("UPDATE bots SET botpion='1'");
  380. $this->sendmsg('Bot pion has been activated!');
  381. return $this->restart();
  382. }
  383. break;
  384.  
  385.  
  386. case 'goto':
  387. if(!in_array($packet['u'], $this->config->admins)){
  388. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  389. }
  390. if($msg == $this->config->room){
  391. $this->sendmsg("I'm already on {$msg}!");
  392. } else {
  393. $this->mysql->query("UPDATE bots SET room='{$msg}'");
  394. $this->sendmsg("I'm going to {$msg}!");
  395. return $this->restart();
  396. }
  397. break;
  398.  
  399.  
  400. case '!filter':
  401. case '!censor':
  402. if(!$this->isAllowed($this->packet['m']['u'])) {$this->sendMessage("Você não tem permissão para alternar o filtro de linguagem!"); return;}
  403. $this->filterWords = !$this->filterWords;
  404. if($this->filterWords) $this->sendMessage("Censor, e seja comportado!");
  405. else $this->sendMessage("Censor é off, Sinta-se livre para relaxar.");
  406. $this->save();
  407. break;
  408. case '!spamfilter':
  409. case '!spam':
  410. case '!sfilter':
  411. if(!$this->isAllowed($this->packet['m']['u'])) {$this->sendMessage("você não tem permissão para alterar o filtro de spam."); return;}
  412. $word = explode(' ',$info[1].' ');
  413. if(is_numeric($word[0]) && is_numeric($word[1]) && !empty($word[1])) {
  414. $this->spam['time'] = $word[1];
  415. $this->spam['limit'] = $word[0];
  416. $this->sendMessage("filtro de spam foi definido para ".$this->spam['limit']."mensagens a cada ".$this->spam['time']." segundos");
  417. $this->sendMessage("se alguém passa esse limite, eles serão chutou resultando em uma proibição em função dos chutes máximos.");
  418. }
  419. $this->save();
  420. break;
  421.  
  422.  
  423. case 'info':
  424. $this->sendmsg('iBot by yuukiyuuki(381455307) aka Kayabe ~Key Por add cmd ', 'PM', $packet['u']);
  425. break;
  426.  
  427. case 'users':
  428. $this->sendmsg($user2.': '.count($this->users).' users online.');
  429. break;
  430.  
  431. case'!chatinfo':
  432. $this->send('ID : '.$this->sala.' | Buttons : _'.$this->chatInfo['buttons'].' | Radio : '.$this->chatInfo['radio'].' | Background : '.$this->chatInfo['background']);
  433. break;
  434.  
  435.  
  436.  
  437. case "time":
  438. $s = time() - $this->time;
  439. $m = floor($s / 60);
  440. $h = floor($m / 60);
  441. $msg = "Run time (approx): Seconds - $s | Minutes - $m | Hours - $h";
  442. $this->sendmsg($msg);
  443. break;
  444.  
  445. case "glow":
  446. case "ng":
  447. case "name":
  448. case "hat":
  449. case "av":
  450. case "avatar":
  451. case "status":
  452. if(!in_array($packet["u"], $this->config->admins)){
  453. return $this->sendmsg($this->withoutaccess, "PM", $packet["u"]);
  454. }
  455.  
  456. if(substr($message[0], 1) == "hat"){
  457. $hat = explode("(hat#", $this->config->name);
  458. $status = explode("##", $this->config->name, 2);
  459. if($status[1]){
  460. if($hat[1]){
  461. $this->mysql->query("UPDATE `bots` SET `name`='".$hat[0]."(hat#".$msg.")##".$status[1]."'");
  462. $this->restart();
  463. $this->sendmsg("Hat alterado com sucesso!");
  464. } else {
  465. $this->mysql->query("UPDATE `bots` SET `name`='".$status[0]."(hat#".$msg.")##".$status[1]."'");
  466. $this->restart();
  467. $this->sendmsg("Hat adicionado com sucesso!");
  468. }
  469. }else{
  470. if($hat[1]){
  471. $this->mysql->query("UPDATE `bots` SET `name`='".$hat[0]."(hat#".$msg.")"."'");
  472. $this->restart();
  473. $this->sendmsg("Hat alterado com sucesso!");
  474. } else {
  475. $this->mysql->query("UPDATE `bots` SET `name`='".$hat[0]."(hat#".$msg.")"."'");
  476. $this->restart();
  477. $this->sendmsg("Hat adicionado com sucesso! [COND1]");
  478. }
  479. }
  480. }else if(substr($message[ 0 ], 1) == "ng" || substr($message[0], 1) == "glow"){
  481. $glow = explode("(glow#", $bot[0]['name']);
  482. if($glow[1]){
  483. $this->mysql->query("UPDATE `bots` SET `name`='".$glow[0]."(glow#".$msg.")"."'");
  484. $this->restart();
  485. $this->sendmsg("Nameglow alterada com sucesso!");
  486. } else {
  487. $this->mysql->query("UPDATE `bots` SET `name`='".$bot[0]['name']."(glow#".$msg.")"."'");
  488. $this->restart();
  489. $this->sendmsg("Nameglow adicionado com sucesso!");
  490. }
  491. }else if(substr($message[0], 1) == "name"){
  492. $special = explode("(", $bot[0]['name']);
  493. if($special[1]){
  494. $this->mysql->query("UPDATE `bots` SET `name`='".$msg."(".$special[1]."'");
  495. $this->restart();
  496. $this->sendmsg("Nome alterado com sucesso!");
  497. }else{
  498. $this->nome = $msg;
  499. $this->restart();
  500. $this->sendmsg("Nome alterado com sucesso!");
  501. }
  502. }else if(substr($message[0], 1) == "av" || substr($message[0], 1) == "avatar"){
  503. $this->avatar = $msg;
  504. $this->mysql->query("UPDATE `bots` SET `avatar`='".$msg."'");
  505. $this->restart();
  506. $this->sendmsg("Avatar alterado com sucesso!");
  507. }else if(substr($message[0], 1) == "status"){
  508. $status = explode("##", $bot[0]['name'], 2);
  509. if($status[1]){
  510. $this->mysql->query("UPDATE `bots` SET `name`='".$status[0]."##".$msg."'");
  511. $this->restart();
  512. $this->sendmsg("Status alterado com sucesso!");
  513. } else {
  514. $this->mysql->query("UPDATE `bots` SET `name`='".$bot[0]['name']."##".$msg."'");
  515. $this->restart();
  516. $this->sendmsg("Status adicionado com sucesso!");
  517. }
  518. }
  519. break;
  520.  
  521. case "restart":
  522. if(!in_array($packet["u"], $this->config->admins)){
  523. return $this->sendmsg($this->withoutaccess, "PM", $packet["u"]);
  524. }
  525. $this->sendmsg("[Servidor]: Estou sendo reiniciado (backoff)");
  526. $this->restart();
  527. break;
  528.  
  529. case'dunceme':
  530. $message = explode(' ', $message[1], 1);
  531. $users = $message[0];
  532. if(empty($users)) $users = $packet['u'];
  533. $this->send('<c p="Você foi dunced por ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'.$packet['u'].'" t="/gd3600" />');
  534. break;
  535.  
  536. case'undunceme':
  537. $message = explode(' ', $message[1], 1);
  538. $users = $message[0];
  539. if(empty($users)) $users = $packet['u'];
  540. $this->send('<c p="You have been dunced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'.$packet['u'].'" t="/gd3600" />');
  541. break;
  542.  
  543. case 'value':
  544. if(!$owner) {
  545. break;
  546. }
  547. $uRow = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  548. $user->sendRoom("<m u=\"0\" t=\"The k-k2 values for [".$args[1]."]: K1-[".$uRow[0]['k']."] K2-[".$uRow[0]['k2']."]\" />");
  549. break;
  550.  
  551.  
  552.  
  553.  
  554. case'modme':
  555. $message = explode(' ', $message[1], 1);
  556. $users = $message[0];
  557. if(!in_array($packet['u'], $this->config->admins)){
  558. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  559. }
  560. $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/m" />');
  561. break;
  562.  
  563. case'kickme':
  564. $message = explode(' ', $message[1], 1);
  565. $users = $message[0];
  566. if(empty($users)) $users = $packet['u'];
  567. $this->send('<c p="You have been kicked by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are kicked." u="'.$packet['u'].'" t="/k" />');
  568. break;
  569.  
  570. case'kick':
  571. $message = explode(' ', $message[1], 1);
  572. $users = $message[0];
  573. if(empty($users)) $users = $packet['u'];
  574. $this->send('<c p="You have been kicked by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are kicked." u="'.$packet['u'].'" t="/k" />');
  575. break;
  576.  
  577. case'guestme':
  578. $message = explode(' ', $message[1], 1);
  579. $users = $message[0];
  580. if(empty($users)) $users = $packet['u'];
  581. $this->send('<c p="You have been dunced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'.$packet['u'].'" t="/r" />');
  582. break;
  583.  
  584. case'smiley':
  585. mysql_connect('localhost','root','');
  586. mysql_select_db('pulse') or $this->sendmsg('Can\'t connect.');
  587. $message = explode(' ', $message[1], 1);
  588. $power = $message[0];
  589. $db = mysql_query("SELECT * FROM `powers` WHERE name='$power'");
  590. $row = mysql_fetch_array($db);
  591. if(!$row['name']) {$this->sendmsg('Power not found! (d)');}
  592. else {
  593. $powers = str_replace(',','#) (',$row['topsh']);
  594. if(empty($row['topsh'])) {$this->sendmsg(ucfirst($power).' are doar ('.$power.') ca smilies.');}
  595. else {
  596. $this->sendmsg('('.$power.'#) Smilies : ('.$powers.'#)');}}
  597.  
  598. break;
  599.  
  600. case "powers":
  601. $user = $this->users[$packet["u"]];
  602. $user2 = ($user["registered"]) ? $user["registered"]: $user["u"];
  603. $this->sendmsg('!everypower '.$user2.'');
  604. break;
  605.  
  606.  
  607. case'memberme':
  608. $message = explode(' ', $message[1], 1);
  609. $users = $message[0];
  610. if(empty($users)) $users = $packet['u'];
  611. $this->send('<c p="You have been dunced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'.$packet['u'].'" t="/e" />');
  612. break;
  613.  
  614. case'last':
  615. $pow2 = file_get_contents('http://xat.com/web_gear/chat/pow2.php?Milk=1234');
  616. $pow2 = json_decode($pow2, true);
  617. $powername = array_search($pow2['0']['1']['id'], $pow2['5']['1']);
  618. $status = ($pow2[0][1]['text'] == '[LIMITED]') ? 'LIMITED':'UNLIMITED';
  619. $smilie = array_merge(array($powername), array_keys($pow2['3']['1'], $pow2['0']['1']['id'])); //get all smilies of the new power
  620. $smilies = array();
  621. $pawns = array();
  622. foreach($smilie as $v)
  623. array_push($smilies, $v);
  624. foreach($pow2[6][1] as $name => $value)
  625. if($name != 'time' && $value[0] == $pow2['0']['1']['id'])
  626. array_push($pawns, 'h'.$name);
  627. $smilielist = implode("), (", $smilies);
  628. $pawnlist = implode(", ", $pawns);
  629. $this->sendmsg(ucfirst($powername).' | ID : '.$pow2['0']['1']['id'].' | Status : '.$status.' | Smilies: ('.ucfirst($smilielist).') | Hats : '.$pawnlist);
  630. break;
  631.  
  632. case 'promocost':
  633. $hours = array(
  634. '0.5' => 8,
  635. '1' => 16,
  636. '1.5' => 25,
  637. '2' => 33,
  638. '2.5' => 41,
  639. '3' => 49,
  640. '3.5' => 57,
  641. '4' => 66,
  642. '4.5' => 74,
  643. '5' => 85,
  644. '5.5' => 93,
  645. '6' => 102
  646. );
  647. if ( key_exists( $message[ 1 ], $hours ) )
  648. $this->sendmsg( '' . $message[ 1 ] . ' ora promovare costa: ' . $message[ 1 ] * 200 . ' xats sau ' . $hours[ $message[ 1 ] ] . ' days' );
  649. else
  650. $this->sendmsg( 'incorrect amount of hours' );
  651. break;
  652.  
  653. {
  654. return false;
  655. }
  656. break;
  657. case 'love':
  658. // !lovetest [alguma coisa] [alguma coisa2]
  659. $gerar = rand( 0, 100 );
  660. $this->sendmsg( $message[ 1 ] . ' + ' . $message[ 2 ] . ' = ' . $gerar . '%' );
  661. break;
  662.  
  663.  
  664. case'unbanme':
  665. $message = explode(' ', $message[1], 1);
  666. $users = $message[0];
  667. if(!in_array($packet['u'], $this->config->admins)){
  668. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  669. }
  670. $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/u" />');
  671. break;
  672.  
  673. case 'calc':
  674. /* Command created by iZerang */
  675. // !calc [numero] [/ * * -] [numero 2]
  676. if ( is_numeric( $message[1] ) && is_numeric( $message[3] ) ) {
  677. switch ( $message[2] ) {
  678.  
  679. case "*":
  680. $x = $message[1] * $message[3];
  681. $this->sendmsg("{$message[1]} x {$message[3]} = {$x}");
  682. break;
  683.  
  684. case "/":
  685. $x = $message[1] / $message[3];
  686. $this->sendmsg("{$message[1]} + {$message[3]} = {$x}");
  687. break;
  688.  
  689. case "+":
  690. $x = $message[1] + $message[3];
  691. $this->sendmsg("{$message[1]} + {$message[3]} = {$x}");
  692. break;
  693.  
  694. case "-":
  695. $x = $message[1] - $message[3];
  696. $this->sendmsg("{$message[1]} - {$message[3]} = {$x}");
  697. break;
  698. }
  699. //$message[2]
  700. } //is_numeric( $message[1] ) && is_numeric( $message[3] )
  701. else {
  702. $this->sendmsg( 'Você deve digitar uma conta valida' , "PM", $packet[ "u" ] );
  703. }
  704. break;
  705.  
  706.  
  707. case 'dx':
  708. $days = intval($message[1]);
  709. if($days < 1)
  710. return $this->sendPM($packet['u'], 'days must be 1 or more');
  711.  
  712. $tradeValue = 13;
  713. $xats = floor($days * $tradeValue);
  714. $this->sendmsg($days.' days costa '.$xats.' xats cu 13 xats pe days');
  715. break;
  716.  
  717.  
  718.  
  719. case "xavi":
  720. $user = $this->users[$packet["u"]];
  721. $user2 = ($user["registered"]) ? $user["registered"]: $user["u"];
  722. $this->sendmsg('!delpower '.$user2.' xavi');
  723. break;
  724.  
  725.  
  726. case'unban':
  727. $message = explode(' ', $message[1], 1);
  728. $users = $message[0];
  729. if(!in_array($packet['u'], $this->config->admins)){
  730. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  731. }
  732. $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/u" />');
  733. break;
  734.  
  735. case'ban':
  736. $message = explode(' ', $message[1], 1);
  737. $users = $message[0];
  738. if(!in_array($packet['u'], $this->config->admins)){
  739. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  740. }
  741. $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/g10000" />');
  742. break;
  743.  
  744. case'ownerme':
  745. $message = explode(' ', $message[1], 1);
  746. $users = $message[0];
  747. if(!in_array($packet['u'], $this->config->admins)){
  748. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  749. }
  750. $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/M" />');
  751. break;
  752.  
  753. case'gag':
  754. $message = explode(' ', $message[1], 1);
  755. $users = $message[0];
  756. if(empty($users)) $users = $packet['u'];
  757. $this->send('<c p="You have been dunced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'.$packet['u'].'" t="/gg" />');
  758. break;
  759.  
  760. case 'lastpower':
  761. /* Command created by IoNuT */
  762. $url = @file_get_contents('http://xat.com/json/powers.php');
  763. if(empty($url)){$this->sendmsg('Falha ao obter o ultimo power, avise um administrador!'); return false;}
  764. $conteudo = json_decode($url, true);
  765. $ultimo_pw = reset($conteudo);
  766. $this->sendmsg('Ultimul power adaugat este : ('.$ultimo_pw['s'].'#).');
  767. break;
  768.  
  769.  
  770. case'mute':
  771. $message = explode(' ', $message[1], 1);
  772. $users = $message[0];
  773. if(empty($users)) $users = $packet['u'];
  774. $this->send('<c p="You have been dunced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'.$packet['u'].'" t="/gm" />');
  775. break;
  776.  
  777. case'banme':
  778. $message = explode(' ', $message[1], 1);
  779. $users = $message[0];
  780. if(empty($users)) $users = $packet['u'];
  781. $this->send('<c p="You have been dunced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'.$packet['u'].'" t="/g6000" />');
  782. break;
  783.  
  784. case 'radio':
  785. $connection = explode(':', $this->radioinfo);
  786. $url = fsockopen($connection[0],$connection[1]);
  787. if($this->radioinfo == 'semnome' or !$this->radioinfo){$this->sendmsg("This group chat does not have a radio."); return false;}
  788. if(!$url){
  789. $this->sendmsg("Connection failed."); return false;
  790. } else {
  791. fputs($url,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
  792. $socket = fread($url, 1000);
  793. $return = explode(",", $socket);
  794. $final = str_replace("</body></html>", "", $return[6]);
  795. if(!$final){
  796. $this->sendmsg("a Musica que esta tocando e: Nao estou reconhecendo."); return false;
  797. } else
  798. $this->sendmsg("a Musica que esta tocando e: {$final}");
  799. }
  800. break;
  801.  
  802.  
  803. case'userinfo':
  804. $message = explode(' ', $message[1], 1);
  805. $user = $message[0];
  806.  
  807. if(!$this->users[$user]['id']){
  808. $this->sendmsg("I'm not a noob.");
  809. } else {
  810. if($this->users[$user]['rel'] == 2) $this->users[$user]['rel'] = "Married";
  811. if($this->users[$user]['rel'] == 1) $this->users[$user]['rel'] = "Bff'd";
  812. $myNick = explode("##", $this->users[$user]['name'], 2);
  813. $myNick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($myNick[0])));
  814. $relation = $this->users[$user]['rel'].' to '.$this->users[$user]['d2'];
  815. if($relation == 'Married to 0') $relation = 'Relation not found.';
  816. $name = explode('##', $this->users[$user]['name']);
  817. $n = $name[1];
  818. $this->sendmsg('Name : '.$myNick[0].' | Status : '.str_replace('#',' | ',$n).'| Avatar : '.$this->users[$user]['avatar'].' | Home : '.$this->users[$user]['home'].' | Relation : '.$relation);
  819. }
  820. break;
  821.  
  822. case "desligar":
  823. case "die":
  824. if(!in_array($packet["u"], $this->config->admins)){
  825. return $this->sendmsg($this->withoutaccess, "PM", $packet["u"]);
  826. }
  827. $this->sendmsg("[Servidor]: Estou sendo desligado (bye)");
  828. die();
  829. break;
  830.  
  831. case 'autowelcome':
  832. if(!in_array($packet['u'], $this->config->admins)){
  833. return $this->sendmsg($this->withoutaccess, "PM", $packet['u']);
  834. }
  835. if(!empty($this->config->autowelcome))
  836. {
  837. $this->mysql->query("UPDATE bots SET autowelcome=''");
  838. $this->sendmsg('Autowelcome of message has been disabled!');
  839. return $this->restart();
  840. }
  841. else
  842. {
  843. $this->mysql->query("UPDATE bots SET autowelcome='Bine ati venit pe [chat] - [user]!'");
  844. $this->sendmsg('Autowelcome of message has been activated!');
  845. return $this->restart();
  846. }
  847. break;
  848. }
  849. }
  850. }
  851.  
  852. function parseU($id){
  853. if(substr_count($id,'_')>=1) $id = substr($id,0,strpos($id,'_'));
  854. return $id;
  855. }
  856.  
  857. public function restart()
  858. {
  859. $this->__construct();
  860. $this->connect();
  861. $this->enter();
  862. }
  863.  
  864. public function fetchUser($id){
  865. $id = $this->parseU($id);
  866. if(isset($this->users[$id]))
  867. return $this->users[$id];
  868. else
  869. return false;
  870. }
  871.  
  872. function member($id,$time=null){
  873. if(!$time) $time = 0;
  874. $id = $this->parseU($id);
  875. $this->sendC($id, '/e',$time);
  876. }
  877.  
  878. function guest($id,$time=null) {
  879. if(!$time) $time = 0;
  880. $id = $this->parseU($id);
  881. $this->sendC($id, '/r',$time);
  882. }
  883.  
  884. public function sendC($id=0, $com='') {
  885. $this->send('<c u="'.$id.'" t="'.$com.'" />');
  886. }
  887.  
  888. public function censor($message) {
  889. $badwords = $this->censor;
  890. $message = @preg_replace('#\((.+)\)#U','',strtolower(' '.$message.' '));
  891. foreach($badwords as $bad) {
  892. $bad = trim($bad);
  893. if(strpos($message.' ', $bad.' ')!==false) {
  894. if(strlen($bad)>=2) {
  895. return true;
  896. }
  897. }
  898.  
  899. }
  900.  
  901. }
  902.  
  903. function sendwelcome($message, $id, $f, $nome)
  904. {
  905. if(!$message)
  906. {
  907. return false;
  908. }
  909. $message = str_replace('[chat]', $this->config->room, $message);
  910. $message = str_replace('[online]', count($this->users), $message);
  911. $message = str_replace('[user]', $nome, $message);
  912. $this->sendmsg($message, 'PM', $id);
  913. }
  914.  
  915. function sendmsg($message, $type = "MSG", $id = 0)
  916. {
  917. if(!$message){
  918. return false;
  919. }
  920. switch($type) {
  921. case "MSG":
  922. $this->send("<m t=\"{$message}\" u=\"{$this->botID}\" />");
  923. break;
  924.  
  925. case "PM":
  926. $this->send("<p u=\"{$id}\" t=\"{$message}\" d=\"{$id}\" />");
  927. break;
  928.  
  929. case "PC":
  930. $this->send("<z d=\"{$id}\" u=\"{$this->botID}\" t=\"{$message}\" />");
  931. break;
  932. }
  933. }
  934. }
  935.  
  936. $bot = new iBot();
  937.  
  938. while(1){
  939. try{
  940. if($bot->load() == "OFF"){
  941. $bot->disconnect();
  942. $bot->enter();
  943. }
  944. }
  945. catch(Exception $e){
  946. die($e);
  947. }
  948. }
  949.  
  950. class database {
  951. public $link, $host, $user, $pass, $name;
  952. public $doe = true;
  953.  
  954. public function __construct($host = null, $user = null, $pass = null, $name = null)
  955. {
  956. if ($name != null) {
  957. $this->host = $host;
  958. $this->user = $user;
  959. $this->pass = $pass;
  960. $this->name = $name;
  961. }
  962.  
  963. if (!$this->connected()) {
  964. $this->link = mysqli_connect($this->host, $this->user, $this->pass, $this->name);
  965. if (!$this->connected()){$this->error("Failed to connect to `{$this->host}`.`{$this->name}` using password [" . (empty($this->pass) ? "NO" : 'YES') . "]");}
  966. }
  967. return true;
  968. }
  969.  
  970. public function connected(){return @mysqli_ping($this->link) ? true : false;}
  971.  
  972. public function error($error)
  973. {
  974. print $error . chr(10);
  975. if ($this->doe == true){exit;}
  976. }
  977.  
  978. public function query($query = "")
  979. {
  980. if (!is_string($query)){return false;}
  981. $this->__construct();
  982. $return = @mysqli_query($this->link, $query);
  983. return $return ? $return : false;
  984. }
  985.  
  986. public function fetch_array($query, $return = array())
  987. {
  988. $this->__construct();
  989. if (!is_string($query) || !($res = $this->query($query))){return array();}
  990. while ($data = mysqli_fetch_assoc($res)) {$return[] = $data;}
  991. return !empty($return) ? $return : array();
  992. }
  993.  
  994. public function sanatize($data)
  995. {
  996. if(is_array($data)){return array_map(array($this,'sanatize'), $data);}
  997. if(function_exists("mb_convert_encoding")) {$data = @mb_convert_encoding($data, "UTF-8", 'auto');}
  998. return $this->link->real_escape_string($data);
  999. }
  1000. }
  1001. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement