Advertisement
Guest User

andybot or ktcbot

a guest
Aug 24th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.73 KB | None | 0 0
  1. <?php
  2. // THIS BOT WAS IN KTCC AND LIQ, IT IS NOW PHP FOR ANY IXAT WHO WANTS TO USE IT
  3. // KTommyBots was made by KTommy
  4. // This script was made by KTommy and recoded from KTCC to PHP by Andy, A (15) oatchats.
  5. set_time_limit(0);
  6. libxml_use_internal_errors(false);
  7. ini_set('display_errors', 'off');
  8. error_reporting(0);
  9. class ktommybots
  10. {
  11. public $ixatlink = "localhost";
  12. public $withoutaccess = "You are not a high enough rank to use this command, the minimum rank is Bot Owner.";
  13. public $radioinfo = 'stm5.painel.foxsolucoes.net:14702';
  14. public $users;
  15. public $logado;
  16. public $socket;
  17. public $chatID;
  18. public $botID;
  19. public $port;
  20. public $ip;
  21. public $k;
  22. public $filterWords;
  23. public $maxKicks = 4; //Number of kicks before ban
  24. public $members = array();
  25. public $spam = 5;
  26. public $bad = "";
  27. public function __construct()
  28. {
  29. $config = (object) array('db' => array(0 => 'localhost', 1 => 'root', 2 => 'KTommy2005', 3 => 'panel'));
  30. $this->mysql = new database($config->db[0], $config->db[1], $config->db[2], $config->db[3]);
  31. require_once "ixat5.php";
  32.  
  33. $this->config->donos = @(array) json_decode($this->config->donos);
  34.  
  35. $this->time = time();
  36. }
  37.  
  38. public function connect()
  39. {
  40. $this->getinfo();
  41. $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  42. $test = socket_connect($this->socket, $this->ip, "1204");
  43. echo "--> Connecting to {$this->ip}:{$this->port}...\n";
  44. if(!$test){
  45. die( "<-- Error to connection!\n" );
  46. }
  47. }
  48. public function disconnect()
  49. {
  50. if(isset($this->socket) && $this->socket == true)
  51. socket_close($this->socket);
  52. $this->socket = false;
  53. }
  54. function getinfo()
  55. {
  56. $curl = curl_init($this->ixatlink.'/mobile?'.time());
  57. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  58. curl_setopt($curl, CURLOPT_POST, true);
  59. curl_setopt($curl, CURLOPT_POSTFIELDS, "username={$this->config->username}&password={$this->config->password}&room={$this->config->room}");
  60. $url = curl_exec($curl);
  61. $parte1 = explode("\"id\":\"", $url);
  62. $id = explode("\"", $parte1[1]);
  63. $this->botID = $id[0];
  64. $parte2 = explode("\"k\":\"", $url);
  65. $k = explode("\"", $parte2[1]);
  66. $this->k = $k[0];
  67. $k3_data = explode("\"k3\":\"", $url);
  68. $k3 = explode("\"", $k3_data[1]);
  69. $this->k3 = $k3[0];
  70. $sala_data = explode('c="', $url);
  71. $salaID = explode('"', $sala_data[1]);
  72. $this->chatID = $salaID[0];
  73. $parte4 = explode("WebSocket('ws://", $url);
  74. $ip = explode(":", $parte4[1]);
  75. $this->ip = $ip[0];
  76. $dx_data = explode("\"xats\":\"", $url);
  77. $dx = explode("\"", $dx_data[1]);
  78. $this->dx = $dx[0];
  79. $d1_data = explode("\"days\":\"", $url);
  80. $d1 = explode("\"", $d1_data[1]);
  81. $this->d1 = $d1[0];
  82. $tesa = explode("var mypowers = JSON.parse('", $url);
  83. $tesa_1 = explode("');", $tesa[1]);
  84. $this->mypowers = json_decode($tesa_1[0], true);
  85. $parte5 = explode($this->ip.':', $url);
  86. $port = explode("/", $parte5[1]);
  87. $this->port = $port[0];
  88. if(empty($url)){
  89. die( "<-- Connection failed, or the website could be closed!!\n");
  90. }
  91. if(empty($this->botID)){
  92. die( "<-- The chat doesn't exist, or the data is incorrect!\n");
  93. }
  94. }
  95. public function passXML($xml, $return = null)
  96. {
  97. $content = @simplexml_load_string(trim($xml));
  98. foreach($content->Attributes() as $i => $u)
  99. $return[$i] = (string) ((string) $u);
  100. return $return;
  101. }
  102. public function send($packet)
  103. {
  104. if($packet[strlen($packet) - 1] != chr(0))
  105. $packet .= chr(0);
  106. echo "[BOT]-> {$packet}\n";
  107. return socket_write($this->socket, $packet, strlen($packet));
  108. }
  109. public function LatestPow($name){
  110. //Codded By ktommybots
  111. $Powers = @file_get_contents('http://'.$this->ixatlink.'/json/powers.php');
  112. $lastpow = reset(json_decode($Powers, true));
  113. $pow2 = @file_get_contents('http://'.$this->ixatlink.'/web_gear/chat/pow2.php');
  114. $lpow2 = json_decode($pow2, true);
  115. $PowName = array_search($lpow2['0']['1']['id'], $lpow2['6']['1']);
  116. $PowId = $lpow2['0']['1']['id'];
  117. $Price = $lastpow["x"] . PHP_EOL;
  118. $Status = ($lpow2[0][1]['text'] == '[LIMITED]') ? 'LIMITED':'UNLIMITED';
  119. $value = array("{lpname}","{lpid}","{lpprice}","{lptype}");
  120. $replace = array(ucfirst($PowName), $PowId, $Price, $Status);
  121. return str_replace($value, $replace, $name);
  122. }
  123. public function enter()
  124. {
  125. $this->connect();
  126. $this->send("<y r=\"{$this->chatID}\" v=\"0\" u=\"{$this->config->botid}\" />");
  127. $x = $this->passXML(socket_read($this->socket, $this->port));
  128. $bot2 = floor(pow(2, $x['ys'] % 27));
  129. $bot1 = floor(2 << ($x['yi'] % 94)) % $x['yc'] + $x['yi'];
  130. $j2 = "cb=\"0\" ";
  131. $j2 .= "auth1=\"{$bot1}\" ";
  132. $j2 .= "auth2=\"{$bot2}\" ";
  133. $j2 .= "y=\"{$x["yi"]}\" ";
  134. $j2 .= "k=\"{$this->k}\" ";
  135. $j2 .= "k3=\"{$this->k3}\" ";
  136. $j2 .= "d1=\"{$this->d1}\" ";
  137. $j2 .= "p=\"0\" ";
  138. $j2 .= "c=\"{$this->chatID}\" ";
  139. $j2 .= "f=\"{$this->config->botpawn}\" ";
  140. $j2 .= "u=\"{$this->config->botid}\" ";
  141. $j2 .= "d0=\"0\" ";
  142. foreach($this->mypowers as $i => $u){
  143. $j2 .= "d".substr($i, 1)."=\"{$u}\" ";
  144. }
  145. $j2 .= "dO=\"\" ";
  146. $j2 .= "dx=\"{$this->dx}\" ";
  147. $j2 .= "N=\"{$this->config->username}\" ";
  148. $j2 .= "n=\"{$this->LatestPow($this->config->name)}(glow#{$this->config->glow})(hat#{$this->config->hat})(text#{$this->config->tglow})##{$this->LatestPow($this->config->sta)}#{$this->config->sta2}\" ";
  149. $j2 .= "a=\"{$this->LatestPow($this->config->avatar)}#{$this->config->pcback}\" ";
  150. $j2 .= "h=\"{$this->config->homepage}\" ";
  151. $j2 .= "v=\"5\"";
  152. $j2 = "<j2 {$j2} />";
  153. $this->send($j2);
  154. }
  155. public function load($check = true, $test_var = true)
  156. {
  157. $x = "";
  158. try {
  159. $x = rtrim(socket_read($this->socket, 2048));
  160. $x = str_replace("", "", $x);
  161. }
  162. catch(Exception $e){
  163. return "OFF";
  164. }
  165. if(!$x)
  166. return "OFF";
  167. if($x[strlen($x) - 1] != ">")
  168. $x .= $this->load(true);
  169. if($check)
  170. $this->packets($x, $test_var);
  171. return $x;
  172. }
  173. public function packets($packet, $test = true, $test2 = false)
  174. {
  175. if(substr_count($packet, ">") > 1){
  176. $packet = explode("/>", $packet);
  177. $test2 = true;
  178. }
  179. foreach((array) $packet as $p ){
  180. if($test2)
  181. $p .= "/>";
  182. $p = trim($p);
  183. if(strlen($p) < 5)
  184. return;
  185.  
  186. $type = trim(strtolower(substr($p, 1, strpos($p." ", " "))));
  187. $p = trim(str_replace("<".$type, "", str_replace("/>", "", $p)));
  188. $p = str_replace("\"", "", str_replace("\" ", "&", str_replace("&", "__38", $p)));
  189. parse_str($p, $this->packet[$type]);
  190. foreach($this->packet[$type] as $x => $v)
  191. $this->packet[$type][$x] = str_replace("__38", "&", str_replace("pl_", "+", $v));
  192. if($test)
  193. $this->type($type, $this->packet[$type]);
  194. }
  195. }
  196. public function type($type, $packet)
  197. {
  198. switch($type){
  199. case 'u':
  200. $u = $this->fetchUser($packet['u']);
  201. $this->users[$this->parseU($packet['u'])] = $packet;
  202. $this->users[$packet['u']]['cb'] = @$packet['cb'];
  203. $this->users[$packet['u']]['s'] = @$packet['s'];
  204. $this->users[$packet['u']]['f'] = (isset($packet['f'])) ? (int)$packet['f']: 0;
  205. $this->users[$packet['u']]['id'] = $packet['u'];
  206. $this->users[$packet['u']]['d0'] = (isset($packet['d0'])) ? (int)$packet['d0']: 0;
  207. $this->users[$packet['u']]['d2'] = (isset($packet['d2'])) ? @$packet['d2']: 0;
  208. $this->users[$packet['u']]['q'] = (isset($packet['q'])) ? (int)$packet['q']: 0;
  209. $this->users[$packet['u']]['registered'] = ((key_exists('N', $packet)) ? $packet['N']: 'Unregistered');
  210. $this->users[$packet['u']]['name'] = @$packet['n'];
  211. $this->users[$packet['u']]['avatar'] = (isset($packet['a'])) ? @$packet['a']: 'No Avatar';
  212. $this->users[$packet['u']]['home'] = (isset($packet['h'])) ? @$packet['h']: 'No Homepage';
  213. $this->users[$packet['u']]['v'] = (@$packet['v']) ? @$packet['v']: 0;
  214. $this->users[$packet['u']]['bride'] = (isset($packet['d2'])) ? @$packet['d2']: 0;
  215. $this->users[$packet['u']]['rel'] = (@$packet['d0'] & 1) ? 1: 2;
  216. $this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1: 0;
  217. $user = ( $packet['N']) ? $packet['N']: $packet['u'];
  218. $avatar = ( $packet['a']) ? $packet['a']: $packet['a'];
  219. $casinha = ( $packet['h']) ? $packet['h']: $packet['h'];
  220. $userid = $packet['i'];
  221. $uid = $packet['u'];
  222. $user4 = ($this->users[$packet["u"]]["n"]) ? $this->users[$packet["u"]]["n"]: $this->users[$packet["u"]]["u"];
  223. $hat = explode("(hat#", $user4, 2);
  224. $hat2 = explode(")", $hat[1], 2);
  225. $glow = explode("(glow#", $user4, 2);
  226. $glow2 = explode(")", $glow[1], 2);
  227. $status = explode("##", $user4, 2);
  228.  
  229. if(!empty($this->config->autowelcome) && !isset($packet['s']))
  230. {
  231. $this->sendwelcome($this->config->autowelcome, $packet['u'], $packet['f'], $user);
  232. $this->mysql->query("INSERT INTO users(user, userid) SELECT '$user', $uid FROM DUAL WHERE NOT EXISTS(SELECT user FROM users WHERE user = '$user')");
  233. $this->mysql->query("UPDATE users SET status = '{$status[1]}', chat = '[".time().",\"{$this->config->room}\"]', home = '{$this->users[$packet['u']]['home']}', nick = '$user4', avatar = '$avatar', casinha = '$casinha' WHERE user = '$user'");
  234. }
  235.  
  236. if($packet['rank'] == 5)
  237. {
  238. if($this->config->automember == 1){
  239. $this->member($packet['u']);
  240. }
  241. }
  242. if($packet['rank'] == 3)
  243. {
  244. if($this->config->autoguest == 1){
  245. $this->guest($packet['u']);
  246. }
  247. }
  248. break;
  249. case "i":
  250. $info = explode(';=', $this->packet['i']['b']);
  251. $this->radioinfo = str_replace("http://", "", $info[4]);
  252. break;
  253. case "z":
  254. $this->sendmsg("{$this->config->ticklemsg}", "PM", $packet["u"]);
  255. break;
  256. case "m":
  257. case "p":
  258. if (substr($packet['t']) && ++$this->users[$packet['u']]['messages'] >= 1 && time() - $this->users[$packet['u']]['time'] < 1)
  259. {
  260. $this->kick("Flood");
  261. }
  262.  
  263. $caps = $packet['t'];
  264. if (ereg("^([A-Z]+)$", $caps[0]))
  265. {
  266. //$this->kick('Caps Lock', $packet['u']);
  267. }
  268.  
  269. if (preg_match('/(.)\1{' . ($this->spam - 1) . ',}/', strtolower($packet['t'])) != 0)
  270. {
  271. $this->kick('Spam Detectado', $packet['u']);
  272. }
  273.  
  274. $bad = explode(chr(10) , file_get_contents('bad.txt'));
  275. $bad = array_map('trim', $bad);
  276. foreach($bad as $word)
  277. {
  278. if (is_numeric(stripos($packet['t'], $word)))
  279. {
  280. $this->kick('Inappropriate Language (In Languages: English)');
  281. break;
  282. }
  283. }
  284. if (isset($packet["i"]) && $packet["i"] > 0) break;
  285. $msg = $message = explode(" ", $packet["t"]);
  286. unset($msg[0]);
  287. $msg = implode(" ", $msg);
  288. $user4 = ($this->users[$packet["u"]]["n"]) ? $this->users[$packet["u"]]["n"]: $this->users[$packet["u"]]["u"];
  289. foreach(unserialize($this->config->responses) as $i => $u)
  290. {
  291. if(($u[1] == True && strtolower($packet["t"]) == $i) || ($u[1] != True && is_numeric(stripos($packet["t"], $i))))
  292. {
  293. $response = str_replace(
  294. array("{nick}"),
  295. array($user4),
  296. $u[0]
  297. );
  298. $this->sendmsg($this->LatestPow($response));
  299. return True;
  300. }
  301. }
  302. if(isset($message[0]) && $message[0][0] != "!")
  303. break;
  304. $user = $this->users[$packet["u"]];
  305. $user2 = ($user["N"]) ? $user["N"]: $user["u"];
  306. $bot = $this->mysql->fetch_array("select * from `bots` where `id`=1;");
  307. switch(substr($message[0], 1)){
  308.  
  309. case "say":
  310. if(!in_array($packet['u'], $this->config->admins)){
  311. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  312. }
  313. $this->sendmsg("[$user2] : ".$msg);
  314. break;
  315. case "kiss":
  316. if(!in_array($packet['u'], $this->config->admins)){
  317. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  318. }
  319. $message = explode(' ', $mensagem[3], 3);
  320. switch($mensagem[1]){
  321. case "Bruna":
  322. $this->sendmsg('<a k="Bruna" p="' . $this->senha . '" m="'. $message[0] .'" />');
  323. break;
  324. case "Foda":
  325. $this->sendmsg('<a k="Foda" p="' . $this->senha . '" m="FODA-SE" />');
  326. break;
  327. case "Dig":
  328. $this->sendmsg('<a k="Digdin" p="' . $this->senha . '" m="SOU FODA" />');
  329. break;
  330. case "Susto":
  331. $this->sendmsg('<a k="Susto" p="' . $this->senha . '" m="OI" />');
  332. break;
  333. case "Shark":
  334. $this->sendmsg('<a k="Shark" p="' . $this->senha . '" m="KISS BOT" />');
  335. break;
  336. }
  337. break;
  338. case 'ban':
  339. if (!in_array($packet['u'], $this->config->admins)) {
  340. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  341. }
  342. $this->ban($message[2], $message[1], $message[3]);
  343. break;
  344.  
  345.  
  346. case "glow":
  347. if (!in_array($packet['u'], $this->config->admins)) {
  348. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  349. }
  350. $this->mysql->query("UPDATE bots SET glow='{$msg}' WHERE id={$this->config->id}");
  351. $this->config->glow = $msg;
  352. $this->sendmsg('Meu NameGlow Foi Alterado Para [(glow#' . $msg . ' )] ! ');
  353. $this->restart();
  354. break;
  355.  
  356. case "ktommybots":
  357. if (!in_array($packet['u'], $this->config->admins)) {
  358. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  359. }
  360. $this->mysql->query("UPDATE bots SET room='{$msg}' WHERE id={$this->config->id}");
  361. $this->config->room = $msg;
  362. $this->sendmsg('Eu fui mudado para o xat [' . $msg . '] ! ');
  363. $this->restart();
  364. break;
  365.  
  366.  
  367. case "nome":
  368. if (!in_array($packet['u'], $this->config->admins)) {
  369. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  370. }
  371. $this->mysql->query("UPDATE bots SET name='{$msg}' WHERE id={$this->config->id}");
  372. $this->config->name = $msg;
  373. $this->sendmsg('Meu Nome Foi Alterado Para [' . $msg . '] ! ');
  374. $this->restart();
  375. break;
  376. case "status":
  377. if (!in_array($packet['u'], $this->config->admins)) {
  378. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  379. }
  380. $this->mysql->query("UPDATE bots SET sta='{$msg}' WHERE id={$this->config->id}");
  381. $this->config->sta = $msg;
  382. $this->sendmsg('Meu Status Foi Alterado Para [' . $msg . '] ! ');
  383. $this->restart();
  384. break;
  385. case "statusglow":
  386. if (!in_array($packet['u'], $this->config->admins)) {
  387. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  388. }
  389. $this->mysql->query("UPDATE bots SET sta2='{$msg}' WHERE id={$this->config->id}");
  390. $this->config->sta2 = $msg;
  391. $this->sendmsg('Meu StatusGlow Foi Alterado Para [' . $msg . '] ! ');
  392. $this->restart();
  393. break;
  394. case "statuscolor":
  395. if (!in_array($packet['u'], $this->config->admins)) {
  396. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  397. }
  398. $this->mysql->query("UPDATE bots SET tglow='{$msg}' WHERE id={$this->config->id}");
  399. $this->config->tglow = $msg;
  400. $this->sendmsg('Meu StatusColor Foi Alterado Para [' . $msg . '] ! ');
  401. $this->restart();
  402. break;
  403. case "info":
  404. if (!in_array($packet['u'], $this->config->admins)) {
  405. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  406. }
  407. $this->sendmsg('Oldbots.com Criado por ktommybots');
  408.  
  409. break;
  410. case "welcome":
  411. if (!in_array($packet['u'], $this->config->admins)) {
  412. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  413. }
  414. $this->mysql->query("UPDATE bots SET autowelcome='{$msg}' WHERE id={$this->config->id}");
  415. $this->config->autowelcome = $msg;
  416. $this->sendmsg('Minha Mensagem Inicial Foi Alterado Para [' . $msg . '] ! ');
  417. $this->restart();
  418. break;
  419. case "casinha":
  420. if (!in_array($packet['u'], $this->config->admins)) {
  421. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  422. }
  423. $this->mysql->query("UPDATE bots SET homepage='{$msg}' WHERE id={$this->config->id}");
  424. $this->config->homepage = $msg;
  425. $this->sendmsg('Minha Casinha Foi Alterado Para [' . $msg . '] ! ');
  426. $this->restart();
  427. break;
  428. case "tickle":
  429. if (!in_array($packet['u'], $this->config->admins)) {
  430. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  431. }
  432. $this->mysql->query("UPDATE bots SET ticklemsg='{$msg}' WHERE id={$this->config->id}");
  433. $this->config->ticklemsg = $msg;
  434. $this->sendmsg('Meu TickleMsg Foi Alterado Para [' . $msg . '] ! ');
  435. $this->restart();
  436. break;
  437. case "avatar":
  438. if (!in_array($packet['u'], $this->config->admins)) {
  439. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  440. }
  441. $this->mysql->query("UPDATE bots SET avatar='{$msg}' WHERE id={$this->config->id}");
  442. $this->config->avatar = $msg;
  443. $this->sendmsg('Minha Imagem Foi Alterado Para [' . $msg . '] ! ');
  444. $this->restart();
  445. break;
  446. case "hat":
  447. if (!in_array($packet['u'], $this->config->admins)) {
  448. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  449. }
  450. $this->mysql->query("UPDATE bots SET hat='{$msg}' WHERE id={$this->config->id}");
  451. $this->config->hat = $msg;
  452. $this->sendmsg('Meu Hat Foi Alterado Para [(hat#' . $msg . ' )] ! ');
  453. $this->restart();
  454. break;
  455.  
  456. case "perg":
  457. case "8ball":
  458. if(!in_array($packet['u'], $this->config->admins)){
  459. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  460. }
  461. // !perg/!8ball [pergunta]
  462. $resposta = array(
  463. 'Talvez sim',
  464. 'Sim.',
  465. 'Nao.',
  466. 'Minhas fontes informou que nao.',
  467. 'Ah, sim e sim',
  468. 'Na verdade nao sei',
  469. 'Nao sei mas o Key Virou Gay \'-\'',
  470. 'Eu acho que nao',
  471. 'Muito bom',
  472. 'Definiu-se que sim.'
  473. );
  474. $resposta = $resposta[ array_rand( $resposta ) ];
  475. $message = array( );
  476. foreach ( $message as $k => $valus ) {
  477. $valus = strtoupper( $valus );
  478. array_push( $message, $values );
  479. } //$message as $k => $valus
  480. $this->sendmsg( '' . $resposta . $packet[ 'u' ] );
  481. break;
  482. case "testegay":
  483. if(!in_array($packet['u'], $this->config->admins)){
  484. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  485. }
  486. // !perg/!8ball [pergunta]
  487. $resposta = array(
  488. 'Ele é gay.',
  489. 'Ele é machao'
  490. );
  491. $resposta = $resposta[ array_rand( $resposta ) ];
  492. $message = array( );
  493. foreach ( $message as $k => $valus ) {
  494. $valus = strtoupper( $valus );
  495. array_push( $message, $values );
  496. } //$message as $k => $valus
  497. $this->sendmsg(" $resposta");
  498. break;
  499. case "online":
  500. if(!in_array($packet['u'], $this->config->admins)){
  501. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  502. }
  503. $this->sendmsg($user2 . '' . ' Existem ' . count($this->users) . ' Usuarios Online.');
  504. break;
  505. case "smileytest":
  506. if(!in_array($packet['u'], $this->config->admins)){
  507. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  508. }
  509. $user = $this->users[ $packet[ "u" ] ];
  510. $usuario = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  511. $this->sendmsg ('('.$msg.') ');
  512. break;
  513. case "sayadm":
  514. if(!in_array($packet['u'], $this->config->admins)){
  515. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  516. }
  517. $this->sendmsg(' '.$msg.'');
  518. break;
  519. case "restart":
  520. if(!in_array($packet["u"], $this->config->admins)){
  521. return $this->sendmsg($this->config->semcmd, "PM", $packet["u"]);
  522. }
  523. $this->sendmsg("[Servidor]: Estou sendo reiniciado (backoff)");
  524. $this->restart();
  525. break;
  526. case'modme':
  527. $message = explode(' ', $message[1], 1);
  528. $users = $message[0];
  529. if(!in_array($packet['u'], $this->config->admins)){
  530. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  531. }
  532. $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/m" />');
  533. break;
  534.  
  535. case 'dx':
  536. if(!in_array($packet['u'], $this->config->admins)){
  537. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  538. }
  539. $days = intval($message[1]);
  540. if($days < 1)
  541. return $this->sendPM($packet['u'], 'days must be 1 or more');
  542. $tradeValue = 13;
  543. $xats = floor($days * $tradeValue);
  544. $this->sendmsg($days.' days costa '.$xats.' xats cu 13 xats pe days');
  545. break;
  546. case "powers":
  547. $user = $this->users[$packet["u"]];
  548. $user2 = ($user["registered"]) ? $user["registered"]: $user["u"];
  549. $this->sendmsg('/!everypower '.$user2.'');
  550. break;
  551. case'ownerme':
  552. $message = explode(' ', $message[1], 1);
  553. $users = $message[0];
  554. if(!in_array($packet['u'], $this->config->admins)){
  555. return $this->sendmsg($this->config->semcmd, "PM", $packet['u']);
  556. }
  557. $this->send('<c p="voce que pediu ['.$this->users[$packet['u']]['registered'].'] " u="'.$packet['u'].'" t="/M" />');
  558. break;
  559.  
  560. case 'lastpower':
  561.  
  562. $url = @file_get_contents('http://xat.com/json/powers.php');
  563. if(empty($url)){$this->sendmsg('Falha ao obter o ultimo power, avise um administrador!'); return false;}
  564. $conteudo = json_decode($url, true);
  565. $ultimo_pw = reset($conteudo);
  566. $this->sendmsg('Ultimo Power Adicionado : ('.$ultimo_pw['s'].'#).');
  567. break;
  568. case 'radio':
  569. $connection = explode(':', $this->radioinfo);
  570. $url = fsockopen("stm5.painel.foxsolucoes.net", 14702);
  571. if (!$url)
  572. {
  573. $this->enviarmsg("Connection failed.");
  574. return false;
  575. }
  576. else
  577. {
  578. fputs($url, "GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
  579. $socket = fread($url, 1000);
  580. $return = explode(",", $socket);
  581. $final = str_replace("</body></html>", "", $return[6]);
  582. if (!$final)
  583. {
  584. $this->sendmsg("Musica Atual:");
  585. return false;
  586. }
  587. else $this->sendmsg("Musica Atual: {$final}");
  588. }
  589. break;
  590.  
  591. case'userinfo':
  592.  
  593. $message = explode(' ', $message[1], 1);
  594. $user = $message[0];
  595. if(!$this->users[$user]['id']){
  596. $this->sendmsg("I'm not a noob.");
  597. } else {
  598. if($this->users[$user]['rel'] == 2) $this->users[$user]['rel'] = "Married";
  599. if($this->users[$user]['rel'] == 1) $this->users[$user]['rel'] = "Bff'd";
  600. $myNick = explode("##", $this->users[$user]['name'], 2);
  601. $myNick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($myNick[0])));
  602. $relation = $this->users[$user]['rel'].' to '.$this->users[$user]['d2'];
  603. if($relation == 'Married to 0') $relation = 'Relation not found.';
  604. $name = explode('##', $this->users[$user]['name']);
  605. $n = $name[1];
  606.  
  607. $this->sendmsg('Nome : '.$myNick[0].' | Status : '.str_replace('#',' | ',$n).'| Avatar : '.$this->users[$user]['avatar'].' | Casinha : '.$this->users[$user]['home'].' | Relacao : '.$relation);
  608. }
  609. break;
  610. case "desligar":
  611. case "off":
  612. if(!in_array($packet["u"], $this->config->donos)){
  613. return $this->sendmsg($this->config->semcmd, "PM", $packet["u"]);
  614. }
  615. $this->sendmsg("{$this->config->desligar}");
  616. die();
  617. break;
  618.  
  619.  
  620.  
  621.  
  622.  
  623. }
  624. }
  625. }
  626. function parseU($id){
  627. if(substr_count($id,'_')>=1) $id = substr($id,0,strpos($id,'_'));
  628. return $id;
  629. }
  630. public function restart()
  631. {
  632. require_once "ls.php";
  633. $this->disconnect();
  634. $this->enter();
  635. }
  636. function fetchUser($id)
  637. {
  638. $id = $this->parseU($id);
  639. if (isset($this->users[$id])) return $this->users[$id];
  640. else return false;
  641. }
  642.  
  643. function kick($message, $id, $log = true)
  644. {
  645. if ($log)
  646. {
  647. if (!empty($this->users[$id]['kicks'])) $this->users[$id]['kicks']++;
  648. else $this->users[$id]['kicks'] = 1;
  649. }
  650. if ($this->users[$id]['kicks'] > $this->maxKicks)
  651. {
  652. $this->ban($message, $id, 3600);
  653. $this->users[$id]['kicks'] = 0;
  654. return;
  655. }
  656. $this->send('<c p="' . $message . " " . $this->users[$id]['kicks'] . '/' . $this->maxKicks . '" u="' . $id . '" t="/k" />');
  657. }
  658. public function ir2Rank($r)
  659. {
  660. switch($r)
  661. {
  662. case 1: return 'main'; break;
  663. case 2: return 'mod'; break;
  664. case 3: return 'member'; break;
  665. case 4: return 'owner'; break;
  666. }
  667. }
  668. function fetchID($id) {
  669. //Only searches users of the local chat room.
  670. if(!is_numeric($id)) {
  671. foreach($this->users as $u) {
  672. if(strtoupper($u['N']) == strtoupper($id)) {
  673. $rid = $u['u'];
  674. }
  675. }
  676. } else {
  677. foreach($this->users as $u) {
  678. if($u['u'] == $id) {
  679. $rid = $u['u'];
  680. } else {
  681. $rid = $id;
  682. }
  683. }
  684. }
  685. $rid = (is_numeric(@$rid)) ? $rid : false;
  686. return $rid;
  687. }
  688. function ban($message, $id, $time)
  689. {
  690. $this->send('<c p="' . ereg_replace('[^A-Za-z0-9.! ]', '', $message) . '" u="' . $id . '" t="/g' . $time . '" />');
  691. }
  692.  
  693. function member($id,$time=null){
  694. if(!$time) $time = 0;
  695. $id = $this->parseU($id);
  696. $this->sendC($id, '/e',$time);
  697. }
  698. function guest($id,$time=null) {
  699. if(!$time) $time = 0;
  700. $id = $this->parseU($id);
  701. $this->sendC($id, '/r',$time);
  702. }
  703. public function sendC($id=0, $com='') {
  704. $this->send('<c u="'.$id.'" t="'.$com.'" />');
  705. }
  706. public function censor($message) {
  707. $badwords = $this->censor;
  708. $message = @preg_replace('#\((.+)\)#U','',strtolower(' '.$message.' '));
  709. foreach($badwords as $bad) {
  710. $bad = trim($bad);
  711. if(strpos($message.' ', $bad.' ')!==false) {
  712. if(strlen($bad)>=2) {
  713. return true;
  714. }
  715. }
  716. }
  717. }
  718. function sendwelcome($message, $id, $f, $nome)
  719. {
  720. if(!$message)
  721. {
  722. return false;
  723. }
  724. $message = str_replace('[chat]', $this->config->room, $message);
  725. $message = str_replace('[online]', count($this->users), $message);
  726. $message = str_replace('[user]', $nome, $message);
  727. $this->sendmsg($message, 'PM', $id);
  728. }
  729. function sendmsg($message, $type = "MSG", $id = 0)
  730. {
  731. if(!$message){
  732. return false;
  733. }
  734. switch($type) {
  735. case "MSG":
  736. $this->send("<m t=\"{$message}\" u=\"{$this->botID}\" />");
  737. break;
  738. case "PM":
  739. $this->send("<p u=\"{$id}\" t=\"{$message}\" d=\"{$id}\" />");
  740. break;
  741. case "PC":
  742. $this->send("<z d=\"{$id}\" u=\"{$this->botID}\" t=\"{$message}\" />");
  743. break;
  744. }
  745. }
  746. }
  747. $bot = new ktommybots();
  748. while(1){
  749. try{
  750. if($bot->load() == "OFF"){
  751. $bot->disconnect();
  752. $bot->enter();
  753. }
  754. }
  755. catch(Exception $e){
  756. die($e);
  757. }
  758. }
  759. class database {
  760. public $link, $host, $user, $pass, $name;
  761. public $doe = true;
  762. public function __construct($host = null, $user = null, $pass = null, $name = null)
  763. {
  764. if ($name != null) {
  765. $this->host = $host;
  766. $this->user = $user;
  767. $this->pass = $pass;
  768. $this->name = $name;
  769. }
  770. if (!$this->connected()) {
  771. $this->link = mysqli_connect($this->host, $this->user, $this->pass, $this->name);
  772. if (!$this->connected()){$this->error("Failed to connect to `{$this->host}`.`{$this->name}` using password [" . (empty($this->pass) ? "NO" : 'YES') . "]");}
  773. }
  774. return true;
  775. }
  776. public function connected(){return @mysqli_ping($this->link) ? true : false;}
  777. public function error($error)
  778. {
  779. print $error . chr(10);
  780. if ($this->doe == true){exit;}
  781. }
  782. public function query($query = "")
  783. {
  784. if (!is_string($query)){return false;}
  785. $this->__construct();
  786. $return = @mysqli_query($this->link, $query);
  787. return $return ? $return : false;
  788. }
  789. public function fetch_array($query, $return = array())
  790. {
  791. $this->__construct();
  792. if (!is_string($query) || !($res = $this->query($query))){return array();}
  793. while ($data = mysqli_fetch_assoc($res)) {$return[] = $data;}
  794. return !empty($return) ? $return : array();
  795. }
  796. public function sanatize($data)
  797. {
  798. if(is_array($data)){return array_map(array($this,'sanatize'), $data);}
  799. if(function_exists("mb_convert_encoding")) {$data = @mb_convert_encoding($data, "UTF-8", 'auto');}
  800. return $this->link->real_escape_string($data);
  801. }
  802. }
  803. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement