Guest User

Untitled

a guest
Mar 26th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 72.15 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set("display_errors", "on");
  5. set_time_limit(0);
  6. date_default_timezone_set('Europe/Warsaw');
  7. gc_enable();
  8. $start = time();
  9. if(!isset($argv[1]) || !is_numeric($argv[1]))
  10. {
  11. exit();
  12. }
  13. while(true)
  14. {
  15. $core = null;
  16. $core = new bot($argv, $start);
  17. do
  18. {
  19. gc_collect_cycles();
  20. } while($core->listen() !== false);
  21. foreach($core as $i => $u)
  22. {
  23. unset($core->{$i}, $i, $u);
  24. }
  25. }
  26.  
  27. class bot
  28. {
  29. public $root, $class, $socket, $xatC, $login, $j2, $e = array();
  30. public $fh = false;
  31. public $sock = array();
  32. public $pools = array();
  33. public $noload = array();
  34. public $commands = array();
  35. public $users = array();
  36. public $loaded = array();
  37. public $ipc = array();
  38. public $kicks = array();
  39. public $special_bot = false;
  40. public $Ranks = array(
  41. "faggots" => -1000000000000,
  42. "banned" => -1,
  43. "guest" => 0,
  44. "member" => 1,
  45. "moderator" => 2,
  46. "owner" => 3,
  47. "mainowner" => 4,
  48. "trusted" => 5,
  49. "botowner" => 6,
  50. "support" => 7,
  51. "admin" => 8
  52. );
  53.  
  54.  
  55. public function __construct($argv, $start)
  56. {
  57. $dd = "Lobby";
  58. $GLOBALS["core"] = &$this;
  59. list($this->debug, $this->botID) = array(isset($argv[2]) ? true : false, $argv[1]);
  60. list($this->ds, $this->root, $this->class, $this->lib) = array(
  61. DIRECTORY_SEPARATOR,
  62. __DIR__ . DIRECTORY_SEPARATOR,
  63. __DIR__ . DIRECTORY_SEPARATOR . "_class" . DIRECTORY_SEPARATOR,
  64. __DIR__ . DIRECTORY_SEPARATOR . "_lib" . DIRECTORY_SEPARATOR
  65. );
  66. $this->load("functions");
  67. $this->load("powers");
  68. $this->load("userClass");
  69. $this->mysql = new Database("localhost", "neobots", "fPt9r05$", "admin_andbots"); // phpMyAdmin
  70. if($argv[1] == 1)
  71. {
  72. $this->mysql->debug = true;
  73. }
  74. /* Load the bot info */
  75. $bot = $this->mysql->fetch_array("select * from `bots` where `ID`={$argv[1]};");
  76. $user = $this->mysql->fetch_array("select `id`, `subscription` from `users` where `botid`={$this->botID};");
  77. if(empty($bot) || empty($user))
  78. {
  79. exit;
  80. }
  81. $this->mysql->query("update `bots` set `pid`=" . getmypid() . " where `ID`={$this->botID};");
  82. list($this->userID, $bot) = array($user[0]['id'], $bot[0]);
  83. /* Set user information */
  84. $this->info = (object) array(
  85. 'cmd_char' => $bot['comchar'],
  86. 'user' => (object) array(
  87. 'id' => 0,
  88. 'user' => $bot['botUser'],
  89. 'pass' => base64_decode($bot['botPass']),
  90. 'nick' => $bot['nick'],
  91. 'avatar' => $bot['avatar'],
  92. 'home' => $bot['home'],
  93. 'status' => $bot['status'],
  94. 'statusglow' => $bot['statusglow'],
  95. 'statuscolor' => $bot['statuscolor'],
  96. 'statusgrad' => $bot['statusgrad'],
  97. 'namecolor' => $bot['namecolor'],
  98. 'nameglow' => $bot['nameglow'],
  99. 'namegrad' => $bot['namegrad'],
  100. 'textglow' => $bot['textglow'],
  101. 'textcolor' => $bot['textcolor'],
  102. 'hat' => $bot['hat'],
  103. 'hatcolor' => $bot['hatcolor'],
  104. 'pcback' => $bot['pcback'],
  105. 'stealth' => false
  106. ),
  107. 'owner' => $bot['ownerID'],
  108. 'language' => $bot['lang'],
  109. 'autowelcome' => $bot['autowelcome'],
  110. 'automember' => $bot['automember'],
  111. 'room' => $bot['room'],
  112. 'responses' => @(array) unserialize($bot['responses'] == '' ? 'a:0:{}' : $bot['responses']),
  113. 'minrank' => @(array) unserialize($bot['minrank'] == '' ? 'a:0:{}' : $bot['minrank']),
  114. 'alias' => @(array) unserialize($bot['alias'] == '' ? 'a:0:{}' : $bot['alias']),
  115. 'mod' => $bot['mod'],
  116. 'mod_max_consecutive' => $bot['mod_max_consec'],
  117. 'mod_flood' => unserialize($bot['mod_flood']),
  118. 'mod_max_kicks' => $bot['mod_max_kicks'],
  119. 'mod_max_caps' => $bot['maxCaps'],
  120. 'detectLink' => $bot['linkDetect'],
  121. 'detectCaps' => $bot['capsDetect'],
  122. 'detectInapp' => $bot['inappDetect'],
  123. 'banTime' => $bot['banTime'],
  124. 'dice' => $bot['dice'],
  125. 'start' => $start,
  126. 'sub' => $user[0]['subscription'],
  127. 'private_commands' => true,
  128. 'stfu' => $bot['stfu'] == '1' ? true : false,
  129. /* Disabled Powers ( Disable invisible by default ) */
  130. 'dpowers' => @(array) unserialize($bot['dpowers'] == '' ? 'a:1:{i:0;s:2:"29";}' : $bot['dpowers'])
  131. );
  132. /* If special chat, give unlimited time */
  133. $file = file_get_contents($this->lib . "special_chats.txt");
  134. preg_match_all("/http:\/\/polskixat\.pl\/([^\/\"]*)\"/", $file, $chats);
  135. $chats = array_map('strtolower', $chats[1]);
  136. if(in_array(strtolower($bot['room']), $chats))
  137. {
  138. $this->special_bot = true;
  139. $this->mysql->query("update `bots` set `type`=1 where `id`={$this->botID};");
  140. }
  141. unset($file);
  142. $this->mysql->query("update `bots` set `uptime`={$start} where `id`={$this->botID};");
  143. $this->info->badwords = explode(chr(10), file_get_contents($this->lib . 'badwords.txt'));
  144. $this->info->badwords = array_map('trim', $this->info->badwords);
  145. /* Parse teh nickname info */
  146. $this->info->user->nick = explode("##", $this->info->user->nick, 2);
  147. $this->info->user->nick = $this->info->user->nick[0];
  148. $this->info->abl = @(array) unserialize($bot['abl'] == "" ? "a:0:{}" : $bot['abl']);
  149. $this->info->snitch = @(array) unserialize($bot['snitch'] == "" ? "a:0:{}" : $bot['snitch']);
  150. $this->info->user->stealth = substr($this->info->user->nick, 0, 1) == '$' ? true : false;
  151. if($this->info->user->stealth == true)
  152. {
  153. $this->info->user->nick = substr($this->info->user->nick, 1);
  154. }
  155. /* End */
  156. $this->ranks = @(array) unserialize($bot["ranks"] == "" ? "a:0:{}" : $bot["ranks"]);
  157. $this->ranks[$this->info->owner] = 6;
  158. unset($this->ranks[1]);
  159. $forcerank = $this->mysql->fetch_array("select `admins`, `support` from `config` limit 0, 1;");
  160. foreach(explode('|', implode('|', $forcerank[0])) as $u)
  161. {
  162. if(!empty($u))
  163. {
  164. $rank = explode(',', $u);
  165. $this->ranks[$rank[0]] = $rank[1];
  166. if($rank[1] != 8)
  167. {
  168. $this->support[] = $rank[0];
  169. }
  170. }
  171. }
  172. /* Configure Room Info */
  173. if(empty($this->info->room))
  174. {
  175. if($this->info->language == 'en')
  176. $this->error("Your need to setup chat link, neo-bots.tk.pl/panel");
  177. if($this->info->language == 'pl')
  178. $this->error("Musisz skonfigurować link bota, neo-bots.tk.pl/panel");
  179. if($this->info->language == 'pt')
  180. $this->error("Você precisa configurar o link do chat, neo-bots.tk.pl/panel");
  181. if($this->info->language == 'es')
  182. $this->error("Es necesario configurar el enlace de chat, neo-bots.tk.pl/panel");
  183. }
  184. do
  185. {
  186. if($bot["_room"] != "")
  187. {
  188. $this->info->room = json_decode($bot["_room"]);
  189. if(time() - $this->info->room->last_update < 86400 && strtolower($bot["room"]) == strtolower($this->info->room->name))
  190. {
  191. break;
  192. }
  193. }
  194. $this->info->room = $this->parseRoom($bot["room"]);
  195. if(!is_object($this->info->room))
  196. {
  197. if($this->info->language == 'en')
  198. $this->error("The chat you provided doesn't exist.");
  199. if($this->info->language == 'pl')
  200. $this->error("Czat który dodajesz nie istnieje.");
  201. if($this->info->language == 'pt')
  202. $this->error("O chat que você adicionou não existe.");
  203. if($this->info->language == 'es')
  204. $this->error("El chat que agregó no existe.");
  205.  
  206. }
  207. if($bot["chatpass"] != "")
  208. {
  209. $this->info->room->pass = $bot["chatpass"];
  210. }
  211. $this->info->room->last_update = time();
  212. $this->mysql->query("update `bots` set `_room`=:a where `ID`={$this->botID};", array("a" => json_encode($this->info->room)));
  213. } while(false);
  214. /* End */
  215. $this->autokick = @(array) unserialize($bot["autokick"] == "" ? "a:0:{}" : $bot["autokick"]);
  216. $this->load("commands");
  217. $this->load("responses", $bot);
  218. /* Join room */
  219. $i = 1;
  220. while(!$this->joinRoom(null, $i--));
  221. /* Cause we love to save memory even though variables are unset when a function returns */
  222. unset($bot, $forcerank, $u, $rank);
  223. }
  224. public function playing($ip, $port)
  225. {
  226. $open = @fsockopen($ip, $port, $errno, $errstr, 1);
  227. if($open) {
  228. fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
  229. $read = fread($open, 200);
  230. $text = preg_split('/^((?:[^,]+,){5}[^,]+),/', $this->split($read, '<body>', '</body>'));
  231. return implode('', $text);
  232. }
  233. return false;
  234. fclose($open);
  235. }
  236. public function load($what, $extras = null)
  237. {
  238. if(array_key_exists($what, $this->loaded))
  239. {
  240. return false;
  241. } else {
  242. $this->loaded[$what] = true;
  243. }
  244. switch($what)
  245. {
  246. case "responses":
  247. require_once $this->class . "responses.php";
  248. $this->response = new response($this, $extras["_responses_"]);
  249. return true;
  250.  
  251. case "functions":
  252. require_once $this->class . "pdo.php";
  253. require_once $this->class . "function.php";
  254. $this->function = new functions($this);
  255. return true;
  256.  
  257. case "commands":
  258. $commands = glob($this->root . "commands{$this->ds}*.php");
  259. foreach($commands as $cmd)
  260. {
  261. list($name, $alias) = array(substr($cmd, strrpos($cmd, $this->ds) + 1, -4), array());
  262. if(!in_array(strtolower($name), $this->noload))
  263. {
  264. if(array_key_exists($name, $this->commands))
  265. {
  266. continue;
  267. }
  268. include $cmd;
  269. $alias = array_merge(array_key_exists($name, $this->info->alias) ? $this->info->alias[$name] : array(), $alias);
  270. foreach($alias as $u)
  271. {
  272. $this->commands[strtolower($u)] = &$this->commands[$name];
  273. $this->alias[strtolower($u)] = $name;
  274. }
  275. }
  276. }
  277. unset($commands, $cmd, $name, $this->noload, $alias, $u);
  278. return true;
  279.  
  280. case "powers":
  281. $this->function->getPowers();
  282. return true;
  283.  
  284. case "userClass":
  285. require_once $this->class . "user.php";
  286. return true;
  287.  
  288. default: return false;
  289. }
  290. }
  291.  
  292. public function update($what)
  293. {
  294. $query = "update `bots` set `%s`=:a where `ID`={$this->botID};";
  295. switch($what)
  296. {
  297. case "ranks":
  298. $this->mysql->query(sprintf($query, 'ranks'), array('a' => serialize($this->ranks)));
  299. return true;
  300.  
  301. case "nick":
  302. $nick = ($this->info->user->stealth ? '$' : '') . $this->info->user->nick . '##' . $this->info->user->status;
  303. $this->mysql->query(sprintf($query, 'nick'), array('a' => $nick));
  304. return true;
  305.  
  306. case "status":
  307. $this->mysql->query(sprintf($query, 'status'), array('a' => $this->info->user->status));
  308. return true;
  309.  
  310. case "statusglow":
  311. $this->mysql->query(sprintf($query, 'statusglow'), array('a' => $this->info->user->statusglow));
  312. return true;
  313.  
  314. case "statuscolor":
  315. $this->mysql->query(sprintf($query, 'statuscolor'), array('a' => $this->info->user->statuscolor));
  316. return true;
  317.  
  318. case "nameglow":
  319. $this->mysql->query(sprintf($query, 'nameglow'), array('a' => $this->info->user->nameglow));
  320. return true;
  321.  
  322. case "namecolor":
  323. $this->mysql->query(sprintf($query, 'namecolor'), array('a' => $this->info->user->namecolor));
  324. return true;
  325.  
  326. case "hat":
  327. $this->mysql->query(sprintf($query, 'hat'), array('a' => $this->info->user->hat));
  328. return true;
  329.  
  330. case "hatcolor":
  331. $this->mysql->query(sprintf($query, 'hatcolor'), array('a' => $this->info->user->hatcolor));
  332. return true;
  333.  
  334. case "pcback":
  335. $this->mysql->query(sprintf($query, 'pcback'), array('a' => $this->info->user->pcback));
  336. return true;
  337.  
  338. case "avatar":
  339. $this->mysql->query(sprintf($query, 'avatar'), array('a' => $this->info->user->avatar));
  340. return true;
  341.  
  342. case "home":
  343. $this->mysql->query(sprintf($query, 'home'), array('a' => $this->info->user->home));
  344. return true;
  345.  
  346. case "autowelcome":
  347. $this->mysql->query(sprintf($query, 'autowelcome'), array('a' => $this->info->autowelcome));
  348. return true;
  349.  
  350. case "automember":
  351. $this->mysql->query(sprintf($query, 'automember'), array('a' => $this->info->automember));
  352. return true;
  353.  
  354. case "responses":
  355. $this->mysql->query(sprintf($query, 'responses'), array('a' => serialize($this->info->responses)));
  356. return true;
  357.  
  358. case "disabled_powers":
  359. $this->mysql->query(sprintf($query, 'dpowers'), array('a' => serialize($this->info->dpowers)));
  360. return true;
  361. }
  362. }
  363.  
  364. /* public function login($force = false)
  365. {
  366. if(!empty($this->login) && !$force)
  367. {
  368. return true;
  369. }
  370. $ports = array(10000, 10001, 10004);
  371. $this->connect(8, $ports[rand(0, 2)]);
  372. $this->write(0, "<v p=\"{$this->function->sanatize($this->info->user->pass)}\" n=\"{$this->function->sanatize($this->info->user->user)}\" />");
  373. $login_array = $this->xmlArray($this->listen(true));
  374. $login_array['cb'] = time();
  375. $this->login = (object) $login_array;
  376. if(property_exists($this->login, 'i') == false || !isset($this->login->n))
  377. {
  378. if(isset($this->login->e))
  379. {
  380. switch((string) $this->login->e)
  381. {
  382. case "E6": $this->error("Bad credentials were provided, did you change them after you setup the bot account in your panel?");
  383. case "F13": $this->forcedom = true; unset($this->login); return false;
  384. case "E21": $this->error("Xat isn't letting us login to your bot account. (Try again in a few seconds)");
  385. case "E37": $this->error("Locking or Protection seems to be enabled on your bot's xat account, please disable them both, or use our bot account.");
  386. }
  387. }
  388. if($this->info->language == 'en')
  389. $this->error("We couldn't login to your bot account [{$this->info->user->user}]");
  390. if($this->info->language == 'pt')
  391. $this->error("Falha ao conectar sua conta [{$this->info->user->user}]");
  392. if($this->info->language == 'es')
  393. $this->error("No hemos podido bot entra a tu cuenta [{$this->info->user->user}]");
  394. }
  395. if($this->info->room->bot != $this->login->i)
  396. {
  397. if($this->info->language == 'en')
  398. $this->error("It would seem bot power was configured incorrectly, you must set the ID to {$this->login->i}");
  399. if($this->info->language == 'pt')
  400. $this->error("Você não configurou a id do bot no chat, configure usando a id {$this->login->i}");
  401. if($this->info->language == 'es')
  402. $this->error("Usted no ha configurado la ID de la bot de chat, configurar el uso de la ID {$this->login->i}");
  403. }
  404. $this->info->user->id = $this->login->i;
  405. $this->info->user->user = $this->login->n;
  406. $this->info->user->bank = (object) array(
  407. "xats" => isset($this->login->dx) ? $this->login->dx : 0,
  408. "days" => @floor(($this->login->d1 - time()) / 60 / 60 / 24)
  409. );
  410. if($this->info->user->bank->days < 1)
  411. {
  412. $this->info->user->bank->days = 0;
  413. }
  414. //Get Bot Powers
  415. $this->info->powers = array();
  416. foreach($this->powers as $power)
  417. {
  418. $sect = isset($this->login->{'d' . ($power['section'] + 4)}) ? $this->login->{'d' . ($power['section'] + 4)} : false;
  419. if($sect & $power['subid'])
  420. {
  421. array_push($this->info->powers, strtolower($power['name']));
  422. }
  423. }
  424. return true;
  425. }*/
  426.  
  427. public function joinRoom($orr = false, $fl = false)
  428. {
  429. $bot = $this->mysql->fetch_array("select * from `bots` where `ID`={$this->botID};");
  430.  
  431. if($fl != false)
  432. {
  433. return false;
  434. }
  435. $curl = curl_init('http://neoxat.tk/mobile?'.time());
  436. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  437. curl_setopt($curl, CURLOPT_POST, true);
  438. curl_setopt($curl, CURLOPT_POSTFIELDS, "username=NXBot&password=kamisama&room={$bot[0]['room']}");
  439. $url = curl_exec($curl);
  440. $parte1 = explode("\"id\":\"", $url);
  441. $id = explode("\"", $parte1[1]);
  442. $this_botID = $id[0];
  443. $parte2 = explode("\"k\":\"", $url);
  444. $k = explode("\"", $parte2[1]);
  445. $this_k = $k[0];
  446. $k3_data = explode("\"k3\":\"", $url);
  447. $k3 = explode("\"", $k3_data[1]);
  448. $this_k3 = $k3[0];
  449. $chat_data = explode('c="', $url);
  450. $chatID = explode('"', $chat_data[1]);
  451. $this_chatID = $chatID[0];
  452. $parte4 = explode("WebSocket('ws://", $url);
  453. $ip = explode(":", $parte4[1]);
  454. $this_ip = $ip[0];
  455. $dx_data = explode("\"xats\":\"", $url);
  456. $dx = explode("\"", $dx_data[1]);
  457. $this_dx = $dx[0];
  458. $d1_data = explode("\"days\":\"", $url);
  459. $d1 = explode("\"", $d1_data[1]);
  460. $this_d1 = $d1[0];
  461. $mypowers = explode("var mypowers = JSON.parse('", $url);
  462. $mypowers_data = explode("');", $mypowers[1]);
  463. $this_mypowers = json_decode($mypowers_data[0], true);
  464. $this->mysql->query("update `bots` set `powers`='" . json_encode($this_mypowers) . "' where `ID`={$this->botID};");
  465. $parte5 = explode($this_ip.':', $url);
  466. $port = explode("/", $parte5[1]);
  467. $this_port = $port[0];
  468. $this->connect($this->info->room->id);
  469. $hat = $this->info->user->hat == 'off' ? "" : "(hat#{$this->info->user->hat}#{$this->info->user->hatcolor})";
  470. if(empty($this->info->user->namegrad) || $this->info->user->namegrad == 'off'){
  471. $namec = $this->info->user->namecolor;
  472. }else{
  473. $namec = $this->info->user->namegrad;
  474. }
  475. if(empty($this->info->user->statusgrad) || $this->info->user->statusgrad == 'off'){
  476. $statusg = $this->info->user->statuscolor;
  477. }else{
  478. $statusg = $this->info->user->statusgrad;
  479. }
  480. $glow = $this->info->user->nameglow == '' ? "" : "(glow#{$this->info->user->nameglow}#{$namec})";
  481. $text = $this->info->user->textglow == '' ? "" : "(text#{$this->info->user->textglow}#{$this->info->user->textcolor})";
  482. $status = $this->info->user->status == '' ? "" : "##{$this->info->user->status}#{$this->info->user->statusglow}#{$statusg}";
  483.  
  484. $j2 = $this->function->build("j2", array(
  485. 'cb' => time(),
  486. 'q' => '1',
  487. 'y' => $this->y['yi'],
  488. 'k' => $this_k,
  489. "k3" => $this_k3,
  490. "d1" => $this_d1,
  491. 'c' => $this_chatID,
  492. 'r' => isset($this->info->room->pass) ? $this->info->room->pass : false,
  493. 'f' => '8192',
  494. 'u' => $this_botID,
  495. "disabled" => "", /* m{section}='0' */
  496. "d0" => isset($this->login->d0) ? $this->login->d0 : false,
  497. "powers" => "", /* p{section}='0' */
  498. "dO" => isset($this->login->dO) ? $this->login->dO : false,
  499. "dx" => isset($this->login->dx) ? $this->login->dx : false,
  500. "dt" => isset($this->login->dt) ? $this->login->dt : false,
  501. 'N' => $this->info->user->user,
  502. 'n' => ($this->info->user->stealth ? '$' : "") . str_replace(' ', ' ', $this->function->sanatize(($this->info->user->nick . $hat . $glow . $text . $status))),
  503. 'a' => $this->function->sanatize($this->info->user->avatar .'#'. $this->info->user->pcback),
  504. 'h' => $this->function->sanatize($this->info->user->home),
  505. 'v' => '0'
  506.  
  507. ));
  508. $powers = array(array(), array());
  509. /* Bot Powers */
  510. /*for($i = 2; $i <= $this->sections + 4; $i++)
  511. {
  512. if(isset($this->login->{"d{$i}"}))
  513. {
  514. $powers[0][] = "d{$i}=\"{$this->login->{"d{$i}"}}\"";
  515. }
  516. }*/
  517. foreach($this_mypowers as $i => $u){
  518. $powers[0][] = "d".substr($i, 1)."=\"{$u}\" ";
  519. }
  520. /* Disabled Powers */
  521. $disabled = array();
  522. foreach($this->info->dpowers as $i => $u)
  523. {
  524. $power = $this->function->powerinfo($u);
  525. $disabled['m' . $power["section"]] = isset($disabled['m' . $power["section"]]) ?
  526. $disabled['m' . $power["section"]] + $power["subid"] : $power["subid"];
  527. }
  528. foreach($disabled as $i => $u)
  529. {
  530. $powers[1][] = $i . "=\"{$u}\"";
  531. }
  532. /* Set Power Options */
  533. $j2 = str_replace(
  534. array("disabled=\"\"", "powers=\"\"", ' '),
  535. array(implode(' ', $powers[1]), implode(' ', $powers[0]), ' '),
  536. $j2);
  537. $this->write(0, $j2);
  538. if($this->fh)
  539. {
  540. sleep(1);
  541. @flock($this->fh, LOCK_UN);
  542. @fclose($this->fh);
  543. }
  544. return true;
  545. }
  546.  
  547. public function write($socket, $data, $nonull = false)
  548. {
  549. if($socket === 0)
  550. {
  551. $this->debug($data, false);
  552. }
  553. if(substr($data, -1) != chr(0) && !$nonull)
  554. {
  555. $data .= chr(0);
  556. }
  557. return @socket_write($this->socket[$socket], $data) ? true : false;
  558. }
  559.  
  560. public function listen($return = false, $data = "", $to = 1800, $timeout = Null)
  561. {
  562. $sockets = $this->socket;
  563. if(!isset($this->restart))
  564. {
  565. $this->restart = time() + $to;
  566. }
  567. $timeout = $this->info->sub - time() < 300 && $this->special_bot === false ? $this->info->sub - time() : $this->restart - time();
  568. if(@socket_select($sockets, $null, $null, $timeout) < 1)
  569. {
  570. if($this->info->sub <= time() && $this->special_bot === false)
  571. {
  572. if($this->info->language == 'en'){
  573. $this->function->respond("The time your bot over, buy more time for your signature!");
  574. $this->error("The time your bot over, buy more time for your signature!");
  575. }
  576. if($this->info->language == 'pl'){
  577. $this->function->respond("Czas dla Twojego bota kończy się, musisz kupić więcej czasu dla Twojej Sygnatury!");
  578. $this->error("Czas dla Twojego bota kończy się, musisz kupić więcej czasu dla Twojej Sygnatury!");
  579. }
  580. if($this->info->language == 'pt'){
  581. $this->function->respond("O tempo do seu bot acabou, compre mais tempo para sua assinatura!");
  582. $this->error("O tempo do seu bot acabou, compre mais tempo para sua assinatura!");
  583. }
  584. if($this->info->language == 'es'){
  585. $this->function->respond("El tiempo de tu bot más, comprar más tiempo para su firma!");
  586. $this->error("El tiempo de tu bot más, comprar más tiempo para su firma!");
  587. }
  588. } elseif($this->restart >= (time() - 2)) {
  589. $this->restart = time() + $to;
  590. $this->function->restart();
  591. }
  592. } else {
  593. foreach($this->socket as $i=>$u)
  594. {
  595. if(in_array($u, $sockets))
  596. {
  597. switch($i)
  598. {
  599. case 0:
  600. $data = "";
  601. do
  602. {
  603. $data .= @socket_read($u, 10075);
  604. } while( substr($data, -1) != chr(0) && $data !== "");
  605. if($data === "")
  606. {
  607. return $this->function->restart();
  608. }
  609. if($return !== false)
  610. {
  611. return $data;
  612. }
  613. $this->debug($data, true);
  614. foreach(explode(chr(0), $data) as $xml)
  615. {
  616. $packet = $this->xmlArray($xml);
  617. if($packet === false || $packet === chr(0))
  618. {
  619. continue;
  620. }
  621. if($this->parse($packet) === false)
  622. {
  623. break 3;
  624. }
  625. }
  626. break;
  627.  
  628. case 1:
  629. $this->socket[] = socket_accept($this->socket[1]);
  630. socket_getsockname(end($this->socket), $ip);
  631. if(!in_array($ip, array(
  632. '127.0.0.1',
  633. )))
  634. {
  635. socket_close(end($this->socket));
  636. unset($this->socket[count($this->socket) - 1]);
  637. }
  638. break;
  639.  
  640. case 2:
  641. $data = trim(strip_tags(socket_read($u, 65535)));
  642. if(strlen($data) < 7)
  643. {
  644. socket_close($u);
  645. $this->socket[2] = null;
  646. break;
  647. }
  648. $data = explode(',', $data, 7);
  649. if(count($data) != 7)
  650. {
  651. $this->function->respond("Radio error [Invalid stream?]");
  652. break;
  653. }
  654. $this->function->respond("Current Song: {$data[6]}");
  655. break;
  656.  
  657. default:
  658. $input = @trim(socket_read($u, 10075));
  659. if($input == "")
  660. {
  661. @socket_close($this->socket[$i]);
  662. unset($this->socket[$i]);
  663. } else {
  664. $input = $this->xmlArray($input);
  665. if(!$input)
  666. {
  667. return;
  668. }
  669. switch(strtoupper($input[chr(0)]))
  670. {
  671. case "RESPONSE_RL";
  672. foreach($this->response as $i => $u)
  673. {
  674. unset($this->response->{$i});
  675. }
  676. unset($this->response);
  677. $bot = $this->mysql->fetch_array("select * from `bots` where `ID`={$this->botID};");
  678. unset($this->loaded["responses"]);
  679. $this->load("responses", $bot[0]);
  680. $this->function->respond("My response list has been updated.");
  681. unset($bot);
  682. break;
  683.  
  684. case "USER_COUNT":
  685. $this->write($i, count($this->users));
  686. break;
  687.  
  688. case "ANNOUNCE":
  689. $this->function->respond("Announcement: {$input['t']}");
  690. break;
  691.  
  692. case "USERS":
  693. $users = "";
  694. foreach($this->users as &$u)
  695. {
  696. $users .= $u->reg ? $u->reg . ", " : $u->userid . ", ";
  697. }
  698. $this->write($i, substr($users, 0, -2));
  699. break;
  700.  
  701. case "RANK":
  702. $this->write($i, $this->info->rank[1]);
  703. break;
  704.  
  705. case "WALLET":
  706. $this->write($i, json_encode($this->info->user->bank));
  707. break;
  708.  
  709. case "MOD":
  710. $this->info->mod = isset($input["enabled"]) ? true : false;
  711. $this->function->respond("Moderation has been " . (isset($input["enabled"]) ? "enabled" : "disabled") . " from the bot panel.");
  712. break;
  713.  
  714. case "MSETTINGS":
  715. if(isset($input["avatar"]))
  716. {
  717. $this->info->user->avatar = $input["avatar"];
  718. }
  719. if(isset($input["nick"]))
  720. {
  721. $this->info->user->nick = $input["nick"];
  722. }
  723. if(isset($input["home"]))
  724. {
  725. $this->info->user->home = $input["home"];
  726. }
  727. if(isset($input["ownerID"]))
  728. {
  729. $this->info->info->owner = $input["ownerID"];
  730. }
  731. if(isset($input["comchar"]))
  732. {
  733. $this->info->info->cmd_char = $input["comchar"];
  734. }
  735. $this -> write ( $i , chr(0) ) ; /* C a u s e I c o u l d : p */
  736. $this -> function -> restart () ; /* C a u s e I c o u l d : p */
  737. break;
  738.  
  739. case "REFRESH":
  740. $this->write(0, "<l u=\"{$this->info->user->id}\" />");
  741. socket_close($this->socket[0]);
  742. exec("nohup php /var/www/html/classes/bot_script/bot.php \"{$this->botID}\" > /dev/null 2>&1 &");
  743. die();
  744. break;
  745.  
  746. case "MOD_UPDATE":
  747. if(isset($input["mod_kicks"]))
  748. {
  749. $this->info->mod_max_kicks = $input["mod_kicks"];
  750. }
  751. if(isset($input["mod_caps"]))
  752. {
  753. $this->info->mod_max_caps = $input["mod_caps"];
  754. }
  755. if(isset($input["detectLink"]))
  756. {
  757. $this->info->detectLink = $input["detectLink"];
  758. }
  759. if(isset($input["detectCaps"]))
  760. {
  761. $this->info->detectCaps = $input["detectCaps"];
  762. }
  763. if(isset($input["detectInapp"]))
  764. {
  765. $this->info->detectInapp = $input["detectInapp"];
  766. }
  767. if(isset($input["banTime"]))
  768. {
  769. $this->info->banTime = $input["banTime"];
  770. }
  771. if(isset($input["mod_consec"]))
  772. {
  773. $this->info->mod_max_consecutive = $input["mod_consec"];
  774. }
  775. if(isset($input["mod_flood"]))
  776. {
  777. $this->info->mod_flood = unserialize(base64_decode($input["mod_flood"]));
  778. }
  779. $this->write($i, chr(0));
  780. $this->function->respond("Mod settings have been changed from bot panel");
  781. break;
  782.  
  783. case "COMMAND":
  784. if(isset($input['t']))
  785. {
  786. $xml = $this->xmlArray("<u u=\"{$this->info->user->id}\" a=\"{$this->info->user->avatar}\" n=\"{$this->info->user->nick}\" />");
  787. $user = new user($xml, $this); /* $this->commands[$args[0]](&$this, &$args, &$xml, &$user); */
  788. $user->botRank = $this->Ranks["botowner"];
  789. if(substr($input['t'], 0, 1) == $this->info->cmd_char)
  790. {
  791. $input[chr(0)] = 'm';
  792. $args = explode(' ', $input['t'], 2);
  793. $args = array_map('trim', $args);
  794. $args[0] = substr(strtolower($args[0]), 1);
  795. if(isset($this->commands[$args[0]]))
  796. {
  797. $this->commands[$args[0]]($this, $args, $input, $user, $args[0]);
  798. }
  799. $this->write($i, "Command executed.");
  800. $executed = 1;
  801. }
  802. }
  803. if(!isset($executed))
  804. {
  805. $this->write($i, chr(0));
  806. }
  807. unset($xml, $user, $args);
  808. break;
  809.  
  810. default: $this->write($i, chr(0)); break;
  811. }
  812. }
  813. break;
  814. }
  815. }
  816. }
  817. }
  818. return true;
  819. }
  820.  
  821. public function parse($xml)
  822. {
  823. switch($xml[chr(0)])
  824. {
  825. case 'a':
  826. switch($xml['k'])
  827. {
  828. case 'T':
  829. if(strtolower($this->info->room->name) == "NeoBots" && $xml['b'] == $this->info->user->id)
  830. {
  831. list($user, $xats) = array($this->function->getuserbyid($xml['u']), (int) $xml['x'] + ($xml['s'] * 13));
  832. $value = ($xats % 300 == 0 ? strtotime("+ " . ($xats / 300) . " months") : strtotime("+ " . ($xats * 2) . " hours")) - time();
  833. if(!isset($xml['t']) && !ctype_alnum($xml['t']))
  834. {
  835. $this->mysql->query("insert into `redeem` values('NULL', " . time() . ", '{$key}', {$value}, 0);");
  836. $user->pc("Link to put your code: http://neo-bots.tk/panel?redeem");
  837. usleep(400000);
  838. $user->pc("Your redemption code is: {$key}");
  839. $this->function->respond("{$userfm->reg}({$xml['u']}) transfer {$xats} xats and purchased " . ($xats % 300 == 0 ? (($xats / 300) . " months") : (round($value / 60 / 60, 2) . " hours")) . ".");
  840. $this->mysql->insert('payments_xats', array('NULL', $user->userid, time(), $xml['x'], $xml['s'], '0'), true);
  841. $this->function->restart(true);
  842. }
  843. else if(isset($xml['t']) && ctype_alnum($xml['t']))
  844. {
  845. $bot = $this->mysql->fetch_array('select * from `bots` where `ID`=:a;', array('a' => $xml['t']));
  846. if(empty($bot))
  847. {
  848. do
  849. {
  850. $key = $this->mysql->rand(64);
  851. } while($r = $this->mysql->fetch_array("select `id` from `redeem` where `code`='{$key}';") && !empty($r));
  852. $this->mysql->query("insert into `redeem` values('NULL', " . time() . ", '{$key}', {$value}, 0);");
  853. $user->pc("You did not provide a valid BotID, redeem the following code at http://neo-bots.tk/panel?redeem");
  854. usleep(400000);
  855. $user->pc("Your redemption code is: {$key}");
  856. $this->function->respond("{$userfm->reg}({$xml['u']}) transfer {$xats} xats and purchased " . ($xats % 300 == 0 ? (($xats / 300) . " months") : (round($value / 60 / 60, 2) . " hours")) . ".");
  857. $this->mysql->insert('payments_xats', array('NULL', $user->userid, time(), $xml['x'], $xml['s'], $xml['t']), true);
  858. } else {
  859. $_user = $this->mysql->fetch_array("select * from `users` where `botid`='{$bot[0]['ID']}';");
  860. if($_user[0]["subscription"] < time())
  861. {
  862. $_user[0]["subscription"] = time();
  863. }
  864. $_user[0]["subscription"] += $value;
  865. $this->mysql->query("update `users` set `subscription`={$_user[0]["subscription"]} where `id`={$_user[0]["id"]};");
  866. $user->pc("Your have purchased " . ($xats % 300 == 0 ? (($xats / 300) . " months") : (round($value / 60 / 60, 2) . " hours")) . " for \"{$_user[0]["user"]}\".");
  867. $this->function->respond("{$userfm->reg}({$xml['u']}) transfer {$xats} xats and purchased " . ($xats % 300 == 0 ? (($xats / 300) . " months") : (round($value / 60 / 60, 2) . " hours")) . ".");
  868. $this->mysql->insert('payments_xats', array('NULL', $user->userid, time(), $xml['x'], $xml['s'], $xml['t']), true);
  869. }
  870. $this->function->restart(true);
  871. } elseif($this->info->user->id == $xml['b']) {
  872. $this->function->restart(true);
  873. }
  874. break; }
  875. return true;
  876. }
  877. case 'p':
  878. if(!in_array('off', $this->info->snitch))
  879. {
  880. foreach($this->info->snitch as $u)
  881. {
  882. if($u == "on")
  883. {
  884. continue;
  885. }
  886. if($u != $this->function->runder($xml['u']) && substr($xml['t'], 0, 1) != '/')
  887. {
  888. list($lamingtons, $user) = array($this->function->getuserbyid($u), $this->function->getuserbyid($xml['u']));
  889. if($lamingtons !== false)
  890. {
  891. $lamingtons->pc('[' . ( $user->reg ? $user->reg : $user->userid ) . "][" . (isset($xml['s']) ? "PC" : "PM") . "]: {$xml['t']}");
  892. }
  893. }
  894. sleep(1);
  895. }
  896. }
  897. if(substr($xml['t'], 0, strlen($this->info->cmd_char)) != $this->info->cmd_char || $this->info->private_commands == false)
  898. {
  899. if(substr($xml['t'], 0, strlen($this->info->cmd_char)) == $this->info->cmd_char)
  900. {
  901. $this->function->respond("Private commands are disabled", 2, $this->function->runder($xml['u']));
  902. }
  903. break;
  904. }
  905. case 'm':
  906. if(isset($xml['s']) && $xml[chr(0)] != 'p' || !isset($xml['u']))
  907. {
  908. break;
  909. }
  910. if(!isset($user))
  911. {
  912. $user = $this->function->getuserbyid($xml['u']);
  913. }
  914. if(!is_object($user) || $this->function->mod($user, $xml) === true)
  915. {
  916. break;
  917. }
  918. $xml['t'] = str_replace(array(' (', ') '), array('(', ')'), $xml['t']);
  919. if(substr($xml['t'], 0, 1) === $this->info->cmd_char)
  920. {
  921. if(!empty($this->info->abl) && in_array('on', $this->info->abl) && !in_array($user->userid, $this->info->abl) && !$user->rank('botowner'))
  922. {
  923. return $user->pm("Only users on the access list!");
  924. }
  925. $args = explode(chr(32), trim($xml['t']), 2);
  926. $args = array_map("trim", $args);
  927. $args[0] = substr(strtolower($args[0]), 1);
  928. if(isset($this->commands[$args[0]]))
  929. {
  930. if(isset($user->last[$args[0]]) && time() - $user->last[$args[0]] <= 2)
  931. {
  932. return $user->pm("Don't use my commands for flood...");
  933. }
  934. $alias = isset($this->alias[$args[0]]) ? $this->alias[$args[0]] : $args[0];
  935. $this->commands [$args[0]] ($this, $args, $xml, $user, $alias);
  936. $user->last[$args[0]] = time();
  937. } else {
  938. $user->pm("Command not found, see more here: http://neo-bots.tk/commands");
  939. }
  940. } elseif($xml[chr(0)] == 'm') {
  941. $respond = false;
  942. foreach($this->info->responses as $i => $u)
  943. {
  944. if( ($u[1] == true && strtolower($xml['t']) == $i) ||
  945. ($u[1] != true && is_numeric(stripos($xml['t'], $i))))
  946. {
  947. $response = str_replace(
  948. array("{nick}"),
  949. array($user->nick),
  950. $u[0]
  951. );
  952. $this->function->respond($response);
  953. return true;
  954. }
  955. }
  956. }
  957. return true;
  958. case 'u':
  959. $xml['u'] = $this->function->runder($xml['u']);
  960. if(!isset($this->users[$xml['u']]))
  961. {
  962. $this->users[$xml['u']] = new user($xml, $this);
  963. if(isset($this->users[$xml['u']]->selfDestruct))
  964. {
  965. unset($this->users[$xml['u']]);
  966. }
  967. $this->write(0, "<z d=\"{$xml['u']}\" u=\"{$this->info->user->id}\" t=\"/l\" />");
  968. } else {
  969. $this->users[$xml['u']]->reset($xml);
  970. }
  971. return true;
  972. case 'l':
  973. if(isset($this->users[$xml['u']]))
  974. {
  975. unset($this->users[$xml['u']]);
  976. }
  977. return true;
  978. case 'z':
  979. $user = $this->function->getuserbyid($xml['u']);
  980. if(!is_object($user))
  981. {
  982. break;
  983. }
  984. switch(substr($xml['t'], 1, 1))
  985. {
  986. case 'l':
  987. if(isset($user->last['z']))
  988. {
  989. if($user->last['z'] > time())
  990. {
  991. break;
  992. }
  993. }
  994. $user->last['z'] = time() + 2;
  995. $this->write(0, "<z d=\"{$xml['u']}\" u=\"{$this->info->user->id}\" t=\"/ayewpk\" />");
  996. $this->function->respond($this->response->_return(51), 1, $user->userid);
  997. break;
  998. case 'a':
  999. $user->reset($xml, true, isset($xml["po"]) ? $xml["po"] : "");
  1000. break;
  1001. }
  1002. return true;
  1003. case 'i':
  1004. $this->e25 = 0;
  1005. $info = explode(";=", $xml['b']);
  1006. $this->info->room = (object) array_merge((array)$this->info->room, array(
  1007. "bg" => $info[0],
  1008. "tabbed" => array(
  1009. "name" => $info[1],
  1010. "id" => $info[2]
  1011. ),
  1012. "lang" => $info[3],
  1013. "radio" => str_replace(array("http://", "https://"), "", $info[4]),
  1014. ));
  1015. $this->info->room->storemessages = $xml['f'] & 256 ? false : true;
  1016. $this->info->room->deleted = $xml['f'] & 33554432 ? true : false;
  1017. $this->info->room->membersonly = $xml['f'] & 128 ? true : false;
  1018. $this->info->room->radio = (array) explode(':', $this->info->room->radio);
  1019. $this->info->rank = array(isset($xml['r']) ? $xml['r'] : 0);
  1020. $this->info->rank[0] = $this->function->relrank($this->info->rank[0]);
  1021. $this->info->rank[1] = $this->function->wordrank($this->info->rank[0]);
  1022. $this->mysql->query("update `bots` set `chatdsc`=:a, `chatrdo`=:b, `chatbg`=:c where `ID`={$this->botID};", array(
  1023. 'a' => $this->info->room->desc,
  1024. 'b' => $info[4],
  1025. 'c' => $info[0]
  1026. ));
  1027. return true;
  1028. case 'v':
  1029. case "dup":
  1030. if($xml[chr(0)] == "dup")
  1031. {
  1032. exit;
  1033. }
  1034. if(isset($xml['n']))
  1035. {
  1036. break;
  1037. }
  1038. if(!empty($xml['e'])) switch(substr($xml['e'], 1))
  1039. {
  1040. case '8': $this->error("Bad Xat-Credentials (bot login information)"); exit;
  1041. case "36": $this->error("We had trouble logging into your bot account!"); exit;
  1042. case "37": $this->error("Locking and Protection must be off to be able to login to your bot!"); exit;
  1043. case "25": $this->error("Bot Power was not configured correctly, make sure it is using the Xat ID \"{$this->info->user->id}\"<br /> <center> <a href=\"http://img849.imageshack.us/img849/1448/2mi0.png\"> Click Here for help with setting up bot power :) </a>"); exit;
  1044. default: $this->function->restart(); break 2; /* break 2 to avoid the exit; ( break out of the current switch, then break out of the parent switch ) */
  1045. }
  1046. sleep(5);
  1047. $this->function->restart();
  1048. break;
  1049. case 'q':
  1050. case "logout":
  1051. case "idle":
  1052. if($xml['e'] == "E25")
  1053. {
  1054. if(!isset($this->e25))
  1055. {
  1056. $this->e25 = 0;
  1057. }
  1058. if(++$this->e25 < 10)
  1059. {
  1060. sleep(1);
  1061. break;
  1062. }
  1063. }
  1064. if(in_array($xml['e'], array("E35", "E21", "E25")))
  1065. {
  1066. $this->error("Xat's telling us that bot power wasn't setup correctly, try reassigning it, then setting the ID to 1000, and then back to your bot's ID");
  1067. }
  1068. sleep(3); /* To stop it "spamming" xat servers */
  1069. $this->function->restart();
  1070. return true;
  1071. case 'done':
  1072. $this->e = array();
  1073. break;
  1074. case 'w':
  1075. $pools = explode(' ', $xml['v']);
  1076. array_shift($pools);
  1077. $this->pools = $pools;
  1078. break;
  1079. }
  1080. return true;
  1081. }
  1082.  
  1083. public function xmlArray($packet, $expected='*', $return=array())
  1084. {
  1085. $xml = @simplexml_load_string($packet);
  1086. if(!method_exists($xml, 'attributes'))
  1087. {
  1088. return false;
  1089. }
  1090. $return[chr(0)] = $xml->getName();
  1091. if(is_array($expected))
  1092. {
  1093. foreach($expected as $i=>$u)
  1094. {
  1095. $return[$i] = false;
  1096. }
  1097. }
  1098. foreach($xml->Attributes() as $i=>$u)
  1099. {
  1100. if(!is_array($expected) || in_array($i, $return))
  1101. {
  1102. $return[$i] = mb_convert_encoding((string) $u, "");
  1103. }
  1104. }
  1105. return $return;
  1106. }
  1107.  
  1108. public function connect($room = 0, $fpt = false, $fail = 0, $force = false)
  1109. {
  1110. if(!empty($this->socket))
  1111. {
  1112. @array_map('socket_close', $this->socket);
  1113. }
  1114. $this->socket = array( socket_create(AF_INET, SOCK_STREAM, SOL_TCP) );
  1115. if(isset($this->forcedom))
  1116. {
  1117. unset($this->forcedom);
  1118. list($fail, $force) = array($fail + 1, true);
  1119. }
  1120. while(true)
  1121. {
  1122. $server = isset($this->serv) && $force === false ? $this->serv : $this->function->connections($this->info->room->id, $fail % 2 == 0 ? false : true);
  1123. switch(@socket_connect($this->socket[0], $server[0], $fpt ? $fpt : $server[1]))
  1124. {
  1125. case false:
  1126. unset($this->serv);
  1127. if(++$fail >= 5)
  1128. {
  1129. $this->error('We are having trouble connecting to xats server.<br />Updates maybe?');
  1130. }
  1131. sleep(60);
  1132. break;
  1133. default:
  1134. $this->write(0, '<y u="' . $this->info->user->id . '" m="1" r="' . $room . '" />');
  1135. print $room;
  1136. $response = $this->xmlArray($this->listen(true));
  1137. if($response[chr(0)] != 'y')
  1138. {
  1139. if(!isset($this->e[$response[chr(0)]]))
  1140. {
  1141. $this->e[$response[chr(0)]] = 0;
  1142. }
  1143. if(++$this->e[$response[chr(0)]] >= 100)
  1144. {
  1145. $this->error('Xat is not allowing us to connect.');
  1146. }
  1147. if($this->e[$response[chr(0)]] % 10 == 0)
  1148. {
  1149. sleep(floor($this->e[$response[chr(0)]] / 10));
  1150. }
  1151. break;
  1152. }
  1153. $this->e = array();
  1154. $this->y = $response;
  1155. list($this->socket[1], $this->socket[2]) = array(
  1156. socket_create_listen(0), /* API Socket */
  1157. Null /* Radio */
  1158. );
  1159. socket_getsockname($this->socket[1], $this->ipc[0], $this->ipc[1]);
  1160. $this->mysql->query('update `bots` set `ipc`=:a where `ID`=' . $this->botID . ';', array('a' => serialize($this->ipc)));
  1161. $this->serv = $server;
  1162. break 2;
  1163. }
  1164. }
  1165. }
  1166.  
  1167. public function single_connect($socket, $ip, $port)
  1168. {
  1169. $this->socket[$socket] = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  1170. socket_connect($this->socket[$socket], $ip, $port);
  1171. }
  1172.  
  1173. function error($text, $noquit = false)
  1174. {
  1175. print $text . chr(10); /* Print the error to CLI */
  1176. /* Below - Insert the error into the users "messages" */
  1177. $this->mysql->insert('messages', array('NULL', $this->userID, 1, $text), true);
  1178. if(!$noquit)
  1179. {
  1180. exit;
  1181. }
  1182. }
  1183.  
  1184. public function parseRoom($room)
  1185. {
  1186. $source = file_get_contents('http://neoxat.tk/' . (is_numeric($room) ? "xat{$room}?x" : $room."?x"));
  1187. $info = array(
  1188. //"id" => $this->split($source, 'roomid=', '&'),
  1189. "id" => "1",
  1190. "name" => substr($this->split($source, '<h1>', '<'),6),
  1191. //"bot" => trim($this->split($source, "xat:bot\" content=\"", '"')),
  1192. "bot" => "8895",
  1193. "desc" => $this->split($source, "<h2>", '<')
  1194. );
  1195. return $info["id"] == false ? false : (object) $info;
  1196. }
  1197.  
  1198. public function split($content, $start, $end, $i=false)
  1199. {
  1200. $engine = $i ? "stripos" : "strpos";
  1201. if(!is_numeric($engine($content, $start)))
  1202. {
  1203. return false;
  1204. }
  1205. $content = substr($content, $engine($content, $start) + strlen($start));
  1206. if(!is_numeric($engine($content, $end)))
  1207. {
  1208. return false;
  1209. }
  1210. $content = substr($content, 0, $engine($content, $end));
  1211. return strlen($content) >= 1 ? $content : false;
  1212. }
  1213.  
  1214. public function debug($packet, $x)
  1215. {
  1216. if($this->debug == true)
  1217. {
  1218. print '[' . time() . "] BOT " . ($x == true ? "<--" : "-->") . " XAT: " . trim($packet) . str_repeat(PHP_EOL, 2);
  1219. }
  1220. }
  1221.  
  1222. }
Add Comment
Please, Sign In to add comment