Guest User

sv.php

a guest
Apr 29th, 2016
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 157.90 KB | None | 0 0
  1. <?php
  2. //!!!*Server created by IoNuT*!!! //
  3. set_time_limit( 0 );
  4. date_default_timezone_set( "America/Sao_Paulo" );
  5. libxml_use_internal_errors(false);
  6. ini_set('display_errors', 'off');
  7. error_reporting(0);
  8.  
  9. do {
  10. $server = new Ixaat12SV();
  11. unset($server);
  12. } while (true);
  13. //*http://oxat.eu*//
  14. class Ixaat12SV {
  15.  
  16. private $info = array();
  17. public $socket = array(null, null);
  18. public $users = array();
  19. public $ipbans = array();
  20. public $protected = array();
  21. public $rfilter = array();
  22. public $debug = true;
  23. public $hasGroupPowers = array("Chat", "Trade");
  24.  
  25. public function __construct() {
  26. //require __DIR__ . "/../_class/config.php";
  27. $config = (object) array( 'db' => array( 0 => 'localhost', 1 => 'root', 2 => '7EeYX26TMyfWH8ex', 3 => 'ixat' ) ); //Configuracao
  28. $this->mysql = new Database($config->db[0], $config->db[1], $config->db[2], $config->db[3]);
  29.  
  30. $this->resetConfig();
  31. $this->bind();
  32.  
  33. while (true) {
  34. $this->bind();
  35.  
  36. while ($this->socket[0]) {
  37. $this->listen();
  38. }
  39.  
  40. array_map('socket_close', $this->socket);
  41. }
  42. }
  43. /* config da database Server */
  44. public function resetConfig() {
  45. $this->config = $this->mysql->fetch_array("select * from `server` limit 0, 1;");
  46. $this->config = (object) $this->config[0];
  47.  
  48. $this->config->spam_wait = 800;
  49. $this->config->staff = (array) json_decode($this->config->staff);
  50. $this->config->volunteers = (array) json_decode($this->config->volunteers);
  51. $this->config->pawns = (array) json_decode($this->config->pawns);
  52.  
  53. $this->config->pcount = $this->mysql->fetch_array('select count(distinct `section`) as `count` from `powers`;');
  54. $this->config->pcount = $this->config->pcount[0]['count'];
  55.  
  56. $this->hash = $this->mysql->rand(25); /* For API Laterz */
  57. $this->ipbans = $this->mysql->fetch_array("select `ipbans` from `server`;");
  58. $this->ipbans = (array) json_decode($this->ipbans[0]['ipbans']);
  59. $this->mysql->query("update `server` set `pid`='" . getmypid() . "';");
  60. }
  61. public function bind( )
  62. {
  63. try
  64. {
  65. global $argv;
  66. $this->socket = Array(
  67. socket_create( AF_INET, SOCK_STREAM, SOL_TCP ),
  68. socket_create_listen( 0 )
  69. );
  70.  
  71. socket_getsockname( end( $this->socket ), $ip, $port );
  72. $this->mysql->query( "update `server` set `ipc`={$port};" );
  73. socket_set_option( $this->socket[ 0 ], SOL_SOCKET, SO_REUSEADDR, True );
  74.  
  75. If ( !Isset( $argv[ 1 ] ) || $argv[ 1 ] != 'debug' )
  76. {
  77. socket_bind( $this->socket[ 0 ], $this->config->server_ip, $this->config->server_pt ) or exit;
  78. } //!Isset( $argv[ 1 ] ) || $argv[ 1 ] != 'debug'
  79. Else
  80. {
  81. $this->debug = True;
  82. socket_bind( $this->socket[ 0 ], $this->config->server_ip, $this->config->backup_pt ) or exit;
  83. }
  84.  
  85. socket_listen( $this->socket[ 0 ] );
  86. socket_set_block( $this->socket[ 0 ] );
  87. }
  88. catch ( Exception $e )
  89. {
  90. print $e->getMessage();
  91. exit;
  92. }
  93. }
  94.  
  95.  
  96. public function listen( $null = null, $ipc = 0 )
  97. {
  98. $read = $this->socket;
  99. Foreach ( $this->users as $user )
  100. {
  101. $read[ ] = $user->sock;
  102. } //$this->users as $user
  103. $except = $read;
  104. If ( @socket_select( $read, $null, $except, null ) < 1 )
  105. {
  106. continue;
  107. } //@socket_select( $read, $null, $except, null ) < 1
  108.  
  109. Foreach ( $this->socket as $i => $psock )
  110. {
  111. If ( in_Array( $psock, $read ) )
  112. {
  113. switch ( (int) $i )
  114. {
  115. case 0:
  116. $socket = socket_accept( $psock );
  117. socket_set_nonblock($socket);
  118. If ( !is_resource( $socket ) || count( $this->users ) >= $this->config->max_total )
  119. {
  120. @socket_close( $socket );
  121. break;
  122. } //!is_resource( $socket ) || count( $this->users ) >= $this->config->max_total
  123.  
  124. socket_getpeername( $socket, $ip );
  125. Foreach ( $this->users as $user )
  126. {
  127. If ( $user->ipaddr == $ip )
  128. {
  129. $ipc++;
  130. } //$user->ipaddr == $ip
  131. } //$this->users as $user
  132.  
  133. If ( $ipc > $this->config->max_per_ip || in_Array( $ip, $this->ipbans ) )
  134. {
  135. Foreach ( $this->users as $user )
  136. {
  137. If ( $user->ipaddr == $ip )
  138. {
  139. $this->disconnect( $user->index );
  140. } //$user->ipaddr == $ip
  141. } //$this->users as $user
  142. break;
  143. } //$ipc > $this->config->max_per_ip || in_Array( $ip, $this->ipbans )
  144.  
  145. do
  146. {
  147. $index = $this->mysql->rand();
  148. } while ( Isset( $this->users[ $index ] ) );
  149.  
  150. $this->users[ $index ] = new client( $socket, $this, $index, $ip );
  151. break;
  152.  
  153. case 1:
  154. $this->socket[ ] = socket_accept( $psock );
  155. break;
  156.  
  157. } //(int) $i
  158. } //in_Array( $psock, $read )
  159. } //$this->socket as $i => $psock
  160. If ( !is_Array( $except ) )
  161. {
  162. $except = Array( );
  163. } //!is_Array( $except )
  164.  
  165. Foreach ( $this->users as $index => $user )
  166. {
  167. If ( in_Array( $user->sock, $except ) || !$user->sock )
  168. {
  169. unset( $this->users[ $index ] );
  170. } //in_Array( $user->sock, $except ) || !$user->sock
  171. ElseIf ( in_Array( $user->sock, $read ) )
  172. {
  173. $input = '';
  174. //while(@socket_recv($user->sock, $buf, (2048 * 2048), 0) >= 1) //CONFIGURAR RAM 2GB
  175. while(@socket_recv($user->sock, $buf, (4096 * 4096), 0) >= 1) //CONFIGURAR RAM 4 GB
  176. {
  177. $input .= $buf;
  178. }
  179. If ( trim( $input ) == '' || ord( substr( $input, 0, 1 ) ) == 136 )
  180. {
  181. unset( $this->users[ $index ] );
  182. continue;
  183. } //trim( $input ) == '' || ord( substr( $input, 0, 1 ) ) == 136
  184. ElseIf ( substr_count( $input, chr( 0 ) ) <= 1 )
  185. {
  186. $this->handle( $input, $user );
  187. } //substr_count( $input, chr( 0 ) ) <= 1
  188. } //in_Array( $user->sock, $read )
  189. } //$this->users as $index => $user
  190. }
  191.  
  192.  
  193.  
  194.  
  195. private function handle($packet, &$user) {
  196. $packet = str_replace('', '', $packet); //RIP Chrome
  197.  
  198. try {
  199. if ($this->debug) {
  200. var_dump($packet);
  201. }
  202.  
  203.  
  204. if ($user->mobile == false && substr($packet, 0, 1) !== '<') {
  205. $user->mobile = true;
  206. } //$user->mobile == False && substr( $packet, 0, 1 ) !== '<'
  207.  
  208. if (substr($packet, 0, 2) == '<x') {
  209. $user->sendRoom($packet);
  210. }
  211.  
  212. if ($user->mobile == true) {
  213. if ($user->mobready == false) {
  214. $user->buffer .= $packet;
  215. if (strlen($user->buffer) >= 4096) {
  216. throw new Exception();
  217. }
  218.  
  219. if (is_numeric(strpos($user->buffer, "\r\n\r\n"))) {
  220. $headers = array();
  221. $lines = explode("\r\n", $user->buffer);
  222. foreach ($lines as $line) {
  223. $line = explode(': ', $line, 2);
  224. if (count($line) < 2)
  225. continue;
  226. $headers[strtolower($line[0])] = $line[1];
  227. }
  228.  
  229. if (!isset($headers['sec-websocket-key'])) {
  230. throw new Exception();
  231. }
  232.  
  233. $secAccept = base64_encode(pack('H*', sha1($headers['sec-websocket-key'] . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11')));
  234. $response = array();
  235. array_push($response, "HTTP/1.1 101 Pulse");
  236. array_push($response, "Upgrade: websocket");
  237. array_push($response, "Connection: Upgrade");
  238. array_push($response, "Sec-WebSocket-Accept: " . $secAccept);
  239. @socket_write($user->sock, implode("\r\n", $response) . "\r\n\r\n");
  240.  
  241. $user->mobready = true;
  242. }
  243.  
  244. return;
  245. } else {
  246. $packet = $this->unmask($packet);
  247. if ($packet == false) {
  248. throw new Exception(1);
  249. }
  250. }
  251. }
  252.  
  253. if (strpos($packet, '<', 1) !== false) {
  254. throw new Exception(2);
  255. }
  256. $packet2 = $packet;
  257. $packet = simplexml_load_string(trim($packet));
  258.  
  259. if (!method_exists($packet, 'getName')) {
  260. libxml_clear_errors(true);
  261. throw new Exception(3);
  262. }
  263.  
  264. $tag = strtolower($packet->getName());
  265. $lPackets = array('policy-file-request', 'j2', 'y', 'login');
  266.  
  267. if (strlen($tag) > 25 || $tag == '') {
  268. throw new Exception(4);
  269. }
  270.  
  271. if (!isset($user->loginKey) || $user->loginKey == null) {
  272. if (!in_array($tag, $lPackets)) {
  273. throw new Exception(5);
  274. }
  275. } elseif ($user->authenticated == null && $tag != 'j2') {
  276. throw new Exception(6);
  277. } elseif (isset($user->id) && in_array($user->id, array(0, 2))) {
  278. throw new Exception(7);
  279. } elseif ($user->hidden == true && $user->online) {
  280. $user->hidden = false;
  281. $user->joinRoom($user->chat, false, true, $user->pool);
  282. };
  283. } catch (Exception $e) {
  284. //print $e->getMessage() . "\n";
  285. return $this->disconnect($user->index);
  286. }
  287.  
  288.  
  289. if (!$user->authenticated && !in_array($tag, $lPackets)) {
  290. return $this->disconnect($user->index, true);
  291. }
  292.  
  293. switch ($tag) {
  294. //For bots
  295. case 'login':
  296. //$key = $this->getAttribute($packet, 'key');//lol later
  297. $user2 = $this->getAttribute($packet, 'user');
  298. $password = $this->getAttribute($packet, 'pass');
  299. $userLogin = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($user2) . '\';');
  300. if (!$this->mysql->validate($password, $userLogin[0]['password']) || empty($userLogin)) {
  301. $user->sendPacket('<login t="Bad Username/Password." e="1" />');
  302. } else {
  303. $loginKey = md5(json_encode(array(time(), $userLogin[0]['username'], $userLogin[0]['password'])));
  304. $this->mysql->query('update `users` set `loginKey`=\'' . $loginKey . '\' where `username`=\'' . $this->mysql->sanatize($userLogin[0]['username']) . '\';');
  305.  
  306. if ((floor(($userLogin[0]['days'] - time()) / (24 * 3600) + 0.3) >= 1 ? floor(($userLogin[0]['days'] - time()) / (24 * 3600) + 0.3) : 0) >= 1)
  307. {
  308. $upowers = $this->mysql->fetch_array("select * from `userpowers` where `userid`={$userLogin[0]['id']};");
  309. $spowers = $this->mysql->fetch_array("select * from `powers` where `name` not like '%(Undefined)%';");
  310. list($vals, $p, $dO, $powerO, $pp) = array(array(), array(), '', '', '');
  311. foreach ($spowers as $i => $u)
  312. {
  313. $vals[$u["id"]] = array($u["section"], $u["subid"]);
  314. if (!isset($p[$u["section"]]))
  315. {
  316. $p[$u["section"]] = 0;
  317. }
  318. }
  319.  
  320. foreach ($upowers as $i => $u)
  321. {
  322. if ($u["count"] >= 1 && isset($vals[$u["powerid"]]) && isset($p[$vals[$u["powerid"]][0]]))
  323. {
  324. $str = $u['powerid'] . '=' . ($u['count'] > 1 ? ($u['count'] - 1) : 1) . '|';
  325. $dO .= $str;
  326.  
  327. if ($u['count'] > 1)
  328. {
  329. $powerO .= $str;
  330. }
  331.  
  332. $p[$vals[$u["powerid"]][0]] += $vals[$u["powerid"]][1];
  333. }
  334. }
  335. }
  336.  
  337. $nickname = explode('##', $userLogin[0]['nickname'], 2);
  338. if (count($nickname) != 2) {
  339. $nickname[1] = "";
  340. }
  341. $vars = "";
  342. $vars .= 'userno="' . $userLogin[0]["id"] . '" ';
  343. $vars .= 'avatar="' . $userLogin[0]["avatar"] . '" ';
  344. $vars .= 'k1="' . $userLogin[0]["k"] . '" ';
  345. $vars .= 'd0="' . $userLogin[0]["d0"] . '" ';
  346. $vars .= 'd1="' . $userLogin[0]["days"] . '" ';
  347. $vars .= 'd2="' . $userLogin[0]["d2"] . '" ';
  348. $vars .= 'd3="" ';
  349.  
  350. foreach ($p as $i => $u)
  351. $vars .= 'd' . (substr($i, 1) + 4) . '="' . $u . '" ';
  352.  
  353. $vars .= 'dt=0" ';
  354. $vars .= 'homepage="' . $userLogin[0]["url"] . '" ';
  355. $vars .= 'Powers="' . implode(",", $p) . '" ';
  356. $vars .= 'PowerO="' . $powerO . '" ';
  357. $vars .= 'status="' . $nickname[1] . '" ';
  358. $vars .= 'dO="'.$dO.'" ';
  359. $vars .= 'dx="' . $userLogin[0]["xats"] . '" ';
  360. $vars .= 'registered="' . $userLogin[0]["username"] . '" ';
  361. $vars .= 'k2="' . $userLogin[0]["k2"] . '" ';
  362. $vars .= 'k3="' . $userLogin[0]["k3"] . '" ';
  363. $vars .= 'name="' . $nickname[0] . '" ';
  364. $vars .= 'loginKey="' . $loginKey . '"';
  365. $user->sendPacket('<v ' . $vars . ' e="0" />');
  366. }
  367. break;
  368. case substr($tag, 0, 1) == 'w': /* pools */
  369. $pool = substr($tag, 1, 2);
  370. $chat = $this->mysql->fetch_array("select * from `chats` where `id`={$user->chat};");
  371. $rank = json_decode($chat[0]['pools'], true);
  372. $rankS = $user->noToRank($rank['rnk']);
  373. if($rankS == "o" && $user->rank != 1){
  374. break;
  375. }
  376. elseif($rankS == "M" && ($user->rank != 1 && $user->rank != 4)){
  377. break;
  378. }
  379. elseif($rankS == "m" && ($user->rank != 1 && $user->rank != 4 && $user->rank != 2)){
  380. break;
  381. }
  382. elseif($rankS == "e" && ($user->rank != 1 && $user->rank != 4 && $user->rank != 2 && $user->rank != 3)){
  383. break;
  384. } else {
  385. $user->sendRoom("<l u=\"{$user->id}\" />");
  386. $user->switchingPools = true;
  387. $user->joinRoom($user->chat, true, true, $pool);
  388. }
  389. break;
  390.  
  391.  
  392. case 'f': /* packet para add amigos */
  393. $users = $this->getAttribute($packet, 'o');
  394. $friends = (array) explode(' ', $users);
  395. $online = array();
  396. foreach($this->users as $i => $_user)
  397. {
  398. if($_user->id != $user->id && in_array($_user->id, $friends) && $_user->hidden === false && !in_array($_user->id, $online))
  399. {
  400. array_push($online, $_user->id);
  401. }
  402. }
  403. $user->sendPacket('<f v="' . implode(',', $online) . '" />');
  404. break;
  405.  
  406. case 'policy-file-request':
  407. if (isset($user->policy)) {
  408. return $this->ipban($user->ipaddr);
  409. }
  410.  
  411. $user->sendPacket('<cross-domain-policy><allow-access-from domain="*" to-ports="*" /></cross-domain-policy>');
  412. $user->policy = 1;
  413. break;
  414.  
  415. case 'r':
  416. break;
  417.  
  418. case 'y': /* packets de conexao do xat */
  419. if (isset($user->loginKey) && $user->loginKey != null) {
  420. return $this->ipban($user->ipaddr);
  421. }
  422.  
  423. $user->loginKey = rand(10000000, 99999999);
  424. $user->loginShift = rand(2, 5);
  425. $user->loginTime = time();
  426.  
  427. $user->sendPacket('<y yi="' . $user->loginKey . '" yc="' . $user->loginTime . '" ys="' . $user->loginShift . '" />');
  428. break;
  429.  
  430. /* Bloqueio para Mudanças na conta */
  431. case 'j2':
  432.  
  433. if($user->authenticated == true)
  434. {
  435. $user->sendPacket('<logout />');
  436. return $this->disconnect($user->index);
  437. }
  438.  
  439. if($user->authenticate($packet) == false)
  440. {
  441. $user->sendPacket('<n t="You must re-login to be able to chat further." />');
  442. $user->sendPacket('<logout />');
  443. $this->disconnect($user->index);
  444. }
  445.  
  446. if($user->isAssigned($packet['c'], 220)){
  447. $user->sendPacket('<g u="'.$packet['u'].'" x="20048" />');
  448. }
  449. break;
  450.  
  451. /* Packet de desconexao */
  452. case 'l':
  453. $this->disconnect($user->index);
  454. break;
  455.  
  456.  
  457. case 'm': /* proteçao de desativar xat */
  458. if ($user->banned > time()) {
  459. return false;
  460. }
  461.  
  462. if (isset($this->protected[$user->chat])) {
  463. if ($this->protected[$user->chat]['end'] < time()) {
  464. unset($this->protected[$user->chat]);
  465. $user->sendRoom("<m t=\"A protecao do chat foi desativa
  466. pois ja se passarao 60 minutos.\" u=\"0\" />");
  467. } elseif ($this->protected[$user->chat]['type'] == 'noguest') {
  468. if ($user->rank == 5 || $user->rank == 40) {
  469. return false;
  470. }
  471. } elseif ($this->protected[$user->chat]['type'] == 'unreg') {
  472. if ($user->guest == true && in_array($user->rank, array(5, 40))) {
  473. return false;
  474. }
  475. }
  476. }
  477. $h_packet = $this->getAttribute($packet, 't');
  478. if($user->hasPower(51) && substr($h_packet, 0, 2) == '/h' && in_array($user->rank, array(1, 4))){
  479. $sec = substr($h_packet, 3, 2);
  480. (is_numeric($sec) && ($sec >= 10 && $sec <= 60)) ? $time2 = substr($h_packet, 3, 2) : '';
  481. switch(strtolower(substr($h_packet, 2, 1))){
  482. case 'g':
  483. /* Hush mutar cargos */
  484. foreach($this->users as &$u)
  485. {
  486. if(!empty($time2) && in_array($u->rank, array(5))){
  487. $time = strtotime("+ {$time2} seconds");
  488. $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
  489. $u->sendRoom('<m t="/gg'.$time2.'" u="' . $u->id . '" />', False, $u->id);
  490. $u->joinRoom($user->chat, false, true, 0);
  491. $u->banned = $time;
  492. }
  493. }
  494. return $time2 ? $user->sendRoom("<m u=\"{$user->id}\" t=\"(hush#w{$time2}) Hush: {$time2}s\" />") : false;
  495. break;
  496. case 'm':
  497. foreach($this->users as &$u)
  498. {
  499. if(!empty($time2) && in_array($u->rank, array(3, 5))){
  500. $time = strtotime("+ {$time2} seconds");
  501. $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
  502. $u->sendRoom('<m t="/gg'.$time2.'" u="' . $u->id . '" />', False, $u->id);
  503. $u->joinRoom($user->chat, false, true, 0);
  504. $u->banned = $time;
  505. }
  506. }
  507. return $time2 ? $user->sendRoom("<m u=\"{$user->id}\" t=\"(hush#w{$time2}) Hush: {$time2}s\" />") : false;
  508. break;
  509. case 'd':
  510. foreach($this->users as &$u)
  511. {
  512. if(!empty($time2) && in_array($u->rank, array(2, 3, 5))){
  513. $time = strtotime("+ {$time2} seconds");
  514. $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
  515. $u->sendRoom('<m t="/gg'.$time2.'" u="' . $u->id . '" />', False, $u->id);
  516. $u->joinRoom($user->chat, false, true, 0);
  517. $u->banned = $time;
  518. }
  519. }
  520. return $time2 ? $user->sendRoom("<m u=\"{$user->id}\" t=\"(hush#w{$time2}) Hush: {$time2}s\" />") : false;
  521. break;
  522. case 'o':
  523. if($user->rank != 1){ break; }
  524. foreach($this->users as &$u)
  525. {
  526. if(!empty($time2) && in_array($u->rank, array(2, 3, 4, 5))){
  527. $time = strtotime("+ {$time2} seconds");
  528. $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
  529. $u->sendRoom('<m t="/gg'.$time2.'" u="' . $u->id . '" />', False, $u->id);
  530. $u->f |= 0x0100;
  531. $u->joinRoom($user->chat, false, true, 0);
  532. $u->banned = $time;
  533. }
  534. }
  535. return $time2 ? $user->sendRoom("<m u=\"{$user->id}\" t=\"(hush#w{$time2}) Hush: {$time2}s\" />") : false;
  536. break;
  537. }
  538. }
  539. if (in_array($user->rank, array(5, 40)) && $user->guest == true) {
  540. if (!isset($this->rfilter[$user->chat])) {
  541. $this->rfilter[$user->chat] = array();
  542. }
  543.  
  544. $ctime = time() - 5;
  545. $count = 1;
  546. foreach ($this->rfilter[$user->chat] as $i => $time) {
  547. if ($ctime > $time) {
  548. unset($this->rfilter[$user->chat][$i]);
  549. continue;
  550. }
  551.  
  552. $count++;
  553. }
  554.  
  555. array_push($this->rfilter[$user->chat], time());
  556. if ($count >= 12) {
  557. $this->protected[$user->chat] = array('end' => time() + 3600, 'type' => 'unreg');
  558. $user->sendRoom("<m u=\"0\" t=\"Protecao do chat foi ativada!(Raid Detected)\" />");
  559. foreach ($this->users as $i => $u) {
  560. if ($u->chat == $user->chat && in_array($u->rank, array(5, 40)) && $u->guest == true) {
  561. $u->sendPacket('<n t="Protection ativada, chutando null users." />');
  562. $this->disconnect($u->index);
  563. }
  564. }
  565.  
  566. unset($this->rfilter[$user->chat]);
  567. }
  568. }
  569.  
  570. $message = $this->getAttribute($packet, 't');
  571.  
  572. if (empty($message)) {
  573. return false;
  574. } elseif (substr($message, 0, 2) == '/!') { // simbolo dos comandos <-- Pode usar Ctrl + f para encontrar <:
  575. $owner = in_array($user->id, $this->config->staff) ? true : false;
  576. $volunt = in_array($user->id, $this->config->volunteers) ? true : false;
  577. $args = explode(chr(32), substr($message, 2));
  578. switch (strtolower($args[0])) {
  579.  
  580. /* Comandos Staff e volunteers... */
  581.  
  582.  
  583. /* Troll user by antenor10 * para usar !troll ola modifica a id*/
  584. case 'troll';
  585. if($owner){
  586. if(strtolower($args[0]) == 'troll')
  587. {
  588. $shitthatiactuallyneed2 = $args[0];
  589. $user->sendRoom('<m t="' . $args[1] . ' ' . $args[2] . ' ' . $args[3] . ' ' . $args[4] . ' ' . $args[5] . ' ' . $args[6] . ' ' . $args[7] . ' ' . $args[8] . ' ' . $args[9] . ' ' . $args[10] . '" u="943567442" />');
  590.  
  591.  
  592. }
  593. return;
  594. }
  595. break;
  596.  
  597.  
  598.  
  599.  
  600. case 'users':
  601. if ($owner || $volunt ){
  602. $user->sendRoom('<n t="0" t="' . count($this->users) . ' currently online!" />');
  603. return;
  604. }
  605. break;
  606.  
  607. case 'setxats':
  608. if (count($args) != 3 || $owner){
  609. $uRow = $this->mysql->fetch_array('select `id`, `username`, `password` from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  610. if (count($uRow) == 1 && is_numeric($args[2])) {
  611. $this->mysql->query('update `users` set `xats`=' . $args[2] . ' where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  612. $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
  613. if ($_user != false) {
  614. $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
  615. }
  616. }
  617. return;
  618. }
  619. break;
  620.  
  621.  
  622. case 'setdays':
  623. if (count($args) != 3 || $owner){
  624. $uRow = $this->mysql->fetch_array('select `id`, `username`, `password` from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  625. if (count($uRow) == 1 && is_numeric($args[2]))
  626. {
  627. $this->mysql->query('update `users` set `days`=' . strtotime("+ " . $args[2] . " days") . ' where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  628. $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
  629. if ($_user != false)
  630. {
  631. $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
  632. }
  633. }
  634. return;
  635. }
  636. break;
  637.  
  638. /* IoNuT */
  639. case 'clears':
  640. if (!$owner) {
  641. break;
  642. }
  643. $this->mysql->query('truncate `messages`;');
  644. $user->sendPacket('<m t="Mesajele din mysql au fost sterse !" u="0" />');
  645. $this->disconnect($user->index);
  646. $user->sendRoom("<l u=\"{$u->id}\" />");
  647. break;
  648.  
  649. /* IoNuT */
  650. case 'us':
  651. if (!$owner) {
  652. break;
  653. }
  654. $this->mysql->query("delete from `users` where `username`=''");
  655. $user->sendPacket('<m t="Useri null au fost eliminati !" u="0" />');
  656. $this->disconnect($user->index);
  657. $user->sendRoom("<l u=\"{$u->id}\" />");
  658. break;
  659.  
  660.  
  661.  
  662.  
  663. /* Clear terminado by IoNuT */
  664. case 'clear':
  665. if($owner){
  666. $this->mysql->query( 'update `messages` set `visible`=0 where `id`=' . $user->chat . ';' );
  667. $user->sendRoom('<n t="0" t="Mensagens de xat limpas.(By ADM '.$user->username.')" />');
  668. $user->joinRoom( $user->chat, 1, True );
  669. foreach($this->users as &$u){
  670. $this->disconnect($u->index);
  671. }
  672. return;
  673. }
  674. break;
  675.  
  676.  
  677. /* powers status */
  678.  
  679.  
  680. case 'release':
  681. if($owner){
  682. $power = $args[1];
  683. $amount = $args[2];
  684. $this->mysql->query("UPDATE `powers` SET `amount`='" . $amount . "' WHERE `name`='" . $power . "'");
  685. $Mais = $amount == 1 ? "" : "s";
  686. $user->sendAll("<n t=\"{$amount} {$power}{$Mais} a fost limitata!\" />");
  687. return;
  688. }
  689. break;
  690.  
  691. case 'unrelease':
  692. if($owner){
  693. $power = $args[1];
  694. $amount = $args[2];
  695. $this->mysql->query("UPDATE `powers` SET `amount`='" . $amount . "' WHERE `name`='" . $power . "'");
  696. $Mais = $amount == 0 ? "" : "s";
  697. $user->sendAll("<n t=\"{$amount} {$power}{$Mais} a fost delimitata!\" />");
  698. return;
  699. }
  700. break;
  701.  
  702.  
  703.  
  704.  
  705. /* userip criado por ionut OBS: nao usar isso para derrubar a net das pessoas */
  706. case 'userip':
  707. if($owner){
  708. $uRow = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  709. $user->sendRoom("<n t=\"0\" t=\"Utilizatorul [".$args[1]."] are ip: ".$uRow[0]['connectedlast']."\" />");
  710. return;
  711. }
  712. break;
  713.  
  714.  
  715.  
  716.  
  717.  
  718. case 'resetrank':
  719. if($owner){
  720. $target = $args[1];
  721. $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `id`='".$target."';");
  722. $i = $t[0]['id'];
  723. $this->mysql->query("DELETE FROM `ranks` WHERE `userid`='".$i."';");
  724. $user->sendPacket('<n t="0" t="o cargo do id '.$target.' foi resetado." />');
  725. return;
  726. }
  727. break;
  728.  
  729.  
  730.  
  731.  
  732. case "global":
  733. if ($owner || $volunt ){
  734. $args = explode(' ', substr($message, 1), 2);
  735. $sum = "<n t=\"{$args[1]}\" />";
  736. $user->sendAll($sum);
  737. return;
  738. }
  739. break;
  740.  
  741.  
  742.  
  743. case 'limited':
  744. if($owner){
  745. $power = $args[1];
  746. $this->mysql->query("UPDATE `powers` SET `limited`='1' WHERE `name`='" . $power . "'");
  747. $user->sendRoom('<n t="0" t="o power [' . $power . '] agora e limitado!" i="0" />');
  748. return;
  749. }
  750. break;
  751.  
  752. case 'unlimited':
  753. if($owner){
  754. $power = $args[1];
  755. $this->mysql->query("UPDATE `powers` SET `limited`='0' WHERE `name`='" . $power . "'");
  756. $user->sendRoom('<n t="0" t="o power [' . $power . '] agora nao e mais limitado!" i="0" />');
  757. return;
  758. }
  759. break;
  760.  
  761.  
  762. case 'getmain':
  763. case 'delrank':
  764. If ( $owner )
  765. {
  766. $this->mysql->query( 'delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';' );
  767. If ( strtolower( $args[ 0 ] ) == 'getmain' )
  768. {
  769. $this->mysql->query( 'insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 1);' );
  770. } //strtolower( $args[ 0 ] ) == 'getmain'
  771. $this->disconnect( $user->index );
  772. } //$owner
  773. break;
  774.  
  775.  
  776. case 'setrank':
  777. if (!$owner) {
  778. break;
  779. }
  780.  
  781. switch ($s) {
  782. case "mod":
  783. case "moderator":
  784. $return = 2;
  785. break;
  786.  
  787. case "guest":
  788. $return = 5;
  789. break;
  790.  
  791. case "member":
  792. $return = 3;
  793. break;
  794.  
  795. case "owner":
  796. $return = 4;
  797. break;
  798. }
  799. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
  800. $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', ' . $return . ');');
  801. $this->disconnect($user->index);
  802. break;
  803.  
  804.  
  805.  
  806.  
  807.  
  808. case 'everypower':
  809. case 'nopowers':
  810. if (count($args) != 2 || !$owner) {
  811. break;
  812. }
  813. $uRow = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  814. if (count($uRow) == 1) {
  815. $this->mysql->query('delete from `userpowers` where `userid`=' . $uRow[0]['id'] . ';');
  816. if (strtolower($args[0]) == 'everypower') {
  817. $powers = $this->mysql->fetch_array('select `id`, `name` from `powers` where `name` not like \'%(Undefined)%\' and `subid`<2147483647;');
  818. $inputs = '';
  819. foreach ($powers as $power) {
  820. if (!is_numeric($power['name'])) {
  821. $inputs .= '(' . $uRow[0]['id'] . ', ' . $power['id'] . ', 1),';
  822. }
  823. }
  824. $this->mysql->query('insert into `userpowers` (`userid`, `powerid`, `count`) values ' . substr($inputs, 0, -1) . ';');
  825. }
  826.  
  827. $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
  828. if ($_user != false) {
  829. $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
  830. }
  831. }
  832. break;
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844. /* Everypower - nopowers melhorado editado por ionut */
  845. case 'gold':
  846. case 'nogold':
  847. if (count($args) != 2 || $owner){
  848. $uRow = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  849. if (count($uRow) == 1) {
  850. $this->mysql->query('delete from `userpowers` where `userid`=' . $uRow[0]['id'] . ';');
  851. if (strtolower($args[0]) == 'every') {
  852. $powers = $this->mysql->fetch_array('select `id`, `name` from `powers` where `name` not like \'%(Undefined)%\' and name !=\'black\' and name !=\'pawnglow\' and name !=\'everycolor\' and name !=\'awesome\' and name !=\'firepawn\' and name !=\'lolpawn\' and name !=\'madpawn\' and name !=\'silver\' and name !=\'reggae\' and name !=\'blitz\' and name !=\'summerpawn\' and name !=\'stormpawn\' and name !=\'tecno\' and name !=\'worldpawn\' and name !=\'tecno\' and name !=\'rainbow\' and name !=\'desertground\' and name !=\'sapphire\' and name !=\'bobmarley\' and name !=\'fadepawn\' and name !=\'celebridade\' and name !=\'electroglow\' and name !=\'invisible\' and name !=\'electroglow\' and name !=\'esmerald\' and name !=\'cyclepawn\' and name !=\'wxpawn\' and name !=\'randomcolor\' and name !=\'remp\' and name !=\'gunny\' and name !=\'timao\' and name !=\'electrox\' and name !=\'yellow\' and name !=\'flashrank\' and name !=\'xavi\' and `subid`<2147483647;');
  853. $inputs = '';
  854. foreach ($powers as $power) {
  855. if (!is_numeric($power['name'])) {
  856. $inputs .= '(' . $uRow[0]['id'] . ', ' . $power['id'] . ', 1),';
  857. }
  858. }
  859. $this->mysql->query('insert into `userpowers` (`userid`, `powerid`, `count`) values ' . substr($inputs, 0, -1) . ';');
  860. }
  861.  
  862. $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
  863. if ($_user != false) {
  864. $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
  865. }
  866. }
  867. return;
  868. }
  869. break;
  870.  
  871.  
  872.  
  873.  
  874. case 'addpower':
  875. case 'delpower':
  876. if (count($args) == 3 && $owner){
  877. $_user = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  878. $power = $this->mysql->fetch_array('select * from `powers` where `name`=\'' . $this->mysql->sanatize($args[2]) . '\';');
  879. if (empty($_user) || empty($power)) {
  880. break;
  881. }
  882. $this->mysql->query('delete from `userpowers` where `userid`=' . $_user[0]['id'] . ' and `powerid`=' . $power[0]['id'] . ';');
  883. if (strtolower($args[0]) == 'addpower') {
  884. $this->mysql->query('insert into `userpowers`(`userid`, `powerid`, `count`) values(' . $_user[0]['id'] . ', ' . $power[0]['id'] . ', 1);');
  885. }
  886.  
  887. $online = $this->getuserbyid($_user[0]['id']);
  888. if (is_object($online)) {
  889. $online->sendPacket($this->doLogin($_user[0]['username'], $_user[0]['password']));
  890. }
  891. }
  892. return;
  893. break;
  894.  
  895. case 'price':
  896. if ($owner || $volunt ){
  897. $price = $this->mysql->fetch_array("SELECT * FROM `powers` WHERE `name`='".$args[1]."'");
  898. $shitthatiactuallyneed = $price[0]['cost'];
  899. $user->sendRoom('<n t="Pretul puteri ['.$args[1].'] este de '.$shitthatiactuallyneed.'" u="1" />');
  900. return;
  901. }
  902. break;
  903.  
  904. /* Global de descriçao do power criado por antenor10 */
  905. case 'power':
  906. if ($owner || $volunt ){
  907. $pinfo = $this->mysql->fetch_array("SELECT * FROM `powers` WHERE `name`='".$args[1]."'");
  908. $desc = $pinfo[0]['description'];
  909. $user->sendRoom('<n t="Descrierea puteri ['.$args[1].'] - '.$desc.'" u="0" />');
  910. return;
  911. }
  912. break;
  913.  
  914.  
  915.  
  916. case 'setcost':
  917. if($owner){
  918. $power = $args[1];
  919. $this->mysql->query("UPDATE `powers` SET `cost`='".$args[2]."' WHERE `name`='".$power."'");
  920. $user->sendRoom('<n t="0" t="Power ['.$power.'] Foi mudado o preco para ['.$args[2].']" i="0" />');
  921. return;
  922. }
  923. break;
  924.  
  925.  
  926. case 'reset':
  927. if($owner){
  928. $target = $args[1];
  929. $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `username`='".$target."';");
  930. $i = $t[0]['id'];
  931. $ray = floor(floor($id)) * 100 / 2;
  932. $inf = base64_encode(serialize(base64_encode($ray)));
  933. $this->mysql->query("DELETE FROM `userpowers` WHERE `userid`='".$i."';");
  934. $this->mysql->query("DELETE FROM `ranks` WHERE `userid`='".$i."';");
  935. if($user->id == '1' OR '-1')
  936. {
  937. $this->mysql->query("INSERT INTO torches(id, torchedBy, reason, ray_id) VALUES ('".$i."', '".$user->username."', 'Torched by an Administrator for unlisted reasons.', '".$inf."');");
  938. } else {
  939. $this->mysql->query("INSERT INTO torches(id, torchedBy, reason, ray_id) VALUES ('".$i."', '".$user->username."', 'Reason Unlistd.', '".$inf."');");
  940. }
  941. $user->sendPacket('<n t="USUARIO '.$target.' FOI RESETADO." />');
  942. return;
  943. }
  944. break;
  945.  
  946. case 'torch': // Torching
  947. if($owner){
  948. $usr = $args[1];
  949. $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `id`='".$usr."';");
  950. $this->mysql->query("UPDATE `users` SET `torched`='1' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
  951. $i = $t[0]['id'];
  952. $ray = floor(floor($id)) * 100 / 2;
  953. $inf = base64_encode(serialize(base64_encode($ray)));
  954. if($user->id == '1' OR '-1')
  955. {
  956. $this->mysql->query("INSERT INTO torches(id, torchedBy, reason, ray_id) VALUES ('".$i."', '".$user->username."', 'Torched by an Administrator for unlisted reasons.', '".$inf."');");
  957. } else {
  958. $this->mysql->query("INSERT INTO torches(id, torchedBy, reason, ray_id) VALUES ('".$i."', '".$user->username."', 'Reason Unlistd.', '".$inf."');");
  959. }
  960. $user->sendRoom('<m u="0" t="Torched Activado en el ID: [' . $usr . '] :)" i="0" />');
  961. return;
  962. }
  963. break;
  964.  
  965. case 'untorch': // UNTorching
  966. if($owner){
  967. $usr = $args[1];
  968. $this->mysql->query("UPDATE `users` SET `torched`='0' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
  969. $user->sendRoom('<m u="0" t="Torched Desactivado en el ID: [' . $usr . '] :)" i="0" />');
  970. return;
  971. }
  972. break;
  973.  
  974.  
  975.  
  976. case 'fundo': // Fixado Vulnabilidade
  977. if($user->id == -1)
  978. if($owner){
  979. $arg1 = $args[1];
  980. $this->mysql->query("UPDATE `chats` SET `bg`='{$arg1}' WHERE `id`='".$user->chat."'");
  981. $user->sendPacket('<m u="0" t="agora o Fundo é '.$arg1.'" i="0" />');
  982. return;
  983. }
  984. break;
  985.  
  986.  
  987. case 'setid': // Setid terminado
  988. if($user->id == -1 || $user->id == 1)
  989. if (count($args) == 3 && is_numeric($args[2]) && $owner){
  990. $_user = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  991. $_test = $this->mysql->fetch_array('select * from `users` where `id`=\'' . $this->mysql->sanatize($args[2]) . '\';');
  992.  
  993. if (!empty($_test)) {
  994. $user->sendPacket('<m t="essa id é tomada por ' . $_test[0]['username'] . '" u="0" />');
  995. break;
  996. }
  997.  
  998. if (empty($_user)) {
  999. $user->sendPacket('<m t="esse usuario nao existe" u="0" />');
  1000. break;
  1001. }
  1002.  
  1003. $this->mysql->query('update `users` set `id`=' . $this->mysql->sanatize($args[2]) . ' where `id`=' . $_user[0]['id'] . ';');
  1004. $this->mysql->query('update `ranks` set `userid`=' . $this->mysql->sanatize($args[2]) . ' where `userid`=' . $_user[0]['id'] . ';');
  1005. $this->mysql->query('update `userpowers` set `userid`=' . $this->mysql->sanatize($args[2]) . ' where `userid`=' . $_user[0]['id'] . ';');
  1006.  
  1007. $online = $this->getuserbyid($_user[0]['id']);
  1008. if (is_object($online)) {
  1009. $online->sendPacket($this->doLogin($_user[0]['username'], $_user[0]['password']));
  1010. }
  1011. }
  1012. return;
  1013. break;
  1014.  
  1015.  
  1016. /* Rchat by kayabe */
  1017. case 'rchat':
  1018. if($user->id == 1)
  1019. if (count($args) != 2 || $owner) {
  1020. $cRow = $this->mysql->fetch_array('select * from `chats` where `name`=\'' . $this->mysql->sanatize($args[1]) . '\';');
  1021. if (count($cRow) == 1) {
  1022. $this->mysql->query('delete from `ranks` where `chatid`=' . $cRow[0]['id'] . ';');
  1023. $sum = "<n t=\"Chat {$args[1]} Foi Resetado\" />";
  1024. $user->sendAll($sum);
  1025. foreach($this->users as &$u){
  1026. $this->disconnect($u->index);
  1027. }
  1028. }
  1029. }
  1030. return;
  1031. break;
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038. /* forcerank by ionut */
  1039. case 'forcerank':
  1040. if ($owner) {
  1041. $arg1 = $args[1];
  1042. $target = $args[1];
  1043. $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `username`='".$target."';");
  1044. $returnmain = 1;
  1045. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`='.$arg1.';');
  1046. $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values('.$arg1.', ' . $user->chat . ', ' . $returnmain . ');');
  1047. $user->sendRoom('<n t="foi dado mainowner a '.$target.'." />');
  1048. return;
  1049. }
  1050. break;
  1051.  
  1052. /* forcedel by ionut para deletar mainowner */
  1053. case 'forcedel':
  1054. if ($owner) {
  1055. $arg1 = $args[1];
  1056. $target = $args[1];
  1057. $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `username`='".$target."';");
  1058. $returnguest = 0;
  1059. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`='.$arg1.';');
  1060. $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values('.$arg1.', ' . $user->chat . ', ' . $returnguest . ');');
  1061. $user->sendRoom('<n t="foi excluido o mainowner do id '.$target.'." />');
  1062. return;
  1063. }
  1064. break;
  1065.  
  1066. /* auto ranks */
  1067. case 'mainowner':
  1068. if ($owner || $volunt ){
  1069. if (strtolower($args[0]) == 'mainowner') {
  1070. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
  1071. $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 1);');
  1072. }
  1073. $this->disconnect($user->index);
  1074. return;
  1075. }
  1076. break;
  1077.  
  1078.  
  1079.  
  1080. case 'owner':
  1081. if ($owner || $volunt ){
  1082. if (strtolower($args[0]) == 'owner'){
  1083. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
  1084. $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 4);');
  1085. }
  1086. $this->disconnect($user->index);
  1087. return;
  1088. }
  1089. break;
  1090.  
  1091. case 'moderator':
  1092. if ($owner || $volunt ){
  1093. if (strtolower($args[0]) == 'moderator'){
  1094. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
  1095. $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 2);');
  1096. }
  1097. $this->disconnect($user->index);
  1098. return;
  1099. }
  1100. break;
  1101.  
  1102.  
  1103. case 'member':
  1104. if ($owner || $volunt ){
  1105. if (strtolower($args[0]) == 'member'){
  1106.  
  1107. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
  1108. $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 3);');
  1109. }
  1110. $this->disconnect($user->index);
  1111. return;
  1112. }
  1113. break;
  1114.  
  1115.  
  1116. case 'guest':
  1117. if ($owner || $volunt ){
  1118. if (strtolower($args[0]) == 'guest'){
  1119.  
  1120. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
  1121. }
  1122. $this->disconnect($user->index);
  1123. return;
  1124. }
  1125. break;
  1126. /* fim dos comandos começo das funçoes xat */
  1127.  
  1128. }
  1129.  
  1130. } elseif (substr($message, 0, 1) == "/") { // away
  1131. if ($message == '/away' && $user->hasPower(144)) {
  1132. $user->f |= 0x4000;
  1133. $user->joinRoom($user->chat, false, true, $user->pool);
  1134. return;
  1135. } elseif ($message == '/back') {
  1136. if ($user->f & 0x4000 && $user->hasPower(144)) {
  1137. $user->f -= 0x4000;
  1138. $user->joinRoom($user->chat, false, true, $user->pool);
  1139. }
  1140.  
  1141. return;
  1142. } else {
  1143. $args = explode(chr(32), substr($message, 2));
  1144.  
  1145. switch (strtolower(substr($message, 1, 1))) {
  1146. case 'd':
  1147. if (in_array($user->rank, array(1, 2, 4))) {
  1148. $mid = substr($message, 2);
  1149.  
  1150. if (is_numeric($mid)) {
  1151. $res = $this->mysql->query('update `messages` set `visible`=0 where `id`=' . $user->chat . ' and `mid`=' . $mid . ';');
  1152. if ($res) {
  1153. $user->sendRoom('<m t="/' . $mid . '" u="0" />');
  1154. unset($user->last['m']);
  1155. }
  1156. } elseif ($mid == 'clear') {
  1157. $res = $this->mysql->query('update `messages` set `visible`=0 where `id`=' . $user->chat . ';');
  1158. }
  1159. }
  1160. return;
  1161. /* Proteçao xat */
  1162. case 'p':
  1163. if ($user->rank == 1 || $user->rank == 4) {
  1164. if (!isset($this->protected[$user->chat])) {
  1165. $user->sendRoom("<m u=\"0\" t=\"Protectia a fost activata pentru 60 minute!({$user->id})\" />");
  1166. $this->protected[$user->chat] = array("end" => (time() + 3600), "type" => 'noguest');
  1167. return false;
  1168. } else {
  1169. unset($this->protected[$user->chat]);
  1170. $user->sendRoom("<m u=\"0\" t=\"Protectie dezactivata!({$user->id})\" />");
  1171. return false;
  1172. }
  1173. }
  1174. break;
  1175. /* ADD amigos */
  1176. case 'f':
  1177. if($user->username != '')
  1178. {
  1179. $friend = substr($message, 2);
  1180.  
  1181. if(!is_numeric($friend) || strlen($friend) > 15 || $friend == 0 || $friend == 2){ return false; }
  1182.  
  1183. $check = $this->mysql->fetch_array("select id from `users` where `id`='{$this->mysql->sanatize($friend)}';");
  1184. if(empty($check)){ return false; }
  1185.  
  1186. $check = $this->mysql->fetch_array("select id from `friends` where `user`='{$user->id}' and `friend`='{$friend}';");
  1187. if(!empty($check)){ return false; }
  1188.  
  1189. $this->mysql->query("insert into `friends` (`id`, `user`, `friend`) values (NULL, '{$user->id}', '{$friend}');");
  1190. }
  1191. break;
  1192. /* rodape xat */
  1193. case 's':
  1194. if ($user->rank != 1) {
  1195. return false;
  1196. }
  1197. $scroll = $this->mysql->sanatize(htmlspecialchars(substr($message, 2), ENT_QUOTES));
  1198. $this->mysql->query("update `chats` set `sc` = '{$scroll}' where `name` = '{$user->group}';");
  1199. $user->sendRoom("<m u=\"{$user->id}\" t=\"/s" . str_replace('"', '', htmlspecialchars_decode(stripslashes($scroll))) . "\" />");
  1200. break;
  1201. /* Guestself faça /g quando tiver o power */
  1202. case 'g':
  1203. if ($user->hasPower(32)) {
  1204. $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
  1205. $user->joinRoom($user->chat, 0, true);
  1206. }
  1207. break;
  1208. /* Ranklock by IoNuT */
  1209. case 'r':
  1210. if(count($args) == 3){
  1211. if(!is_numeric($args[1])) { break; }
  1212. $ranks = $this->mysql->fetch_array('select * from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $args[1] . ';');
  1213. if(in_array($user->rank, array(1, 4)) && in_array($args[2], array('guest', 'member', 'mod', 'owner', 'off')) && $this->higherRank($user->rank, $ranks[0]['f'], true) && substr($message, 0, 2) == '/r' && $user->hasPower(394)){
  1214. $args[2] == 'off' ? $lock = 0 : $lock = 1;
  1215. $this->mysql->query("update `ranks` set `locked`='{$lock}' where `chatid`='{$user->chat}' and `userid`='{$args[1]}';");
  1216. return $user->sendPacket('<m t="' . $args[1] . ' ranklock: ' . $args[2] . '" u="0" />');
  1217. }
  1218. }
  1219. elseif(count($args) == 2){
  1220. if(!is_numeric($args[1])) { break; }
  1221. $ranks = $this->mysql->fetch_array('select * from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $args[1] . ';');
  1222. if(in_array($user->rank, array(1, 4)) && $this->higherRank($user->rank, $ranks[0]['f'], true) && substr($message, 0, 2) == '/r' && $user->hasPower(394)){
  1223. $this->mysql->query("update `ranks` set `locked`='0' where `chatid`='{$user->chat}' and `userid`='{$args[1]}';");
  1224. return $user->sendPacket('<m t="' . $args[1] . ' ranklock: off" u="0" />');
  1225. }
  1226. }
  1227. break;
  1228.  
  1229. default:
  1230. $user->message($message);
  1231. return false;
  1232. }
  1233. }
  1234. }
  1235.  
  1236. if ($this->spamfilter($tag, $user, 700))
  1237. break;
  1238. $this->mysql->query("insert into `messages` (`id`, `uid`, `message`, `name`, `registered`, `avatar`, `time`, `pool`) values ('{$this->mysql->sanatize($user->chat)}', '{$this->mysql->sanatize($user->id)}', '{$this->mysql->sanatize($message)}', '{$this->mysql->sanatize($user->nickname)}', '{$this->mysql->sanatize($user->username)}', '{$this->mysql->sanatize($user->avatar)}', '" . time() . "', '{$this->mysql->sanatize($user->pool)}');");
  1239. $user->message($message);
  1240. $user->last = array();
  1241. break;
  1242.  
  1243.  
  1244. /* Trade Atualizado */
  1245. case 'x':
  1246. $attr = $this->getMultiAttr($packet, array('x', 's', 'b', 'm', 'p', 'k', 'f', 'i', 'u', 'd', 't'));
  1247. if($attr['i'] == '30008' && $attr['u'] && $attr['d'] && $attr['t'])
  1248. {
  1249. $tradee = $this->getUserByID($attr['d'], $user->chat);
  1250.  
  1251. if(is_object($tradee))
  1252. {
  1253. if(substr($attr['t'], 0, 1) == 'T')
  1254. {
  1255. if(isset($tradee->trade[$user->id]))
  1256. {
  1257. $trade = explode(',', $attr['t']);
  1258. if(count($trade) == 4)
  1259. {
  1260. $tdata = explode(';', $trade[1]);
  1261. $tusr2 = explode(';', $trade[2]);
  1262.  
  1263. if(count($tdata) == 3 && count($tusr2) == 3)
  1264. {
  1265. if(!is_numeric($tdata[0]) || !is_numeric($tdata[1])){ break; }
  1266. elseif(!$this->mysql->checkPass($trade[3], $user->password))
  1267. {
  1268. $user->sendPacket('<x i="30008" t="E,8,1" />');
  1269. $tradee->sendPacket('<x i="30008" t="E,1,8" />');
  1270. }
  1271. elseif($user->banned)
  1272. {
  1273. $user->sendPacket('<x i="30008" t="E,13,1" />');
  1274. $tradee->sendPacket('<x i="30008" t="E,1,13" />');
  1275. }
  1276. elseif($tdata[0] > $user->xats || $tdata[0] < 0)
  1277. {
  1278. $user->sendPacket('<x i="30008" t="E,11,1" />');
  1279. $tradee->sendPacket('<x i="30008" t="E,1,11" />');
  1280. }
  1281. elseif($tdata[1] > $user->days || $tdata[1] < 0)
  1282. {
  1283. $user->sendPacket('<x i="30008" t="E,18,1" />');
  1284. $tradee->sendPacket('<x i="30008" t="E,1,18" />');
  1285. } else {
  1286. if($tusr2 != $tradee->trade[$user->id][1] || $tdata != $tradee->trade[$user->id][2])
  1287. {
  1288. $user->sendPacket('<n t="An error occured while trading, did something change?" />');
  1289. $tradee->sendPacket('<n t="An error occured while trading, did something change?" />');
  1290. } else {
  1291. $reset0 = $this->mysql->fetch_array('select `xats`, `days`, `password` from `users` where `id`=' . $user->id . ';');
  1292. $reset1 = $this->mysql->fetch_array('select `xats`, `days`, `password` from `users` where `id`=' . $tradee->id . ';');
  1293. $u1powers = $this->mysql->fetch_array('select * from `userpowers` where `userid`=' . $user->id);
  1294. $u2powers = $this->mysql->fetch_array('select * from `userpowers` where `userid`=' . $tradee->id);
  1295. $u1p = $u2p = $u1p0 = $u2p0 = array();
  1296. $u1t = $u2t = array(array(), array());
  1297. $user->xats = $reset0[0]['xats'];
  1298. $tradee->xats = $reset1[0]['xats'];
  1299. $user->days = floor(($reset0[0]['days'] - time()) / 86400 + 0.3);
  1300. $tradee->days = floor(($reset1[0]['days'] - time()) / 86400 + 0.3);
  1301.  
  1302. foreach($u1powers as $i => $u) $u1p[$u['powerid']] = $u['count'];
  1303. foreach($u2powers as $i => $u) $u2p[$u['powerid']] = $u['count'];
  1304. $u1trade = explode('|', $tdata[2]);
  1305. $u2trade = explode('|', $tradee->trade[$user->id][1][2]);
  1306. $u1p0 = $u1p; $u2p0 = $u2p;
  1307.  
  1308. foreach($u1trade as $i => $u)
  1309. {
  1310. $power = explode('=', $u);
  1311. if(count($power) == 2)
  1312. {
  1313. if(isset($u1p[$power[0]]) && $u1p[$power[0]] >= $power[1])
  1314. {
  1315. $u1p[$power[0]] = $u1p[$power[0]] - $power[1];
  1316. $u2p[$power[0]] = isset($u2p[$power[0]]) ? ($u2p[$power[0]] + $power[1]) : $power[1];
  1317. } else {
  1318. $user->sendPacket('<x i="30008" t="E,33,1" />');
  1319. $tradee->sendPacket('<x i="30008" t="E,1,33" />');
  1320. break;
  1321. }
  1322. }
  1323. }
  1324.  
  1325. foreach($u2trade as $i => $u)
  1326. {
  1327. $power = explode('=', $u);
  1328. if(count($power) == 2)
  1329. {
  1330. if(isset($u2p[$power[0]]) && $u2p[$power[0]] >= $power[1])
  1331. {
  1332. $u2p[$power[0]] = $u2p[$power[0]] - $power[1];
  1333. $u1p[$power[0]] = isset($u1p[$power[0]]) ? ($u1p[$power[0]] + $power[1]) : $power[1];
  1334. } else {
  1335. $tradee->sendPacket('<x i="30008" t="E,33,1" />');
  1336. $user->sendPacket('<x i="30008" t="E,1,33" />');
  1337. break;
  1338. }
  1339. }
  1340. }
  1341.  
  1342. $user->xats += $tradee->trade[$user->id][1][0];
  1343. $tradee->xats -= $tradee->trade[$user->id][1][0];
  1344.  
  1345. $user->xats -= $tdata[0];
  1346. $tradee->xats += $tdata[0];
  1347.  
  1348. $user->days -= $tdata[1];
  1349. $tradee->days += $tdata[1];
  1350.  
  1351. $tradee->days -= $tradee->trade[$user->id][1][1];
  1352. $user->days += $tradee->trade[$user->id][1][1];
  1353.  
  1354. $u1d = time() + ($user->days * 86400);
  1355. $u2d = time() + ($tradee->days * 86400);
  1356.  
  1357. $this->mysql->query('update `users` set `xats`=' . $user->xats . ', `days`=' . $u1d . ' where `id`=' . $user->id . ';');
  1358. $this->mysql->query('update `users` set `xats`=' . $tradee->xats . ', `days`=' . $u2d . ' where `id`=' . $tradee->id . ';');
  1359.  
  1360. foreach($u1p as $id => $count)
  1361. {
  1362. if($count < 1)
  1363. {
  1364. $this->mysql->query('delete from `userpowers` where `userid`=' . $user->id . ' and `powerid`=' . $id . ';');
  1365. }
  1366. elseif(isset($u1p0[$id]))
  1367. {
  1368. $this->mysql->query('update `userpowers` set `count`=' . $count . ' where `userid`=' . $user->id . ' and `powerid`=' . $id . ';');
  1369. } else {
  1370. $this->mysql->query('insert into `userpowers`(`userid`, `powerid`, `count`) values(' . $user->id . ', ' . $id . ', ' . $count . ');');
  1371. }
  1372. }
  1373.  
  1374. foreach($u2p as $id => $count)
  1375. {
  1376. if($count < 1)
  1377. {
  1378. $this->mysql->query('delete from `userpowers` where `userid`=' . $tradee->id . ' and `powerid`=' . $id . ';');
  1379. }
  1380. elseif(isset($u2p0[$id]))
  1381. {
  1382. $this->mysql->query('update `userpowers` set `count`=' . $count . ' where `userid`=' . $tradee->id . ' and `powerid`=' . $id . ';');
  1383. } else {
  1384. $this->mysql->query('insert into `userpowers`(`userid`, `powerid`, `count`) values(' . $tradee->id . ', ' . $id . ', ' . $count . ');');
  1385. }
  1386. }
  1387. }
  1388.  
  1389. $user->sendPacket('<x i="30008" t="E" />');
  1390. $tradee->sendPacket('<x i="30008" t="E" />');
  1391. $data1 = $this->doLogin($user->username, $user->password);
  1392. $data2 = $this->doLogin($tradee->username, $tradee->password);
  1393. $user->sendPacket($data1);
  1394. $tradee->sendPacket($data2);
  1395. }
  1396. }
  1397. }
  1398. } else {
  1399. $trade = explode(',', $attr['t']);
  1400. if(count($trade) == 4)
  1401. {
  1402. $tdata = explode(';', $trade[1]);
  1403. $tdu2 = explode(';', $trade[2]);
  1404. if(count($tdata) == 3 && count($tdu2) == 3)
  1405. {
  1406. if(!is_numeric($tdata[0]) || !is_numeric($tdata[1])){ break; }
  1407. elseif(!$this->mysql->checkPass($trade[3], $user->password))
  1408. {
  1409. $user->sendPacket('<x i="30008" t="E,8,1" />');
  1410. $tradee->sendPacket('<x i="30008" t="E,1,8" />');
  1411. }
  1412. elseif($user->banned)
  1413. {
  1414. $user->sendPacket('<x i="30008" t="E,13,1" />');
  1415. $tradee->sendPacket('<x i="30008" t="E,1,13" />');
  1416. }
  1417. elseif($tdata[0] > $user->xats || $tdata[0] < 0)
  1418. {
  1419. $user->sendPacket('<x i="30008" t="E,11,1" />');
  1420. $tradee->sendPacket('<x i="30008" t="E,1,11" />');
  1421. }
  1422. elseif($tdata[1] > $user->days || $tdata[1] < 0)
  1423. {
  1424. $user->sendPacket('<x i="30008" t="E,18,1" />');
  1425. $tradee->sendPacket('<x i="30008" t="E,1,18" />');
  1426. } else {
  1427. $user->trade[$tradee->id] = array($trade, $tdata, $tdu2);
  1428. }
  1429. }
  1430. }
  1431. }
  1432. }
  1433. }
  1434. break;
  1435. } else {
  1436. $x = $attr['x'];
  1437. $s = $attr['s'];
  1438. $b = $attr['b'];
  1439. $m = $attr['m'];
  1440. $p = $attr['p'];
  1441. $k = $attr['k'];
  1442. $f = $attr['f'];
  1443. $i = $attr['i'];
  1444. $user->sendPacket("<x i=\"{$i}\" u=\"{$user->id}\" b=\"{$b}\" x=\"{$x}\" t=\"{$m}\" />");
  1445. }
  1446. break;
  1447.  
  1448. /* funçao para ativar e desativar powers */
  1449. case 'ap':
  1450. $attributes = array('p', 'a');
  1451. $attributes = $this->getMultiAttr($packet, $attributes);
  1452. $p = $attributes["p"];
  1453. $a = $attributes["a"];
  1454. $power = $this->mysql->fetch_array("SELECT * FROM `powers` WHERE `id`='{$this->mysql->sanatize($p)}';");
  1455. $double = $this->mysql->fetch_array( "SELECT * FROM `userpowers` WHERE `powerid`='{$this->mysql->sanatize($p)}' AND `userid`='{$user->id}';" );
  1456. $count = $this->mysql->fetch_array("SELECT * FROM `group_powers` WHERE `group`='{$user->group}' and `power`='{$this->mysql->sanatize($p)}' AND `assignedBy`='{$user->id}';" );
  1457. switch($a)
  1458. {
  1459. case '1':
  1460. $flixs = array(92, 96, 98, 102, 108, 148, 156, 278, 297);
  1461. if(isset($double[0]['count']) && isset($count[0]['count']) && ($double[0]['count'] < $count[0]['count'] + 1) && ($count[0]['count'] < 32) && in_array($p, $flixs))
  1462. {
  1463. $user->sendPacket("<ap p=\"{$p}\" r=\"3\" />");
  1464. break;
  1465. }
  1466. $s = $this->mysql->fetch_array("SELECT * FROM `group_powers` WHERE `group`='{$user->group}' AND `power`='{$p}';");
  1467. if(!empty($s) && (!in_array($p, $flixs) && isset($double[0]['count']) && $count[0]['count'] > 32))
  1468. {
  1469. $user->sendPacket("<ap p=\"{$p}\" r=\"4\" />");
  1470. break;
  1471. }
  1472. if(empty($s))
  1473. {
  1474. $this->mysql->query("INSERT INTO group_powers(`group`,`power`,`assignedBy`) VALUES ('{$user->group}', '{$p}', '{$user->id}');");
  1475. $user->sendPacket("<ap p=\"{$p}\" r=\"1\" />");
  1476. }
  1477. elseif(isset($double[0]['count']) && ($count[0]['count'] >= 1 && $count[0]['count'] < 32) && in_array($p, $flixs))
  1478. {
  1479. $this->mysql->query("UPDATE `group_powers` SET `count`=`count`+1 WHERE `group`='{$user->group}' and `power`='{$p}' and `assignedBy`='{$user->id}';");
  1480. $user->sendPacket("<ap p=\"{$p}\" r=\"1\" />");
  1481. } else {
  1482. $user->sendPacket("<ap p=\"{$p}\" r=\"4\" />");
  1483. }
  1484. break;
  1485.  
  1486. case '0':
  1487. $i = $this->mysql->fetch_array("SELECT * FROM `group_powers` WHERE `assignedBy`='{$user->id}' AND `group`='{$user->group}' and `power`='{$p}';");
  1488. if(empty($i))
  1489. {
  1490. $user->sendPacket("<ap p=\"{$p}\" r=\"2\" />");
  1491. break;
  1492. }
  1493. if($i[0]['count'] == 1)
  1494. {
  1495. $this->mysql->query("DELETE FROM `group_powers` WHERE `assignedBy`='{$user->id}' AND `group`='{$user->group}' AND `power`='{$p}';");
  1496. $user->sendPacket("<ap p=\"{$p}\" r=\"0\" />");
  1497. }
  1498. elseif($i[0]['count'] <= 32)
  1499. {
  1500. $this->mysql->query("UPDATE `group_powers` SET `count`=`count`-1 WHERE `group`='{$user->group}' and `assignedBy`='{$user->id}' and `power`='{$p}';");
  1501. $user->sendPacket("<ap p=\"{$p}\" r=\"0\" />");
  1502. }
  1503. break;
  1504. }
  1505. break;
  1506.  
  1507. /* kiss xat */
  1508. case 'a':
  1509. if($this->spamfilter($tag, $user, $this->config->spam_wait) || $user->banned > time()) { break; }
  1510. if($user->guest == true) { return false; }
  1511.  
  1512. $attributes = array('x', 's', 'b', 'm', 'p', 'k', 'f');
  1513. $attributes = $this->getMultiAttr($packet, $attributes);
  1514. $x = $attributes['x'];
  1515. $s = $attributes['s'];
  1516. $b = $attributes['b'];
  1517. $m = $attributes['m'];
  1518. $p = $attributes['p'];
  1519. $k = $attributes['k'];
  1520. $f = $attributes['f'];
  1521.  
  1522. if(!$b && !$f)
  1523. {
  1524. if($user->xats < 25)
  1525. {
  1526. return $user->sendPacket('<m t="/wYou don\'t have enough xats!" u="0" />');
  1527. }
  1528.  
  1529. $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
  1530. $usr = $usr[0];
  1531. if(!$this->mysql->checkPass($p, $usr['password']))
  1532. {
  1533. return $user->sendPacket('<v e="8" />');
  1534. }
  1535.  
  1536. $user->xats = ($usr['xats'] - 25);
  1537. $this->mysql->query("update `users` set `xats` = '{$user->xats}', `reserve`=`reserve`-25 where `id` = '{$user->id}';");
  1538. $user->sendRoom("<a u=\"{$user->id}\" k=\"{$k}\" t=\"{$m}\" />", true);
  1539. $user->sendPacket("<a u=\"{$user->id}\" k=\"{$k}\" t=\"{$m}\" c=\"{$user->xats}\" />");
  1540. /* fim do kiss xat */
  1541. } else {
  1542. switch($k)
  1543. {
  1544. /* married e bff terminado e divorce terminado */
  1545. case 'Confetti':
  1546. case 'Hearts':
  1547. case 'Marriage':
  1548. case 'Marry':
  1549. case 'Rings':
  1550. case 'Sunset':
  1551. if($user->d2 != 0)
  1552. {
  1553. $user->sendPacket('<n t="/wYou already have a BFF or are married." u="0" />');
  1554. break;
  1555. }
  1556. if($user->id == $b)
  1557. {
  1558. $user->sendPacket('<n t="/wYou can\'t marry yourself" u="0" />');
  1559. break;
  1560. }
  1561. $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
  1562. $usr = $usr[0];
  1563. if(!$this->mysql->checkPass($p, $usr['password']))
  1564. {
  1565. return $user->sendPacket('<v e="8" />');
  1566. }
  1567. if($user->xats < 200)
  1568. {
  1569. $user->sendPacket('<v e="11" />');
  1570. break;
  1571. }
  1572. $u = $this->getUserByID($b, $user->chat);
  1573. if(!is_object($u)) { break; }
  1574. if($u->hasPower(99))
  1575. {
  1576. return $user->sendPacket('<n t="' . $u->id . ' has single power." />');
  1577. }
  1578. $user->xats = ($usr['xats'] - 200);
  1579. if($u->d2 != 0)
  1580. {
  1581. $user->sendPacket('<m t="/wThat has a BFF or is already married." u="0" />');
  1582. break;
  1583. }
  1584. $this->mysql->query("update `users` set `bride` = '{$u->id}', `d2` = '{$u->id}', `xats` = '{$user->xats}', `reserve`=`reserve`-200 where `id` = '{$user->id}';");
  1585. $this->mysql->query("update `users` set `bride` = '{$user->id}', `d2` = '{$user->id}' where `id` = '{$u->id}';");
  1586. $data1 = $this->doLogin($user->username, $user->password);
  1587. $data2 = $this->doLogin($u->username, $u->password);
  1588. $user->sendRoom("<a u=\"{$user->id}\" k=\"{$k}\" t=\"{$m}\" />", true);
  1589. $user->sendPacket("<a u=\"{$user->id}\" k=\"{$k}\" t=\"{$m}\" c=\"{$user->xats}\" />");
  1590. $user->sendPacket($data1);
  1591. $u->sendPacket($data2);
  1592. break;
  1593.  
  1594. case 'Champagne':
  1595. if($user->d2 != 0)
  1596. {
  1597. $user->sendPacket('<m t="/wYou\'re already BFF\'d | Married" u="0" />');
  1598. break;
  1599. }
  1600. if($user->id == $b)
  1601. {
  1602. $user->sendPacket('<m t="/wYou can\'t BFF yourself" u="0" />');
  1603. break;
  1604. }
  1605. $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
  1606. $usr = $usr[0];
  1607. if(!$this->mysql->checkPass($p, $usr['password']))
  1608. {
  1609. return $user->sendPacket('<v e="8" />');
  1610. }
  1611. if($user->xats < 200)
  1612. {
  1613. $user->sendPacket('<v e="11" />');
  1614. break;
  1615. }
  1616. $u = $this->getUserByID($f, $user->chat);
  1617. if(!is_object($u)) { break; }
  1618. if($u->hasPower(99))
  1619. {
  1620. return $user->sendPacket('<n t="' . $u->id . ' has single power." />');
  1621. }
  1622. $user->xats = ($usr['xats'] - 25);
  1623. if($u->d2 != 0)
  1624. {
  1625. $user->sendPacket('<m t="/wThat user is already BFF\'d/Married" u="0" />');
  1626. break;
  1627. }
  1628.  
  1629. $this->mysql->query("update `users` set `d0` = '1', `d2` = '{$u->id}', `xats` = '{$user->xats}', `reserve`=`reserve`-25 where `id` = '{$user->id}';");
  1630. $this->mysql->query("update `users` set `d0` = '1', `d2` = '{$user->id}' where `id` = '{$u->id}';");
  1631. $data1 = $this->doLogin($user->username, $user->password);
  1632. $data2 = $this->doLogin($u->username, $u->password);
  1633. $user->sendRoom("<a u=\"{$user->id}\" k=\"{$k}\" t=\"{$m}\" />", true);
  1634. $user->sendPacket("<a u=\"{$user->id}\" k=\"{$k}\" t=\"{$m}\" c=\"{$user->xats}\" />");
  1635. $user->sendPacket($data1);
  1636. $u->sendPacket($data2);
  1637. break;
  1638.  
  1639. case 'Argue':
  1640. case 'Hippod':
  1641. case 'Divorce':
  1642. case 'Divorced':
  1643. case 'Botd':
  1644. $this->mysql->query("update `users` set `d0` = '0', `d2` = '0', `bride` = '' where `id` = '{$user->id}';");
  1645. $user->sendRoom("<a u=\"{$user->id}\" k=\"{$k}\" t=\"{$m}\" />", true);
  1646. $user->sendPacket("<a u=\"{$user->id}\" k=\"{$k}\" t=\"{$m}\" c=\"{$user->xats}\" />");
  1647. $data1 = $this->doLogin($user->username, $user->password);
  1648. $user->sendPacket($data1);
  1649. break;
  1650.  
  1651. case 'T':
  1652. if ($x < 0 || !is_numeric($x)){
  1653. $this->disconnect($user->index);
  1654. }
  1655. else
  1656. {
  1657. $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
  1658. $usr = $usr[0];
  1659.  
  1660. $s = intval($s);
  1661.  
  1662. if ($usr['transferblock'] > time()) {
  1663. $user->sendPacket('<v e="10" />'); //Transfer block
  1664. }
  1665. else if (!$this->mysql->checkPass($p, $usr['password'])) {
  1666. $user->sendPacket('<v e="8" />');
  1667. }
  1668. else if ($x > $usr['xats']) {
  1669. $user->sendPacket('<v e="11" />'); //not enough xats
  1670. }
  1671. else if($s > 7970)
  1672. {
  1673. $user->sendPacket('<v e="18" />');
  1674. }
  1675. else if (strtotime("+ {$s} days") > $usr['days']) {
  1676. $user->sendPacket('<v e="18" />'); //not enough days
  1677. }
  1678. else
  1679. {
  1680. $u = $this->getUserByID($b, $user->chat);
  1681. if (!is_object($u)) {
  1682. $user->sendPacket('<v e="0" m="a" t="" />');
  1683. }
  1684. else
  1685. {
  1686. /*if ($user->ipaddr == $u->ipaddr) {
  1687. return $user->sendPacket('<n t="You can\'t trade with yourself D:" />');
  1688. }*/
  1689.  
  1690. $u->xats += $x;
  1691. $u->days = $u->days <= 0 ? $s : $u->days + $s;
  1692.  
  1693. $user->xats -= $x;
  1694. $user->days -= $s;
  1695.  
  1696. $this->mysql->query( "update `users` set `xats`='{$u->xats}', `days`='" . strtotime( "+ " . $u->days . " days" ) . "' where `id` = '{$u->id}';" );
  1697. $this->mysql->query( "update `users` set `xats`='{$user->xats}', `days`='" . strtotime( "+ " . $user->days . " days" ) . "' where `id` = '{$user->id}';" );
  1698. $this->mysql->query( "insert into `transfers` (`to`, `from`, `xats`, `days`, `timestamp`) values ('{$u->id}', '{$user->id}', '{$x}', '{$s}', '" . time() . "');" );
  1699.  
  1700. $user->sendPacket( "<a c=\"{$user->xats}\" u=\"{$user->id}\" b=\"{$b}\" s=\"{$s}\" x=\"{$x}\" k=\"T\" t=\"{$m}\" />" );
  1701. $u->sendPacket( "<a c=\"{$u->xats}\" u=\"{$user->id}\" b=\"{$b}\" s=\"{$s}\" x=\"{$x}\" k=\"T\" t=\"{$m}\" />" );
  1702.  
  1703. $user->joinRoom( $user->chat, 1 );
  1704. $u->joinRoom( $user->chat, 1 );
  1705. }
  1706. }
  1707. }
  1708. break;
  1709. }
  1710. }
  1711. break;
  1712.  
  1713. case 'p':
  1714. $u = $this->getuserbyid($this->getAttribute($packet, 'u', true), $user->chat);
  1715. if (!is_object($u)) {
  1716. break;
  1717. }
  1718.  
  1719. $attr = $this->getMultiAttr($packet, array('t', 's'));
  1720. /* badge - temp mod -temp own - temp member */
  1721. if (substr($attr['t'], 0, 1) == "/") {
  1722. switch (1) {
  1723. case substr($attr['t'], 1, 2) == 'nb':
  1724. if (!in_array($user->rank, array(1, 2, 4)) || !$this->higherRank($user->rank, $u->rank, true)) {
  1725. break;
  1726. }
  1727. if($u->f & 262144){
  1728. $this->mysql->query("delete from `badge` where `chatid`='{$user->chat}' and `id`='{$u->id}';");
  1729. $u->f -= 262144;
  1730. $u->joinRoom($user->chat, 0, true);
  1731. } else {
  1732. $time = strtotime("+ 20 years");
  1733. $this->mysql->query("insert into `badge` (`id`, `chatid`, `reason`) values ('{$u->id}', '{$user->chat}', '".substr($attr['t'], 3)."');");
  1734. $u->f = $u->f & 262144;
  1735. $u->joinRoom($user->chat, 0, true);
  1736. $user->sendRoom('<m p="'.substr($attr['t'], 3).'" t="/gd" w="264" u="' . $user->id . '" d="' . $u->id . '" />');
  1737. }
  1738. break;
  1739.  
  1740.  
  1741. case substr($attr['t'], 1, 2) == 'mo':
  1742. if (!in_array($user->rank, array(1, 2, 4)) || !$this->higherRank($user->rank, $u->rank, true)) {
  1743. break;
  1744. }
  1745. $time = round(substr($attr['t'], 3), 1);
  1746. if (!is_numeric($time) || $time > 24 || $time < 1) {
  1747. return $user->sendPacket("<n t=\"Please use the following format\n/mo2.5 for 2.5 hours.\nMax:24\nMin:1\" />");
  1748. }
  1749. $this->mysql->query("delete from `ranks` where `userid`='{$u->id}' and `chatid`='{$user->chat}';");
  1750. $this->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`, `tempend`) values('{$u->id}', '{$u->chatid}', 4, " . (time() + ($time * 60 * 60)) . ");");
  1751. $x = "<i>";
  1752. $x = htmlspecialchars($x);
  1753. $user->sendRoom("<m u=\"{$user->id}\" t=\"{$x} I have made {$u->username} an owner for {$time} hours!\" />");
  1754. $u->joinRoom($user->chat, 0, true);
  1755. break;
  1756.  
  1757. case substr($attr['t'], 1, 2) == 'mb':
  1758. if (!in_array($user->rank, array(1, 2, 4)) || !$this->higherRank($user->rank, $u->rank, true)) {
  1759. break;
  1760. }
  1761. $time = round(substr($attr['t'], 3), 1);
  1762. if (!is_numeric($time) || $time > 24 || $time < 1) {
  1763. return $user->sendPacket("<n t=\"Please use the following format\n/mo2.5 for 2.5 hours.\nMax:24\nMin:1\" />");
  1764. }
  1765. $this->mysql->query("delete from `ranks` where `userid`='{$u->id}' and `chatid`='{$user->chat}';");
  1766. $this->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`, `tempend`) values('{$u->id}', '{$u->chatid}', 3, " . (time() + ($time * 60 * 60)) . ");");
  1767. $x = "<i>";
  1768. $x = htmlspecialchars($x);
  1769. $user->sendRoom("<m u=\"{$user->id}\" t=\"{$x} I have made {$u->username} a Member for {$time} hours!\" />");
  1770. $u->joinRoom($user->chat, 0, true);
  1771. break;
  1772.  
  1773.  
  1774.  
  1775. case substr($attr['t'], 1, 1) == 'm':
  1776. if (!in_array($user->rank, array(1, 4)) || !$this->higherRank($user->rank, $u->rank, true)) {
  1777. break;
  1778. }
  1779. $time = round(substr($attr['t'], 2), 1);
  1780. if (!is_numeric($time) || $time > 24 || $time < 1) {
  1781. return $user->sendPacket("<n t=\"Please use the following format\n/m2.5 for 2.5 hours.\nMax:24\nMin:1\" />");
  1782. }
  1783. $this->mysql->query("delete from `ranks` where `userid`='{$u->id}' and `chatid`='{$user->chat}';");
  1784. $this->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`, `tempend`) values('{$u->id}', '{$u->chatid}', 2, " . (time() + ($time * 60 * 60)) . ");");
  1785. $user->sendRoom("<m u=\"{$user->id}\" t=\"&lt;i&gt; I have made {$u->username} a moderator for {$time} hours!\" />");
  1786. $u->joinRoom($user->chat, 0, true);
  1787. break;
  1788. default:
  1789. $attr['t'] = htmlspecialchars($attr['t']);
  1790. $attr['s'] = htmlspecialchars($attr['s']);
  1791. $u->sendPacket("<p u=\"{$user->id}\" t=\"{$attr['t']}\" s=\"{$attr['s']}\" />");
  1792. return;
  1793. }
  1794. } else {
  1795. $attr['t'] = htmlspecialchars($attr['t']);
  1796. $attr['s'] = htmlspecialchars($attr['s']);
  1797. $u->sendPacket("<p u=\"{$user->id}\" t=\"{$attr['t']}\" s=\"{$attr['s']}\" />");
  1798. if ($this->spamfilter($tag, $user, 700))
  1799. break;
  1800. }
  1801. break;
  1802.  
  1803.  
  1804. case 'p2':
  1805. $u = $this->getUserByID($this->getAttribute($packet, 'u', true), $user->chat);
  1806. if(!is_object($u)) break;
  1807. $attr = $this->getMultiAttr($packet, array('t', 's'));
  1808. $u->sendPacket("<p u=\"{$user->id}\" t=\"{$attr["t"]}\" s=\"{$attr["s"]}\" u=\"{$u->id}\" />");
  1809. break;
  1810.  
  1811. case 'z':
  1812. if($user->switchingPools == true){$user->switchingPools = false; break; }
  1813. if($this->spamfilter($tag, $user, 1)) break;
  1814. $d = $this->getAttribute($packet, 'd');
  1815. $u = $this->getUserByID($d);
  1816. if(!is_object($u))
  1817. {
  1818.  
  1819. $t = $this->getAttribute($packet, 't');
  1820. if(trim($t) != "" && substr($t, 0, 1) !== "/" && is_numeric($d))
  1821. {
  1822. if(strlen($t) < 300)
  1823. {
  1824. $d = $this->mysql->sanatize($d);
  1825. $check = $this->mysql->fetch_array("select xto from `offline_messages` where `xto`='{$d}' and `xfrom`='{$user->id}' and `unread`='1';");
  1826. if(count($check) >= 12)
  1827. {
  1828. return $user->sendPacket("<n t=\"Max offline unread msgs: 12\" />");
  1829. }
  1830. unset($check);
  1831. $msg = $this->mysql->sanatize($t);
  1832. $this->mysql->query("insert into `offline_messages` (id, xto, xfrom, xmessage, unread) VALUES (NULL, '{$d}', '{$user->id}', '{$msg}', 1);");
  1833. }
  1834. }
  1835. break;
  1836.  
  1837. }
  1838. if(!is_object($user))
  1839. {
  1840. break;
  1841. }
  1842. $t2 = $this->getAttribute($packet, 't');
  1843. $t = substr($t2, 0, 2);
  1844. $t3 = substr($t2, 0, 3);
  1845. $param = substr($t2, 2);
  1846. switch($t)
  1847. {
  1848. /* locarizaçao usuario e nofollow */
  1849. case '/l':
  1850. if ($u->id == 8986){
  1851.  
  1852. }
  1853. if($u->hidden == true) { return false; }
  1854. $check = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$u->id}' and `friend`='{$user->id}';");
  1855. $check2 = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$user->id}' and `friend`='{$u->id}';");
  1856. if(empty($check) || empty($check2))
  1857. {
  1858. $str = " t=\"/a_\"";
  1859. } else {
  1860. $str = (($u->haspower(5) && $u->chat != $user->chat) || !isset($u->group)) ? " t=\"/a_NF\"" : " t=\"/ahttp://{$this->config->server_domain}/{$u->group}\"";
  1861. }
  1862. if($u->haspower(27))
  1863. {
  1864. $user->sendPacket('<z b="1" d="' . $user->id . '" u="' . $u->id . '"' . ( $str ) . ' po="' . $u->dO . '" ' . $u->pStr . 'x="' . $u->xats . '" y="' . $u->days . '" q="3"' . ($u->username == '' ? '' : ' N="' . $u->username . '"') . ' n="' . html_entity_decode(htmlspecialchars_decode(($u->nickname))) . '" a="' . $this->mysql->sanatize($u->avatar) . '" h="' . $this->mysql->sanatize($u->url) . '" v="2" />');
  1865. $u->sendPacket('<z b="1" d="' . $u->id . '" u="' . $user->id . '" t="/l" po="' . $user->dO . '" ' . $user->pStr . 'x="' . $user->xats . '" y="' . $user->days . '" q="3"' . ($user->username == '' ? '' : ' N="' . $user->username . '"') . ' n="' . html_entity_decode(htmlspecialchars_decode(($user->nickname))) . '" a="' . $this->mysql->sanatize($user->avatar) . '" h="' . $this->mysql->sanatize($user->url) . '" v="2" />');
  1866. } else {
  1867. $user->sendPacket('<z b="1" d="' . $user->id . '" u="' . $u->id . '"' . ( $str ) . ' po="' . $u->dO . '" ' . $u->pStr . 'x="' . $u->xats . '" y="' . $u->days . '" q="3"' . ($u->username == '' ? '' : ' N="' . $u->username . '"') . ' n="' . html_entity_decode(htmlspecialchars_decode(($u->nickname))) . '" a="' . $this->mysql->sanatize($u->avatar) . '" h="' . $this->mysql->sanatize($u->url) . '" v="2" />');
  1868. $u->sendPacket('<z b="1" d="' . $u->id . '" u="' . $user->id . '" t="/l" po="' . $user->dO . '" ' . $user->pStr . 'x="' . $user->xats . '" y="' . $user->days . '" q="3"' . ($user->username == '' ? '' : ' N="' . $user->username . '"') . ' n="' . html_entity_decode(htmlspecialchars_decode(($user->nickname))) . '" a="' . $this->mysql->sanatize($user->avatar) . '" h="' . $this->mysql->sanatize($user->url) . '" v="2" />');
  1869. $guser = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `id`='".$u->id."';");
  1870. if(!empty($guser[0]['tickle'])){
  1871. $user->sendPacket("<z u=\"".$u->id."\" t=\"[Auto-msg] ".$guser[0]['tickle']."\" d=\"".$user->id."\" />");
  1872. }
  1873. }
  1874. break;
  1875.  
  1876. case '/a':
  1877. $checkk = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$u->id}' and `friend`='{$user->id}';");
  1878. $check2 = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$user->id}' and `friend`='{$u->id}';");
  1879. if(empty($checkk) || empty($check2)){
  1880. $str = " t=\"/a_\"";
  1881. } else {
  1882. $str = (($u->haspower(5) && $u->chat != $user->chat) || !isset($u->group)) ? " t=\"/a_NF\"" : " t=\"/ahttp://{$this->config->server_domain}/{$u->group}\"";
  1883. }
  1884. $check = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$user->id}' and `friend`='{$u->id}';");
  1885. if($check)
  1886. {
  1887. if($u->haspower(27))
  1888. {
  1889. $user->sendRoom('<z d="'.$user->id.'" u="'.$u->id.($str).$u->pStr.'x="'.$u->xats.'" y="'.$u->days.'" d0="'.$u->d0.($u->days >= 1 ? ' q="3"' : ' q="1"').($u->username == '' ? '' : ' N="'.$u->username.'"').' n="'.html_entity_decode(htmlspecialchars_decode(($u->nickname))).'" a="'.$this->mysql->sanatize($u->avatar).'" h="'.$this->mysql->sanatize($u->url).'" pawn="'.$this->mysql->sanatize($u->pawn).'" v="2" />');
  1890. } else {
  1891. $user->sendRoom('<z d="'.$user->id.'" u="'.$u->id.($str).$u->pStr.'x="'.$u->xats.'" y="'.$u->days.'" d0="'.$u->d0.($u->days >= 1 ? ' q="3"' : ' q="1"').($u->username == '' ? '' : ' N="'.$u->username.'"').' n="'.html_entity_decode(htmlspecialchars_decode(($u->nickname))).'" a="'.$this->mysql->sanatize($u->avatar).'" h="'.$this->mysql->sanatize($u->url).'" pawn="'.$this->mysql->sanatize($u->pawn).'" v="2" />');
  1892. }
  1893. }
  1894. break;
  1895.  
  1896. default:
  1897. $u = $this->getUserByID($this->getAttribute($packet, 'u', true), $user->chat);
  1898. if(!is_object($u)) break;
  1899. $t = $this->getAttribute($packet, 't');
  1900. $s = $this->getAttribute($packet, 's');
  1901. $u->sendPacket("<z u=\"" . $user->id . "\" t=\"" . $t . "\" s=\"" . $s . "\" d=\"" . $u->id . "\" />");
  1902. break;
  1903. }
  1904. break;
  1905. case 'c':
  1906. if($this->spamfilter($tag, $user, 800)) { break; }
  1907. if($user->banned > time()) { return false; }
  1908. if($user->rExpire != 0 && $user->rExpire < time())
  1909. {
  1910. $this->mysql->query("delete from `ranks` where `userid`={$user->id} and `chatid`='{$user->chat}';");
  1911. $this->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`) values({$user->id}, {$user->chat}, 3);");
  1912. return $user->joinRoom($user->chat, 0, true);
  1913. }
  1914.  
  1915. $attr = $this->getAttribute( $packet, 'u', True );
  1916. $t2 = $this->getAttribute( $packet, 't' );
  1917. $uid = $this->getAttribute( $packet, 'u' );
  1918. $game = $this->getAttribute( $packet, 'w' );
  1919. $p = $this->getAttribute( $packet, 'p' );
  1920. $u = $this->getUserByID( $attr, $user->chat );
  1921. $bchat = $this->mysql->fetch_Array( "select * from `chats` where `id`='{$user->chat}';" );
  1922. $blastban = $bchat[ 0 ][ "blastban" ];
  1923. $blastkick = $bchat[ 0 ][ "blastkick" ];
  1924. $blastpro = $bchat[ 0 ][ "blastpro" ];
  1925. $blastde = $bchat[ 0 ][ "blastde" ];
  1926. $param3 = substr( $t2, 3 );
  1927. $param = substr( $t2, 2 );
  1928.  
  1929. switch(substr($t2, 0, 2))
  1930. {
  1931. case '/b':
  1932. $friend = explode(',', $t2);
  1933. if($friend[1] == '1' && $friend[2] !== '')
  1934. {
  1935. $friend_id = $this->mysql->fetch_array("SELECT id FROM `users` WHERE `username`='{$friend[2]}';");
  1936. $this->mysql->query("insert into `friends` (`id`, `user`, `friend`) values (NULL, '{$user->id}', '{$friend_id[0]['id']}');");
  1937. }
  1938. elseif($friend[1] == '2' && $friend[0][2] !== '')
  1939. {
  1940. $this->mysql->query("delete from `friends` where `user`={$user->id} and `friend`='".str_replace('/b ', '', $friend[0])."';");
  1941. }
  1942. break;
  1943. }
  1944.  
  1945. if(!is_object($u)) { return; } //Delete friend
  1946.  
  1947.  
  1948. switch (substr($t2, 0, 3)) {
  1949. case '/gm':
  1950. If ( $this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array(
  1951. 1,
  1952. 2,
  1953. 4
  1954. ) ) )
  1955. // Mute
  1956. {
  1957. $verIficar = $this->mysql->fetch_Array( "SELECT * FROM `bans` WHERE userid = {$u->id} AND `chatid` = {$user->chat} AND type = 'f256';" );
  1958. If ( !$verIficar[ 0 ][ 'index' ] )
  1959. {
  1960. $time = $param3 == 0 ? strtotime( "+ 20 years" ) : strtotime( "+ {$param3} seconds" );
  1961. $this->mysql->query( "insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');" );
  1962. $u->joinRoom( $user->chat, False, True, 1 );
  1963. $user->sendRoom( '<m p="' . $this->getAttribute( $packet, 'p' ) . '" t="/gm' . $param3 . '" u="' . $user->id . '" d="' . $u->id . '" />', False, $u->id );
  1964. $u->banned = $time;
  1965. } //!$verIficar[ 0 ][ 'index' ]
  1966. Else
  1967. {
  1968. $this->mysql->query( "delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' and type='f256';" );
  1969. $u->f -= 256;
  1970. $u->joinRoom( $user->chat, 0, True );
  1971. }
  1972. } //$this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array( 1, 2, 4 ) )
  1973. return;
  1974. break;
  1975.  
  1976. case '/gg':
  1977. if($this->higherRank($user->rank,$u->rank,true) && in_array($user->rank, array(1, 4))){
  1978. if($u->f & 256){
  1979. $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' or `chatid`='{$user->chat}' and `ip`='{$u->ipaddr}';");
  1980. $user->sendRoom('<m t="/u" u="' . $user->id . '" d="' . $u->id . '" />');
  1981. $u->sendPacket('<c u="0" d="' . $u->id . '" t="/u" />');
  1982. $u->f -= 256;
  1983. $u->joinRoom($user->chat, false, true, 0);
  1984. } else {
  1985. $time = $param3 == 0 ? strtotime("+ 20 years") : strtotime("+ {$param3} seconds");
  1986. $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
  1987. $u->f |= 256;
  1988. $u->joinRoom($user->chat, false, true, 0);
  1989. $user->sendRoom('<m p="'.$this->getAttribute($packet, 'p').'" t="/gg'.$param3.'" u="'.$user->id.'" d="'.$u->id.'" />',false,$u->id);
  1990. $u->banned = $time;
  1991. }
  1992. }
  1993. return;
  1994. break;
  1995.  
  1996. case '/gn':
  1997. If ( $this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array(
  1998. 1,
  1999. 2,
  2000. 4
  2001. ) ) )
  2002. // Naughty
  2003. {
  2004. $verIficar = $this->mysql->fetch_Array( "SELECT * FROM `bans` WHERE userid = {$u->id} AND `chatid` = {$user->chat} AND type = 'f524288';" );
  2005. If ( !$verIficar[ 0 ][ 'index' ] )
  2006. {
  2007. $time = $param3 == 0 ? strtotime( "+ 20 years" ) : strtotime( "+ {$param3} seconds" );
  2008. $this->mysql->query( "insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f524288');" );
  2009. $u->joinRoom( $user->chat, False, True, 0 );
  2010. $user->sendRoom( '<m p="' . $this->getAttribute( $packet, 'p' ) . '" t="/gn' . $param3 . '" u="' . $user->id . '" d="' . $u->id . '" />', False, $u->id );
  2011. //$user->sendRoom("<m p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />", false);
  2012. $this->disconnect($u->index);
  2013. $user->sendRoom("<l u=\"{$u->id}\" />");
  2014. $u->banned = $time;
  2015. } //!$verIficar[ 0 ][ 'index' ]
  2016. Else
  2017. {
  2018. $this->mysql->query( "delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' and type='f524288';" );
  2019. $u->f -= 524288;
  2020. $u->joinRoom( $user->chat, 0, True );
  2021. }
  2022. } //$this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array( 1, 2, 4 ) )
  2023. return;
  2024. break;
  2025.  
  2026.  
  2027.  
  2028. case '/gy':
  2029. If ( $this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array(
  2030. 1,
  2031. 2,
  2032. 4
  2033. ) ) )
  2034. // Yellowcard
  2035. {
  2036. $verIficar = $this->mysql->fetch_Array( "SELECT * FROM `bans` WHERE userid = {$u->id} AND `chatid` = {$user->chat} AND type = 'f1048576';" );
  2037. If ( !$verIficar[ 0 ][ 'index' ] )
  2038. {
  2039. $time = $param3 == 0 ? strtotime( "+ 20 years" ) : strtotime( "+ {$param3} seconds" );
  2040. $this->mysql->query( "insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f1048576');" );
  2041. $u->joinRoom( $user->chat, False, True, 0 );
  2042. $user->sendRoom( '<m p="' . $this->getAttribute( $packet, 'p' ) . '" t="/gy' . $param3 . '" u="' . $user->id . '" d="' . $u->id . '" />', False, $u->id );
  2043. //$user->sendRoom("<m p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />", false);
  2044. $this->disconnect($u->index);
  2045. $user->sendRoom("<l u=\"{$u->id}\" />");
  2046. } //!$verIficar[ 0 ][ 'index' ]
  2047. Else
  2048. {
  2049. $this->mysql->query( "delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' and type='f1048576';" );
  2050. $u->f -= 1048576;
  2051. $u->joinRoom( $user->chat, 0, True );
  2052. }
  2053. } //$this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array( 1, 2, 4 ) )
  2054. return;
  2055.  
  2056. case '/gr':
  2057. If ( $this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array(
  2058. 1,
  2059. 2,
  2060. 4
  2061. ) ) )
  2062. // redcard
  2063. {
  2064. $verIficar = $this->mysql->fetch_Array( "SELECT * FROM `bans` WHERE userid = {$u->id} AND `chatid` = {$user->chat} AND type = 'f2097152';" );
  2065. If ( !$verIficar[ 0 ][ 'index' ] )
  2066. {
  2067. $time = $param3 == 0 ? strtotime( "+ 20 years" ) : strtotime( "+ {$param3} seconds" );
  2068. $this->mysql->query( "insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f2097152');" );
  2069. $u->joinRoom( $user->chat, False, True, 0 );
  2070. $user->sendRoom( '<m p="' . $this->getAttribute( $packet, 'p' ) . '" t="/gr' . $param3 . '" u="' . $user->id . '" d="' . $u->id . '" />', False, $u->id );
  2071. //$user->sendRoom("<m p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />", false);
  2072.  
  2073. } //!$verIficar[ 0 ][ 'index' ]
  2074. Else
  2075. {
  2076. $this->mysql->query( "delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' and type='f2097152';" );
  2077. $u->f -= 2097152;
  2078. $u->joinRoom( $user->chat, 2, True );
  2079. }
  2080. } //$this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array( 1, 2, 4 ) )
  2081. return;
  2082.  
  2083.  
  2084. case '/gd':
  2085. if($this->higherRank($user->rank,$u->rank,true) && in_array($user->rank, array(1, 2, 4)))
  2086. { // Dunce
  2087. if($u->f & 0x8000)
  2088. {
  2089. $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' or `chatid`='{$user->chat}' and `ip`='{$u->ipaddr}';");
  2090. $user->sendRoom('<m t="/u" u="' . $user->id . '" d="' . $u->id . '" />');
  2091. $u->sendPacket('<c u="0" d="' . $u->id . '" t="/u" />');
  2092. $u->f -= 0x8000;
  2093. $u->joinRoom($user->chat, false, true, 0);
  2094. }
  2095. else
  2096. {
  2097. $time = $param3 == 0 ? strtotime("+ 20 years") : strtotime("+ {$param3} seconds");
  2098. $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f32768');");
  2099. if($u->group && $user->hasPower(296))
  2100. {
  2101. $user->sendRoom('<bl u="'.$user->id.'" d="'.$u->id.'" t="blastdunce" v="1" r="'.$this->BlastCor($u->rank).'" o="'.$this->BlastCargo($u->rank).'" /> ', false);
  2102. }
  2103. $u->joinRoom($user->chat, false, true, 0);
  2104. $user->sendRoom('<m p="'.$this->getAttribute($packet, 'p').'" t="/gd3600'.$param3.'" u="'.$user->id.'" d="'.$u->id.'" w="158" />', false, $u->id);
  2105. //$user->sendRoom("<m p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />", false);
  2106.  
  2107. }
  2108. }
  2109. return;
  2110. }
  2111.  
  2112. switch (substr($t2, 0, 2)) {
  2113. case '/r': // Guest
  2114. case '/e': // Member
  2115. case '/m': // Mod
  2116. case '/M': // Owner
  2117. $ranks = array(
  2118. 'r' => array(array(1, 2, 4), 5),
  2119. 'e' => array(array(1, 2, 4), 3),
  2120. 'm' => array(array(1, 4), 2),
  2121. 'M' => array(array(1), 4)
  2122. );
  2123.  
  2124. $rank = $ranks[substr($t2, 1, 1)];
  2125.  
  2126. if (in_array($user->rank, $rank[0]) && $this->higherRank($user->rank, $u->rank, true)) {
  2127. $this->mysql->query('delete from `ranks` where `userid`=' . $u->id . ' and `chatid`=' . $user->chat . ';');
  2128. $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $u->id . ', ' . $user->chat . ', ' . $rank[1] . ');');
  2129. $p = $this->getAttribute($packet, 'p');
  2130. $silent = 'm'; //$user->hasPower(72) && in_array($user->rank, array(1, 4)) && $rank == $ranks['e'] ? 'c' : 'm';
  2131. $u->sendPacket('<c p="' . $p . '" t="' . substr($t2, 0, 2) . '" u="' . $user->id . '" d="' . $u->id . '" />');
  2132. //$user->sendRoom('<' . $silent . ' p="' . $p . '" t="' . substr($t2, 0, 2) . '" u="' . $user->id . '" d="' . $u->id . '" />');
  2133. $user->sendRoom('<m u="' . $user->id . '" d="' . $u->id . '" t="/m" p="' . substr($t2, 1, 1) . '" />');
  2134. /*
  2135. * Guest: 0x009900
  2136. * Member: 0x3366FF
  2137. * Moderator: 0xFFFFFF
  2138. * Owner: 0xFF9900
  2139. */
  2140. $cols = array(
  2141. "/r" => "0x009900",
  2142. "/e" => "0x3366FF",
  2143. "/m" => "0xFFFFFF",
  2144. "/M" => "0xFF9900"
  2145. );
  2146. $colIndex = substr( $t2, 0, 2 );
  2147. $blaster = $cols[ $colIndex ];
  2148. $oAttr = Array(
  2149. "/r" => "r",
  2150. "/e" => "e",
  2151. "/m" => "m",
  2152. "/M" => "M"
  2153. );
  2154. $oIndex = substr( $t2, 0, 2 );
  2155. $useO = $oAttr[ $oIndex ];
  2156. $user->sendRoom( '<bl u="' . $user->id . '" d="' . $u->id . '" t="blastpro" v="' . $blastpro . '" r="' . $blaster . '" o="' . $useO . '" />', False );
  2157. $u->joinRoom( $user->chat, 0, True );
  2158. } //in_Array( $user->rank, $rank[ 0 ] ) && $this->higherRank( $user->rank, $u->rank, True )
  2159. break;
  2160.  
  2161. case '/g': // Ban
  2162. if (in_array($user->rank, array(1, 2, 4)) && $this->higherRank($user->rank, $u->rank, true)) {
  2163. if ($user->rank == 2) { // Mod8
  2164. $hours = round((($param3 / 60) / 60), 1);
  2165. $mod8 = $user->haspower(3);
  2166. if ($hours > 6 && !$mod8 || $mod8 && $hours > 8) {
  2167. return;
  2168. }
  2169. }
  2170.  
  2171. $time = $param3 == 0 ? strtotime("+ 20 years") : strtotime("+ {$param3} seconds");
  2172.  
  2173. if ($game !== false && is_numeric($game) && $game > 0) {
  2174. if ($user->hasPower($game)) {
  2175. $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'w{$game}');");
  2176. $user->sendRoom('<m p="' . $p . '" t="/g' . $param . '" w="' . $game . '" u="' . $user->id . '" d="' . $u->id . '" />');
  2177. $u->sendPacket('<c p="' . $p . '" w="' . $game . '" t="/g' . $time . '" u="' . $user->id . '" d="' . $u->id . '" />');
  2178. $Blastbans = $this->mysql->fetch_Array( "SELECT * FROM `group_powers` WHERE `group`='{$user->group}' AND `power`=86;" );
  2179. If ( !count( $Blastbans ) == 0 )
  2180. { $user->sendRoom('<bl u="' . $user->id . '" d="' . $u->id . '" t="blastban" v="1" r="' . $this->BlastCor($u->rank) . '" o="' . $this->BlastCargo($u->rank) . '" />', false);
  2181. }
  2182. $u->joinRoom($user->chat, false, true, 0);
  2183. } else {
  2184. $user->sendPacket('<n t="You don\'t have that power!" />');
  2185. }
  2186. } else {
  2187. $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}');");
  2188. $user->sendRoom('<m p="' . $this->getAttribute($packet, 'p') . '" t="/g' . $param . '" u="' . $user->id . '" d="' . $u->id . '" />');
  2189. $u->sendPacket('<c p="' . $this->getAttribute($packet, 'p') . '" t="/g' . $time . '" u="' . $this->getAttribute($packet, 'u') . '" d="' . $this->getAttribute($packet, 'd') . '" />');
  2190. $u->sendRoom("<l u=\"{$u->id}\" />");
  2191. $Blastbans = $this->mysql->fetch_Array( "SELECT * FROM `group_powers` WHERE `group`='{$user->group}' AND `power`=86;" );
  2192. If ( !count( $Blastbans ) == 0 )
  2193. { $user->sendRoom('<bl u="' . $user->id . '" d="' . $u->id . '" t="blastban" v="1" r="' . $this->BlastCor($u->rank) . '" o="' . $this->BlastCargo($u->rank) . '" />', false);
  2194. }
  2195. $u->sendRoom("<l u=\"{$u->id}\" />"); // Left off here [Blasts]
  2196. $u->joinRoom($user->chat, false, true, 2);
  2197. }
  2198. }
  2199. break;
  2200.  
  2201.  
  2202. case "/k": // Kick/Boot
  2203. If ( in_Array( $user->rank, Array(
  2204. 1,
  2205. 2,
  2206. 4
  2207. ) ) && $this->higherRank( $user->rank, $u->rank, True ) )
  2208. {
  2209. $args = explode( "#", $pee = $this->getAttribute( $packet, 'p' ) );
  2210. If ( count( $args ) == 2 )
  2211. {
  2212. $chat = $this->mysql->fetch_Array( "select * from `chats` where `id`='{$this->mysql->sanatize($args[1])}' or `name`='{$this->mysql->sanatize($args[1])}';" );
  2213. If ( empty( $chat ) )
  2214. {
  2215. $user->sendPacket( "<n t=\"Este chat nao existe!\" />" );
  2216. } //empty( $chat )
  2217. Else
  2218. {
  2219. $user->sendRoom( "<m p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />", False );
  2220. $u->sendPacket( "<q p2=\"{$pee}\" u=\"{$u->id}\" d2=\"{$user->id}\" r=\"{$chat[0]['id']}\" />" );
  2221. $u->joinRoom( $chat[ 0 ][ 'id' ], True );
  2222. $user->sendRoom( "<l u=\"{$u->id}\" />" );
  2223. }
  2224. } //count( $args ) == 2
  2225. Else
  2226. {
  2227. If ( count( $args ) == 3 && !$user->hasPower( 121 ) )
  2228. {
  2229. $user->sendPacket( "<n t=\"Voce nao tem o power ZAP!\" />" );
  2230. } //count( $args ) == 3 && !$user->hasPower( 121 )
  2231. Else
  2232. {
  2233. $user->sendRoom( "<m p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />", False );
  2234. $u->sendPacket( "<c p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />" );
  2235. $user->sendRoom( '<bl u="' . $user->id . '" d="' . $u->id . '" t="blastkick" v="' . $blastkick . '" r="' . $this->BlastCor( $u->rank ) . '" o="' . $this->BlastCargo( $u->rank ) . '" />', False );
  2236. $this->disconnect( $u->index );
  2237. $user->sendRoom( "<l u=\"{$u->id}\" />" );
  2238. }
  2239. }
  2240. } //in_Array( $user->rank, Array( 1, 2, 4 ) ) && $this->higherRank( $user->rank, $u->rank, True )
  2241. Else
  2242. {
  2243. $this->disconnect( $user->index );
  2244. }
  2245. break;
  2246.  
  2247. case '/u':
  2248. if (in_array($user->rank, array(1, 2, 4)) && ($u->rank == 16 && $this->higherRank($user->rank, $u->rank, true))) {
  2249. $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' or `chatid`='{$user->chat}' and `ip`='{$u->ipaddr}';");
  2250. $user->sendRoom('<m t="/u" u="' . $user->id . '" d="' . $u->id . '" />');
  2251. $u->sendPacket('<c u="0" d="' . $u->id . '" t="/u" />');
  2252. $u->joinRoom($user->chat, 0, true);
  2253. }
  2254. break;
  2255. }
  2256. break;
  2257. default:
  2258. $this->disconnect($user->index);
  2259. break;
  2260. }
  2261. }
  2262.  
  2263. public function BlastCor($rank) {
  2264. $ranks = array(1, 2, 3, 4, 5);
  2265. $cor = "0x009900";
  2266. if ($rank == 5)
  2267. $cor = "0x009900";
  2268. if ($rank == 4)
  2269. $cor = "0xFF9900";
  2270. if ($rank == 3)
  2271. $cor = "0x3366FF";
  2272. if ($rank == 2)
  2273. $cor = "0xFFFFFF";
  2274. if ($rank == 1)
  2275. $cor = "X";
  2276. return $cor;
  2277. }
  2278.  
  2279. public function BlastCargo($rank) {
  2280. $ranks = array(1, 2, 3, 4, 5);
  2281. $cargo = "0x009900";
  2282. if ($rank == 5)
  2283. $cargo = "r"; // Guest
  2284. if ($rank == 4)
  2285. $cargo = "M"; // Owner
  2286. if ($rank == 3)
  2287. $cargo = "e"; // Member
  2288. if ($rank == 2)
  2289. $cargo = "m"; // Mod
  2290. if ($rank == 1)
  2291. $cargo = "X"; // Main Owner
  2292. return $cargo;
  2293. }
  2294.  
  2295. public function mask($packet) {
  2296. $length = strlen($packet);
  2297.  
  2298. if ($length < 126) {
  2299. return pack('CC', 0x80 | (0x1 & 0x0f), $length) . $packet;
  2300. } elseif ($length < 65536) {
  2301. return pack('CCn', 0x80 | (0x1 & 0x0f), 126, $length) . $packet;
  2302. } else {
  2303. return pack('CCNN', 0x80 | (0x1 & 0x0f), 127, $length) . $packet;
  2304. }
  2305. }
  2306.  
  2307. public function unmask($packet) {
  2308. try {
  2309. $length = ord($packet[1]) & 127;
  2310. if ($length == 126) {
  2311. $masks = substr($packet, 4, 4);
  2312. $data = substr($packet, 8);
  2313. } elseif ($length == 127) {
  2314. $masks = substr($packet, 10, 4);
  2315. $data = substr($packet, 14);
  2316. } else {
  2317. $masks = substr($packet, 2, 4);
  2318. $data = substr($packet, 6);
  2319. }
  2320.  
  2321. $response = '';
  2322. $dlength = strlen($data);
  2323. for ($i = 0; $i < $dlength; ++$i) {
  2324. $response .= $data[$i] ^ $masks[$i % 4];
  2325. }
  2326.  
  2327. return $response == '' ? false : $response;
  2328. } catch (Exception $e) {
  2329. return false;
  2330. }
  2331. }
  2332. /* funçao de transferencia de power para conta */
  2333. public function doLogin($user, $pass) {
  2334. /* Variables */
  2335. $vals = array();
  2336. $p = array();
  2337. $pp = '';
  2338. $dO = '';
  2339. $powerO = '';
  2340.  
  2341. $user = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($user) . '\';');
  2342. if (isset($user[0])) {
  2343. $bride = $user[0]['d2'] == 0 ? false : $user[0]['bride'];
  2344. if($user[0]['torched'] != 1)
  2345.  
  2346. {
  2347. if ((floor(($user[0]['days'] - time()) / (24 * 3600) + 0.3) >= 1 ? floor(($user[0]['days'] - time()) / (24 * 3600) + 0.3) : 0) >= 1) {
  2348. $upowers = $this->mysql->fetch_array('select * from `userpowers` where `userid`=' . $user[0]['id'] . ';');
  2349. $spowers = $this->mysql->fetch_array('select * from `powers` where `name` not like \'%(Undefined)%\';');
  2350.  
  2351. foreach ($spowers as $power) {
  2352. $vals[$power['id']] = array($power['section'], $power['subid']);
  2353. $p[$power['section']] = 0;
  2354. }
  2355.  
  2356. foreach ($upowers as $power) {
  2357. if ($power['count'] >= 1 && isset($vals[$power['powerid']]) && isset($p[$vals[$power['powerid']][0]])) {
  2358. $str = $power['powerid'] . '=' . ($power['count'] > 1 ? ($power['count'] - 1) : 1) . '|';
  2359. $p[$vals[$power['powerid']][0]] += $vals[$power['powerid']][1];
  2360. $dO .= $str;
  2361. if ($power['count'] > 1) {
  2362. $powerO .= $str;
  2363. }
  2364. }
  2365. }
  2366.  
  2367. foreach ($p as $i => $u) {
  2368. $pp .= " d" . (substr($i, 1) + 4) . "=\"{$u}\"";
  2369. }
  2370. }
  2371.  
  2372. $this->mysql->query("update `users` set `dO`='{$this->mysql->sanatize($powerO)}' where `username`='{$this->mysql->sanatize($user[0]['username'])}';");
  2373. if($user[0]['torched'] == 1)
  2374.  
  2375. {
  2376.  
  2377. $user[0]['xats'] = 0;
  2378.  
  2379. $user[0]['days'] = 0;
  2380.  
  2381. }
  2382. return "<v RL=\"1\" i=\"{$user[0]['id']}\" c=\"{$user[0]['xats']}\" dt=\"0\" n=\"{$user[0]['username']}\" k1=\"{$user[0]['k']}\" k2=\"{$user[0]['k2']}\" k3=\"{$user[0]['k3']}\" bride=\"{$bride}\" d0=\"{$user[0]['d0']}\" d1=\"{$user[0]['days']}\" d2=\"{$user[0]['d2']}\" d3=\"\"{$pp} dx=\"{$user[0]['xats']}\" dO=\"{$powerO}\" PowerO=\"{$powerO}\" />";
  2383. }
  2384. }
  2385. return false;
  2386. }
  2387. public function getUserByID($id, $chat = null){
  2388. if ($id == 2 || $id == 0) {
  2389. return false;
  2390. }
  2391. foreach ($this->users as $user) {
  2392. if ($user->id == $id && ($chat == null || $user->chat == $chat)) {
  2393. return $user->online ? $user : false;
  2394. }
  2395. }
  2396. return false;
  2397. }
  2398. /* funçao de identificaçao de cargo para block nas pools */
  2399. function higherRank($rank1, $rank2, $minMod = false) {
  2400. if ($rank1 == $rank2) {
  2401. return false;
  2402. }
  2403. $order = array(1, 2, 3, 4);
  2404. if (in_array($rank1, $order) && !in_array($rank2, $order)) {
  2405. return true;
  2406. }
  2407. if ($rank1 == 1) {
  2408. return true;
  2409. }
  2410. if ($rank1 == 4 && $rank2 != 1) {
  2411. return true;
  2412. }
  2413. if ($rank1 == 2 && $rank2 != 1 && $rank2 != 4) {
  2414. return true;
  2415. }
  2416. if ($minMod == true) {
  2417. return false;
  2418. }
  2419. if ($rank1 == 3 && $rank2 != 1 && $rank2 != 4 && $rank2 != 2) {
  2420. return true;
  2421. }
  2422. return false;
  2423. }
  2424.  
  2425. function objectToArray($object) {
  2426. $array = array();
  2427. foreach ($object as $member => $data) {
  2428. $array[$member] = $data;
  2429. }
  2430. return $array;
  2431. }
  2432.  
  2433. public function getAttribute($xml, $attName, $reverse = false) {
  2434. $att = $this->objectToArray($xml->attributes());
  2435. if ($reverse == true) {
  2436. array_reverse($att);
  2437. }
  2438.  
  2439. foreach ($att as $a => $b) {
  2440. if ($a == $attName) {
  2441. $b = htmlspecialchars($b);
  2442. return $b;
  2443. }
  2444. }
  2445. return false;
  2446. }
  2447.  
  2448. public function getMultiAttr($xml, $names = array(), $values = array()) {
  2449. setType($names, 'array');
  2450. if (!method_exists($xml, 'attributes')) {
  2451. return array();
  2452. }
  2453.  
  2454. foreach ($names as $u) {
  2455. $values[$u] = false;
  2456. }
  2457.  
  2458. foreach ($xml->attributes() as $i => $u) {
  2459. if (in_array($i, $names) || empty($names)) {
  2460. $values[$i] = ((string) ((string) $u));
  2461. }
  2462. }
  2463.  
  2464. return $values;
  2465. }
  2466.  
  2467. public function disconnect($userID, $logout = null, $num = null, $chatid = null) {
  2468. if (isset($this->users[$userID]) && $user = $this->users[$userID]) {
  2469. if (!is_null($logout) && $user->online) {
  2470. $user->sendPacket("<logout />");
  2471. }
  2472.  
  2473. if (is_resource($user->sock)) {
  2474. socket_close($user->sock);
  2475. $user->sock = null;
  2476. }
  2477. $user->online = false;
  2478.  
  2479. return true;
  2480. }
  2481. return false;
  2482. }
  2483.  
  2484. public function ipban($ip, $dcall = true) {
  2485. if (!filter_var($ip, FILTER_VALIDATE_IP)) {
  2486. return false;
  2487. }
  2488.  
  2489. $this->ipbans[] = $ip;
  2490. if ($dcall == true) {
  2491. foreach ($this->users as $u) {
  2492. if ($u->ipaddr == $ip) {
  2493. $this->disconnect($u->index);
  2494. }
  2495. }
  2496. }
  2497. $bans = json_encode($this->ipbans);
  2498. $this->mysql->query("update `server` set `ipbans`='{$this->mysql->sanatize($bans)}';");
  2499. return true;
  2500. }
  2501.  
  2502. public function ipUnban($ip) {
  2503. if (!filter_var($ip, FILTER_VALIDATE_IP)) {
  2504. return false;
  2505. }
  2506. foreach ($this->ipbans as $index => $addr) {
  2507. if ($ip == $addr) {
  2508. unset($this->ipbans[$index]);
  2509. $bans = json_encode($this->ipbans);
  2510. $this->mysql->query("update `server` set `ipbans`='{$this->mysql->sanatize($bans)}';");
  2511. return true;
  2512. } else {
  2513. continue;
  2514. }
  2515. }
  2516. return false;
  2517. }
  2518.  
  2519.  
  2520.  
  2521. public function spamfilter($element, $user, $ms = 800, $time = null, $dc = true) {
  2522. if (is_null($time)) {
  2523. $time = round(microtime(true) * 1000);
  2524. }
  2525. if (isset($user->last[$element]) && ($user->last[$element] + $ms) >= $time) {
  2526. return (is_null($dc) ? true : $this->disconnect($user->index));
  2527. }
  2528. $user->last[$element] = $time;
  2529. return false;
  2530. }
  2531.  
  2532. }
  2533. /* class do client do server para identificar as funçoes */
  2534. class client {
  2535.  
  2536. public $sock, $parent;
  2537. public $bride, $rank, $id, $username, $nickname, $k, $k2, $k3, $password, $avatar, $url, $powers, $room, $xats, $days, $chat, $banned, $hidden = false, $pool = 0, $switchingPools = false;
  2538. public $d0, $d1, $d2, $d3, $d4, $d5, $d6, $dt, $dx, $dO, $p0, $p1, $p2, $p4, $PowerO, $d7, $p3, $homepage, $h, $group, $away = false, $pStr;
  2539. public $loginKey = null, $last = array(), $authenticated = null, $online = false, $disconnect = false, $rExpire = 0, $chatPass = false, $pawn = '';
  2540. public $mobready = false, $buffer = '';
  2541.  
  2542. public function __construct(&$socket, &$parent, $index, $ipaddr, $mobile = false) {
  2543. list($this->index, $this->sock, $this->parent, $this->ipaddr, $this->mobile) = array(
  2544. $index, $socket, $parent, $ipaddr, $mobile
  2545. );
  2546. }
  2547.  
  2548. public function resetDetails($id, $bans = null) {
  2549. $user = $this->parent->mysql->fetch_array("select * from `users` where `id`='{$this->parent->mysql->sanatize($id)}' and `id` not in(0, 2);");
  2550. if (empty($user)) {
  2551. $this->guest = true;
  2552. } else {
  2553. if ($user[0]['username'] == '') {
  2554. list($this->guest, $this->k, $this->k2, $this->k3) = array(
  2555. true, $user[0]['k'], $user[0]['k2'], $user[0]['k3']
  2556. );
  2557. } else {
  2558. $this->xats = $user[0]['xats'];
  2559. $this->days = floor(($user[0]['days'] - time()) / (24 * 3600) + 0.3) >= 1 ? floor(($user[0]['days'] - time()) / (24 * 3600) + 0.3) : 0;
  2560. $this->username = $user[0]['username'];
  2561. $this->password = $user[0]['password'];
  2562. $this->enabled = $user[0]['enabled'];
  2563. $this->k = $user[0]['k'];
  2564. $this->k2 = $user[0]['k2'];
  2565. $this->k3 = $user[0]['k3'];
  2566. $this->PowerO = $user[0]['dO'];
  2567. $this->powers = $user[0]['powers'];
  2568. $this->avatar = $user[0]['avatar'];
  2569. $this->url = $user[0]['url'];
  2570. $this->d1 = 0;
  2571. $this->d2 = $user[0]['d2'];
  2572. $this->bride = $user[0]['bride'];
  2573. $this->d3 = null;
  2574. $this->pawn = $user[0]['pawn'] == 'off' ? '' : $user[0]['pawn'];
  2575.  
  2576. if ($this->mobile) {
  2577. $this->nickname = $this->username == '' ? 'Unregistered' : $this->username;
  2578. } else { //$this->mobile
  2579. $this->nickname = explode("##", $user[0]['nickname'], 2);
  2580. $this->nickname[0] = htmlspecialchars_decode($this->nickname[0]);
  2581. $this->nickname = count($this->nickname) > 1 ? implode("##", $this->nickname) : $this->nickname[0];
  2582. }
  2583.  
  2584. if (true || $user[0]['torched'] != 1) { // Torching - Add Later
  2585.  
  2586. if(!$this->getPowers())
  2587.  
  2588. {
  2589.  
  2590. return false;
  2591.  
  2592. }
  2593.  
  2594.  
  2595.  
  2596. $this->dO = $user[0]['dO'];
  2597.  
  2598. }
  2599. $this->dt = null;
  2600. $this->guest = false;
  2601. }
  2602.  
  2603. $trolls = json_decode($user[0]['trolls'], true);
  2604. if (is_array($trolls)) {
  2605. foreach ($trolls as $i => $u) {
  2606. $this->{$i} = $u;
  2607. }
  2608. }
  2609. }
  2610.  
  2611. if ($this->guest === true) {
  2612. $this->username = '';
  2613. }
  2614. return true;
  2615. }
  2616.  
  2617. public function getPowers($pV = array()) {
  2618. if ($this->days < 1)
  2619. {
  2620. for ($i = 0; $i <= $this->parent->config->pcount; $this->{'p' . $i++} = 0);
  2621. return true;
  2622. }
  2623.  
  2624. $powers = $this->parent->mysql->fetch_array('select * from `userpowers` where `userid`=' . $this->id . ';');
  2625. $powerv = $this->parent->mysql->fetch_array('select `id`, `section`, `subid` from `powers` where `name` not like \'%(Undefined)%\';');
  2626. $pv = $test = $final = array();
  2627. foreach ($powerv as $power) {
  2628. $pv[$power['id']] = array('sect' => $power['section'], 'sub' => (int) $power['subid']);
  2629. $test[$power['section']] = 0;
  2630. $last[$power['section']] = 0;
  2631. }
  2632.  
  2633. foreach ($powers as $power) {
  2634. if (isset ($test[$pv[$power['powerid']]['sect']])){
  2635. $test[$pv[$power['powerid']]['sect']] += $pv[$power['powerid']]['sub'];
  2636. }
  2637. }
  2638.  
  2639. foreach ($test as $sect => $val) {
  2640. if (isset($this->{$sect .'v'}) && (int) $val != (int) $this->{$sect . 'v'}) {
  2641. return false;
  2642. }
  2643. }
  2644.  
  2645. foreach ($powers as $power) {
  2646. if (isset($pv[$power['powerid']])) {
  2647. $power = $pv[$power['powerid']];
  2648. if ((int) $this->{$power['sect'] . 'v'} & $test[$power['sect']]) {
  2649. if (!((int) $power['sub'] & $test[$power['sect']])) {
  2650. return false;
  2651. }
  2652.  
  2653. if (!($this->{'m' . substr($power['sect'], 1)} & (int) $power['sub'])) {
  2654. $last[$power['sect']] += (int) $power['sub'];
  2655. }
  2656. }
  2657. }
  2658. }
  2659.  
  2660. $this->pStr = '';
  2661. foreach ($test as $sect => $u) {
  2662. $this->{$sect} = $last[$sect];
  2663. $this->pStr .= $sect . '="' . $this->{$sect} . '" ';
  2664. }
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673. return true;
  2674. }
  2675.  
  2676. public function updateDetails() {
  2677. $upowers = $this->parent->mysql->fetch_array('select * from `userpowers` where `userid`=' . $this->id . ';');
  2678. $spowers = $this->parent->mysql->fetch_array('select * from `powers` where `name` not like \'%(Undefined)%\';');
  2679.  
  2680. $vals = array();
  2681. $p = array();
  2682. $powerO = '';
  2683.  
  2684. foreach ($spowers as $power)
  2685. {
  2686. $vals[$power['id']] = array($power['section'], $power['subid']);
  2687. $p[$power['section']] = 0;
  2688. }
  2689.  
  2690. foreach ($upowers as $power)
  2691. {
  2692. if ($power['count'] >= 1 && isset($vals[$power['powerid']]) && isset($p[$vals[$power['powerid']][0]]))
  2693. {
  2694. $str = $power['powerid'] . '=' . ($power['count'] > 1 ? ($power['count'] - 1) : 1) . '|';
  2695. $p[$vals[$power['powerid']][0]] += $vals[$power['powerid']][1];
  2696. if ($power['count'] > 1) {
  2697. $powerO .= $str;
  2698. }
  2699. }
  2700. }
  2701. if ($this->id != 0 && $this->id != 2 && $this->mobile == false) {
  2702. $this->parent->mysql->query(
  2703. "update `users` set
  2704. `nickname`='{$this->parent->mysql->sanatize($this->nickname)}',
  2705. `avatar`='{$this->parent->mysql->sanatize($this->avatar)}',
  2706. `url`='{$this->parent->mysql->sanatize($this->url)}',
  2707. `dO`='{$this->parent->mysql->sanatize($powerO)}',
  2708. `connectedlast`='{$this->ipaddr}'
  2709. where `id`='{$this->parent->mysql->sanatize($this->id)}';"
  2710. );
  2711. } //$this->id != 0 && $this->id != 2 && $this->mobile == False
  2712. return ($this->id != 0 && $this->id != 2) ? true : false;
  2713. }
  2714.  
  2715. public function hasPower($power) {
  2716. list($subid, $section) = array(
  2717. pow(2, $power % 32),
  2718. $power >> 5
  2719. );
  2720.  
  2721. return $this->{'p' . $section} & $subid ? true : false;
  2722. ;
  2723. }
  2724.  
  2725. public function authenticate($packet) {
  2726. //print_r($packet->Attributes());
  2727. /* Load Packet Information */
  2728. /* Load Packet / Values */
  2729. $attributes = array('u', 'N', 'k', 'pool', 'f', 'auth1', 'auth2', 'h', 'd0', 'a', 'c', 'banned', 'r');
  2730. for ($i = 0; $i <= $this->parent->config->pcount; $i++) {
  2731. array_push($attributes, 'd' . ($i + 4));
  2732. array_push($attributes, 'm' . $i);
  2733. }
  2734.  
  2735. $info = $this->getMultiAttr($packet, $attributes);
  2736.  
  2737. for ($i = 0; $i <= $this->parent->config->pcount; $i++) {
  2738. $this->{'p' . $i . 'v'} = (int) $info['d' . ($i + 4)];
  2739. $this->{'m' . $i} = (int) $info['m' . $i];
  2740. }
  2741. /* End */
  2742. $this->id = (string) $info['u'];
  2743. $this->d0 = (integer) $info['d0'];
  2744. $this->f = (integer) $info['f'];
  2745. $n = (string) $info['N'];
  2746. $k = (integer) $info['k'];
  2747. $pool = $this->pool;
  2748.  
  2749.  
  2750. If ( $this->mobile && !( $this->f & 0x0200 ) )
  2751. {
  2752. $this->f += 0x0200;
  2753. } //$this->mobile && !( $this->f & 0x0200 )
  2754.  
  2755.  
  2756. $this->b = $this->f & 8 ? true : false;
  2757. $chat = (int) $info['c'];
  2758.  
  2759. if ($this->days < 1)
  2760. {
  2761.  
  2762. for ($i = 0; $i <= $this->parent->config->pcount; $i++)
  2763. {
  2764. $this->pStr .= 'p' . $i . '="0" ';
  2765. }
  2766. } else {
  2767. for ($i = 0; $i <= $this->parent->config->pcount; $i++)
  2768. {
  2769. $this->{'p' . $i . 'v'} = isset($info['d' . ($i + 4)]) ? $info['d' . ($i + 4)] : 0;
  2770. $this->{'m' . $i} = isset($info['m' . $i]) ? $info['m' . $i] : 0;
  2771. $this->pStr .= 'p' . $i . '="' . $this->{'p' . $i . 'v'} . '" ';
  2772. }
  2773. }
  2774. /* End */
  2775. /* Reset details, Check powers */
  2776. if (!$this->resetDetails($this->id)) {
  2777. return false;
  2778. }
  2779. $this->url = (string) $info['h'];
  2780. $this->avatar = (string) $info['a'];
  2781. $xInfo = $this->parent->mysql->fetch_Array( "select * from `chats` where `id`='{$this->parent->mysql->sanatize($chat)}';" );
  2782.  
  2783. /* End */
  2784. /* Bot Protection */
  2785.  
  2786. /* End */
  2787. /* Chat Password [get main] */
  2788. if ($info['r'] !== false) {
  2789. $this->chatPass = $info['r'];
  2790. }
  2791. /* Sanatize Name / Explode Status */
  2792. $this->nickname = $this->getAttribute($packet, 'n');
  2793. $this->nickname = explode('##', $this->nickname, 2);
  2794. if (count($this->nickname) > 1) {
  2795. $this->nickname[1] = htmlspecialchars(str_replace("", "", $this->nickname[1]));
  2796. $this->nickname = implode('##', $this->nickname);
  2797. } else {
  2798. $this->nickname = $this->nickname[0];
  2799. }
  2800. if (strlen($this->nickname) > 255) {
  2801. //return false;
  2802. }
  2803. /* End */
  2804. /* Just some information checking for guest system, + user exists */
  2805. if ($this->guest == true && isset($this->enabled) && $this->id != 2) {
  2806. return false;
  2807. } elseif ($this->id != 2 && is_numeric($k)) {
  2808. $user = $this->parent->mysql->fetch_array("select * from `users` where `id`='{$this->parent->mysql->sanatize($this->id)}' and `k`='{$this->parent->mysql->sanatize($k)}' and `id`!='' and `k`!='';");
  2809. if (empty($user)) {
  2810. return false;
  2811. } elseif ($user[0]['username'] == 'Unregistered') {
  2812. $this->guest = true;
  2813. } else {
  2814. $this->guest = false;
  2815. }
  2816. } else {
  2817. $this->guest = true;
  2818. }
  2819. /* End */
  2820. $this->updateDetails();
  2821. $this->authenticated = true;
  2822.  
  2823. $banned = $this->parent->mysql->fetch_array("select * from `bans` where `chatid`='{$chat}' and `type`='';");
  2824. $banned_id = (isset($banned[0]['userid'])) ? (int) $banned[0]['userid']: 0;
  2825. if($this->id == $banned_id){
  2826. return $this->joinRoom($chat, 1, false, 2);
  2827. } else {
  2828. return $this->joinRoom($chat, 1, false, $pool);
  2829. }
  2830. }
  2831.  
  2832. public function getAttribute($xml, $name) {
  2833. if (method_exists($xml, 'attributes')) {
  2834. foreach ($xml->attributes() as $a => $b) {
  2835. if ($a == $name)
  2836. return (string) $b;
  2837. }
  2838. }
  2839. return false;
  2840. }
  2841.  
  2842. public function getMultiAttr($xml, $names = array(), $values = array()) {
  2843. setType($names, 'array');
  2844. if (!method_exists($xml, 'attributes')) {
  2845. return array();
  2846. }
  2847. foreach ($names as $u) {
  2848. $values[$u] = false;
  2849. }
  2850. foreach ($xml->attributes() as $i => $u) {
  2851. if (in_array($i, $names)) {
  2852. $values[$i] = mb_convert_encoding((string) $u, "utf-8");
  2853. }
  2854. }
  2855. return $values;
  2856. }
  2857.  
  2858. public function message($t, $ex = true) {
  2859. $this->sendMessage($t, $this->id, 0, false, $ex);
  2860. }
  2861.  
  2862. public function sendMessage($t, $u = '[C]', $i = 0, $s = false, $ex = false) {
  2863. if ($u == '[C]')
  2864. $u = $this->id;
  2865. $packet = "<m t=\"{$t}\" u=\"{$u}\" i=\"{$i}\" />";
  2866. $ex != false ? $this->sendRoom($packet, $ex) : $this->sendPacket($packet);
  2867. }
  2868.  
  2869. public function sendPacket($packet) {
  2870. if ($this->sock) {
  2871. if ($this->mobile == true) {
  2872. $packet = simplexml_load_string($packet);
  2873. if (!method_exists($packet, 'getName')) {
  2874. $this->parent->disconnect($this->sock);
  2875. return false;
  2876. }
  2877.  
  2878. $json = new stdClass();
  2879. $json->tag = $packet->getName();
  2880. foreach ($packet->Attributes() as $i => $u) {
  2881. $json->{$i} = (string) $u;
  2882. }
  2883.  
  2884. $packet = json_encode($json);
  2885. $packet = $this->parent->mask($packet);
  2886. } elseif (substr($packet, -1) != chr(0)) {
  2887. $packet .= chr(0);
  2888. }
  2889.  
  2890. // socket_set_nonblock($this->sock);
  2891. if (!@socket_write($this->sock, $packet, strlen($packet))) {
  2892. $this->parent->disconnect($this->sock);
  2893. return false;
  2894. }
  2895.  
  2896. // socket_set_block($this->sock);
  2897. return true;
  2898. }
  2899. }
  2900.  
  2901. public function sendAll($packet) {
  2902. if (stristr($packet, strlen($packet) - 1, 1) != chr(0)) {
  2903. $packet = $packet . chr(0);
  2904. }
  2905. foreach ($this->parent->users as &$user) {
  2906. if (!@socket_write($user->sock, $packet, strlen($packet))) {
  2907. $this->parent->disconnect($user->index);
  2908. }
  2909. }
  2910. return true;
  2911. }
  2912.  
  2913. public function parseRank($rank) {
  2914. $ranks = array(1, 2, 3, 4, 5);
  2915. if (!is_numeric($rank)) {
  2916. switch (strtolower($rank)) {
  2917. case 'guest': return 5;
  2918. case 'owner': return 4;
  2919. case 'member': return 3;
  2920. case 'moderator': return 2;
  2921. case 'mainowner': return 1;
  2922. default: return 0;
  2923. }
  2924. } elseif (!in_array($rank, $ranks)) {
  2925. return 0;
  2926. }
  2927. return $rank;
  2928. }
  2929.  
  2930. public function rank($numrank, $word = null, $compare = null) { // Made this for the hell of it
  2931. $ranks = array(
  2932. 5 => array(5, 'guest'),
  2933. 3 => array(4, 'member'),
  2934. 2 => array(3, 'moderator'),
  2935. 4 => array(2, 'owner'),
  2936. 1 => array(1, 'mainOwner')
  2937. );
  2938. if (!in_array($numrank, $ranks)) {
  2939. $rank = $ranks[5];
  2940. } else {
  2941. $rank = $ranks[$numrank];
  2942. }
  2943. return is_null($compare) ? (is_null($word) ? $rank[0] : $rank[1]) : ($rank[0] < $ranks[$compare][0] ? true : false);
  2944. }
  2945.  
  2946. public function __destruct() {
  2947. /* It's done like this to avoid a bitch of a memory leak */
  2948. if (isset($this->id) && !isset($this->noLogout)) {
  2949. $this->sendRoom('<l u="' . $this->id . '" />', true);
  2950. }
  2951. }
  2952.  
  2953. public function joinRoom($chat, $reload = true, $nodup = false, $pool = 0, $banTick = 0) {
  2954. /* Initial Information */
  2955.  
  2956. list($this->pool, $this->hidden) = array($pool, false);
  2957.  
  2958. if (!$this->authenticated || !is_numeric($chat) || $chat < 1) {
  2959. return false;
  2960. }
  2961.  
  2962. $chat = $this->parent->mysql->fetch_array("select * from `chats` where `id`='{$this->parent->mysql->sanatize($chat)}';");
  2963. if (empty($chat)) {
  2964. return false;
  2965. }
  2966.  
  2967.  
  2968. list($this->chatid, $this->group) = array($chat[0]['id'], $chat[0]['name']);
  2969.  
  2970. $badge = $this->parent->mysql->fetch_array("select * from `badge` where `id`='{$this->parent->mysql->sanatize($this->id)}' and `chatid`='{$this->parent->mysql->sanatize($chat[0]['id'])}' order by `id` desc limit 0,1;");
  2971. if($this->id == isset($badge[0]['id'])){ $this->f += 262144; }
  2972. /* Do Ranks */
  2973. $ranks = $this->parent->mysql->fetch_array("select * from `ranks` where `chatid`='{$chat[0]['id']}' and `userid`='{$this->parent->mysql->sanatize($this->id)}';");
  2974. if ($this->chatPass !== false) {
  2975. if ($this->parent->mysql->validate($this->chatPass, $chat[0]['pass']) === true) {
  2976. if (empty($ranks)) {
  2977. $this->parent->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`) values({$this->id}, {$this->chatid}, 1);");
  2978. } else {
  2979. $this->parent->mysql->query("update `ranks` set `f`=1 where `userid`={$this->id} and `chatid`={$this->chatid};");
  2980. }
  2981. $ranks[0] = array(
  2982. 'userid' => $this->id,
  2983. 'chatid' => $this->chatid,
  2984. 'f' => 1,
  2985. 'tempend' => 0
  2986. );
  2987. }
  2988. }
  2989. if (!isset($ranks[0]['f'])) {
  2990. $ranks[0] = array('f' => 5);
  2991. $this->parent->mysql->query("insert into `ranks` (`userid`, `chatid`, `f`) values ('{$this->parent->mysql->sanatize($this->id)}', '{$chat[0]['id']}', '5');");
  2992. } elseif ($ranks[0]['tempend'] > 0 && $ranks[0]['tempend'] < time()) {
  2993. $ranks[0] = array("f" => 3);
  2994. $this->parent->mysql->query("update `ranks` set `f`=3, `tempend`=0 where `userid`={$this->id} and `chatid`={$this->chatid};");
  2995. } else {
  2996. $userRank = $ranks[0]['f'];
  2997. $this->rExpire = $ranks[0]['tempend'] > time() ? $ranks[0]['tempend'] : 0;
  2998. }
  2999.  
  3000. $this->rank = $ranks[0]['f'];
  3001.  
  3002. if ($this->hasPower(29) && !$this->online && in_array($this->rank & 7, array(1, 4))) {
  3003. $this->hidden = true;
  3004.  
  3005. if (!($this->f & 0x0400)) {
  3006. $this->f += 0x0400;
  3007. }
  3008. } elseif ($this->f & 0x0400) {
  3009. $this->f -= 0x0400;
  3010. }
  3011.  
  3012. $this->updateDetails();
  3013. $this->resetDetails($this->id, true);
  3014. /* End */
  3015. /* Update / Check Bans */
  3016. $game = '';
  3017. $this->banned = 0;
  3018. $this->unban = false;
  3019. $ban = $this->parent->mysql->fetch_array("select * from `bans` where `userid`='{$this->parent->mysql->sanatize($this->id)}' and `chatid`='{$this->parent->mysql->sanatize($chat[0]['id'])}' or `ip`='{$this->ipaddr}' and `chatid`='{$this->parent->mysql->sanatize($this->chatid)}' order by `unbandate` desc limit 0,1;");
  3020. if (!empty($ban) && ($this->id == $ban[0]['userid'] || $this->ipaddr == $ban[0]['ip'])) {
  3021. $ban = $ban[0];
  3022. if ($ban['unbandate'] >= $this->loginTime) {
  3023. if (substr($ban['type'], 0, 1) == 'w') {
  3024. $this->rank = 16;
  3025. $game = ' w="' . substr($ban['type'], 1) . '"';
  3026. } elseif (substr($ban['type'], 0, 1) == 'r') {
  3027. $this->rank |= (int) substr($ban['type'], 1);
  3028. } elseif (substr($ban['type'], 0, 1) == 'f') {
  3029. $this->f |= (int) substr($ban['type'], 1);
  3030. } else {
  3031. $this->rank = 16;
  3032. }
  3033.  
  3034. if (!($this->f & 0x8000)) { // desban do dunced
  3035. $this->banned = $ban['unbandate'];
  3036. }
  3037. } elseif ($this->id == $ban['userid']) {
  3038. $this->unban = true;
  3039. $this->parent->mysql->query("delete from `bans` where `userid`='{$this->parent->mysql->sanatize($this->id)}' and `chatid`='{$this->parent->mysql->sanatize($chat[0]['id'])}' and `unbandate`<={$this->loginTime};");
  3040. }
  3041. } elseif (empty($ban) && $this->b == true) {
  3042. $this->unban = true;
  3043. } elseif (isset($ban['unbandate'])) {
  3044. $this->sendPacket("<n t=\"You are banned for " . round(($ban['unbandate'] - time()) / 60, 1) . " more minutes.\" />");
  3045. }
  3046. /* End */
  3047. /* Chat Information */
  3048. if (empty($chat[0]['attached'])) {
  3049. $chat[0]['attached'] = array('Lobby', '1');
  3050. } else {
  3051. $info = $this->parent->mysql->fetch_array("select * from `chats` where `name`='{$this->parent->mysql->sanatize($chat[0]['attached'])}';");
  3052. if (empty($info) || $info[0]['id'] == $chat[0]['id']) {
  3053. $chat[0]['attached'] = array('Lobby', '1');
  3054. } else {
  3055. $chat[0]['attached'] = array(
  3056. 0 => $info[0]['name'],
  3057. 1 => $info[0]['id']
  3058. );
  3059. $this->f = $this->f |= 2;
  3060. }
  3061. }
  3062. if ($chat[0]['attached'][1] == $this->chatid) {
  3063. $chat[0]['attached'] = array('0', '0');
  3064. }
  3065. if ($chat[0]['NoSmilie'] == 1){ // Funçoes de OPÇOES EXTRA
  3066.  
  3067. $this->f |= 0x0800;
  3068. }
  3069. if ($chat[0]['DefNoSound'] == 1){
  3070. $this->f |= 131072;
  3071. }
  3072.  
  3073. if ($chat[0]['MembersOnly'] == 1){
  3074. $this->f |= 128;
  3075. }
  3076.  
  3077. if ($chat[0]['MembersOnly2'] == 1){
  3078. $this->f |= 0x100000;
  3079. }
  3080.  
  3081. if ($chat[0]['Live'] == 1){
  3082. $this->f |= 0x200000;
  3083. }
  3084.  
  3085. if ($chat[0]['NoList'] == 1){
  3086. $this->f |= 0x0200;
  3087. }
  3088.  
  3089. if ($this->unban == true) {
  3090. $this->sendPacket('<c u="0" d="' . $this->id . '" t="/u" />');
  3091. $this->unban = false;
  3092. }
  3093. $pawn = strlen($this->pawn) == 6 ? ' pawn="' . $this->pawn . '"' : '';
  3094. $lang = strlen($chat[0]['lang']) >= 1 ? $chat[0]['lang'] : '';
  3095.  
  3096. $this->sendPacket("<i{$pawn}{$game} b=\"{$chat[0]['bg']};={$chat[0]['attached'][0]};={$chat[0]['attached'][1]};={$lang};={$chat[0]['radio']};={$chat[0]['button']}\" f=\"{$this->f}\" ".($this->days >= 1 ? 'v="3"' : 'v="1"')." r=\"{$this->rank}\" cb=\"10\" />");
  3097.  
  3098. if($this->isAssigned($this->group, 114) && $this->isAssigned($this->group, 126))
  3099. $this->sendPacket("<w v=\"{$pool} 0 2 1\" />");
  3100. elseif($this->isAssigned($this->group, 114) && !$this->isAssigned($this->group, 126))
  3101. $this->sendPacket("<w v=\"{$pool} 0 1\" />");
  3102.  
  3103. $this->sendPacket($this->buildGp());
  3104.  
  3105. // $this->sendPacket('<gp p="0|0|1431372864|1074025493|273678340|268435456|16384|1|0|0|0|0|0|" g80="{\'mg\':\'0\',\'mb\':\'11\',\'kk\':\'0\',\'bn\':\'0\',\'ubn\':\'0\',\'prm\':\'0\',\'bge\':\'0\',\'mxt\':50,\'sme\':\'11\',\'dnc\':\'8\'}" g114="{\'m\':\'' . $chat[0]['chat'] . '\',\'t\':\'' . $chat[0]['mods'] . '\',\'rnk\':\'7\',\'b\':\'' . $chat[0]['banned'] . '\',\'v\':1}" g90="' . $chat[0]['badword'] . '" g74="' . $chat[0]['smiles'] . '" g106="' . $chat[0]['gback'] . '" g188="a91" g100="' . $chat[0]['link'] . '" u="1" />');
  3106. //@$this->sendPacket('<gp g80="{\'mg\':\'0\',\'mb\':\'11\',\'kk\':\'0\',\'bn\':\'0\',\'ubn\':\'0\',\'prm\':\'0\',\'bge\':\'0\',\'mxt\':50,\'sme\':\'11\',\'dnc\':\'8\'}" g114="{\'m\':\'' . $chat[0]['chat'] . '\',\'t\':\'' . $chat[0]['mods'] . '\',\'rnk\':\'7\',\'b\':\'' . $chat[0]['banned'] . '\',\'v\':1}" g90="' . $chat[0]['badword'] . '" g74="' . $chat[0]['gline'] . '" g106="' . $chat[0]['gback'] . '" g188="a91" g100="' . $chat[0]['link'] . '" p="0|0|1431372864|1074025493|273678340|268435456|16384|1|0|0|0|0|0|" />'); /* End */
  3107. /* Check if user is already on chat */
  3108. if ($nodup == false) {
  3109. while ($r = $this->parent->getUserByID((int) $this->id, (int) $chat[0]['id'])) {
  3110. if (is_object($r) && $r->online === true) {
  3111. $r->sendPacket("<dup />");
  3112. $r->noLogout = true;
  3113. $this->parent->disconnect($r->index, true);
  3114. }
  3115. }
  3116. }
  3117. /* End */
  3118. /* Compile, and send user list */
  3119. $this->chat = $chat[0]['id'];
  3120. $myNick = explode("##", $this->nickname, 2);
  3121. $myNick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($myNick[0])));
  3122. $myNick = count($myNick) > 1 ? implode("##", $myNick) : $myNick[0];
  3123.  
  3124. $myPack = "<u{$pawn} so=\"1\" f=\"{$this->f}\" flag=\"{$this->f}\" rank=\"{$this->rank}\" u=\"{$this->id}\" ".($this->days >= 1 ? ' q="3"' : ' q="1"') . ($this->username == '' ? '' : " N=\"{$this->username}\"") . " n=\"{$myNick}\" a=\"{$this->avatar}\" h=\"{$this->url}\" d0=\"{$this->d0}\" d2=\"{$this->d2}\" bride=\"{$this->bride}\" {$this->pStr}v=\"1\" />";
  3125. $valid = simplexml_load_string($myPack);
  3126. if (!method_exists($valid, 'getName')) {
  3127. return false;
  3128. } else {
  3129. foreach ($this->parent->users as $user) {
  3130. if ($this->mobile == true && $user->mobile == true && $user->ipaddr == $this->ipaddr && $user->username != $this->username) {
  3131. $this->parent->disconnect($user->index);
  3132. }
  3133.  
  3134. if ($user->chat == $chat[0]['id'] && $user->id != $this->id && $user->pool == $this->pool) {
  3135. if (!in_array($user->id, array(0, 2)) && $user->hidden == false) {
  3136. $user->bride = $user->d2 == 0 ? null : $user->d2;
  3137. $nick = explode('##', $user->nickname, 2);
  3138. $nick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($nick[0])));
  3139. $nick = count($nick) > 1 ? implode('##', $nick) : $nick[0];
  3140. $pawn = strlen($user->pawn) == 6 ? ' pawn="' . $user->pawn . '"' : '';
  3141.  
  3142. $packet = "<u{$pawn} flag=\"{$user->f}\" s=\"1\" f=\"{$user->f}\" rank=\"{$user->rank}\" u=\"{$user->id}\" ".($user->days >= 1 ? ' q="3"' : ' q="1"') . ($user->username == '' ? '' : " N=\"{$user->username}\"") . " n=\"{$nick}\" a=\"{$user->avatar}\" h=\"{$user->url}\" d0=\"{$user->d0}\" d2=\"{$user->d2}\" bride=\"{$user->bride}\" {$user->pStr}v=\"1\" />";
  3143. $valid = simplexml_load_string($packet);
  3144.  
  3145. if (method_exists($valid, 'getName')) {
  3146. $this->sendPacket($packet);
  3147. } else {
  3148. $this->parent->disconnect($user->index);
  3149. continue;
  3150. }
  3151. }
  3152.  
  3153. if (!in_array($this->id, array(0, 2)) && $this->hidden == false) {
  3154. $user->sendPacket($myPack);
  3155. }
  3156. }
  3157. }
  3158. }
  3159. /* End */
  3160. /* Send Previous Messages (15) */
  3161. if ($reload == true) {
  3162. $messages = $this->parent->mysql->fetch_array("select * from `messages` where `id`='{$chat[0]['id']}' and `pool`={$this->pool} order by time desc limit 0,15;");
  3163. for ($i = 0; $i < count($messages); $i++) {
  3164. $message = $messages[count($messages) - $i - 1];
  3165. if ($message['visible'] == '1') {
  3166. $this->sendPacket("<m u=\"{$message['uid']}\" n=\"{$message['name']}\" N=\"{$message['registered']}\" a=\"{$message['avatar']}\" i=\"{$message['mid']}\" t=\"{$message['message']}\" s=\"1\" />");
  3167. }
  3168. }
  3169. unset($messages);
  3170. unset($message);
  3171. }
  3172. /* End */
  3173. $this->sendPacket("<done />");
  3174. /* Other info, scrollies, protection meh */
  3175. $this->sendPacket("<m u=\"{$chat[0]['ch']}\" t=\"/s{$chat[0]['sc']}\" />");
  3176.  
  3177. if (isset($this->parent->protected[$this->chat])) {
  3178. $time = floor(($this->parent->protected[$this->chat]['end'] - time()) / 60);
  3179. switch ($this->parent->protected[$this->chat]['type']) {
  3180. case 'noguest':
  3181. $this->sendPacket("<z d=\"0\" u=\"0\" t=\"This chat is protected for another {$time} minutes. Guests cannot chat until given a higher rank.\" />");
  3182. break;
  3183. case 'unreg':
  3184. $this->sendPacket("<z d=\"0\" u=\"0\" t=\"This chat is protected for another {$time} minutes. Unregistered users cannot chat until given a higher rank.\" />");
  3185. break;
  3186. }
  3187. } elseif ($this->f & 1 && 1 == 2) {
  3188. $this->sendPacket("<logout e=\"E12\" />");
  3189. }
  3190. $check = $this->parent->mysql->fetch_array("select xfrom,xmessage from `offline_messages` where `xto`='{$this->id}' and `unread`='1' limit 0,5;");
  3191. if(!empty($check))
  3192. {
  3193. foreach($check as $c)
  3194. {
  3195. $this->sendPacket("<z u=\"".$c["xfrom"]."\" t=\"".$c["xmessage"]."\" s=\"2\" d=\"".$this->id."\" />");
  3196. }
  3197. $this->parent->mysql->query("update `offline_messages` set `unread`='0' where `xto`='{$this->id}';");
  3198. }
  3199. $this->online = true;
  3200. /* End */
  3201. return true;
  3202. }
  3203.  
  3204. public function isAssigned($group, $p){
  3205. $assigned = $this->parent->mysql->fetch_array("select * from `group_powers` where `group`='{$group}' and `power`='{$p}' and `enabled`='1';");
  3206. empty($assigned) ? $a = false : $a = true;
  3207. return $a;
  3208. }
  3209.  
  3210. public function flixs($p, $group, $data){
  3211. $power = $this->parent->mysql->fetch_array("select * from `group_powers` where `group`='{$group}' and `power`='{$p}';");
  3212. $data = json_decode($data, true);
  3213. $data['v'] = $power[0]['count'];
  3214. $data = str_replace('"', "'", json_encode($data));
  3215. empty($data) ? $gp = '' : $gp = "g{$p}=\"{$data}\" ";
  3216. return $gp;
  3217. }
  3218.  
  3219. public function buildGp(){
  3220. $gdata = $this->parent->mysql->fetch_array("SELECT * FROM `chats` WHERE `name`='" . $this->group . "';");
  3221. $group_powers = $this->parent->mysql->fetch_array("select * from `group_powers` as `gp` INNER JOIN `powers` as `pw` ON gp.power = pw.id WHERE gp.group = '".$this->group."' and gp.enabled='1';");
  3222. $section = array();
  3223. foreach($group_powers as $gp){ @$section[$gp['section']] |= $gp['subid']; }
  3224. for($i=0; $i<14; $i++){ ${'p'.$i} = isset($section['p'.$i]) ? $section['p'.$i] : 0; }
  3225. $p = array($p0, $p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8, $p9, $p10, $p11, $p12, $p13);
  3226. $gpp = implode('|', $p);
  3227.  
  3228. $gp = "<gp ";
  3229. $gp .= "p=\"{$gpp}\" ";
  3230. if($this->isAssigned($this->group, 74) && !empty($gdata[0]['gline'])){$gp .= "g74=\"{$gdata[0]['gline']}\" ";}
  3231. if($this->isAssigned($this->group, 80) && !empty($gdata[0]['gcontrol'])){$gp .= "g80=\"{$gdata[0]['gcontrol']}\" "; }
  3232. if($this->isAssigned($this->group, 90) && !empty($gdata[0]['bad'])){$gp .= "g90=\"{$gdata[0]['bad']}\" ";}
  3233. if($this->isAssigned($this->group, 92) && !empty($gdata[0]['horrorflix'])){$gp .= $this->flixs(92, $this->group, $gdata[0]['horrorflix']);}
  3234. if($this->isAssigned($this->group, 96) && !empty($gdata[0]['winterflix'])){$gp .= $this->flixs(96, $this->group, $gdata[0]['winterflix']);}
  3235. if($this->isAssigned($this->group, 98) && !empty($gdata[0]['feastflix'])){$gp .= $this->flixs(98, $this->group, $gdata[0]['feastflix']);}
  3236. if($this->isAssigned($this->group, 100) && !empty($gdata[0]['link'])){$gp .= "g100=\"{$gdata[0]['link']}\" ";}
  3237. if($this->isAssigned($this->group, 102) && !empty($gdata[0]['fairyflix'])){$gp .= $this->flixs(102, $this->group, $gdata[0]['fairyflix']);}
  3238. if($this->isAssigned($this->group, 108) && !empty($gdata[0]['loveflix'])){$gp .= $this->flixs(108, $this->group, $gdata[0]['loveflix']);}
  3239. if($this->isAssigned($this->group, 112) && !empty($gdata[0]['announce'])){$gp .= "g112=\"{$gdata[0]['announce']}\" ";}
  3240. if($this->isAssigned($this->group, 114) && !empty($gdata[0]['pools'])){$gp .= "g114='{$gdata[0]['pools']}' "; }
  3241. if($this->isAssigned($this->group, 130) || $this->isAssigned($this->group, 130)){
  3242. if($this->isAssigned($this->group, 130) && substr($gdata[0]['gback'], 0, 1) == '#' && strlen(substr($gdata[0]['gback'], 1)) == 6){
  3243. $gback = substr($gdata[0]['gback'], 1).'#';
  3244. $gp .= "g130=\"{$gback}\" ";
  3245. }
  3246. elseif($this->isAssigned($this->group, 130) && substr($gdata[0]['gback'], 6, 1) == '#' && strlen(substr($gdata[0]['gback'], 0, 6)) == 6){
  3247. $gp .= "g130=\"{$gdata[0]['gback']}\" ";
  3248. }
  3249. elseif($this->isAssigned($this->group, 130) && $this->isAssigned($this->group, 130) && substr($gdata[0]['gback'], 0, 1) != '#' && substr($gdata[0]['gback'], 6, 1) == '#'){
  3250. $gp .= "g130\"{$gdata[0]['gback']}\" ";
  3251. }
  3252. elseif($this->isAssigned($this->group, 130) && substr($gdata[0]['gback'], 0, 1) != '#'){
  3253. $gp .= "g130=\"{$gdata[0]['gback']}\" ";
  3254. }
  3255. }
  3256. if($this->isAssigned($this->group, 148) && !empty($gdata[0]['spookyflix'])){$gp .= $this->flixs(148, $this->group, $gdata[0]['spookyflix']);}
  3257. if($this->isAssigned($this->group, 156) && !empty($gdata[0]['santaflix'])){$gp .= $this->flixs(156, $this->group, $gdata[0]['santaflix']);}
  3258. if($this->isAssigned($this->group, 180) && !empty($gdata[0]['gsound'])){$gp .= "g180='{$gdata[0]['gsound']}' "; }
  3259. if($this->isAssigned($this->group, 206) && !empty($gdata[0]['customlang'])){$gp .= "g206='{$gdata[0]['customlang']}' "; }
  3260. if($this->isAssigned($this->group, 246)){$gp .= "g246=\"{'dt':70,'v':1}\" ";}
  3261. if($this->isAssigned($this->group, 252) && !empty($gdata[0]['redirect'])){$gp .= "g252='{$gdata[0]['redirect']}' ";}
  3262. if($this->isAssigned($this->group, 256)){$gp .= "g256=\"{'rnk':'2','dt':65,'rt':15,'rc':'1','tg':200,'v':1}\" ";}
  3263. if($this->isAssigned($this->group, 278) && !empty($gdata[0]['springflix'])){$gp .= $this->flixs(278, $this->group, $gdata[0]['springflix']);}
  3264. if($this->isAssigned($this->group, 297) && !empty($gdata[0]['summerflix'])){$gp .= $this->flixs(297, $this->group, $gdata[0]['summerflix']);}
  3265. $gp .= "/>";
  3266. return $gp;
  3267. }
  3268. public function sendRoom($packet, $passme = false, $exclude = 0) {
  3269. foreach ($this->parent->users as $user) {
  3270. if (
  3271. $user->chat == $this->chat &&
  3272. $user->id != $exclude &&
  3273. (
  3274. isset($user->pool) &&
  3275. isset($this->pool) &&
  3276. $user->pool == $this->pool
  3277. )
  3278. ) {
  3279. if ($user->id != $this->id || $passme == false) {
  3280. $user->sendPacket($packet);
  3281. }
  3282. }
  3283. }
  3284. }
  3285.  
  3286. public function noToRank($rank){
  3287. if ($rank >= 14){
  3288. return 'o';
  3289. };
  3290. if ($rank >= 10){
  3291. return 'M';
  3292. };
  3293. if ($rank >= 7){
  3294. return 'm';
  3295. };
  3296. if ($rank >= 3){
  3297. return 'e';
  3298. };
  3299. return 'r';
  3300. }
  3301.  
  3302. }
  3303.  
  3304.  
  3305. class database {
  3306.  
  3307. public $link, $host, $user, $pass, $name;
  3308. public $doe = true;
  3309.  
  3310. public function __construct($host = null, $user = null, $pass = null, $name = null) {
  3311. if ($name != null) {
  3312. $this->host = $host;
  3313. $this->user = $user;
  3314. $this->pass = $pass;
  3315. $this->name = $name;
  3316. }
  3317.  
  3318. if (!$this->connected()) {
  3319. $this->link = @mysqli_connect($this->host, $this->user, $this->pass, $this->name);
  3320. if (!$this->connected()) {
  3321. $this->error("Failed to connect to `{$this->host}`.`{$this->name}` using password [" . (empty($this->pass) ? "NO" : 'YES') . "]");
  3322. }
  3323. } return true; // Cause I can put it there if I want to
  3324. }
  3325.  
  3326. public function connected() {
  3327. return @mysqli_ping($this->link) ? true : false;
  3328. }
  3329.  
  3330. public function error($error) {
  3331. print $error . chr(10);
  3332. if ($this->doe == true) {
  3333. exit('line:' . __LINE__);
  3334. }
  3335. }
  3336.  
  3337. public function query($query = "") {
  3338. if (!is_string($query)) {
  3339. return false;
  3340. }
  3341. $this->__construct();
  3342. $return = mysqli_query($this->link, $query);
  3343. return $return ? $return : false;
  3344. }
  3345.  
  3346. public function fetch_array($query, $return = array()) {
  3347. $this->__construct();
  3348. if (!is_string($query) || !($res = $this->query($query))) {
  3349. return array();
  3350. }
  3351. while ($data = mysqli_fetch_assoc($res)) {
  3352. $return[] = $data;
  3353. }
  3354. return !empty($return) ? $return : array();
  3355. }
  3356.  
  3357. public function sanatize($data) {
  3358. if (is_array($data)) {
  3359. return array_map(array($this, 'sanatize'), $data);
  3360. }
  3361. if (function_exists("mb_convert_encoding")) {
  3362. $data = mb_convert_encoding($data, "UTF-8", 'auto');
  3363. }
  3364. return $this->link->real_escape_string($data);
  3365. }
  3366.  
  3367. public function rand($length = 32, $low = true, $upp = true, $num = true, $indent = false) {
  3368. $chars = array_merge(
  3369. $low ? range('a', 'z') : array(), $upp ? range('A', 'Z') : array(), $num ? range('0', '9') : array()
  3370. );
  3371. for ($rand = ""; strlen($rand) < $length; $rand .= $chars[array_rand($chars)])
  3372. ;
  3373. if ($indent != false) {
  3374. $rand = implode('-', str_split($rand, $indent));
  3375. }
  3376. return $rand;
  3377. }
  3378.  
  3379. static function urs($x, $y) {
  3380. return ($x >> $y) & (2147483647 >> ($y - 1));
  3381. }
  3382.  
  3383. public function hash($str, $rawsalt = '', $hash = 'sha512') {
  3384. if ($rawsalt == '') {
  3385. $rawsalt = $this->rand(((strlen($str) % 3) + 1) * 5);
  3386. }
  3387.  
  3388. $loc = array(hash('sha1', $rawsalt), hash('sha1', $str), '');
  3389. foreach (str_split($loc[0], 1) as $index => $character) {
  3390. $loc[2] .= $character . $loc[1][$index];
  3391. }
  3392.  
  3393. $hash = hash($hash, $loc[2]);
  3394. return substr_replace($hash, $rawsalt, (strlen($str) << 2) % strlen($hash), 0);
  3395. }
  3396.  
  3397. public function validate($str, $hash, $engine = 'sha512') {
  3398. $salt = substr($hash, (strlen($str) << 2) % strlen(hash($engine, 1)), ((strlen($str) % 3) + 1) * 5);
  3399. return $this->hash($str, $salt, $engine) === $hash ? true : false;
  3400. }
  3401.  
  3402. public function hashPass($pass, $salt = null, $hashtype = 'sha512', $hash = "") {
  3403. return $this->hash($pass, $salt, $hashtype);
  3404. }
  3405.  
  3406. public function checkPass($input, $real, $hash = 'sha512') {
  3407. return $this->validate($input, $real, $hash);
  3408. }
  3409.  
  3410. }
Add Comment
Please, Sign In to add comment