Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- date_default_timezone_set("America/Sao_Paulo");
- libxml_use_internal_errors(false);
- ini_set('display_errors', 'off');
- ini_set('log_errors', 0);
- ini_set('error_log', 'superxat.log');
- error_reporting(E_ALL);
- do
- {
- $server = new UXAT();
- unset($server);
- }
- while (true);
- class UXAT
- {
- private $info = array();
- public $socket = array(null, null);
- public $users = array();
- public $ipbans = array();
- public $protected = array();
- public $rfilter = array();
- public $debug = false;
- public $nulleGp;
- public $loginTime;
- public $hasGroupPowers = array("Lobby");
- public $trade = [];
- public function __construct()
- {
- //require __DIR__ . "/../_class/config.php";
- $this->flags = (object)array('away' => '16384', 'naugthy' => '524288', 'gag' => '256', 'yellowcard' => '1048576','redcard' => '2097152', 'dunce' => '32768'); //Flags
- $config = (object)array('db' => array(0 => 'localhost', 1 => 'root', 2 => '', 3 => 'xat')); //Configuracao
- $this->mysql = new Database($config->db[0], $config->db[1], $config->db[2], $config->db[3]);
- $this->resetConfig();
- $this->bind();
- while (true)
- {
- $this->bind();
- while ($this->socket[0])
- {
- $this->listen();
- }
- array_map('socket_close', $this->socket);
- }
- }
- /* config da database Server */
- public function resetConfig()
- {
- $this->config = $this->mysql->fetch_array("select * from `server` limit 0, 1;");
- $this->config = (object)$this->config[0];
- $this->config->spam_wait = 800;
- $this->config->staff = (array)json_decode($this->config->staff);
- $this->config->volunteers = (array)json_decode($this->config->volunteers);
- $this->config->pawns = (array)json_decode($this->config->pawns);
- $this->config->pcount = $this->mysql->fetch_array('select count(distinct `section`) as `count` from `powers`;');
- $this->config->pcount = $this->config->pcount[0]['count'];
- $this->hash = $this->mysql->rand(25); /* For API Laterz */
- $this->ipbans = $this->mysql->fetch_array("select `ipbans` from `server`;");
- $this->ipbans = (array)json_decode($this->ipbans[0]['ipbans']);
- $this->loginTime = time();
- $this->mysql->query("update `server` set `pid`='" . getmypid() . "';");
- }
- public function array_column(array $input, $columnKey, $indexKey = null)
- {
- $array = array();
- foreach ($input as $value)
- {
- if (!array_key_exists($columnKey, $value))
- {
- trigger_error("Key \"$columnKey\" does not exist in array");
- return false;
- }
- if (is_null($indexKey))
- {
- $array[] = $value[$columnKey];
- }
- else
- {
- if (!array_key_exists($indexKey, $value))
- {
- trigger_error("Key \"$indexKey\" does not exist in array");
- return false;
- }
- if (!is_scalar($value[$indexKey]))
- {
- trigger_error("Key \"$indexKey\" does not contain scalar value");
- return false;
- }
- $array[$value[$indexKey]] = $value[$columnKey];
- }
- }
- return $array;
- }
- public function bind()
- {
- try
- {
- global $argv;
- $this->socket = [socket_create(AF_INET, SOCK_STREAM, SOL_TCP), socket_create_listen(0) ];
- socket_getsockname(end($this->socket), $ip, $port);
- $this->mysql->query("update `server` set `ipc`={$port};");
- socket_set_option($this->socket[0], SOL_SOCKET, SO_REUSEADDR, True);
- if (!Isset($argv[1]) || $argv[1] != 'debug')
- {
- socket_bind($this->socket[0], $this->config->server_ip, $this->config->server_pt) or exit;
- } //!Isset( $argv[ 1 ] ) || $argv[ 1 ] != 'debug'
- else
- {
- $this->debug = True;
- socket_bind($this->socket[0], $this->config->server_ip, $this->config->backup_pt) or exit;
- }
- socket_listen($this->socket[0]);
- socket_set_block($this->socket[0]);
- }
- catch(Exception $e)
- {
- print $e->getMessage();
- exit;
- }
- }
- public function recv($socket)
- {
- $len = 32768;
- $data = "";
- $i = 0;
- while (true)
- {
- $bytes = socket_recv($socket, $chunk, $len, 0);
- $data .= $chunk;
- if ($bytes < $len || $i == 5) break;
- $i++;
- }
- return $data;
- }
- public function listen($null = null, $except = null, $ipc = 0)
- {
- $read = $this->socket;
- foreach ($this->users as $user)
- {
- $read[] = $user->sock;
- }
- if (@socket_select($read, $null, $except, null) < 1)
- {
- return;
- }
- foreach ($this->socket as $i => $psock)
- {
- if (in_Array($psock, $read))
- {
- switch ((int)$i)
- {
- case 0:
- $socket = socket_accept($psock);
- socket_set_nonblock($socket);
- if (!is_resource($socket) || count($this->users) >= $this->config->max_total)
- {
- @socket_close($socket);
- break;
- }
- socket_getpeername($socket, $ip);
- foreach ($this->users as $user)
- {
- if ($user->ipaddr == $ip)
- {
- $ipc++;
- }
- }
- if ($ipc > $this->config->max_per_ip || in_Array($ip, $this->ipbans))
- {
- foreach ($this->users as $user)
- {
- if ($user->ipaddr == $ip)
- {
- $this->disconnect($user->index);
- }
- }
- break;
- }
- do
- {
- $index = $this->mysql->rand();
- }
- while (Isset($this->users[$index]));
- $this->users[$index] = new client($socket, $this, $index, $ip);
- break;
- case 1:
- $this->socket[] = socket_accept($psock);
- break;
- default:
- $data = @trim(socket_read($psock, 1204));
- if (strlen($data) <= 1)
- {
- socket_close($psock);
- unset($this->socket[$i]);
- break;
- }
- $packet = @simplexml_load_string($data);
- $data = $this->GetMultiAttr($packet);
- if (!method_exists($packet, 'getName'))
- {
- break;
- }
- foreach ($packet->Attributes() as $i => $u)
- {
- $return[$i] = (string)((string)$u);
- print_r($return);
- }
- switch ($packet->getName())
- {
- case 'gift':
- $user = $this->getUserByID($return['u']);
- if (!is_object($user)) break;
- $user->sendRoom($user->createPacket("a", array("u" => $return['u'], "k" => "Gifts", "t" => $return['text'], "c" => $return['c'])));
- break;
- }
- }
- }
- }
- if (!is_Array($except))
- {
- $except = Array();
- }
- foreach ($this->users as $index => $user)
- {
- if (in_Array($user->sock, $except) || !$user->sock)
- {
- unset($this->users[$index]);
- }
- ElseIf (in_Array($user->sock, $read))
- {
- $input = $this->recv($user->sock);
- while (@socket_recv($user->sock, $buf, (1024 * 1024), 0) >= 1) //CONFIGURAR RAM 2GB
- //while(@socket_recv($user->sock, $buf, 8192, 0)) //CONFIGURAR RAM 4 GB
- {
- $input .= $buf;
- }
- if (trim($input) == '' || ord(substr($input, 0, 1)) == 136)
- {
- unset($this->users[$index]);
- continue;
- }
- ElseIf (substr_count($input, chr(0)) <= 1)
- {
- $this->handle($input, $user);
- } //substr_count( $input, chr( 0 ) ) <= 1
- }
- }
- }
- private function handle($packet, &$user)
- {
- $packet = str_replace('', '', $packet); //RIP Chrome
- try
- {
- if ($this->debug)
- {
- var_dump($packet);
- }
- if ($user->mobile == false && substr($packet, 0, 1) !== '<')
- {
- $user->mobile = true;
- }
- if ($user->mobile == true)
- {
- if ($user->mobready == false)
- {
- $user->buffer .= $packet;
- if (strlen($user->buffer) >= 4096)
- {
- throw new Exception();
- }
- if (is_numeric(strpos($user->buffer, "\r\n\r\n")))
- {
- $headers = array();
- $lines = explode("\r\n", $user->buffer);
- foreach ($lines as $line)
- {
- $line = explode(': ', $line, 2);
- if (count($line) < 2) continue;
- $headers[strtolower($line[0]) ] = $line[1];
- }
- if (!isset($headers['sec-websocket-key']))
- {
- throw new Exception();
- }
- $secAccept = base64_encode(pack('H*', sha1($headers['sec-websocket-key'] . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11')));
- $response = array();
- array_push($response, "HTTP/1.1 101 Pulse");
- array_push($response, "Upgrade: websocket");
- array_push($response, "Connection: Upgrade");
- array_push($response, "Sec-WebSocket-Accept: " . $secAccept);
- @socket_write($user->sock, implode("\r\n", $response) . "\r\n\r\n");
- $user->mobready = true;
- }
- return;
- }
- else
- {
- $packet = $this->unmask($packet);
- if ($packet == false)
- {
- throw new Exception(1);
- }
- }
- }
- if (strpos($packet, '<', 1) !== false)
- {
- throw new Exception(2);
- }
- $packet2 = $packet;
- $packet = $this->parsePacket($packet);
- $tag = strtolower($packet['node']);
- $packet = $packet['elements'];
- $lPackets = array('policy-file-request', 'j2', 'y', 'v');
- if (strlen($tag) > 25 || $tag == '')
- {
- throw new Exception(4);
- }
- if (!isset($user->loginKey) || $user->loginKey == null)
- {
- if (!in_array($tag, $lPackets))
- {
- throw new Exception(5);
- }
- }
- elseif ($user->authenticated == null && $tag != 'j2' && $tag != 'v')
- {
- throw new Exception(6);
- }
- elseif (isset($user->id) && in_array($user->id, array(0, 2)))
- {
- throw new Exception(7);
- }
- elseif ($user->hidden == true && $user->online)
- {
- $user->hidden = false;
- $user->joinRoom($user->chat, false, true, $user->pool);
- };
- }
- catch(Exception $e)
- {
- //print $e->getMessage() . "\n";
- return $this->disconnect($user->index);
- }
- if (!$user->authenticated && !in_array($tag, $lPackets))
- {
- return $this->disconnect($user->index, true);
- }
- switch ($tag)
- {
- case 'v':
- $user2 = $this->getAttribute($packet, 'n');
- $password = $this->getAttribute($packet, 'p');
- $userLogin = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($user2) . '\';');
- if (!$this->mysql->validate($password, $userLogin[0]['password']) || empty($userLogin))
- {
- $user->joinRoom(2, false, true, $user->pool);
- }
- else
- {
- $user->sendPacket($this->doLogin($user2, $password));
- }
- break;
- case substr($tag, 0, 1) == 'w':
- $pool = substr($tag, 1, 2);
- $chat = $this->mysql->fetch_array("select * from `chats` where `id`={$user->chat};");
- $rank = str_replace('\'', '"', $chat[0]['pools']);
- $rank = json_decode($rank, true);
- $rankS = $user->noToRank($rank['rnk']);
- if ($rankS == "o" && $user->rank != 1)
- {
- break;
- }
- elseif ($rankS == "M" && ($user->rank != 1 && $user->rank != 4))
- {
- break;
- }
- elseif ($rankS == "m" && ($user->rank != 1 && $user->rank != 4 && $user->rank != 2))
- {
- break;
- }
- elseif ($rankS == "e" && ($user->rank != 1 && $user->rank != 4 && $user->rank != 2 && $user->rank != 3))
- {
- break;
- }
- else
- {
- $user->sendRoom($user->createPacket("l", array("u" => $user->id)));
- $user->switchingPools = true;
- $user->joinRoom($user->chat, false, true, $pool, true);
- $user->sendRoom($user->createPacket("m", array("t" => "/RTypeOff", "u" => $user->id)));
- }
- break;
- case 'f': /* packet para add amigos */
- $users = $this->getAttribute($packet, 'o');
- $friends = (array)explode(' ', $users);
- $online = array();
- foreach ($this->users as $i => $_user)
- {
- if ($_user->id != $user->id && in_array($_user->id, $friends) && $_user->hidden === false && !in_array($_user->id, $online))
- {
- array_push($online, $_user->id);
- }
- }
- $user->sendPacket($user->createPacket("f", array("v" => implode(',', $online))));
- break;
- case 'policy-file-request':
- if (isset($user->policy))
- {
- return $this->ipban($user->ipaddr);
- }
- $user->sendPacket('<cross-domain-policy><allow-access-from domain="*" to-ports="*" /></cross-domain-policy>');
- $user->policy = 1;
- break;
- case 'r':
- break;
- case 'y': /* packets de conexao do xat */
- if (isset($user->loginKey) && $user->loginKey != null)
- {
- return $this->ipban($user->ipaddr);
- }
- $user->loginKey = rand(10000000, 99999999);
- $user->loginShift = rand(2, 5);
- $user->loginTime = time();
- $user->sendPacket($user->createPacket('y', array('i' => $user->loginKey, 'c' => $user->loginTime, 'p' => '100_100_5_100', 'y' => $user->loginKey, 'cb' => $user->loginTime)));
- break;
- case 'j2':
- if ($user->authenticated == true)
- {
- $user->sendPacket('<logout />');
- return $this->disconnect($user->index);
- }
- if ($user->authenticate($packet) == false)
- {
- $user->sendPacket('<n t="You must re-login to be able to chat further." />');
- $user->sendPacket('<logout />');
- $this->disconnect($user->index);
- }
- $chatr = $this->mysql->fetch_array("select * from `chats` where `id`={$user->chat};");
- if (isset($chatr[0]['MembersOnly2']) && $chatr[0]['MembersOnly2'] == 1)
- {
- if ($user->guest == true && in_array($user->rank, array(5, 40)))
- {
- $user->sendPacket('<m u="0" t="This is a registered users only chat, you can private chat an owner or moderator and ask to join." i="0" />');
- }
- }
- $user->sendRoom($user->createPacket('m', array('t' => '/RTypeOff', 'u' => $user->id)));
- /*End*/
- if ($user->isAssigned($packet['c'], 220))
- {
- $user->sendPacket($user->createPacket('g', array('u' => $packet['u'], 'x' => '20048')));
- }
- if ($user->guest == true || $user->authenticated == true)
- {
- $users = array();
- foreach ($this->users as & $u)
- {
- @array_push($users, $u->group);
- }
- $count = @array_count_values($users);
- $this->mysql->query('update `chats` set `users`=' . (isset($count[$user->group]) ? $count[$user->group] : 0) . ' where `name`=\'' . $user->group . '\';');
- }
- $usr = $this->mysql->fetch_array("select * from `users` where `id`={$packet['u']};");
- if (isset($usr[0]['block']) && $usr[0]['block'] != 0)
- {
- $user->sendPacket('<n t="Blocked <i>" />');
- $user->sendPacket('<logout />');
- $this->disconnect($user->index);
- }
- break;
- /* Packet de desconexao */
- case 'l':
- $this->disconnect($user->index);
- $this->disconnect($user->id);
- $user->sendRoom($user->createPacket('l', array('u' => $user->id)));
- break;
- case 'm': /* proteçao de desativar xat */
- if ($user->banned > time())
- {
- return false;
- }
- if ($user->f & 128)
- {
- if ($user->rank == 5)
- {
- break;
- }
- }
- if ($user->f & 256)
- {
- break;
- }
- $chatr = $this->mysql->fetch_array("select * from `chats` where `id`={$user->chat};");
- if ($chatr[0]['MembersOnly2'] == 1)
- {
- if ($user->guest == true && in_array($user->rank, array(5, 40)))
- {
- break;
- }
- }
- if (isset($this->protected[$user->chat]))
- {
- if ($this->protected[$user->chat]['end'] < time())
- {
- unset($this->protected[$user->chat]);
- $user->sendRoom("<m t=\"A protecao do chat foi desativa pois ja se passarao 60 minutos.\" u=\"0\" />");
- }
- elseif ($this->protected[$user->chat]['type'] == 'noguest')
- {
- if ($user->rank == 5 || $user->rank == 40)
- {
- return false;
- $user->f |= 256;
- }
- }
- elseif ($this->protected[$user->chat]['type'] == 'raid')
- {
- if ($user->rank == 5 || $user->rank == 40)
- {
- $user->sendPacket($user->createPacket("logout", array("e" => "E38")));
- return false;
- $this->disconnect($user->index);
- }
- }
- elseif ($this->protected[$user->chat]['type'] == 'unreg')
- {
- if ($user->guest == true && in_array($user->rank, array(5, 40)))
- {
- return false;
- }
- }
- }
- $h_packet = $this->getAttribute($packet, 't');
- if ($user->hasPower(51) && substr($h_packet, 0, 2) == '/h' && in_array($user->rank, array(1, 4)))
- {
- $sec = substr($h_packet, 3, 2);
- (is_numeric($sec) && ($sec >= 10 && $sec <= 60)) ? $time2 = substr($h_packet, 3, 2) : '';
- switch (strtolower(substr($h_packet, 2, 1)))
- {
- case 'g':
- /* Hush mutar cargos */
- foreach ($this->users as & $u)
- {
- if ($u->chat == $user->chat && !empty($time2) && in_array($u->rank, array(5)))
- {
- $time = strtotime("+ {$time2} seconds");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
- $u->sendRoom($user->createPacket("m", array("t" => "/gg{$time}", "u" => $u->id)), False, $u->id);
- $u->joinRoom($user->chat, false, true, 0);
- $u->banned = $time;
- }
- }
- return $time2 ? $user->sendRoom($user->createPacket("m", array("u" => $user->id, "t" => "(hush#w{$time}) Hush: {$time}s"))) : false;
- break;
- case 'm':
- foreach ($this->users as & $u)
- {
- if ($u->chat == $user->chat && !empty($time2) && in_array($u->rank, array(3, 5)))
- {
- $time = strtotime("+ {$time2} seconds");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
- $u->sendRoom($u->createPacket("m", array("t" => "/gg{$time2}", "u" => $u->id)), False, $u->id);
- $u->joinRoom($user->chat, false, true, 0);
- $u->banned = $time;
- }
- }
- return $time2 ? $user->sendRoom($user->createPacket("m", array("u" => $user->id, "t" => "(hush#w{$time2}) Hush: {$time2}s"))) : false;
- break;
- case 'd':
- foreach ($this->users as & $u)
- {
- if ($u->chat == $user->chat && !empty($time2) && in_array($u->rank, array(2, 3, 5)))
- {
- $time = strtotime("+ {$time2} seconds");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
- $u->sendRoom($u->createPacket("m", array("t" => "/gg{$time2}", "u" => $u->id)), False, $u->id);
- $u->joinRoom($user->chat, false, true, 0);
- $u->banned = $time;
- }
- }
- return $time2 ? $user->sendRoom($user->createPacket("m", array("u" => $user->id, "t" => "(hush#w{$time2}) Hush: {$time2}s"))) : false;
- break;
- case 'o':
- if ($user->rank != 1)
- {
- break;
- }
- foreach ($this->users as & $u)
- {
- if ($u->chat == $user->chat && !empty($time2) && in_array($u->rank, array(2, 3, 4, 5)))
- {
- $time = strtotime("+ {$time2} seconds");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
- $u->sendRoom($u->createPacket("m", array("t" => "/gg{$time2}", "u" => $u->id)), False, $u->id);
- $u->f |= 0x0100;
- $u->joinRoom($user->chat, false, true, 0);
- $u->banned = $time;
- }
- }
- return $time2 ? $user->sendRoom($user->createPacket("m", array("u" => $user->id, "t" => "(hush#w{$time2}) Hush: {$time2}s"))) : false;
- break;
- }
- }
- if (in_array($user->rank, array(5, 40)) && $user->guest == true)
- {
- if (!isset($this->rfilter[$user->chat]))
- {
- $this->rfilter[$user->chat] = array();
- }
- $ctime = time() - 5;
- $count = 1;
- foreach ($this->rfilter[$user->chat] as $i => $time)
- {
- if ($ctime > $time)
- {
- unset($this->rfilter[$user->chat][$i]);
- continue;
- }
- $count++;
- }
- array_push($this->rfilter[$user->chat], time());
- if ($count >= 12)
- {
- $this->protected[$user->chat] = array('end' => time() + 3600, 'type' => 'unreg');
- $user->sendRoom($user->createPacket("m", array("u" => 0, "t" => "Protecao do chat foi ativada!(Raid Detected)")));
- foreach ($this->users as $i => $u)
- {
- if ($u->chat == $user->chat && in_array($u->rank, array(5, 40)) && $u->guest == true)
- {
- $u->sendPacket('<n t="Protection ativada, chutando null users." />');
- $this->disconnect($u->index);
- }
- }
- unset($this->rfilter[$user->chat]);
- }
- }
- $message = $this->getAttribute($packet, 't');
- if (empty($message))
- {
- return false;
- }
- elseif (substr($message, 0, 1) == '!')
- {
- $owner = in_array($user->id, $this->config->staff) ? true : false;
- $volunt = in_array($user->id, $this->config->volunteers) ? true : false;
- $args = explode(chr(32), substr($message, 1));
- switch (strtolower($args[0]))
- {
- case 'users':
- if ($owner || $volunt)
- {
- $user->sendPacket('<m t="Tem ' . count($this->users) . ' usuarios online!!" u="0" />');
- }
- return;
- break;
- case 'setdays':
- if (!$owner || count($args) != 3)
- {
- break;
- }
- $uRow = $this->mysql->fetch_array('select `id`, `username`, `password` from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\'');
- if (count($uRow) == 1 && is_numeric($args[2]))
- {
- $days = $this->getDays($args[2]);
- $udays = time() + ($days * 86400);
- $this->mysql->query('update `users` set `days`= (days +' . $udays . ') where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
- if ($_user != false)
- {
- $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
- }
- }
- return;
- break;
- case 'addxats':
- if (count($args) == 3 && $owner)
- {
- $uRow = $this->mysql->fetch_array('select `id`, `username`, `password` from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- if (count($uRow) == 1 && is_numeric($args[2]))
- {
- $this->mysql->query('update `users` set `xats`= (xats +' . $args[2] . ') where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
- if ($_user != false)
- {
- $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
- }
- }
- }
- return;
- break;
- case 'setxats':
- if (count($args) != 3 || $owner)
- {
- $uRow = $this->mysql->fetch_array('select `id`, `username`, `password` from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- if (count($uRow) == 1 && is_numeric($args[2]))
- {
- $this->mysql->query('update `users` set `xats`=' . $args[2] . ' where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
- if ($_user != false)
- {
- $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
- }
- }
- }
- return;
- break;
- case 'setdays1':
- if (count($args) != 3 || $owner)
- {
- $uRow = $this->mysql->fetch_array('select `id`, `username`, `password` from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- if (count($uRow) == 1 && is_numeric($args[2]))
- {
- $this->mysql->query('update `users` set `days`=' . strtotime("+ " . $args[2] . " days") . ' where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
- if ($_user != false)
- {
- $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
- }
- }
- }
- return;
- break;
- case 'clears':
- if (!$owner)
- {
- break;
- }
- $this->mysql->query('truncate `messages`;');
- $this->mysql->query('truncate `offline_messages`;');
- $user->sendPacket('<m t="Mesajele au fost curatate!" u="0" />');
- $this->disconnect($user->index);
- $user->sendRoom("<l u=\"{$u->id}\" />");
- return;
- break;
- case 'us':
- if (!$owner)
- {
- break;
- }
- $this->mysql->query("DELETE FROM users WHERE username IS NULL");
- $user->sendPacket('<m t="Todos os usuários nulos foram deletados!" u="0" />');
- $this->disconnect($user->index);
- $user->sendRoom("<l u=\"{$u->id}\" />");
- return;
- break;
- case 'clear':
- if ($owner || $volunt)
- {
- $this->mysql->query('update `messages` set `visible`=0 where `id`=' . $user->chat . ';');
- $user->sendRoom('<n t="0" t="Mensagens do xat limpas!" />');
- $user->joinRoom($user->chat, 1, True);
- foreach ($this->users as & $u)
- {
- $this->disconnect($u->index);
- }
- }
- return;
- break;
- /* powers status */
- case 'release':
- if ($owner)
- {
- $power = $args[1];
- $amount = $args[2];
- $this->mysql->query("UPDATE `powers` SET `amount`='" . $amount . "' WHERE `name`='" . $power . "'");
- $Mais = $amount == 1 ? "" : "s";
- $user->sendAll("<n t=\"{$amount} {$power}{$Mais} a fost limitata!\" />");
- }
- return;
- break;
- case 'unrelease':
- if ($owner)
- {
- $power = $args[1];
- $amount = $args[2];
- $this->mysql->query("UPDATE `powers` SET `amount`='" . $amount . "' WHERE `name`='" . $power . "'");
- $Mais = $amount == 0 ? "" : "s";
- $user->sendAll("<n t=\"{$amount} {$power}{$Mais} a fost delimitata!\" />");
- }
- return;
- break;
- case 'userip':
- if ($owner)
- {
- $uRow = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- $user->sendPacket("<m t=\"Utilizatorul [" . $args[1] . "] are ip: " . $uRow[0]['connectedlast'] . " sa inregistrat : " . $uRow[0]['time_stamp'] . " are id : " . $uRow[0]['id'] . "\" u=\"0\" />");
- }
- return;
- break;
- case 'resetrank':
- if ($owner)
- {
- $target = $args[1];
- $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `id`='" . $target . "';");
- $i = $t[0]['id'];
- $this->mysql->query("DELETE FROM `ranks` WHERE `userid`='" . $i . "';");
- $user->sendPacket('<n t="0" t="o cargo do id ' . $target . ' foi resetado." />');
- }
- return;
- break;
- case 'global':
- $args = explode(' ', substr($message, 1), 2);
- $sum = "<n u=\"0\" t=\"{$args[1]}\" />";
- $user->sendPacket($sum);
- return;
- break;
- case 'relog':
- if (count($args) == 2 && $owner) {
- $_user = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- if (empty($_user)) {
- break;
- }
- $online = $this->getuserbyid($_user[0]['id']);
- if (is_object($online)) {
- $online->sendPacket($this->doLogin($_user[0]['username'], $_user[0]['password']));
- }
- }
- return;
- break;
- case 'anunt':
- if ($owner)
- {
- $args = explode(' ', substr($message, 1), 2);
- $sum = "<m t=\"{$args[1]}\" u=\"0\" />";
- $user->sendAll($sum);
- }
- return;
- break;
- case 'limited':
- if ($owner)
- {
- $power = $args[1];
- $this->mysql->query("UPDATE `powers` SET `limited`='1' WHERE `name`='" . $power . "'");
- $user->sendRoom('<n t="0" t="Puterea [' . $power . '] a fost limitata!" i="0" />');
- }
- return;
- break;
- case 'unlimited':
- if ($owner)
- {
- $power = $args[1];
- $this->mysql->query("UPDATE `powers` SET `limited`='0' WHERE `name`='" . $power . "'");
- $user->sendRoom('<n t="0" t="Puterea [' . $power . '] a fost unlimited!" i="0" />');
- }
- return;
- break;
- case 'getmain':
- case 'delrank':
- if ($owner)
- {
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
- if (strtolower($args[0]) == 'getmain')
- {
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 1);');
- } //strtolower( $args[ 0 ] ) == 'getmain'
- $this->disconnect($user->index);
- } //$owner
- return;
- break;
- case 'addmain':
- if (count($args) == 2 && $owner) {
- if(!is_numeric($args[1]))
- {
- $u = $this->mysql->fetch_array("select * from `users` where `username`='{$args[1]}';");
- if(empty($u)) break;
- $userid = @(int) $u[0]['id'];
- } else { $userid = @(int) $args[1]; }
- if(in_array($userid))
- $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `username`='".$args[1]."';");
- $returnmain = 1;
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`='.$userid.';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values('.$userid.', ' . $user->chat . ', ' . $returnmain . ');');
- $user->sendRoom('<m u="0" t="Foi adicionado mainowner no user ['.$args[1].']" />');
- $_user = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- if (empty($_user)) {
- break;
- }
- $online = $this->getuserbyid($_user[0]['id']);
- if (is_object($online)) {
- $online->sendPacket($this->doLogin($_user[0]['username'], $_user[0]['password']));
- }
- }
- return;
- break;
- case 'delmain':
- if (count($args) == 2 && $owner) {
- if(!is_numeric($args[1]))
- {
- $u = $this->mysql->fetch_array("select * from `users` where `username`='{$args[1]}';");
- if(empty($u)) break;
- $userid = @(int) $u[0]['id'];
- } else { $userid = @(int) $args[1]; }
- if(in_array($userid))
- $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `username`='".$args[1]."';");
- $returnguest = 5;
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`='.$userid.';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values('.$userid.', ' . $user->chat . ', ' . $returnguest . ');');
- $user->sendRoom('<m u="0" t="Foi removido mainowner no user ['.$args[1].']" />');
- $_user = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- if (empty($_user)) {
- break;
- }
- $online = $this->getuserbyid($_user[0]['id']);
- if (is_object($online)) {
- $online->sendPacket($this->doLogin($_user[0]['username'], $_user[0]['password']));
- }
- }
- return;
- break;
- case 'setrank':
- if (!$owner)
- {
- break;
- }
- switch ($s)
- {
- case "mod":
- case "moderator":
- $return = 2;
- break;
- case "guest":
- $return = 5;
- break;
- case "member":
- $return = 3;
- break;
- case "owner":
- $return = 4;
- break;
- }
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', ' . $return . ');');
- $this->disconnect($user->index);
- return;
- break;
- case 'everypower':
- case 'nopowers':
- if (count($args) != 2 || !$owner)
- {
- break;
- }
- $powers = "";
- $uRow = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- if (count($uRow) == 1)
- {
- if (strtolower($args[0]) == 'everypower')
- {
- $powers = array_map(function ($x)
- {
- return 1;
- }, array_flip($this->array_column($this->mysql->fetch_array('select `id` from `powers`;'), 'id')));
- $final = $this->PowDecode($uRow['powers']);
- array_walk_recursive($powers, function ($item, $key) use (&$final)
- {
- $final[$key] = isset($final[$key]) ? $item + $final[$key] : $item;
- });
- $powers = $this->PowEncode($final);
- }
- $this->mysql->query("update `users` set `powers`='{$powers}' where `id`='{$uRow[0]['id']}';");
- $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
- if ($_user != false)
- {
- $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
- }
- }
- return;
- break;
- case 'every':
- $powers = "";
- $uRow = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($user->username) . '\';');
- if (count($uRow) == 1) {
- if (strtolower($args[0]) == 'every') {
- $powers = array_map(function ($x) {
- return 1;
- }, array_flip($this->array_column($this->mysql->fetch_array('select `id` from `powers`;'), 'id')));
- $final = $this->PowDecode($uRow['powers']);
- array_walk_recursive($powers, function ($item, $key) use (&$final) {
- $final[$key] = isset($final[$key]) ? $item + $final[$key] : $item;
- });
- $powers = $this->PowEncode($final);
- }
- $this->mysql->query("update `users` set `powers`='{$powers}' where `id`='{$uRow[0]['id']}';");
- $_user = $this->getuserbyid($uRow[0]['id'], $user->chat);
- if ($_user != false) {
- $_user->sendPacket($this->doLogin($uRow[0]['username'], $uRow[0]['password']));
- }
- }
- return;
- break;
- case 'addpower':
- if ($owner)
- {
- if (count($args) > 4 || count($args) < 3)
- {
- return false;
- }
- $_user = $this->mysql->fetch_array("select * from `users` where `username`='{$this->mysql->sanatize($args[1]) }';");
- $power = $this->mysql->fetch_array("select * from `powers` where `name`='{$this->mysql->sanatize($args[2]) }';");
- if (empty($_user) || empty($power))
- {
- return false;
- }
- $upowers = $this->mysql->fetch_array("select * from `users` where `id`='{$_user[0]['id']}';");
- $upowers = $this->PowDecode($upowers[0]['powers']);
- if (isset($upowers[$power[0]['id']])) $upowers[$power[0]['id']] += isset($args[3]) && is_numeric($args[3]) ? $args[3] : 1;
- else $upowers[$power[0]['id']] = isset($args[3]) && is_numeric($args[3]) ? $args[3] : 1;
- $this->mysql->query("update `users` set `powers`='" . $this->PowEncode($upowers) . "' where `id`='{$_user[0]['id']}';");
- $online = $this->getuserbyid($_user[0]['id']);
- }
- if (is_object($online))
- {
- $online->sendPacket($this->doLogin($_user[0]['username'], $_user[0]['password']));
- }
- return;
- break;
- case 'delpower':
- if ($owner)
- {
- if (count($args) !== 3) return false;
- $_user = $this->mysql->fetch_array("select * from `users` where `username`='{$this->mysql->sanatize($args[1]) }';");
- $power = $this->mysql->fetch_array("select * from `powers` where `name`='{$this->mysql->sanatize($args[2]) }';");
- if (empty($_user) || empty($power)) return false;
- $upowers = $this->mysql->fetch_array("select * from `users` where `id`='{$_user[0]['id']}';");
- $upowers = $this->PowDecode($upowers[0]['powers']);
- unset($upowers[$power[0]['id']]);
- $this->mysql->query("update `users` set `powers`='" . $this->PowEncode($upowers) . "' where `id`='{$_user[0]['id']}';");
- $online = $this->getuserbyid($_user[0]['id']);
- }
- if (is_object($online))
- {
- $online->sendPacket($this->doLogin($_user[0]['username'], $_user[0]['password']));
- }
- return;
- break;
- case 'price':
- if ($owner)
- {
- $price = $this->mysql->fetch_array("SELECT * FROM `powers` WHERE `name`='" . $args[1] . "'");
- $shitthatiactuallyneed = $price[0]['cost'];
- $user->sendRoom('<n t="Pretul puteri [' . $args[1] . '] este de ' . $shitthatiactuallyneed . '" u="1" />');
- }
- return;
- break;
- /* Global de descriçao do power */
- case 'power':
- if ($owner)
- {
- $pinfo = $this->mysql->fetch_array("SELECT * FROM `powers` WHERE `name`='" . $args[1] . "'");
- $desc = $pinfo[0]['description'];
- $user->sendRoom('<n t="Descrierea puteri [' . $args[1] . '] - ' . $desc . '" u="0" />');
- }
- return;
- break;
- case 'setcost':
- if ($owner)
- {
- $power = $args[1];
- $this->mysql->query("UPDATE `powers` SET `cost`='" . $args[2] . "' WHERE `name`='" . $power . "'");
- $user->sendRoom('<n t="0" t="Power [' . $power . '] Foi mudado o preco para [' . $args[2] . ']" i="0" />');
- }
- return;
- break;
- case 'addvolunter': // Adicionar voluntario by Nasc
- if (count($args) == 2 && $owner) {
- $server = $this->mysql->fetch_array("select * from `server` limit 0, 1;");
- $server = (object) $server[0];
- $volunteers = json_decode($server->volunteers, true);
- if(!isset($args[1]))
- {
- $user->sendRoom('<m u="0" t="Por favor, proporcionar una ID para añadir a voluntarios." />');
- break;
- }
- if(!is_numeric($args[1]))
- {
- $u = $this->mysql->fetch_array("select * from `users` where `username`='{$args[1]}';");
- if(empty($u)) break;
- $userid = @(int) $u[0]['id'];
- } else { $userid = @(int) $args[1]; }
- if(in_array($userid, $volunteers))
- {
- $user->sendRoom('<m u="0" t="'. $args[1] .' ya es volunteer!" />');
- break;
- }
- $volunteers[] = $userid;
- $this->config->volunteers = null;
- $this->config->volunteers = $volunteers;
- $sJSON = json_encode($volunteers);
- $this->mysql->query("update `server` set `volunteers`='{$sJSON}';");
- $user->sendRoom('<m u="0" t="'.$userid.' agora é voluntario." />');
- }
- return;
- break;
- case 'addcelebrity': // Celebrity by Nasc
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `users` SET `celebrity`='1' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="Agora o usuário [' . $usr . '] é uma celebridade, aproveite!" i="0" />');
- }
- return;
- break;
- case 'delcelebrity': // Celebrity by Nasc
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `users` SET `celebrity`='0' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="O usuário [' . $usr . '] não é mais uma celebridade." i="0" />');
- }
- return;
- break;
- case 'addgames': // Tornar chat Games
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `chats` SET `games`='1' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="O grupo [' . $usr . '] agora é game." i="0" />');
- }
- return;
- break;
- case 'delgames': // Remover chat Games
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `chats` SET `games`='0' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="O grupo [' . $usr . '] agora não é mais game." i="0" />');
- }
- return;
- break;
- case 'addsupor': // Tornar chat Suportados
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `chats` SET `supporter`='1' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="O grupo [' . $usr . '] agora é suportado." i="0" />');
- }
- return;
- break;
- case 'delsupor': // Remover chat Suportados
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `chats` SET `supporter`='0' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="O grupo [' . $usr . '] agora não é mais suportado." i="0" />');
- }
- return;
- break;
- case 'adddeleted': // Tornar chat deleted
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `chats` SET `deleted`='1' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="O grupo [' . $usr . '] foi deletado." i="0" />');
- }
- return;
- break;
- case 'deldeleted': // Remover chat deleted
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `chats` SET `deleted`='0' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="O grupo [' . $usr . '] agora não é mais deletado." i="0" />');
- }
- return;
- break;
- case 'reset':
- if ($owner)
- {
- $target = $args[1];
- $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `username`='" . $target . "';");
- $i = $t[0]['id'];
- $ray = floor(floor($id)) * 100 / 2;
- $inf = base64_encode(serialize(base64_encode($ray)));
- $this->mysql->query("update `users` set `powers`='' where `id`='" . $i . "';");
- $this->mysql->query("DELETE FROM `ranks` WHERE `userid`='" . $i . "';");
- if ($user->id == '1' or '-1')
- {
- $this->mysql->query("INSERT INTO torches(id, torchedBy, reason, ray_id) VALUES ('" . $i . "', '" . $user->username . "', 'Torched by an Administrator for unlisted reasons.', '" . $inf . "');");
- }
- else
- {
- $this->mysql->query("INSERT INTO torches(id, torchedBy, reason, ray_id) VALUES ('" . $i . "', '" . $user->username . "', 'Reason Unlistd.', '" . $inf . "');");
- }
- $user->sendPacket('<n t="O USUARIO ' . $target . ' FOI RESETADO." />');
- }
- return;
- break;
- case 'torch': // Torching
- if ($owner)
- {
- $usr = $args[1];
- $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `id`='" . $usr . "';");
- $this->mysql->query("UPDATE `users` SET `torched`='1' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $i = $t[0]['id'];
- $ray = floor(floor($id)) * 100 / 2;
- $inf = base64_encode(serialize(base64_encode($ray)));
- if ($user->id == '1' or '-1')
- {
- $this->mysql->query("INSERT INTO torches(id, torchedBy, reason, ray_id) VALUES ('" . $i . "', '" . $user->username . "', 'Torched by an Administrator for unlisted reasons.', '" . $inf . "');");
- }
- else
- {
- $this->mysql->query("INSERT INTO torches(id, torchedBy, reason, ray_id) VALUES ('" . $i . "', '" . $user->username . "', 'Reason Unlistd.', '" . $inf . "');");
- }
- $user->sendRoom('<m u="0" t="Torched Activado en el ID: [' . $usr . '] :)" i="0" />');
- }
- return;
- break;
- case 'untorch': // UNTorching
- if ($owner)
- {
- $usr = $args[1];
- $this->mysql->query("UPDATE `users` SET `torched`='0' WHERE `id`='" . $this->mysql->sanatize($usr) . "'");
- $user->sendRoom('<m u="0" t="Torched Desactivado en el ID: [' . $usr . '] :)" i="0" />');
- }
- return;
- break;
- case 'fundo': // Fixado Vulnabilidade
- if ($owner)
- {
- $arg1 = $args[1];
- $this->mysql->query("UPDATE `chats` SET `bg`='{$arg1}' WHERE `id`='" . $user->chat . "'");
- $user->sendPacket('<m u="0" t="agora o fundo é ' . $arg1 . '" i="0" />');
- }
- return;
- break;
- case 'gback': // Fixado Vulnabilidade
- if ($owner)
- {
- $arg1 = $args[1];
- $this->mysql->query("UPDATE `chats` SET `gback`='{$arg1}' WHERE `id`='" . $user->chat . "'");
- $user->sendPacket('<m u="0" t="agora o gback é ' . $arg1 . '" i="0" />');
- }
- return;
- break;
- case 'button': // Fixado Vulnabilidade
- if ($owner)
- {
- $arg1 = $args[1];
- $this->mysql->query("UPDATE `chats` SET `button`='{$arg1}' WHERE `id`='" . $user->chat . "'");
- $user->sendPacket('<m u="0" t="agora a cor dos botões é ' . $arg1 . '" i="0" />');
- }
- return;
- break;
- case 'setid': // Setid terminado
- if (count($args) == 3 && is_numeric($args[2]) && $owner)
- {
- $_user = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- $_test = $this->mysql->fetch_array('select * from `users` where `id`=\'' . $this->mysql->sanatize($args[2]) . '\';');
- if (!empty($_test))
- {
- $user->sendPacket('<m t="essa id é tomada por ' . $_test[0]['username'] . '" u="0" />');
- break;
- }
- if (empty($_user))
- {
- $user->sendPacket('<m t="esse usuario nao existe" u="0" />');
- break;
- }
- $this->mysql->query('update `users` set `id`=' . $this->mysql->sanatize($args[2]) . ' where `id`=' . $_user[0]['id'] . ';');
- $this->mysql->query('update `ranks` set `userid`=' . $this->mysql->sanatize($args[2]) . ' where `userid`=' . $_user[0]['id'] . ';');
- // $this->mysql->query('update `userpowers` set `userid`=' . $this->mysql->sanatize($args[2]) . ' where `userid`=' . $_user[0]['id'] . ';');
- $online = $this->getuserbyid($_user[0]['id']);
- if (is_object($online))
- {
- $online->sendPacket($this->doLogin($_user[0]['username'], $_user[0]['password']));
- }
- }
- return;
- break;
- /* Rchat by kayabe */
- case 'rchat':
- if (count($args) != 2 || $owner)
- {
- $cRow = $this->mysql->fetch_array('select * from `chats` where `name`=\'' . $this->mysql->sanatize($args[1]) . '\';');
- if (count($cRow) == 1)
- {
- $this->mysql->query('delete from `ranks` where `chatid`=' . $cRow[0]['id'] . ';');
- $sum = "<n t=\"Chat {$args[1]} Foi Resetado\" />";
- $user->sendAll($sum);
- foreach ($this->users as & $u)
- {
- $this->disconnect($u->index);
- }
- }
- }
- return;
- break;
- case 'forcerank':
- if ($owner)
- {
- $arg1 = $args[1];
- $target = $args[1];
- $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `username`='" . $target . "';");
- $returnmain = 1;
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $arg1 . ';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $arg1 . ', ' . $user->chat . ', ' . $returnmain . ');');
- $user->sendRoom('<n t="foi dado mainowner a ' . $target . '." />');
- }
- return;
- break;
- case 'forcedel':
- if ($owner)
- {
- $arg1 = $args[1];
- $target = $args[1];
- $t = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `username`='" . $target . "';");
- $returnguest = 0;
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $arg1 . ';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $arg1 . ', ' . $user->chat . ', ' . $returnguest . ');');
- $user->sendRoom('<n t="foi excluido o mainowner do id ' . $target . '." />');
- }
- return;
- break;
- /* auto ranks */
- case 'mainowner':
- if ($owner || $volunt)
- {
- if (strtolower($args[0]) == 'mainowner')
- {
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 1);');
- }
- $this->disconnect($user->index);
- }
- return;
- break;
- case 'owner':
- if ($owner || $volunt)
- {
- if (strtolower($args[0]) == 'owner')
- {
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 4);');
- }
- $this->disconnect($user->index);
- }
- return;
- break;
- case 'moderator':
- if ($owner || $volunt)
- {
- if (strtolower($args[0]) == 'moderator')
- {
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 2);');
- }
- $this->disconnect($user->index);
- }
- return;
- break;
- case 'member':
- if ($owner || $volunt)
- {
- if (strtolower($args[0]) == 'member')
- {
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
- $this->mysql->query('insert into `ranks`(`userid`, `chatid`, `f`) values(' . $user->id . ', ' . $user->chat . ', 3);');
- }
- $this->disconnect($user->index);
- }
- return;
- break;
- case 'guest':
- if ($owner || $volunt)
- {
- if (strtolower($args[0]) == 'guest')
- {
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
- }
- $this->disconnect($user->index);
- }
- return;
- break;
- /* fim dos comandos começo das funçoes xat */
- }
- }
- elseif (substr($message, 0, 3) == '/go')
- {
- $vars = explode('/go', $message);
- if (empty($vars[1])) continue;
- $chat = $this->mysql->fetch_Array('select * from `chats` where `name`=\'' . trim($vars[1]) . '\';');
- if (empty($chat)) continue;
- $user->sendRoom('<l u="' . $user->id . '" />');
- $user->sendPacket('<q r="' . $chat[0]['id'] . '" u="' . $user->id . '" />');
- $user->joinRoom($chat[0]['id'], true);
- }
- elseif (substr($message, 0, 1) == "/")
- { // away
- if ($message == '/away' && $user->hasPower(144))
- {
- $user->f |= $this->flags->away;
- $user->sendPacket($user->buildGp());
- $user->joinRoom($user->chat, false, true, $user->pool);
- return;
- }
- elseif ($message == '/back')
- {
- if ($user->f & $this->flags->away && $user->hasPower(144))
- {
- $user->f -= $this->flags->away;
- $user->sendPacket($user->buildGp());
- $user->joinRoom($user->chat, false, true, $user->pool);
- return;
- }
- }
- /*Typing stop fix*/
- elseif ($message == '/RTypeOff')
- {
- $user->sendRoom('<m t="/RTypeOff" u="' . $user->id . '" />');
- }
- /*end*/
- else
- {
- $args = explode(chr(32), substr($message, 2));
- switch (strtolower(substr($message, 1, 1)))
- {
- case 'd':
- if (in_array($user->rank, array(1, 2, 4)))
- {
- $mid = substr($message, 2);
- if (is_numeric($mid))
- {
- $res = $this->mysql->query('update `messages` set `visible`=0 where `id`=' . $user->chat . ' and `mid`=' . $mid . ';');
- if ($res)
- {
- $user->sendRoom('<m t="/' . $mid . '" u="0" />');
- unset($user->last['m']);
- }
- }
- elseif ($mid == 'clear')
- {
- $res = $this->mysql->query('update `messages` set `visible`=0 where `id`=' . $user->chat . ';');
- }
- }
- return;
- /* Proteçao xat */
- case 'p':
- if ($user->rank == 1 || $user->rank == 4)
- {
- if (substr(strtolower($message), 2) == "r")
- {
- /* Raid protection */
- if (!isset($this->protected[$user->chat]))
- {
- /* activate */
- foreach ($this->users as $i => $u)
- {
- if ($u->chat == $user->chat && in_array($u->rank, array(5, 40)))
- {
- $u->sendPacket('<m t="You have been kicked due to raid bots, be back later!" u="0" />');
- $this->disconnect($u->index);
- }
- }
- $user->sendRoom("<m u=\"0\" t=\"Raid Protection has been enabled for the next 60 minutes!({$user->id})\" />");
- $this->protected[$user->chat] = array("end" => (time() + 3600), "type" => 'raid');
- return false;
- }
- else
- {
- /* un-activate */
- unset($this->protected[$user->chat]);
- $user->sendRoom("<m u=\"0\" t=\"Raid Protection has been disabled!({$user->id})\" />");
- }
- return False;
- }
- if (!isset($this->protected[$user->chat]))
- {
- $user->sendRoom("<m u=\"0\" t=\"Protection has been enabled for the next 60 minutes!({$user->id})\" />");
- $this->protected[$user->chat] = array("end" => (time() + 3600), "type" => 'noguest');
- return false;
- }
- else
- {
- unset($this->protected[$user->chat]);
- $user->sendRoom("<m u=\"0\" t=\"Protection has been disabled!({$user->id})\" />");
- return false;
- }
- }
- break;
- /* ADD amigos */
- case 'f':
- if ($user->username != '')
- {
- $friend = substr($message, 2);
- if (!is_numeric($friend) || strlen($friend) > 15 || $friend == 0 || $friend == 2)
- {
- return false;
- }
- $check = $this->mysql->fetch_array("select id from `users` where `id`='{$this->mysql->sanatize($friend) }';");
- if (empty($check))
- {
- return false;
- }
- $check = $this->mysql->fetch_array("select id from `friends` where `user`='{$user->id}' and `friend`='{$friend}';");
- if (!empty($check))
- {
- return false;
- }
- $this->mysql->query("insert into `friends` (`id`, `user`, `friend`) values (NULL, '{$user->id}', '{$friend}');");
- }
- break;
- case 's':
- if ($user->rank != 1)
- {
- return false;
- }
- $rscroll = (explode(',', strtolower(substr($message, 2))));
- if (strlen($rscroll[0]) == 1)
- {
- switch ($rscroll[0])
- {
- case 'm':
- print $rscroll[1];
- break;
- }
- }
- else
- {
- $scroll = $this->mysql->sanatize(htmlspecialchars(substr($message, 2), ENT_QUOTES));
- $this->mysql->query("update `chats` set `sc`='{$scroll}' where `name`='{$user->group}';");
- $user->sendRoom("<m u=\"{$user->id}\" t=\"/s" . str_replace('"', '', htmlspecialchars_decode(stripslashes($scroll))) . "\" />");
- }
- break;
- case 'g':
- if ($user->hasPower(32))
- {
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '', '{$user->chat}', '{$date}', 'guestself', 'Guestself', '','');");
- $this->mysql->query('delete from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $user->id . ';');
- $user->joinRoom($user->chat, 0, true);
- }
- break;
- case 'ka':
- $user->sendRoom("<m u=\"{$user->id}\" t=\"/kaa\" />");
- break;
- case 'r':
- if (count($args) == 3)
- {
- if (!is_numeric($args[1]))
- {
- break;
- }
- $ranks = $this->mysql->fetch_array('select * from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $args[1] . ';');
- 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))
- {
- $args[2] == 'off' ? $lock = 0 : $lock = 1;
- $this->mysql->query("update `ranks` set `locked`='{$lock}' where `chatid`='{$user->chat}' and `userid`='{$args[1]}';");
- return $user->sendPacket('<m t="' . $args[1] . ' ranklock: ' . $args[2] . '" u="0" />');
- }
- }
- elseif (count($args) == 2)
- {
- if (!is_numeric($args[1]))
- {
- break;
- }
- $ranks = $this->mysql->fetch_array('select * from `ranks` where `chatid`=' . $user->chat . ' and `userid`=' . $args[1] . ';');
- if (in_array($user->rank, array(1, 4)) && $this->higherRank($user->rank, $ranks[0]['f'], true) && substr($message, 0, 2) == '/r' && $user->hasPower(394))
- {
- $this->mysql->query("update `ranks` set `locked`='0' where `chatid`='{$user->chat}' and `userid`='{$args[1]}';");
- return $user->sendPacket('<m t="' . $args[1] . ' ranklock: off" u="0" />');
- }
- }
- break;
- default:
- $user->message($message);
- return false;
- }
- }
- }
- if ($this->spamfilter($tag, $user, 700)) break;
- $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) }');");
- $user->message($message);
- $user->last = array();
- break;
- case 'x':
- $attr = $this->getMultiAttr($packet, array('x', 's', 'b', 'm', 'p', 'k', 'f', 'i', 'u', 'd', 't'));
- if ($attr['i'] == '30008' && $attr['u'] && $attr['d'] && $attr['t'])
- {
- $trade = explode(',', $attr['t']);
- if ($trade[0] == 'j' || $trade[0] == 'C')
- {
- return $user->sendRoom($packet2);
- }
- else if ($trade[0] == 'G')
- {
- return $user->sendPacket($packet2);
- }
- else if ($trade[0] == 'S' || $trade[0] == 'O')
- {
- $trader = $this->getUserByID($attr['d'], $user->chat);
- if (!is_object($trader))
- {
- return false;
- }
- return $trader->sendPacket($packet2);
- }
- else if ($trade[0] != 'T' || $user->id != $attr['u'] || !is_numeric($attr['d'])) return false;
- $this->trade[$user->chat][$attr['u']][$attr['d']] = ['password' => $trade[3], 'data' => explode(';', $trade[1]) ];
- if (isset($this->trade[$user->chat][$attr['u']][$attr['d']], $this->trade[$user->chat][$attr['d']][$attr['u']]))
- {
- $trader1 = $this->getUserByID($attr['u'], $user->chat);
- $trader2 = $this->getUserByID($attr['d'], $user->chat);
- $err = [1, 1];
- if (is_object($trader1) && is_object($trader2))
- {
- $err[0] = !$this->mysql->checkPass($this->trade[$user->chat][$trader1->id][$trader2->id]['password'], $trader1->password) ? 8 : ($trader1->banned ? 13 : ($this->trade[$user->chat][$trader1->id][$trader2->id]['data'][0] > $trader1->xats || $this->trade[$user->chat][$trader1->id][$trader2->id]['data'][0] < 0 ? 11 : ($this->trade[$user->chat][$trader1->id][$trader2->id]['data'][1] > $trader1->days || $this->trade[$user->chat][$trader1->id][$trader2->id]['data'][1] < 0 ? 18 : 1)));
- $err[1] = !$this->mysql->checkPass($this->trade[$user->chat][$trader2->id][$trader1->id]['password'], $trader2->password) ? 8 : ($trader2->banned ? 13 : ($this->trade[$user->chat][$trader2->id][$trader1->id]['data'][0] > $trader2->xats || $this->trade[$user->chat][$trader2->id][$trader1->id]['data'][0] < 0 ? 11 : ($this->trade[$user->chat][$trader2->id][$trader1->id]['data'][1] > $trader2->days || $this->trade[$user->chat][$trader2->id][$trader1->id]['data'][1] < 0 ? 18 : 1)));
- if ($err[0] != 1 || $err[1] != 1)
- {
- $trader1->sendPacket("<x i=\"{$attr['i']}\" u=\"{$trader2->id}\" d=\"{$trader1->id}\" t=\"E,{$err[0]},{$err[1]}\" />");
- $trader2->sendPacket("<x i=\"{$attr['i']}\" u=\"{$trader1->id}\" d=\"{$trader2->id}\" t=\"E,{$err[1]},{$err[0]}\" />");
- }
- else
- {
- $reset0 = $this->mysql->fetch_array("select `xats`,`days`,`powers`,`password` from `users` where `id`='{$trader1->id}';");
- $reset1 = $this->mysql->fetch_array("select `xats`,`days`,`powers`,`password` from `users` where `id`='{$trader2->id}';");
- $u1powers = $this->PowDecode($reset0[0]['powers']);
- $u2powers = $this->PowDecode($reset1[0]['powers']);
- $u1trade = $this->trade[$user->chat][$trader1->id][$trader2->id]['data'][2];
- $u2trade = $this->trade[$user->chat][$trader2->id][$trader1->id]['data'][2];
- var_dump($u1trade);
- var_dump($u2trade);
- $u1trade = $this->PowDecode($u1trade);
- $u2trade = $this->PowDecode($u2trade);
- $u1p = $u2p = [];
- $trader1->xats = $reset0[0]['xats'];
- $trader2->xats = $reset1[0]['xats'];
- $user->days = $this->getDays($reset0[0]['days']);
- $tradee->days = $this->getDays($reset1[0]['days']);
- $u1d = time() + ($user->days * 86400);
- $u2d = time() + ($tradee->days * 86400);
- print $this->du1;
- for ($i = 1;$i <= 2;$i++)
- {
- if (is_array($
- {
- "u{$i}powers"
- }))
- {
- foreach ($
- {
- "u{$i}powers"
- } as $id => $count) $
- {
- "u{$i}p"
- }
- [$id] = $count;
- unset($id, $count);
- }
- }
- unset($i);
- for ($i = 1;$i <= 2;$i++)
- {
- foreach ($
- {
- "u{$i}trade"
- } as $id => $count)
- {
- if (isset($
- {
- "u{$i}p"
- }
- [$id]) && $
- {
- "u{$i}p"
- }
- [$id] >= $count)
- {
- $
- {
- "u{$i}p"
- }
- [$id] = $
- {
- "u{$i}p"
- }
- [$id] - $count;
- $
- {
- 'u' . ($i == 1 ? 2 : 1) . 'p'
- }
- [$id] = isset($
- {
- 'u' . ($i == 1 ? 2 : 1) . 'p'
- }
- [$id]) ? ($
- {
- 'u' . ($i == 1 ? 2 : 1) . 'p'
- }
- [$id] + $count) : $count;
- }
- else
- {
- $trader1->sendPacket("<x i=\"{$attr['i']}\" u=\"{$trader2->id}\" d=\"{$trader1->id}\" t=\"E,33,1\" />");
- $trader2->sendPacket("<x i=\"{$attr['i']}\" u=\"{$trader1->id}\" d=\"{$trader2->id}\" t=\"E,1,33\" />");
- return false;
- break;
- }
- }
- unset($id, $count);
- }
- unset($i);
- for ($i = 1;$i <= 2;$i++)
- {
- foreach ($
- {
- "u{$i}p"
- } as $id => $count)
- {
- if ($count < 1)
- {
- unset($
- {
- "u{$i}powers"
- }
- [$id]);
- continue;
- }
- $
- {
- "u{$i}powers"
- }
- [$id] = $count;
- }
- unset($id, $count);
- }
- unset($i);
- $this->mysql->query("update `users` set `powers`='{$this->PowEncode($u1powers) }',`xats`='{$trader1->xats}',`days`='{$u1d}' where `id`='{$trader1->id}';");
- $this->mysql->query("update `users` set `powers`='{$this->PowEncode($u2powers) }',`xats`='{$trader2->xats}',`days`='{$u2d}' where `id`='{$trader2->id}';");
- $trader1->sendPacket("<x i=\"{$attr['i']}\" u=\"{$trader2->id}\" d=\"{$trader1->id}\" t=\"E,0,0,0\" />");
- $trader2->sendPacket("<x i=\"{$attr['i']}\" u=\"{$trader1->id}\" d=\"{$trader2->id}\" t=\"E,0,0,0\" />");
- $data1 = $this->doLogin($trader1->username, $trader1->password);
- $data2 = $this->doLogin($trader2->username, $trader2->password);
- $trader1->sendPacket($data1);
- $trader2->sendPacket($data2);
- }
- unset($this->trade[$user->chat][$trader1->id][$trader2->id], $this->trade[$user->chat][$trader2->id][$trader1->id]);
- }
- }
- break;
- }
- else
- {
- $x = $attr['x'];
- $b = $attr['b'];
- $m = $attr['m'];
- $i = $attr['i'];
- $user->sendRoom("<x i=\"{$i}\" u=\"{$user->id}\" b=\"{$b}\" x=\"{$x}\" t=\"{$m}\" />");
- }
- break;
- case 'ap':
- $attributes = array('p', 'a');
- $attributes = $this->getMultiAttr($packet, $attributes);
- $p = $attributes["p"];
- $a = $attributes["a"];
- $power = $this->mysql->fetch_array("SELECT * FROM `powers` WHERE `id`='{$this->mysql->sanatize($p) }';");
- $double = $this->mysql->fetch_array("SELECT * FROM `userpowers` WHERE `powerid`='{$this->mysql->sanatize($p) }' AND `userid`='{$user->id}';");
- $count = $this->mysql->fetch_array("SELECT * FROM `group_powers` WHERE `group`='{$user->group}' and `power`='{$this->mysql->sanatize($p) }' AND `assignedBy`='{$user->id}';");
- switch ($a)
- {
- case '1':
- $flixs = array(92, 96, 98, 102, 108, 148, 156, 278, 297, 94, 86, 84, 88);
- if (isset($double[0]['count']) && isset($count[0]['count']) && ($double[0]['count'] < $count[0]['count'] + 1) && ($count[0]['count'] < 32) && in_array($p, $flixs))
- {
- $user->sendPacket("<ap p=\"{$p}\" r=\"3\" />");
- break;
- }
- $s = $this->mysql->fetch_array("SELECT * FROM `group_powers` WHERE `group`='{$user->group}' AND `power`='{$p}';");
- if (!empty($s) && (!in_array($p, $flixs) && isset($double[0]['count']) && $count[0]['count'] > 32))
- {
- $user->sendPacket("<ap p=\"{$p}\" r=\"4\" />");
- break;
- }
- if (empty($s))
- {
- $this->mysql->query("INSERT INTO group_powers(`group`,`power`,`assignedBy`) VALUES ('{$user->group}', '{$p}', '{$user->id}');");
- $user->sendPacket("<ap p=\"{$p}\" r=\"1\" />");
- }
- elseif (isset($double[0]['count']) && ($count[0]['count'] >= 1 && $count[0]['count'] < 32) && in_array($p, $flixs))
- {
- $this->mysql->query("UPDATE `group_powers` SET `count`=`count`+1 WHERE `group`='{$user->group}' and `power`='{$p}' and `assignedBy`='{$user->id}';");
- $user->sendPacket("<ap p=\"{$p}\" r=\"1\" />");
- }
- else
- {
- $user->sendPacket("<ap p=\"{$p}\" r=\"4\" />");
- }
- break;
- case '0':
- $i = $this->mysql->fetch_array("SELECT * FROM `group_powers` WHERE `assignedBy`='{$user->id}' AND `group`='{$user->group}' and `power`='{$p}';");
- if (empty($i))
- {
- $user->sendPacket("<ap p=\"{$p}\" r=\"2\" />");
- break;
- }
- if ($i[0]['count'] == 1)
- {
- $this->mysql->query("DELETE FROM `group_powers` WHERE `assignedBy`='{$user->id}' AND `group`='{$user->group}' AND `power`='{$p}';");
- $user->sendPacket("<ap p=\"{$p}\" r=\"0\" />");
- }
- elseif ($i[0]['count'] <= 32)
- {
- $this->mysql->query("UPDATE `group_powers` SET `count`=`count`-1 WHERE `group`='{$user->group}' and `assignedBy`='{$user->id}' and `power`='{$p}';");
- $user->sendPacket("<ap p=\"{$p}\" r=\"0\" />");
- }
- break;
- }
- break;
- /* kiss xat */
- case 'a':
- if ($this->spamfilter($tag, $user, $this->config->spam_wait) || $user->banned > time())
- {
- break;
- }
- if ($user->guest == true)
- {
- return false;
- }
- $attributes = array('x', 's', 'b', 'm', 'p', 'k', 'f', 'h', 'e', 'j');
- $attributes = $this->getMultiAttr($packet, $attributes);
- $x = $attributes['x'];
- $s = $attributes['s'];
- $b = $attributes['b'];
- $m = $attributes['m'];
- $p = $attributes['p'];
- $k = $attributes['k'];
- $f = $attributes['f'];
- $h = $attributes['h'];
- $e = $attributes['e'];
- $j = $attributes['j'];
- $hugs = array(366, 367, 369, 375, 10375, 20375, 379, 380, 381, 382, 384, 100387, 110387, 120387, 130387, 140387, 388, 391, 393, 100394, 395, 399, 35, 100400, 401, 10401, 20401, 404, 406, 10406, 100407, 110407, 408, 409, 410, 411, 412, 413, 417, 418, 420, 421, 427, 431, 437, 439, 456, 463, 465, 471, 476, 482, 486, 498); // adauga id de la puterea cu hugs,
- $jinxList = array("jumble", "dle", "reverse", "mix", "ends", "hang", "egg", "space"); // adauga nume jinx
- if (in_array($h % 10000, $hugs))
- {
- $jinxTime = 0;
- $jinxName = "";
- $jinxProbability = 0;
- preg_match_all('/[a-z]+|\d+/', $j, $matches);
- if (count($matches) == 3)
- {
- $jinxTime = time() + (intval($matches[0]) * 60);
- $jinxName = strtolower($matches[1]);
- $jinxProbability = intval($matches[2]);
- }
- if ($user->hasPower($h % 10000))
- {
- if (!$e && $b)
- { #hugall - pc
- $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
- $usr = $usr[0];
- if ($usr['xats'] < 10) return $user->sendPacket($user->createPacket("v", array("e" => 1, "t" => "You don't have enough xats!")));
- break;
- $user->xats = ($usr['xats'] - 10);
- $u = $this->getUserByID($b, $user->chat);
- if (!is_object($u)) break;
- if (in_array($jinxName, $jinxList))
- {
- $u->jinx = "{$jinxTime}{$jinxName}{$jinxProbability}";
- $j = "{$jinxTime}{$jinxName}{$jinxProbability}";
- }
- $this->mysql->query("update `users` set `xats` = '{$user->xats}', `reserve`=`reserve`-10 where `id` = '{$user->id}';");
- $user->sendRoom($user->createPacket("a", array("u" => $user->id, "b" => $u->id, "h" => $h, "t" => $m, "j" => $j)), true);
- $user->sendRoom($user->createPacket("a", array("u" => $user->id, "b" => $u->id, "h" => $h, "t" => $m, "c" => $user->xats, "j" => $j)));
- }
- else if (!$e && !$b)
- { #hug / hugall - only main
- $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
- $usr = $usr[0];
- if (in_array($jinxName, $jinxList) || in_array($j, $jinxList)) return $user->sendPacket('<m t="testttttttttttmessages" u="0" />');
- $user->xats = ($usr['xats'] - 10);
- $this->mysql->query("update `users` set `xats` = '{$user->xats}', `reserve`=`reserve`-10 where `id` = '{$user->id}';");
- $user->sendRoom($user->createPacket("a", array("u" => $user->id, "h" => $h, "t" => $m, "c" => $user->xats, "j" => $j)));
- }
- else
- { #hug - only pc
- $u = $this->getUserByID($b, $user->chat);
- if (!is_object($u)) break;
- if (in_array($jinxName, $jinxList))
- {
- $u->jinx = "{$jinxTime}{$jinxName}{$jinxProbability}";
- $j = "{$jinxTime}{$jinxName}{$jinxProbability}";
- }
- $u->sendRoom($user->createPacket("z", array("d" => $b, "u" => $user->id, "h" => $h, "t" => $m, "s" => 2, "T" => 1, "j" => $j)));
- $user->sendRoom($user->createPacket("a", array("u" => $user->id, "b" => $b, "h" => $h, "t" => $m, "c" => $user->xats, "j" => $j)));
- }
- }
- }
- else if (!$b && !$f)
- {
- if ($user->xats < 25)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 1, "t" => "You don't have enough xats!")));
- break;
- }
- $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
- $usr = $usr[0];
- if (!$this->mysql->checkPass($p, $usr['password']))
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 8)));
- break;
- }
- $user->xats = ($usr['xats'] - 25);
- $this->mysql->query("update `users` set `xats` = '{$user->xats}', `reserve`=`reserve`-25 where `id` = '{$user->id}';");
- $user->sendRoom($user->createPacket("a", array("u" => $user->id, "k" => $k, "t" => $m), true));
- }
- else
- {
- switch ($k)
- {
- /* married e bff terminado e divorce terminado */
- case 'Confetti':
- case 'Hearts':
- case 'Marriage':
- case 'Marry':
- case 'Rings':
- case 'Sunset':
- if ($user->d2 != 0)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 1, "t" => "You already have a BFF or are married.")));
- break;
- }
- if ($user->id == $b)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 1, "t" => "You can't marry yourself")));
- break;
- }
- $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
- $usr = $usr[0];
- if (!$this->mysql->checkPass($p, $usr['password']))
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 8)));
- break;
- }
- if ($user->xats < 200)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 11)));
- break;
- }
- $u = $this->getUserByID($b, $user->chat);
- if (!is_object($u))
- {
- break;
- }
- if ($u->hasPower(99))
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 50)));
- break;
- }
- $user->xats = ($usr['xats'] - 200);
- if ($u->d2 != 0)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 1, "t" => "That has a BFF or is already married.")));
- break;
- }
- $this->mysql->query("update `users` set `bride` = '{$u->id}', `d2` = '{$u->id}', `xats` = '{$user->xats}', `reserve`=`reserve`-200 where `id` = '{$user->id}';");
- $this->mysql->query("update `users` set `bride` = '{$user->id}', `d2` = '{$user->id}' where `id` = '{$u->id}';");
- $data1 = $this->doLogin($user->username, $user->password);
- $data2 = $this->doLogin($u->username, $u->password);
- $user->sendRoom($user->createPacket("a", array("u" => $user->id, "k" => $k, "t" => $m)), true);
- $user->sendPacket($user->createPacket("a", array("u" => $user->id, "k" => $k, "t" => $m, "c" => $user->xats)));
- $user->sendPacket($data1);
- $u->sendPacket($data2);
- break;
- case 'Beer':
- case 'Photo':
- case 'Donut':
- case 'Led':
- case 'Champagne':
- if ($user->d2 != 0)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 1, "t" => "You're already BFF | Married")));
- break;
- }
- if ($user->id == $b)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 1, "t" => "You can't BFF yourself")));
- break;
- }
- $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
- $usr = $usr[0];
- if (!$this->mysql->checkPass($p, $usr['password']))
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 8)));
- break;
- }
- if ($user->xats < 200)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 11)));
- break;
- }
- $u = $this->getUserByID($f, $user->chat);
- if (!is_object($u))
- {
- break;
- }
- if ($u->hasPower(99))
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 50)));
- break;
- }
- $user->xats = ($usr['xats'] - 25);
- if ($u->d2 != 0)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 1, "t" => "That user is already BFF' Married")));
- break;
- }
- $this->mysql->query("update `users` set `d0` = '1', `d2` = '{$u->id}', `xats` = '{$user->xats}', `reserve`=`reserve`-25 where `id` = '{$user->id}';");
- $this->mysql->query("update `users` set `d0` = '1', `d2` = '{$user->id}' where `id` = '{$u->id}';");
- $data1 = $this->doLogin($user->username, $user->password);
- $data2 = $this->doLogin($u->username, $u->password);
- $user->sendRoom($user->createPacket("a", array("u" => $user->id, "k" => $k, "t" => $m)), true);
- $user->sendPacket($user->createPacket("a", array("u" => $user->id, "k" => $k, "t" => $m, "c" => $user->xats)));
- $user->sendPacket($data1);
- $u->sendPacket($data2);
- break;
- case 'Argue':
- case 'Hippod':
- case 'Divorce':
- case 'Divorced':
- case 'Botd':
- $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
- $usr = $usr[0];
- if (!$this->mysql->checkPass($p, $usr['password']))
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 8)));
- break;
- }
- $this->mysql->query("update `users` set `d0` = '0', `d2` = '0', `bride` = '' where `id` = '{$user->id}';");
- $this->mysql->query("update `users` set `d0` = '0', `d2` = '0', `married` = '' where `id` = '{$user->id}';");
- $user->sendRoom($user->createPacket("a", array("u" => $user->id, "k" => $k, "t" => $m)), true);
- $user->sendPacket($user->createPacket("a", array("u" => $user->id, "k" => $k, "t" => $m, "c" => $user->xats)));
- $data1 = $this->doLogin($user->username, $user->password);
- $user->sendPacket($data1);
- break;
- case 'T':
- if ($x < 0 || !is_numeric($x))
- {
- $this->disconnect($user->index);
- }
- else
- {
- $usr = $this->mysql->fetch_array("select * from `users` where `id`='{$user->id}';");
- $usr = $usr[0];
- $s = intval($s);
- if ($usr['transferblock'] > time())
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 10)));
- break;
- }
- else if (!$this->mysql->checkPass($p, $usr['password']))
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 8)));
- break;
- }
- else if ($x > $usr['xats'])
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 11)));
- break;
- }
- else if ($s > 7970)
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 18)));
- break;
- }
- else if (strtotime("+ {$s} days") > $usr['days'])
- {
- return $user->sendPacket($user->createPacket("v", array("e" => 18)));
- break;
- }
- else
- {
- $u = $this->getUserByID($b, $user->chat);
- if (!is_object($u))
- {
- $user->sendPacket('<v e="0" m="a" t="" />');
- }
- else
- {
- /*if ($user->ipaddr == $u->ipaddr) {
- return $user->sendPacket('<n t="You can\'t trade with yourself D:" />');
- }*/
- $u->xats += $x;
- $u->days = $u->days <= 0 ? $s : $u->days + $s;
- $user->xats -= $x;
- $user->days -= $s;
- $this->mysql->query("update `users` set `xats`='{$u->xats}', `days`='" . strtotime("+ " . $u->days . " days") . "' where `id` = '{$u->id}';");
- $this->mysql->query("update `users` set `xats`='{$user->xats}', `days`='" . strtotime("+ " . $user->days . " days") . "' where `id` = '{$user->id}';");
- $this->mysql->query("insert into `transfers` (`to`, `from`, `xats`, `days`, `timestamp`) values ('{$u->id}', '{$user->id}', '{$x}', '{$s}', '" . time() . "');");
- $user->sendPacket($user->createPacket("a", array("c" => $user->xats, "u" => $user->id, "b" => $b, "s" => $s, "x" => $x, "k" => "T", "t" => $m)));
- $u->sendPacket($u->createPacket("a", array("c" => $u->xats, "u" => $user->id, "b" => $b, "s" => $s, "x" => $x, "h" => "T", "t" => $m)));
- $user->joinRoom($user->chat, $user->pool);
- $u->joinRoom($u->chat, $u->pool);
- }
- }
- }
- break;
- }
- }
- break;
- case 'p':
- $u = $this->getuserbyid($this->getAttribute($packet, 'u', true), $user->chat);
- if (!is_object($u))
- {
- break;
- }
- $attr = $this->getMultiAttr($packet, array('t', 's'));
- /* badge - temp mod -temp own - temp member */
- if (substr($attr['t'], 0, 1) == "/")
- {
- switch (1)
- {
- case substr($attr['t'], 1, 2) == 'nb':
- if (!in_array($user->rank, array(1, 2, 4)) || !$this->higherRank($user->rank, $u->rank, true))
- {
- break;
- }
- if ($u->f & 262144)
- {
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'b2', 'Un Badge', 'forever','{$reason}');");
- $this->mysql->query("delete from `badge` where `chatid`='{$user->chat}' and `id`='{$u->id}';");
- $u->f -= 262144;
- $u->sendPacket('<c u="' . $u->id . '" t="/u" />');
- $user->sendRoom('<m t="/u" u="' . $user->id . '" d="' . $u->id . '" />');
- $u->joinRoom($user->chat, 0, true);
- }
- else
- {
- $time = strtotime("+ 20 years");
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'b1', 'Awarded a badge', 'forever','{$reason}');");
- $this->mysql->query("insert into `badge` (`id`, `chatid`, `reason`) values ('{$u->id}', '{$user->chat}', '" . substr($attr['t'], 3) . "');");
- $u->joinRoom($user->chat, 0, true);
- $user->sendRoom('<m p="' . substr($attr['t'], 3) . '" t="/gd" w="264" u="' . $user->id . '" d="' . $u->id . '" />');
- }
- break;
- /*RankScroll*/
- /*end*/
- case substr($attr['t'], 1, 2) == 'mo':
- if (!in_array($user->rank, array(1, 2, 4)) || !$this->higherRank($user->rank, $u->rank, true))
- {
- break;
- }
- $time = round(substr($attr['t'], 3), 1);
- if (!is_numeric($time) || $time > 24 || $time < 1)
- {
- return $user->sendPacket("<n t=\"Please use the following format\n/mo2.5 for 2.5 hours.\nMax:24\nMin:1\" />");
- }
- $date = time();
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'mo', 'Make owner', '{$time}', '');");
- $this->mysql->query("delete from `ranks` where `userid`='{$u->id}' and `chatid`='{$user->chat}';");
- $this->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`, `tempend`) values('{$u->id}', '{$u->chatid}', 4, " . (time() + ($time * 60 * 60)) . ");");
- $x = "<i>";
- $x = htmlspecialchars($x);
- $user->sendRoom("<m u=\"{$user->id}\" t=\"<i> I have made {$u->username} an owner for {$time} hours!\" />");
- $u->joinRoom($user->chat, 0, true);
- break;
- case substr($attr['t'], 1, 2) == 'mb':
- if (!in_array($user->rank, array(1, 2, 4)) || !$this->higherRank($user->rank, $u->rank, true))
- {
- break;
- }
- $time = round(substr($attr['t'], 3), 1);
- if (!is_numeric($time) || $time > 24 || $time < 1)
- {
- return $user->sendPacket("<n t=\"Please use the following format\n/mo2.5 for 2.5 hours.\nMax:24\nMin:1\" />");
- }
- $date = time();
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'mo', 'Make owner', '{$time}', '');");
- $this->mysql->query("delete from `ranks` where `userid`='{$u->id}' and `chatid`='{$user->chat}';");
- $this->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`, `tempend`) values('{$u->id}', '{$u->chatid}', 3, " . (time() + ($time * 60 * 60)) . ");");
- $x = "<i>";
- $x = htmlspecialchars($x);
- $user->sendRoom("<m u=\"{$user->id}\" t=\"<i> I have made {$u->username} a Member for {$time} hours!\" />");
- $u->joinRoom($user->chat, 0, true);
- break;
- case substr($attr['t'], 1, 1) == 'm':
- if (!in_array($user->rank, array(1, 4)) || !$this->higherRank($user->rank, $u->rank, true))
- {
- break;
- }
- $time = round(substr($attr['t'], 2), 1);
- if (!is_numeric($time) || $time > 24 || $time < 1)
- {
- return $user->sendPacket("<n t=\"Please use the following format\n/m2.5 for 2.5 hours.\nMax:24\nMin:1\" />");
- }
- $date = time();
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'rank', 'Make mod', '{$time}','');");
- $this->mysql->query("delete from `ranks` where `userid`='{$u->id}' and `chatid`='{$user->chat}';");
- $this->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`, `tempend`) values('{$u->id}', '{$u->chatid}', 2, " . (time() + ($time * 60 * 60)) . ");");
- $user->sendRoom("<m u=\"{$user->id}\" t=\"<i> I have made {$u->username} a moderator for {$time} hours!\" />");
- $u->joinRoom($user->chat, 0, true);
- break;
- default:
- $attr['t'] = htmlspecialchars($attr['t']);
- $attr['s'] = htmlspecialchars($attr['s']);
- $u->sendPacket("<p u=\"{$user->id}\" t=\"{$attr['t']}\" s=\"{$attr['s']}\" />");
- return;
- }
- }
- else
- {
- $attr['t'] = htmlspecialchars($attr['t']);
- $attr['s'] = htmlspecialchars($attr['s']);
- $u->sendPacket("<p u=\"{$user->id}\" t=\"{$attr['t']}\" s=\"{$attr['s']}\" />");
- if ($this->spamfilter($tag, $user, 700)) break;
- }
- break;
- case 'p2':
- $u = $this->getUserByID($this->getAttribute($packet, 'u', true), $user->chat);
- if (!is_object($u)) break;
- $attr = $this->getMultiAttr($packet, array('t', 's'));
- $u->sendPacket("<p u=\"{$user->id}\" t=\"{$attr["t"]}\" s=\"{$attr["s"]}\" u=\"{$u->id}\" />");
- break;
- case 'z':
- if ($user->switchingPools == true)
- {
- $user->switchingPools = false;
- break;
- }
- if ($this->spamfilter($tag, $user, 1)) break;
- $d = $this->getAttribute($packet, 'd');
- $u = $this->getUserByID($d, $user->chatid);
- if ($u == false)
- {
- foreach ($this->users as & $_user)
- {
- if ((is_numeric($d) && $_user->id == $d))
- {
- if ($_user->online)
- {
- $u = $_user;
- break;
- }
- }
- }
- }
- if (!is_object($u))
- {
- $t = $this->getAttribute($packet, 't');
- if (trim($t) != "" && substr($t, 0, 1) !== "/" && is_numeric($d))
- {
- if (strlen($t) < 300)
- {
- $d = $this->mysql->sanatize($d);
- $check = $this->mysql->fetch_array("select xto from `offline_messages` where `xto`='{$d}' and `xfrom`='{$user->id}' and `unread`='1';");
- if (count($check) >= 12)
- {
- return $user->sendPacket("<n t=\"Max offline unread msgs: 12\" />");
- }
- unset($check);
- $msg = $this->mysql->sanatize($t);
- $this->mysql->query("insert into `offline_messages` (id, xto, xfrom, xmessage, unread) VALUES (NULL, '{$d}', '{$user->id}', '{$msg}', 1);");
- }
- }
- break;
- }
- if (!is_object($user))
- {
- break;
- }
- $t2 = $this->getAttribute($packet, 't');
- $t = substr($t2, 0, 2);
- $t3 = substr($t2, 0, 3);
- $param = substr($t2, 2);
- switch ($t)
- {
- /* locarizaçao usuario e nofollow */
- case '/l':
- if ($u->hidden == true)
- {
- return false;
- }
- $check = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$u->id}' and `friend`='{$user->id}';");
- $check2 = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$user->id}' and `friend`='{$u->id}';");
- if (empty($check) || empty($check2))
- {
- $str = " t=\"/a_\"";
- }
- else
- {
- $str = (($u->haspower(5) && $u->chat != $user->chat) || !isset($u->group)) ? " t=\"/a_NF\"" : " t=\"/ahttp://{$this->config->server_domain}/{$u->group}\"";
- }
- if ($u->haspower(27))
- {
- $user->sendPacket('<z b="1" d="' . $user->id . '" u="' . $u->id . '"' . ($str) . ' po="' . $u->dO . '" ' . $u->pStr . 'x="' . $u->xats . '" y="' . $u->days . ($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) . '" v="7" />');
- $u->sendPacket('<z b="1" d="' . $u->id . '" u="' . $user->id . '" t="/l" po="' . $user->dO . '" ' . $user->pStr . 'x="' . $user->xats . '" y="' . $user->days . ($user->days >= 1 ? '" q="3"' : '" q="1"') . ($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="7" />');
- }
- else
- {
- $user->sendPacket('<z b="1" d="' . $user->id . '" u="' . $u->id . '"' . ($str) . ' po="' . $u->dO . '" ' . $u->pStr . 'x="' . $u->xats . '" y="' . $u->days . ($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) . '" v="7" />');
- $u->sendPacket('<z b="1" d="' . $u->id . '" u="' . $user->id . '" t="/l" po="' . $user->dO . '" ' . $user->pStr . 'x="' . $user->xats . '" y="' . $user->days . ($user->days >= 1 ? '" q="3"' : '" q="1"') . ($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="7" />');
- $guser = $this->mysql->fetch_array("SELECT * FROM `users` WHERE `id`='" . $u->id . "';");
- if (!empty($guser[0]['tickle']))
- {
- $user->sendPacket("<z u=\"" . $u->id . "\" t=\"[Auto-msg] " . $guser[0]['tickle'] . "\" d=\"" . $user->id . "\" />");
- }
- }
- break;
- case '/a':
- $checkk = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$u->id}' and `friend`='{$user->id}';");
- $check2 = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$user->id}' and `friend`='{$u->id}';");
- if (empty($checkk) || empty($check2))
- {
- $str = " t=\"/a_\"";
- }
- else
- {
- $str = (($u->haspower(5) && $u->chat != $user->chat) || !isset($u->group)) ? " t=\"/a_NF\"" : " t=\"/ahttp://{$this->config->server_domain}/{$u->group}\"";
- }
- $check = $this->mysql->fetch_array("SELECT * FROM `friends` WHERE `user`='{$user->id}' and `friend`='{$u->id}';");
- if ($check)
- {
- if ($u->haspower(27))
- {
- $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="7" />');
- }
- else
- {
- $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" />');
- }
- }
- break;
- default:
- var_dump("PV ???");
- //$u = $this->getUserByID($this->getAttribute($packet, 'u', true), $user->chat);
- //if(!is_object($u)) break;
- $t = $this->getAttribute($packet, 't');
- $s = $this->getAttribute($packet, 's');
- $u->sendPacket("<z u=\"" . $user->id . "\" t=\"" . $t . "\" s=\"" . $s . "\" d=\"" . $u->id . "\" />");
- break;
- }
- break;
- case 'c':
- if ($this->spamfilter($tag, $user, 800))
- {
- break;
- }
- if ($user->banned > time())
- {
- return false;
- }
- if ($user->rExpire != 0 && $user->rExpire < time())
- {
- $this->mysql->query("delete from `ranks` where `userid`={$user->id} and `chatid`='{$user->chat}';");
- $this->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`) values({$user->id}, {$user->chat}, 3);");
- return $user->joinRoom($user->chat, 0, true);
- }
- $attr = $this->getAttribute($packet, 'u', true);
- $t2 = $this->getAttribute($packet, 't');
- $uid = $this->getAttribute($packet, 'u');
- $game = $this->getAttribute($packet, 'w');
- $p = $this->getAttribute($packet, 'p');
- $u = $this->getUserByID($attr, $user->chat);
- $bchat = $this->mysql->fetch_array("select * from `chats` where `id`='{$user->chat}';");
- $Blastbans = $this->mysql->fetch_Array("SELECT * FROM `group_powers` WHERE `group`='{$user->group}' AND `power`=86;");
- $blastkicks = $this->mysql->fetch_Array("SELECT * FROM `group_powers` WHERE `group`='{$user->group}' AND `power`=94;");
- $Blastpros = $this->mysql->fetch_Array("SELECT * FROM `group_powers` WHERE `group`='{$user->group}' AND `power`=84;");
- $Blastdes = $this->mysql->fetch_Array("SELECT * FROM `group_powers` WHERE `group`='{$user->group}' AND `power`=88;");
- $blastban = $bchat[0]["blastban"];
- $blastkick = $bchat[0]["blastkick"];
- $blastpro = $bchat[0]["blastpro"];
- $blastde = $bchat[0]["blastde"];
- $param3 = substr($t2, 3);
- $param = substr($t2, 2);
- print substr($t2, 0, 2);
- print substr($t2, 0, 3);
- switch (substr($t2, 0, 2))
- {
- case '/b':
- $friend = explode(',', $t2);
- if ($friend[1] == '1' && $friend[2] !== '')
- {
- $friend_id = $this->mysql->fetch_array("SELECT id FROM `users` WHERE `username`='{$friend[2]}';");
- $this->mysql->query("insert into `friends` (`id`, `user`, `friend`) values (NULL, '{$user->id}', '{$friend_id[0]['id']}');");
- }
- elseif ($friend[1] == '2' && $friend[0][2] !== '')
- {
- $this->mysql->query("delete from `friends` where `user`={$user->id} and `friend`='" . str_replace('/b ', '', $friend[0]) . "';");
- }
- break;
- }
- if (!is_object($u))
- {
- return;
- } //Delete friend
- switch (substr($t2, 0, 3))
- {
- case '/gm':
- if ($this->higherRank($user->rank, $u->rank, true) && in_array($user->rank, array(1, 4)))
- {
- $gag = $this->mysql->fetch_array("select * from `bans` where `userid`='{$u->id}' and `chatid`='{$u->chat}' and `type`='f256';");
- if ($u->f & 256)
- {
- $date = time();
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' or `chatid`='{$user->chat}' and `ip`='{$u->ipaddr}';");
- $user->sendRoom($user->createPacket("m", array("t" => "/u", "u" => $user->id, "d" => $u->id)));
- $user->sendRoom($user->createPacket("m", array("t" => "/p", "u" => $user->id, "d" => $u->id)));
- $u->f -= 256;
- $u->joinRoom($user->chat, false, true, 0);
- }
- else
- {
- $time = $param3 == 0 ? strtotime("+ 20 years") : strtotime("+ {$param3} seconds");
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'mute', 'Mute', '{$time}', '{$p}');");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
- $u->joinRoom($user->chat, false, true, 0);
- $u->f |= 256;
- $user->sendRoom($user->createPacket('m', array('p' => $this->getAttribute($packet, 'p'), 't' => '/gm', "u" => $user->id, 'd' => $u->id)));
- $u->banned = $time;
- }
- }
- return;
- break;
- case '/gg':
- if ($this->higherRank($user->rank, $u->rank, true) && in_array($user->rank, array(1, 4)))
- {
- $gag = $this->mysql->fetch_array("select * from `bans` where `userid`='{$u->id}' and `chatid`='{$u->chat}' and `type`='f256';");
- if ($u->f & 256)
- {
- $date = time();
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' or `chatid`='{$user->chat}' and `ip`='{$u->ipaddr}';");
- $user->sendRoom($user->createPacket("m", array("t" => "/u", "u" => $user->id, "d" => $u->id)));
- $u->f -= 256;
- $u->joinRoom($user->chat, false, true, 0);
- }
- else
- {
- $time = $param3 == 0 ? strtotime("+ 20 years") : strtotime("+ {$param3} seconds");
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'gag', 'Gag', '{$time}', '{$p}');");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f256');");
- $u->joinRoom($user->chat, false, true, 0);
- $u->f |= 256;
- $user->sendRoom($user->createPacket("m", array("p" => $this->getAttribute($packet, 'p'), "t" => "/gg{$param3}", "u" => $user->id, "d" => $u->id)));
- $u->banned = $time;
- }
- }
- return;
- break;
- case '/gn':
- if ($this->higherRank($user->rank, $u->rank, true) && in_array($user->rank, array(1, 4)))
- {
- // naughty
- if ($u->f & 524288)
- {
- $date = time();
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'n2', 'UnNaughty', '', '{$p}');");
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' or `chatid`='{$user->chat}' and `ip`='{$u->ipaddr}';");
- $user->sendRoom('<m t="/u" u="' . $user->id . '" d="' . $u->id . '" />');
- $u->f -= 524288;
- $u->joinRoom($user->chat, false, true, 0);
- }
- else
- {
- $date = time();
- $time = $this->loginTime * $this->loginTime;
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'n1', 'Naughty', 'forever', '{$p}');");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f524288');");
- $u->f |= 524288;
- $u->joinRoom($user->chat, false, true, 0);
- $user->sendRoom('<m p="' . $this->getAttribute($packet, 'p') . '" t="/gn' . $param3 . '" u="' . $user->id . '" d="' . $u->id . '" w="284" />');
- $u->banned = $time;
- }
- }
- return;
- break;
- case '/gy':
- if ($this->higherRank($user->rank, $u->rank, True) && in_Array($user->rank, Array(1, 2, 4)))
- // Yellowcard
- {
- print $u->id;
- print $user->chat;
- $verIficar = $this->mysql->fetch_array("select * from `bans` where `userid`='{$u->id}' and `chatid`='{$u->chat}' and `type`='f1048576';");
- if (!$verIficar)
- {
- $date = time();
- $time = $this->loginTime * $this->loginTime;
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'y1', 'Yellowcard', 'forever', '{$p}');");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f1048576');");
- $u->f |= 0x100000;
- $user->sendRoom('<m p="' . $this->getAttribute($packet, 'p') . '" t="/gy' . $param3 . '" u="' . $user->id . '" d="' . $u->id . '" w="292" />');
- $u->joinRoom($user->chat, False, True, 0);
- $user->sendRoom("<bl u=\"{$user->id}\" d=\"{$u->id}\" t=\"blastyellow\" v=\"1\" r=\"{$this->blastCor($u->rank) }\" o=\"{$this->blastCargo($u->rank) }\" />");
- } //!$verIficar[ 0 ][ 'index' ]
- else
- {
- $date = time();
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'y2', 'UnYellowcard', '', '');");
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' and type='f1048576';");
- $u->f -= 0x100000;
- $u->sendPacket('<c u="' . $u->id . '" t="/u" />');
- $u->joinRoom($user->chat, 0, True);
- }
- } //$this->higherRank( $user->rank, $u->rank, True ) && in_Array( $user->rank, Array( 1, 2, 4 ) )
- return;
- break;
- case '/gr':
- if ($this->higherRank($user->rank, $u->rank, True) && in_Array($user->rank, Array(1, 2, 4)))
- // redcard
- {
- $verIficar = $this->mysql->fetch_Array("SELECT * FROM `bans` WHERE userid = {$u->id} AND `chatid` = {$user->chat} AND type = 'f2097152';");
- if (!$verIficar[0]['index'])
- {
- $date = time();
- $time = $param3 == 0 ? strtotime("+ 20 years") : strtotime("+ {$param3} seconds");
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'r1', 'Redcard', 'forever', '{$p}');");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f2097152');");
- $u->joinRoom($user->chat, False, True, 0);
- $user->sendRoom('<m p="' . $this->getAttribute($packet, 'p') . '" t="/gr' . $param3 . '" u="' . $user->id . '" d="' . $u->id . '" />', False, $u->id);
- $user->sendRoom("<bl u=\"{$user->id}\" d=\"{$u->id}\" t=\"blastred\" v=\"1\" r=\"{$this->blastCor($u->rank) }\" o=\"{$this->blastCargo($u->rank) }\" />");
- }
- else
- {
- $date = time();
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'r2', 'UnRedcard', '', '');");
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' and type='f2097152';");
- $u->f -= 2097152;
- $u->joinRoom($user->chat, 0, True);
- }
- }
- return;
- break;
- case '/gd':
- if (!in_array($user->rank, array(1, 2, 4)))
- {
- return;
- }
- else
- {
- if ($u->f & 32768)
- {
- $this->mysql->query("delete from `bans` where `userid`='{$u->id}' and `chatid`='{$u->chat}' and `type`='f32768';");
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'undunce', 'un-dunce', '', '');");
- $u->f -= 32768;
- $u->nulleGp = true;
- $u->joinRoom($user->chat, false, true, $u->pool);
- $user->sendRoom($user->createPacket("m", array("t" => "/u", "u" => $user->id, "d" => $u->id, "w" => "158", "E" => time())));
- }
- else
- {
- $date = time();
- $time = $param3 == 0 ? strtotime("+ 20 years") : strtotime("+ {$param3} seconds");
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'dunce', 'Dunce', 'forever', '{$p}');");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'f32768');");
- if (!count($Blastbans) == 0 && $Blastbans[0]['enabled'] == 1)
- {
- $user->sendRoom($this->Blaster($user->id, $u->id, $u->rank, "blastdunce", $blastban), false);
- }
- $u->f |= 32768;
- $u->nulleGp = true;
- $user->sendRoom($user->createPacket("m", array("t" => "/gd{$param}", "u" => $user->id, "d" => $u->id, "w" => "158", "E" => time())));
- $u->unban = true;
- $u->joinRoom($user->chat, false, true, 0);
- }
- }
- return;
- break;
- }
- switch (substr($t2, 0, 2))
- {
- case '/r':
- case '/e':
- case '/m':
- case '/M':
- $ranks = array('r' => array(array(1, 2, 4), 5), 'e' => array(array(1, 2, 4), 3), 'm' => array(array(1, 4), 2), 'M' => array(array(1), 4));
- $rank = $ranks[substr($t2, 1, 1) ];
- $locked = $this->mysql->fetch_array("select * from `ranks` where `userid`='{$u->id}' and `chatid`='{$user->chat}';");
- if ($locked[0]['locked'] == 0 && in_array($user->rank, $rank[0]) && $this->higherRank($user->rank, $u->rank, true))
- {
- if ($locked[0]['f'] == 5 && $rank[1] == 4)
- {
- $wblast = 'blastpro';
- }
- elseif ($locked[0]['f'] == 5 && $rank[1] == 3)
- {
- $wblast = 'blastpro';
- }
- elseif ($locked[0]['f'] == 5 && $rank[1] == 2)
- {
- $wblast = 'blastpro';
- }
- elseif ($locked[0]['f'] == 3 && $rank[1] == 4)
- {
- $wblast = 'blastpro';
- }
- elseif ($locked[0]['f'] == 3 && $rank[1] == 2)
- {
- $wblast = 'blastpro';
- }
- elseif ($locked[0]['f'] == 2 && $rank[1] == 4)
- {
- $wblast = 'blastpro';
- }
- else
- {
- $wblast = 'blastde';
- }
- $this->mysql->query('delete from `ranks` where `userid`=' . $u->id . ' and `chatid`=' . $user->chat . ';');
- $this->mysql->query('insert into `ranks` (`userid`, `chatid`, `f`) values(' . $u->id . ', ' . $user->chat . ', ' . $rank[1] . ');');
- $p = $this->getAttribute($packet, 'p');
- $silent = $user->hasPower(142) && substr($t2, 0, 2) == '/e' && in_array($user->rank, array(1, 2, 4)) && $rank == $ranks['e'] ? 'c' : 'm';
- $u->sendPacket('<c p="' . $p . '" t="' . substr($t2, 0, 2) . '" u="' . $user->id . '" d="' . $u->id . '" />');
- if($u->f & 256){
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' or `chatid`='{$user->chat}' and `ip`='{$u->ipaddr}';");
- $user->sendRoom('<m t="/p" u="' . $user->id . '" d="' . $u->id . '" />');
- $u->f -= 256;
- }
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' and type='f256';");
- $user->sendRoom('<' . $silent . ' u="' . $user->id . '" d="' . $u->id . '" t="/m" p="' . substr($t2, 1, 1) . '" />');
- $cols = array("/r" => "0x009900", "/e" => "0x3366FF", "/m" => "0xFFFFFF", "/M" => "0xFF9900");
- $colIndex = substr($t2, 0, 2);
- $blaster = $cols[$colIndex];
- $oAttr = array("/r" => "r", "/e" => "e", "/m" => "m", "/M" => "M");
- $oIndex = substr($t2, 0, 2);
- $useO = $oAttr[$oIndex];
- if (!count($Blastpros) == 0 && $Blastpros[0]['enabled'] == 1 && $wblast == "blastpro")
- {
- $user->sendRoom('<bl u="' . $user->id . '" d="' . $u->id . '" t="' . $wblast . '" v="' . $blastpro . '" r="' . $blaster . '" o="' . $useO . '" />', false);
- }
- elseif (!count($Blastdes) == 0 && $Blastdes[0]['enabled'] == 1 && $wblast == "blastde")
- {
- $user->sendRoom('<bl u="' . $user->id . '" d="' . $u->id . '" t="' . $wblast . '" v="' . $blastde . '" r="' . $blaster . '" o="' . $useO . '" />', false);
- }
- $u->nulleGp = true;
- $u->joinRoom($user->chat, 0, true);
- }
- break;
- case '/g': // Ban
- if (in_array($user->rank, array(1, 2, 4)) && $this->higherRank($user->rank, $u->rank, true))
- {
- if ($user->rank == 2)
- { // Mod8
- $hours = round((($param3 / 60) / 60), 1);
- $mod8 = $user->haspower(3);
- if ($hours > 6 && !$mod8 || $mod8 && $hours > 8)
- {
- return;
- }
- }
- $time = $param3 == 0 ? strtotime("+ 20 years") : strtotime("+ {$param3} seconds");
- if ($game !== false && is_numeric($game) && $game > 0)
- {
- if ($user->hasPower($game))
- {
- $date = time();
- switch ($game)
- {
- case 134:
- $gban = "SnakeBan";
- break;
- case 136:
- $gban = "SpaceBan";
- break;
- case 140:
- $gban = "MatchBan";
- break;
- case 152:
- $gban = "MazeBan";
- break;
- case 162:
- $gban = "CodeBan";
- break;
- case 176:
- $gban = "Reverse";
- break;
- case 184:
- $gban = "Zip";
- break;
- }
- $verIficar = $this->mysql->fetch_Array("SELECT * FROM `bans` WHERE userid = {$u->id} AND `chatid` = {$user->chat} AND type = 'w{$game}';");
- if (!$verIficar[0]['index'])
- {
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', '{$game}', '{$gban}', '{$time}', '{$p}');");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`, `type`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}', 'w{$game}');");
- $user->sendRoom('<m p="' . $p . '" t="/g' . $param . '" w="' . $game . '" u="' . $user->id . '" d="' . $u->id . '" />');
- $u->sendPacket('<m p="' . $p . '" w="' . $game . '" t="/g' . $time . '" u="' . $user->id . '" d="' . $u->id . '" />');
- if (!count($Blastbans) == 0 && $Blastbans[0]['enabled'] == 1)
- {
- $user->sendRoom('<bl u="' . $user->id . '" d="' . $u->id . '" t="blastban" v="' . $blastban . '" r="' . $this->BlastCor($u->rank) . '" o="' . $this->BlastCargo($u->rank) . '" />', false);
- }
- $u->joinRoom($user->chat, false, true, 0);
- }
- else
- {
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' and type='w{$game}';");
- $user->sendRoom('<m t="/u" u="' . $user->id . '" d="' . $u->id . '" />');
- $u->sendPacket('<c u="0" d="' . $u->id . '" t="/u" />');
- $u->joinRoom($user->chat, false, true, 0);
- }
- }
- else
- {
- $user->sendPacket('<n t="You don\'t have that power!" />');
- }
- }
- else
- {
- $date = time();
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'g', 'Ban', '{$time}', '{$p}');");
- $this->mysql->query("insert into `bans` (`chatid`, `userid`, `unbandate`, `ip`) values ('{$user->chat}', '{$u->id}', '{$time}', '{$u->ipaddr}');");
- $user->sendRoom('<m p="' . $this->getAttribute($packet, 'p') . '" t="/g' . $param . '" u="' . $user->id . '" d="' . $u->id . '" />');
- $u->sendPacket('<c p="' . $this->getAttribute($packet, 'p') . '" t="/g' . $time . '" u="' . $this->getAttribute($packet, 'u') . '" d="' . $this->getAttribute($packet, 'd') . '" />');
- $u->sendRoom("<l u=\"{$u->id}\" />");
- if (!count($Blastbans) == 0 && $Blastbans[0]['enabled'] == 1)
- {
- $user->sendRoom('<bl u="' . $user->id . '" d="' . $u->id . '" t="blastban" v="' . $blastban . '" r="' . $this->BlastCor($u->rank) . '" o="' . $this->BlastCargo($u->rank) . '" />', false);
- }
- $u->sendRoom("<l u=\"{$u->id}\" />"); // Left off here [Blasts]
- $u->joinRoom($user->chat, false, true, 2);
- }
- }
- break;
- case "/k":
- $checkUser = $user->rank == 3 && $u->banned > time() ? True : False;
- if ((in_Array($user->rank, Array(1, 2, 4)) && $this->higherRank($user->rank, $u->rank, True)) || $checkUser)
- {
- $args = explode("#", $pee = $this->getAttribute($packet, 'p'));
- if (count($args) == 2)
- {
- $chat = $this->mysql->fetch_Array("select * from `chats` where `id`='{$this->mysql->sanatize($args[1]) }' or `name`='{$this->mysql->sanatize($args[1]) }';");
- if (empty($chat))
- {
- $user->sendPacket("<n t=\"Este chat nao existe!\" />");
- }
- Else
- {
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'k', 'Boot', '', '{$pee}');");
- $user->sendRoom("<m p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />", False);
- $u->sendPacket("<q p2=\"{$pee}\" u=\"{$u->id}\" d2=\"{$user->id}\" r=\"{$chat[0]['id']}\" />");
- if (!count($blastkicks) == 0 && $blastkicks[0]['enabled'] == 1)
- {
- $user->sendRoom('<bl u="' . $user->id . '" d="' . $u->id . '" t="blastkick" v="' . $blastkick . '" r="' . $this->BlastCor($u->rank) . '" o="' . $this->BlastCargo($u->rank) . '" />', False);
- }
- $u->joinRoom($chat[0]['id'], True);
- $user->sendRoom("<l u=\"{$u->id}\" />");
- }
- }
- Else
- {
- if (count($args) == 3 && !$user->hasPower(121))
- {
- $user->sendPacket("<n t=\"Voce nao tem o power ZAP!\" />");
- }
- Else
- {
- $user->sendRoom("<m p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />", False);
- $u->sendPacket("<c p=\"{$pee}\" t=\"/k\" u=\"{$user->id}\" d=\"{$u->id}\" />");
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'k', 'Kick', '', '{$pee}');");
- if (!count($blastkicks) == 0 && $blastkicks[0]['enabled'] == 1)
- {
- $user->sendRoom('<bl u="' . $user->id . '" d="' . $u->id . '" t="blastkick" v="' . $blastkick . '" r="' . $this->BlastCor($u->rank) . '" o="' . $this->BlastCargo($u->rank) . '" />', False);
- }
- $this->disconnect($u->index);
- $user->sendRoom("<l u=\"{$u->id}\" />");
- }
- }
- }
- Else
- {
- $this->disconnect($user->index);
- }
- break;
- case '/u':
- if (in_array($user->rank, array(1, 2, 4)) && ($u->rank == 16 && $this->higherRank($user->rank, $u->rank, true)))
- {
- $date = time();
- $this->mysql->query("insert into `events`(`id`, `userid`, `victim`, `chat`, `timestamp`, `type`, `action`, `hours`, `reason`) values('null', '{$user->id}', '{$u->id}', '{$user->chat}', '{$date}', 'unban', 'Unban', '', '');");
- $this->mysql->query("delete from `bans` where `chatid`='{$user->chat}' and `userid`='{$u->id}' or `chatid`='{$user->chat}' and `ip`='{$u->ipaddr}';");
- $user->sendRoom('<m t="/u" u="' . $user->id . '" d="' . $u->id . '" />');
- $u->sendPacket('<c u="0" d="' . $u->id . '" t="/u" />');
- $u->sendRoom("<l u=\"{$u->id}\" />");
- $u->joinRoom($user->chat, false, true, 0);
- $user->joinRoom($user->chat, false, true, $user->pool);
- }
- break;
- }
- break;
- default:
- $this->disconnect($user->index);
- break;
- }
- }
- public function BlastCor($rank)
- {
- switch ($rank)
- {
- case 5:
- $cor = "0x009900";
- break;
- case 4:
- $cor = "0xFF9900";
- break;
- case 3:
- $cor = "0x3366FF";
- break;
- case 2:
- $cor = "0xFFFFFF";
- break;
- case 1:
- $cor = "X";
- break;
- default:
- $cor = "0x009900";
- }
- return $cor;
- }
- public function BlastCargo($rank)
- {
- switch ($rank)
- {
- case 5:
- $rank = "r";
- break;
- case 4:
- $rank = "M";
- break;
- case 3:
- $rank = "e";
- break;
- case 2:
- $rank = "m";
- break;
- case 1:
- $rank = "X";
- break;
- default:
- $rank = "0x009900";
- }
- return $rank;
- }
- public function Blaster($myid, $userid, $rank, $blast, $blasttype)
- {
- return "<bl u=\"{$myid}\" d=\"{$userid}\" t=\"{$blast}\" v=\"{$blasttype}\" r=\"{$this->blastCor($rank) }\" o=\"{$this->blastCargo($rank) }\" />";
- }
- public function mask($packet)
- {
- $length = strlen($packet);
- if ($length < 126)
- {
- return pack('CC', 0x80 | (0x1 & 0x0f), $length) . $packet;
- }
- elseif ($length < 65536)
- {
- return pack('CCn', 0x80 | (0x1 & 0x0f), 126, $length) . $packet;
- }
- else
- {
- return pack('CCNN', 0x80 | (0x1 & 0x0f), 127, $length) . $packet;
- }
- }
- public function unmask($packet)
- {
- try
- {
- $length = ord($packet[1]) & 127;
- if ($length == 126)
- {
- $masks = substr($packet, 4, 4);
- $data = substr($packet, 8);
- }
- elseif ($length == 127)
- {
- $masks = substr($packet, 10, 4);
- $data = substr($packet, 14);
- }
- else
- {
- $masks = substr($packet, 2, 4);
- $data = substr($packet, 6);
- }
- $response = '';
- $dlength = strlen($data);
- for ($i = 0;$i < $dlength;++$i)
- {
- $response .= $data[$i] ^ $masks[$i % 4];
- }
- return $response == '' ? false : $response;
- }
- catch(Exception $e)
- {
- return false;
- }
- }
- /* funçao de transferencia de power para conta */
- public function doLogin($user, $pass)
- {
- /* Variables */
- $vals = array();
- $p = array();
- $pp = '';
- $dO = '';
- $powerO = '';
- $user = $this->mysql->fetch_array('select * from `users` where `username`=\'' . $this->mysql->sanatize($user) . '\';');
- if (isset($user[0]))
- {
- $bride = $user[0]['d2'] == 0 ? false : $user[0]['bride'];
- if ($user[0]['torched'] != 1)
- {
- if ((floor(($user[0]['days'] - time()) / (24 * 3600) + 0.3) >= 1 ? floor(($user[0]['days'] - time()) / (24 * 3600) + 0.3) : 0) >= 1)
- {
- $upowers = $this->PowDecode($user[0]['powers']);
- $spowers = $this->mysql->fetch_array('select * from `powers` where `name` not like \'%(Undefined)%\';');
- foreach ($spowers as $power)
- {
- $vals[$power['id']] = array($power['section'], $power['subid']);
- $p[$power['section']] = 0;
- }
- foreach ($upowers as $powerid => $count)
- {
- if ($count >= 1 && isset($vals[$powerid]) && isset($p[$vals[$powerid][0]]))
- {
- $str = $powerid . '=' . ($count > 1 ? ($count - 1) : 1) . '|';
- $p[$vals[$powerid][0]] += $vals[$powerid][1];
- $dO .= $str;
- if ($count > 1)
- {
- $powerO .= $str;
- }
- }
- }
- foreach ($p as $i => $u)
- {
- $pp .= " d" . (substr($i, 1) + 4) . "=\"{$u}\"";
- }
- }
- $this->mysql->query("update `users` set `dO`='{$this->mysql->sanatize($powerO) }' where `username`='{$this->mysql->sanatize($user[0]['username']) }';");
- if ($user[0]['torched'] == 1)
- {
- $user[0]['xats'] = 0;
- $user[0]['days'] = 0;
- }
- 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}\" />";
- }
- }
- return false;
- }
- public function getUserByID($id, $chat = null)
- {
- if ($id == 2 || $id == 0)
- {
- return false;
- }
- foreach ($this->users as $user)
- {
- if ($user->id == $id && ($chat == null || $user->chat == $chat))
- {
- return $user->online ? $user : false;
- }
- }
- return false;
- }
- /* funçao de identificaçao de cargo para block nas pools */
- function higherRank($rank1, $rank2, $minMod = false) {
- if ($rank1 == $rank2) {
- return false;
- }
- $order = array(1, 2, 3, 4);
- if (in_array($rank1, $order) && !in_array($rank2, $order)) {
- return true;
- }
- if ($rank1 == 1) {
- return true;
- }
- if ($rank1 == 4 && $rank2 != 1) {
- return true;
- }
- if ($rank1 == 2 && $rank2 != 1 && $rank2 != 4) {
- return true;
- }
- if ($minMod == true) {
- return false;
- }
- if ($rank1 == 3 && $rank2 != 1 && $rank2 != 4 && $rank2 != 2) {
- return true;
- }
- return false;
- }
- public function getAttribute($att, $attName, $reverse = false)
- {
- if ($reverse == true)
- {
- array_reverse($att);
- }
- foreach ($att as $a => $b)
- {
- if ($a == $attName)
- {
- $b = htmlspecialchars($b);
- return $b;
- }
- }
- return false;
- }
- public function getMultiAttr($xml, $names = array(), $values = array())
- {
- setType($names, 'array');
- foreach ($names as $u)
- {
- $values[$u] = false;
- }
- foreach ($xml as $i => $u)
- {
- if (in_array($i, $names) || empty($names))
- {
- $values[$i] = ((string)((string)$u));
- }
- }
- return $values;
- }
- public function disconnect($userID, $logout = null, $num = null, $chatid = null)
- {
- if (isset($this->users[$userID]) && $user = $this->users[$userID])
- {
- if (!is_null($logout) && $user->online)
- {
- if ($user->hasPower(172))
- {
- $user->sendRoom('<m t="/RTypeOff" u="' . $user->id . '" />');
- }
- $user->sendPacket("<logout />");
- }
- if (is_resource($user->sock))
- {
- socket_close($user->sock);
- $user->sock = null;
- }
- $user->online = false;
- return true;
- }
- return false;
- }
- public function ipban($ip, $dcall = true)
- {
- if (!filter_var($ip, FILTER_VALIDATE_IP))
- {
- return false;
- }
- $this->ipbans[] = $ip;
- if ($dcall == true)
- {
- foreach ($this->users as $u)
- {
- if ($u->ipaddr == $ip)
- {
- $this->disconnect($u->index);
- }
- }
- }
- $bans = json_encode($this->ipbans);
- $this->mysql->query("update `server` set `ipbans`='{$this->mysql->sanatize($bans) }';");
- return true;
- }
- public function ipUnban($ip)
- {
- if (!filter_var($ip, FILTER_VALIDATE_IP))
- {
- return false;
- }
- foreach ($this->ipbans as $index => $addr)
- {
- if ($ip == $addr)
- {
- unset($this->ipbans[$index]);
- $bans = json_encode($this->ipbans);
- $this->mysql->query("update `server` set `ipbans`='{$this->mysql->sanatize($bans) }';");
- return true;
- }
- else
- {
- continue;
- }
- }
- return false;
- }
- public function spamfilter($element, $user, $ms = 800, $time = null, $dc = true)
- {
- if (is_null($time))
- {
- $time = round(microtime(true) * 1000);
- }
- if (isset($user->last[$element]) && ($user->last[$element] + $ms) >= $time)
- {
- return (is_null($dc) ? true : $this->disconnect($user->index));
- }
- $user->last[$element] = $time;
- return false;
- }
- public function temp_unsanitize($str)
- {
- $str = str_replace(chr(0xCB) . chr(0x83), '>', $str);
- $str = str_replace('<', '<', $str);
- $str = str_replace(''', "'", $str);
- $str = str_replace('"', '"', $str);
- $str = str_replace('&', '&', $str);
- return $str;
- }
- public function parsePacket($string)
- {
- $node = null;
- $elements = [];
- $string = trim($string);
- if (strlen($string) < 3) throw new Exception();
- if ($string[0] != '<' || substr($string, -2) != '/>') throw new Exception();
- $string = substr($string, 1, -2);
- $pos = strpos($string, ' ');
- $node = ($pos === false) ? $string : substr($string, 0, $pos);
- $n = preg_match_all('! ([^ =]+(?:="[^"]+"|="")?)!', $string, $matches);
- for ($i = 0;$i < $n;$i++)
- {
- $pos = strpos($matches[1][$i], '=');
- $elements[($pos === false ? : substr($matches[1][$i], 0, $pos)) ] = ($pos === false ? $matches[1][$i] : $this->temp_unsanitize(substr($matches[1][$i], $pos + 2, -1)));
- }
- return ['node' => $node, 'elements' => $elements];
- }
- public function PowEncode($array = null)
- {
- $str = "";
- if (is_array($array))
- {
- foreach ($array as $i => $u) $str .= "{$i}={$u}|";
- }
- return $str;
- }
- public function PowDecode($str = null)
- {
- $encPow = [];
- if (is_string($str) && $str != null)
- {
- $oPow = explode('|', rtrim($str, '|'));
- foreach ($oPow as $u)
- {
- $pow = explode("=", $u);
- if (!isset($pow[0])) return [];
- if (!isset($pow[1]) || $pow[1] <= 0 || $pow[1] > 10000) $pow[1] = 1;
- $encPow[$pow[0]] = (int)$pow[1];
- }
- }
- return $encPow;
- }
- public function getDays($days)
- {
- return floor(($days - time()) / (24 * 3600) + 0.3) >= 1 ? floor(($days - time()) / (24 * 3600) + 0.3) : 0;
- }
- }
- /* class do client do server para identificar as funçoes */
- class client {
- public $sock, $parent;
- public $bride, $rank, $id, $username, $nickname, $k, $k2, $k3, $password, $avatar, $url, $powers, $room, $xats, $days, $chat, $banned, $hidden = false, $pool = 0, $switchingPools = false;
- public $d0, $d1, $d2, $d3, $d4, $d5, $d6, $dt, $dx, $dO, $p0, $p1, $p2, $p4, $PowerO, $d7, $p3, $homepage, $h, $group, $away = false, $pStr;
- public $loginKey = null, $last = array(), $authenticated = null, $online = false, $disconnect = false, $rExpire = 0, $chatPass = false, $pawn = '';
- public $mobready = false, $buffer = '';
- public $guest;
- public function __construct(&$socket, &$parent, $index, $ipaddr, $mobile = false)
- {
- list($this->index, $this->sock, $this->parent, $this->ipaddr, $this->mobile) = array($index, $socket, $parent, $ipaddr, $mobile);
- }
- public function resetDetails($id, $bans = null)
- {
- $user = $this->parent->mysql->fetch_array("select * from `users` where `id`='{$this->parent->mysql->sanatize($id) }' and `id` not in(0, 2);");
- if (empty($user))
- {
- $this->guest = true;
- }
- else
- {
- if ($user[0]['username'] == '')
- {
- list($this->guest, $this->k, $this->k2, $this->k3) = array(true, $user[0]['k'], $user[0]['k2'], $user[0]['k3']);
- }
- else
- {
- $this->xats = $user[0]['xats'];
- $this->days = floor(($user[0]['days'] - time()) / (24 * 3600) + 0.3) >= 1 ? floor(($user[0]['days'] - time()) / (24 * 3600) + 0.3) : 0;
- $avatar = htmlspecialchars(substr($user[0]['avatar'], 0, strpos($user[0]['avatar'] . '&', '&')));
- $url = htmlspecialchars(substr($user[0]['url'], 0, strpos($user[0]['url'] . '&', '&')));
- $this->username = $user[0]['username'];
- $this->password = $user[0]['password'];
- $this->enabled = $user[0]['enabled'];
- $this->k = $user[0]['k'];
- $this->k2 = $user[0]['k2'];
- $this->k3 = $user[0]['k3'];
- $this->PowerO = $user[0]['dO'];
- $this->powers = $user[0]['powers'];
- $this->avatar = $avatar;
- $this->url = $url;
- $this->d1 = 0;
- $this->d2 = $user[0]['d2'];
- $this->bride = $user[0]['bride'];
- $this->d3 = null;
- $this->pawn = $user[0]['pawn'] == 'off' ? '' : $user[0]['pawn'];
- if ($this->mobile)
- {
- $this->nickname = $this->username == '' ? 'Unregistered' : $this->username;
- }
- else
- { //$this->mobile
- $this->nickname = explode("##", $user[0]['nickname'], 2);
- $this->nickname[0] = htmlspecialchars_decode($this->nickname[0]);
- $this->nickname = count($this->nickname) > 1 ? implode("##", $this->nickname) : $this->nickname[0];
- }
- if (true || $user[0]['torched'] != 1)
- { // Torching - Add Later
- if (!$this->getPowers())
- {
- return false;
- }
- $this->dO = $user[0]['dO'];
- }
- $this->dt = null;
- $this->guest = false;
- }
- $trolls = json_decode($user[0]['trolls'], true);
- if (is_array($trolls))
- {
- foreach ($trolls as $i => $u)
- {
- $this->{$i} = $u;
- }
- }
- }
- if ($this->guest === true)
- {
- $this->username = '';
- }
- return true;
- }
- public function getPowers($pV = array())
- {
- if ($this->days < 1)
- {
- for ($i = 0;$i <= $this->parent->config->pcount;$this->{'p' . $i++} = 0);
- return true;
- }
- $powers = $this->parent->mysql->fetch_array('select `powers` from `users` where `id`=' . $this->id . ';');
- $powers = isset($powers[0]['powers']) ? $this->parent->PowDecode($powers[0]['powers']) : [];
- $powerv = $this->parent->mysql->fetch_array('select `id`, `section`, `subid` from `powers` where `name` not like \'%(Undefined)%\';');
- $pv = $test = $final = array();
- foreach ($powerv as $power)
- {
- $pv[$power['id']] = array('sect' => $power['section'], 'sub' => (int)$power['subid']);
- $test[$power['section']] = 0;
- $last[$power['section']] = 0;
- }
- foreach ($powers as $powerid => $count)
- {
- if (isset($test[$pv[$powerid]['sect']]))
- {
- $test[$pv[$powerid]['sect']] += $pv[$powerid]['sub'];
- }
- }
- foreach ($test as $sect => $val)
- {
- if (isset($this->{$sect . 'v'}) && (int)$val != (int)$this->{$sect . 'v'})
- {
- return false;
- }
- }
- foreach ($powers as $powerid => $count)
- {
- if (isset($pv[$powerid]))
- {
- $power = $pv[$powerid];
- if ((int)$this->{$power['sect'] . 'v'} & $test[$power['sect']])
- {
- if (!((int)$power['sub'] & $test[$power['sect']]))
- {
- return false;
- }
- if (!($this->{'m' . substr($power['sect'], 1) } & (int)$power['sub']))
- {
- $last[$power['sect']] += (int)$power['sub'];
- }
- }
- }
- }
- $this->pStr = '';
- foreach ($test as $sect => $u)
- {
- $this->{$sect} = $last[$sect];
- $this->pStr .= $sect . '="' . $this->{$sect} . '" ';
- }
- return true;
- }
- public function updateDetails()
- {
- $upowers = $this->parent->mysql->fetch_array('select `powers` from `users` where `id`=' . $this->id . ';');
- $upowers = isset($upowers[0]['powers']) ? $this->parent->PowDecode($upowers[0]['powers']) : [];
- $spowers = $this->parent->mysql->fetch_array('select * from `powers` where `name` not like \'%(Undefined)%\';');
- $vals = array();
- $p = array();
- $powerO = '';
- foreach ($spowers as $power)
- {
- $vals[$power['id']] = array($power['section'], $power['subid']);
- $p[$power['section']] = 0;
- }
- foreach ($upowers as $powerid => $count)
- {
- if ($count >= 1 && isset($vals[$powerid]) && isset($p[$vals[$powerid][0]]))
- {
- $str = $powerid . '=' . ($count > 1 ? ($count - 1) : 1) . '|';
- $p[$vals[$powerid][0]] += $vals[$powerid][1];
- if ($count > 1)
- {
- $powerO .= $str;
- }
- }
- }
- if ($this->id != 0 && $this->id != 2 && $this->mobile == false)
- {
- $this->parent->mysql->query("update `users` set `nickname`='{$this->parent->mysql->sanatize($this->nickname) }', `avatar`='{$this->parent->mysql->sanatize($this->avatar) }', `url`='{$this->parent->mysql->sanatize($this->url) }', `dO`='{$this->parent->mysql->sanatize($powerO) }', `connectedlast`='{$this->ipaddr}' where `id`='{$this->parent->mysql->sanatize($this->id) }';");
- }
- return ($this->id != 0 && $this->id != 2) ? true : false;
- }
- public function hasPower($power)
- {
- list($subid, $section) = array(pow(2, $power % 32), $power >> 5);
- return isset($this->{'p' . $section}) && $this->{'p' . $section} & $subid ? true : false;;
- }
- public function authenticate($packet)
- {
- $attributes = array('u', 'N', 'k', 'pool', 'f', 'f2', 'l5', 'l3', 'l4', 'l2', 'h', 'd0', 'a', 'c', 'banned', 'r', 'i', 'p', 'v', 'rank');
- for ($i = 0;$i <= $this->parent->config->pcount;$i++)
- {
- array_push($attributes, 'd' . ($i + 4));
- array_push($attributes, 'm' . $i);
- }
- $info = $this->getMultiAttr($packet, $attributes);
- for ($i = 0;$i <= $this->parent->config->pcount;$i++)
- {
- $this->{'p' . $i . 'v'} = (int)$info['d' . ($i + 4) ];
- $this->{'m' . $i} = (int)$info['m' . $i];
- }
- /* End */
- $this->id = (string)$info['u'];
- $this->d0 = (integer)$info['d0'];
- $this->f = (integer)$info['f'];
- $this->f = (integer)$info['f2'];
- $this->v = (integer)$info['v'];
- $this->L5 = (integer)$info['l5'];
- $n = (string)$info['N'];
- $k = (integer)$info['k'];
- $pool = $this->pool;
- if ($this->mobile && !($this->f & 0x0200))
- {
- $this->f |= 0x0200;
- }
- $this->b = $this->f & 8 ? true : false;
- $chat = (int)$info['c'];
- if ($this->days < 1)
- {
- for ($i = 0;$i <= $this->parent->config->pcount;$i++)
- {
- $this->pStr .= 'p' . $i . '="0" ';
- }
- }
- else
- {
- for ($i = 0;$i <= $this->parent->config->pcount;$i++)
- {
- $this->{'p' . $i . 'v'} = isset($info['d' . ($i + 4) ]) ? $info['d' . ($i + 4) ] : 0;
- $this->{'m' . $i} = isset($info['m' . $i]) ? $info['m' . $i] : 0;
- $this->pStr .= 'p' . $i . '="' . $this->{'p' . $i . 'v'} . '" ';
- }
- }
- /* End */
- /* Reset details, Check powers */
- if (!$this->resetDetails($this->id))
- {
- return false;
- }
- $this->url = (string)$info['h'];
- $this->avatar = (string)$info['a'];
- $xInfo = $this->parent->mysql->fetch_Array("select * from `chats` where `id`='{$this->parent->mysql->sanatize($chat) }';");
- if ($xInfo[0]['botid'] == $info['u'])
- {
- $this->f |= 0x2000;
- }
- $l5 = $this->getL5($this->loginKey, "100_100_5_100");
- print $l5;
- #if($this->L5 != $l5){
- #return false;
- #}
- if ($info['r'] !== false)
- {
- $this->chatPass = $info['r'];
- }
- /* Sanatize Name / Explode Status */
- $this->nickname = $this->getAttribute($packet, 'n');
- $this->nickname = explode('##', $this->nickname, 2);
- if (count($this->nickname) > 1)
- {
- $this->nickname[1] = htmlspecialchars(str_replace("", "", $this->nickname[1]));
- $this->nickname = implode('##', $this->nickname);
- }
- else
- {
- $this->nickname = $this->nickname[0];
- }
- if (strlen($this->nickname) > 255)
- {
- //return false;
- }
- /* End */
- /* Just some information checking for guest system, + user exists */
- if ($this->guest == true && isset($this->enabled) && $this->id != 2)
- {
- return false;
- }
- elseif ($this->id != 2 && is_numeric($k))
- {
- $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`!='';");
- $cyan = $this->parent->mysql->fetch_array("select * from `cyan` where `userid`='{$this->parent->mysql->sanatize($this->id) }';");
- if ($cyan)
- {
- if (time() > $cyan[0]['endtime'])
- {
- $this->parent->mysql->query("update `users` set `d0`='0' `id`='" . $this->id . "';");
- }
- }
- if (empty($user))
- {
- return false;
- }
- elseif ($user[0]['username'] == 'Unregistered')
- {
- $this->guest = true;
- }
- else
- {
- $this->guest = false;
- }
- }
- else
- {
- $this->guest = true;
- }
- $this->updateDetails();
- $this->authenticated = true;
- $banned = $this->parent->mysql->fetch_array("select * from `bans` where `chatid`='{$chat}' and `type`='';");
- $banned_id = (isset($banned[0]['userid'])) ? (int)$banned[0]['userid'] : 0;
- //join new pools fixed by devil for aspixat
- $cpool = floor($xInfo[0]['users'] / 30); // 30 in 1 pool
- $npool = $cpool != 0 ? $cpool + 2 : 0;
- $pool = $npool;
- if ($this->id == $banned_id)
- {
- return $this->joinRoom($chat, 1, false, 2);
- }
- else
- {
- #return $this->joinRoom($chat, 1, false, $pool);
- return $this->joinRoom($chat, false, true, $pool);
- }
- }
- public function getAttribute($xml, $name)
- {
- foreach ($xml as $a => $b)
- {
- if ($a == $name) return (string)$b;
- }
- return false;
- }
- public function getMultiAttr($xml, $names = array(), $values = array())
- {
- setType($names, 'array');
- foreach ($names as $u)
- {
- $values[$u] = false;
- }
- foreach ($xml as $i => $u)
- {
- if (in_array($i, $names))
- {
- $values[$i] = mb_convert_encoding((string)$u, "utf-8");
- }
- }
- return $values;
- }
- public function message($t, $ex = true)
- {
- $this->sendMessage($t, $this->id, 0, false, $ex);
- }
- public function sendMessage($t, $u = '[C]', $i = 0, $s = false, $ex = false)
- {
- if ($u == '[C]') $u = $this->id;
- $packet = "<m t=\"{$t}\" u=\"{$u}\" i=\"{$i}\" />";
- $ex != false ? $this->sendRoom($packet, $ex) : $this->sendPacket($packet);
- }
- public function write($tag, $data)
- {
- $packet = "<" . $tag;
- if (!empty($data) && is_array($data))
- {
- foreach ($data as $k => $v)
- {
- $packet .= " " . $k . "=\"" . $v . "\"";
- }
- }
- $packet .= " />";
- if ($packet{strlen($packet) - 1} != chr(0)) $packet .= chr(0);
- print_r($data);
- socket_write($this->sock, $packet);
- }
- public function createPacket($type, $values)
- {
- $xml = Array();
- Foreach ($values AS $n => $v)
- {
- If ($v !== False) $xml[] = "{$n}=\"{$this->parent->mysql->sanatize($v) }\"";
- }
- $return = "<{$type} " . implode(chr(32), $xml) . " />";
- print_r($return);
- return $return;
- }
- public function sendPacket($packet)
- {
- if ($this->sock)
- {
- if ($this->mobile == true)
- {
- $packet = simplexml_load_string($packet);
- if (!method_exists($packet, 'getName'))
- {
- $this->parent->disconnect($this->sock);
- return false;
- }
- $json = new stdClass();
- $json->tag = $packet->getName();
- foreach ($packet->Attributes() as $i => $u)
- {
- $json->{$i} = (string)$u;
- }
- $packet = json_encode($json);
- $packet = $this->parent->mask($packet);
- }
- elseif (substr($packet, -1) != chr(0))
- {
- $packet .= chr(0);
- }
- if (!@socket_write($this->sock, $packet, strlen($packet)))
- {
- $this->parent->disconnect($this->sock);
- return false;
- }
- return true;
- }
- }
- public function sendAll($packet)
- {
- if (stristr($packet, strlen($packet) - 1, 1) != chr(0))
- {
- $packet = $packet . chr(0);
- }
- foreach ($this->parent->users as & $user)
- {
- if (!@socket_write($user->sock, $packet, strlen($packet)))
- {
- $this->parent->disconnect($user->index);
- }
- }
- return true;
- }
- public function parseRank($rank)
- {
- $ranks = array(1, 2, 3, 4, 5);
- if (!is_numeric($rank))
- {
- switch (strtolower($rank))
- {
- case 'guest':
- return 5;
- case 'owner':
- return 4;
- case 'member':
- return 3;
- case 'moderator':
- return 2;
- case 'mainowner':
- return 1;
- default:
- return 0;
- }
- }
- elseif (!in_array($rank, $ranks))
- {
- return 0;
- }
- return $rank;
- }
- public function rank($numrank, $word = null, $compare = null)
- { // Made this for the hell of it
- $ranks = array(5 => array(5, 'guest'), 3 => array(4, 'member'), 2 => array(3, 'moderator'), 4 => array(2, 'owner'), 1 => array(1, 'mainOwner'));
- if (!in_array($numrank, $ranks))
- {
- $rank = $ranks[5];
- }
- else
- {
- $rank = $ranks[$numrank];
- }
- return is_null($compare) ? (is_null($word) ? $rank[0] : $rank[1]) : ($rank[0] < $ranks[$compare][0] ? true : false);
- }
- public function __destruct()
- {
- if ($this->hasPower(172))
- {
- $this->sendRoom('<m t="/RTypeOff" u="' . $this->id . '" />');
- }
- if (isset($this->id) && !isset($this->noLogout))
- {
- $this->sendRoom('<l u="' . $this->id . '" />', true);
- }
- }
- public function getL5($i, $p)
- {
- $l5_info = explode('_', $p);
- $p_w = $l5_info[0];
- $p_h = $l5_info[1];
- $p_octaves = $l5_info[2];
- $p_seed = $l5_info[3];
- $t1 = $p_w * $p_h;
- $t = $i % $t1;
- $p_x = $t % $p_w;
- $p_y = floor($t / $p_w) + 1;
- $file = fopen("100_100_5_" . $p_seed . ".txt", "r");
- $contents = '';
- $contents = fread($file, filesize($p . ".txt"));
- explode('\n', $contents);
- fclose($file);
- $value = explode(":", $contents);
- $ifp = "" . $p_x . "," . $p_y . "";
- $split = str_replace(',', '', $ifp);
- return $value[$split];
- print $value[$split];
- }
- public function joinRoom($chat, $reload = true, $nodup = false, $pool = 0, $noi = false, $norel = false)
- {
- /* Initial Information */
- list($this->pool, $this->hidden) = array($pool, false);
- if (!$this->authenticated || !is_numeric($chat) || $chat < 1)
- {
- return false;
- }
- $chat = $this->parent->mysql->fetch_array("select * from `chats` where `id`='{$this->parent->mysql->sanatize($chat) }';");
- if (empty($chat))
- {
- return false;
- }
- list($this->chatid, $this->group) = array($chat[0]['id'], $chat[0]['name']);
- $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;");
- if ($this->id == isset($badge[0]['id']))
- {
- $this->f |= 262144;
- }
- /* Do Ranks */
- $ranks = $this->parent->mysql->fetch_array("select * from `ranks` where `chatid`='{$chat[0]['id']}' and `userid`='{$this->parent->mysql->sanatize($this->id) }';");
- if ($this->chatPass !== false)
- {
- if ($this->parent->mysql->validate($this->chatPass, $chat[0]['pass']) === true)
- {
- if (empty($ranks))
- {
- $this->parent->mysql->query("insert into `ranks`(`userid`, `chatid`, `f`) values({$this->id}, {$this->chatid}, 1);");
- }
- else
- {
- $this->parent->mysql->query("update `ranks` set `f`=1 where `userid`={$this->id} and `chatid`={$this->chatid};");
- }
- $ranks[0] = array('userid' => $this->id, 'chatid' => $this->chatid, 'f' => 1, 'tempend' => 0);
- }
- }
- if (!isset($ranks[0]['f']))
- {
- $ranks[0] = array('f' => 5);
- $this->parent->mysql->query("insert into `ranks` (`userid`, `chatid`, `f`) values ('{$this->parent->mysql->sanatize($this->id) }', '{$chat[0]['id']}', '5');");
- }
- elseif ($ranks[0]['tempend'] > 0 && $ranks[0]['tempend'] < time())
- {
- $ranks[0] = array("f" => 3);
- $this->parent->mysql->query("update `ranks` set `f`=3, `tempend`=0 where `userid`={$this->id} and `chatid`={$this->chatid};");
- }
- else
- {
- $userRank = $ranks[0]['f'];
- $this->rExpire = $ranks[0]['tempend'] > time() ? $ranks[0]['tempend'] : 0;
- }
- $this->rank = $ranks[0]['f'];
- if ($this->hasPower(29) && !$this->online && in_array($this->rank & 7, array(1, 4)))
- {
- $this->hidden = true;
- if (!($this->f & 0x0400))
- {
- $this->f += 0x0400;
- }
- }
- elseif ($this->f & 0x0400)
- {
- $this->f -= 0x0400;
- $this->nulleGp = true;
- }
- $this->updateDetails();
- $this->resetDetails($this->id, true);
- /* End */
- /* Update / Check Bans */
- $game = '';
- $this->banned = 0;
- $this->unban = false;
- $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;");
- if (!empty($ban) && ($this->id == $ban[0]['userid'] || $this->ipaddr == $ban[0]['ip']))
- {
- $ban = $ban[0];
- $date = time();
- if ($ban['unbandate'] >= $this->loginTime)
- {
- $banflag = (int)substr($ban['type'], 1);
- switch (substr($ban['type'], 0, 1))
- {
- case 'w':
- $game = " w=\"{$banflag}\"";
- break;
- case 'r':
- $this->rank |= $banflag;
- break;
- case 'f':
- $this->f |= $banflag;
- break;
- default:
- $this->rank = 16;
- }
- if (!($this->f & 0x8000))
- { // desban do dunced
- $this->banned = $ban['unbandate'];
- }
- if ($this->f & 256)
- { // desban do dunced
- $this->sendPacket($this->createPacket("c", array("u" => $this->id, "t" => "/p,{$ban['unbandate']}")));
- }
- else
- {
- $this->sendPacket($this->createPacket("c", array("u" => $this->id, "t" => "/p")));
- }
- }
- elseif ($this->id == $ban['userid'])
- {
- $this->unban = true;
- $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};");
- }
- }
- elseif (empty($ban) && $this->b == true)
- {
- $this->unban = true;
- }
- elseif (isset($ban['unbandate']))
- {
- $this->sendPacket("<n t=\"You are banned for " . round(($ban['unbandate'] - time()) / 60, 1) . " more minutes.\" />");
- }
- /* End */
- /* Chat Information */
- if (empty($chat[0]['attached']))
- {
- $chat[0]['attached'] = array('Ajuda', '9');
- }
- else
- {
- $info = $this->parent->mysql->fetch_array("select * from `chats` where `name`='{$this->parent->mysql->sanatize($chat[0]['attached']) }';");
- if (empty($info) || $info[0]['id'] == $chat[0]['id'])
- {
- $chat[0]['attached'] = array('Ajuda', '9');
- }
- else
- {
- $chat[0]['attached'] = array(0 => $info[0]['name'], 1 => $info[0]['id']);
- $this->f |= 2;
- }
- }
- if ($chat[0]['attached'][1] == $this->chatid)
- {
- $chat[0]['attached'] = array('0', '0');
- }
- if ($chat[0]['NoSmilie'] == 1)
- { // Funçoes de OPÇOES EXTRA
- $this->f |= 0x0800;
- }
- if ($chat[0]['DefNoSound'] == 1)
- {
- $this->f |= 131072;
- }
- if ($chat[0]['MembersOnly'] == 1)
- {
- $this->f |= 128;
- }
- if ($chat[0]['MembersOnly2'] == 1)
- {
- $this->f |= 0x100000;
- }
- if ($chat[0]['Live'] == 1)
- {
- $this->f |= 0x200000;
- }
- if ($chat[0]['NoList'] == 1)
- {
- $this->f |= 0x0200;
- }
- if ($chat[0]['NoStore'] == 1)
- {
- $this->parent->mysql->query("update `messages` set `visible`=0 where `id`='{$this->chatid}';");
- }
- if ($this->unban == true)
- {
- $this->sendPacket('<c u="0" d="' . $this->id . '" t="/u" />');
- $this->unban = true;
- }
- if ($this->days >= 1)
- {
- $this->v |= 0x03;
- }
- else
- {
- $this->v |= 0x01;
- }
- if ($this->haspower(0))
- {
- $this->v |= 0x04;
- }
- $this->sendPacket($this->buildGp());
- if ($noi == false)
- {
- $this->sendPacket($this->buildGp());
- $lang = strlen($chat[0]['lang']) >= 1 ? $chat[0]['lang'] : '';
- $b = "{$chat[0]['bg']};={$chat[0]['attached'][0]};={$chat[0]['attached'][1]};={$lang};={$chat[0]['radio']};={$chat[0]['button']}";
- $this->sendPacket($this->createPacket("i{$game}", array("b" => $b, "f" => $this->f, "f2" => $this->f, "v" => $this->v, "B" => 150, "r" => $this->rank, "cb" => $this->loginTime)));
- $this->sendPacket($this->buildGp());
- }
- $this->sendPacket($this->buildGp());
- if ($this->isAssigned($this->group, 114) && $this->isAssigned($this->group, 126))
- {
- $this->sendPacket($this->createPacket("w", array("v" => "{$pool} 0 2 1")));
- }
- elseif ($this->isAssigned($this->group, 114) && !$this->isAssigned($this->group, 126))
- {
- $this->sendPacket($this->createPacket("w", array("v" => "{$pool} 0 2")));
- }
- if ($nodup == false)
- {
- while ($r = $this->parent->getUserByID((int)$this->id, (int)$chat[0]['id']))
- {
- if (is_object($r) && $r->online === true)
- {
- $r->sendPacket("<dup />");
- $r->noLogout = true;
- $this->parent->disconnect($r->index, true);
- }
- }
- }
- /* Compile, and send user list */
- $this->chat = $chat[0]['id'];
- $myNick = explode("##", $this->nickname, 2);
- $myNick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($myNick[0])));
- $myNick = count($myNick) > 1 ? implode("##", $myNick) : $myNick[0];
- $myPack = "<u{$game} f=\"{$this->f}\" f2=\"{$this->f}\" flag=\"{$this->f}\" so=\"1\" 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=\"{$this->v}\" />";
- foreach ($this->parent->users as $user)
- {
- if ($this->mobile == true && $user->mobile == true && $user->ipaddr == $this->ipaddr && $user->username != $this->username)
- {
- $this->parent->disconnect($user->index);
- }
- if ($user->chat == $chat[0]['id'] && $user->id != $this->id && $user->pool == $this->pool)
- {
- if (!in_array($user->id, array(0, 2)) && $user->hidden == false)
- {
- $user->bride = $user->d2 == 0 ? null : $user->d2;
- $nick = explode('##', $user->nickname, 2);
- $nick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($nick[0])));
- $nick = count($nick) > 1 ? implode('##', $nick) : $nick[0];
- $packet = "<u{$game} flag=\"{$user->f}\" f2=\"{$this->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=\"{$this->v}\" />";
- var_dump($packet);
- $valid = simplexml_load_string($packet);
- if (method_exists($valid, 'getName'))
- {
- $this->sendPacket($packet);
- }
- else
- {
- $this->parent->disconnect($user->index);
- continue;
- }
- }
- if (!in_array($this->id, array(0, 2)) && $this->hidden == false)
- {
- var_dump($myPack);
- $user->sendPacket($myPack);
- }
- }
- }
- /* End */
- /* Send Previous Messages (15) */
- if ($reload == true)
- {
- $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;");
- for ($i = 0;$i < count($messages);$i++)
- {
- $message = $messages[count($messages) - $i - 1];
- if (isset($this->parent->protected[$user->chat]['type']) && $this->parent->protected[$user->chat]['type'] == 'raid' && $this->rank == 5)
- {
- break;
- }
- if ($message['visible'] == '1')
- {
- $user_message = $this->parent->mysql->fetch_array("select `days` from `users` where `id`='{$message['uid']}';");
- $days = floor(($user_message[0]['days'] - time()) / (24 * 3600) + 0.3);
- $days = $days >= 1 ? $days : 0;
- if ($user->id != $chat[0]['botid'])
- {
- $this->sendPacket("<m u=\"{$message['uid']}\" n=\"{$message['name']}\" " . ($days >= 1 ? ' q="3"' : ' q="1"') . ($message['registered'] == '' ? '' : " N=\"{$message['registered']}\"") . " a=\"{$message['avatar']}\" i=\"{$message['mid']}\" t=\"{$message['message']}\" s=\"1\" />");
- }
- }
- }
- unset($messages);
- unset($message);
- }
- /* End */
- $this->sendPacket("<done />");
- /* Other info, scrollies, protection meh */
- if ($this->isAssigned($this->group, 488))
- {
- switch ($this->rank)
- {
- case 2:
- $this->sendPacket("<m u=\"{$chat[0]['ch']}\" t=\"/sYou is moderator\" />");
- break;
- case 3:
- $this->sendPacket("<m u=\"{$chat[0]['ch']}\" t=\"/sYou is member\" />");
- break;
- case 4:
- $this->sendPacket("<m u=\"{$chat[0]['ch']}\" t=\"/sYou is Owner\" />");
- break;
- case 5:
- $this->sendPacket("<m u=\"{$chat[0]['ch']}\" t=\"/sYou is Guest\" />");
- break;
- default:
- $this->sendPacket("<m u=\"{$chat[0]['ch']}\" t=\"/s{$chat[0]['sc']}\" />");
- }
- }
- else
- {
- $this->sendPacket("<m u=\"{$chat[0]['ch']}\" t=\"/s{$chat[0]['sc']}\" />");
- }
- if (isset($this->parent->protected[$this->chat]))
- {
- $time = floor(($this->parent->protected[$this->chat]['end'] - time()) / 60);
- switch ($this->parent->protected[$this->chat]['type'])
- {
- case 'noguest':
- $this->sendPacket("<z d=\"0\" u=\"0\" t=\"This chat is protected for another {$time} minutes. Guests cannot chat until given a higher rank.\" />");
- break;
- case 'unreg':
- $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.\" />");
- break;
- case 'raid':
- $this->sendPacket("<z d=\"0\" u=\"0\" t=\"Chat in protect Raid mode For {$time} minutes.\" />");
- break;
- }
- }
- elseif ($this->f & 1 && 1 == 2)
- {
- $this->sendPacket("<logout e=\"E12\" />");
- }
- if (isset($this->parent->protected[$user->chat]['type']) && $this->parent->protected[$user->chat]['type'] == 'raid' && $this->rank == 5)
- {
- $this->sendPacket("<logout e=\"E38\" />");
- }
- $check = $this->parent->mysql->fetch_array("select xfrom,xmessage from `offline_messages` where `xto`='{$this->id}' and `unread`='1' limit 0,5;");
- if (!empty($check))
- {
- foreach ($check as $c)
- {
- $this->sendPacket("<z u=\"" . $c["xfrom"] . "\" t=\"" . $c["xmessage"] . "\" s=\"2\" d=\"" . $this->id . "\" />");
- }
- $this->parent->mysql->query("update `offline_messages` set `unread`='0' where `xto`='{$this->id}';");
- }
- $this->online = true;
- /* End */
- return true;
- }
- public function isAssigned($group, $p)
- {
- $assigned = $this->parent->mysql->fetch_array("select * from `group_powers` where `group`='{$group}' and `power`='{$p}' and `enabled`='1';");
- empty($assigned) ? $a = false : $a = true;
- return $a;
- }
- public function flixs($p, $group, $data)
- {
- $power = $this->parent->mysql->fetch_array("select * from `group_powers` where `group`='{$group}' and `power`='{$p}';");
- $data = json_decode($data, true);
- $data['v'] = $power[0]['count'];
- $data = str_replace('"', "'", json_encode($data));
- empty($data) ? $gp = '' : $gp = "g{$p}=\"{$data}\" ";
- return $gp;
- }
- public function buildGp(){
- $gdata = $this->parent->mysql->fetch_array("SELECT * FROM `chats` WHERE `name`='" . $this->group . "';");
- $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';");
- $section = array();
- foreach($group_powers as $gp){ @$section[$gp['section']] |= $gp['subid']; }
- for($i=0; $i<14; $i++){ ${'p'.$i} = isset($section['p'.$i]) ? $section['p'.$i] : 0; }
- $p = array($p0, $p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8, $p9, $p10, $p11, $p12, $p13);
- $gpp = implode('|', $p);
- $gp = "<gp ";
- $gp .= "p=\"{$gpp}\" ";
- if($this->isAssigned($this->group, 74) && !empty($gdata[0]['gline'])){$gp .= "g74=\"{$gdata[0]['gline']}\" ";}
- if($this->isAssigned($this->group, 80) && !empty($gdata[0]['gcontrol'])){$gp .= "g80='{$gdata[0]['gcontrol']}' "; }
- if($this->isAssigned($this->group, 90) && !empty($gdata[0]['bad'])){$gp .= "g90=\"{$gdata[0]['bad']}\" ";}
- if($this->isAssigned($this->group, 92) && !empty($gdata[0]['horrorflix'])){$gp .= $this->flixs(92, $this->group, $gdata[0]['horrorflix']);}
- if($this->isAssigned($this->group, 96) && !empty($gdata[0]['winterflix'])){$gp .= $this->flixs(96, $this->group, $gdata[0]['winterflix']);}
- if($this->isAssigned($this->group, 98) && !empty($gdata[0]['feastflix'])){$gp .= $this->flixs(98, $this->group, $gdata[0]['feastflix']);}
- if($this->isAssigned($this->group, 100) && !empty($gdata[0]['link'])){$gp .= "g100=\"{$gdata[0]['link']}\" ";}
- if($this->isAssigned($this->group, 102) && !empty($gdata[0]['fairyflix'])){$gp .= $this->flixs(102, $this->group, $gdata[0]['fairyflix']);}
- if($this->isAssigned($this->group, 108) && !empty($gdata[0]['loveflix'])){$gp .= $this->flixs(108, $this->group, $gdata[0]['loveflix']);}
- if($this->isAssigned($this->group, 112) && !empty($gdata[0]['announce'])){$gp .= "g112=\"{$gdata[0]['announce']}\" ";}
- if($this->isAssigned($this->group, 114) && !empty($gdata[0]['pools'])){$gp .= "g114='{$gdata[0]['pools']}' "; }
- if($this->isAssigned($this->group, 130) || $this->isAssigned($this->group, 106)){
- if($this->isAssigned($this->group, 106) && substr($gdata[0]['gback'], 0, 1) == '#' && strlen(substr($gdata[0]['gback'], 1)) == 6){
- $gback = substr($gdata[0]['gback'], 1).'#';
- $gp .= "g106=\"{$gback}\" ";
- }
- elseif($this->isAssigned($this->group, 106) && substr($gdata[0]['gback'], 6, 1) == '#' && strlen(substr($gdata[0]['gback'], 0, 6)) == 6){
- $gp .= "g106=\"{$gdata[0]['gback']}\" ";
- }
- elseif($this->isAssigned($this->group, 130) && $this->isAssigned($this->group, 106) && substr($gdata[0]['gback'], 0, 1) != '#' && substr($gdata[0]['gback'], 6, 1) == '#'){
- $gp .= "g106\"{$gdata[0]['gback']}\" ";
- }
- elseif($this->isAssigned($this->group, 130) && substr($gdata[0]['gback'], 0, 1) != '#'){
- $gp .= "g130='{$gdata[0]['gback']}' ";
- }
- }
- if($this->isAssigned($this->group, 148) && !empty($gdata[0]['spookyflix'])){$gp .= $this->flixs(148, $this->group, $gdata[0]['spookyflix']);}
- if($this->isAssigned($this->group, 156) && !empty($gdata[0]['santaflix'])){$gp .= $this->flixs(156, $this->group, $gdata[0]['santaflix']);}
- if($this->isAssigned($this->group, 180) && !empty($gdata[0]['gsound'])){$gp .= "g180='{$gdata[0]['gsound']}' "; }
- if($this->isAssigned($this->group, 206) && !empty($gdata[0]['customlang'])){$gp .= "g206='{$gdata[0]['customlang']}' "; }
- if($this->isAssigned($this->group, 246)){$gp .= "g246=\"{'dt':70,'v':1}\" ";}
- if($this->isAssigned($this->group, 150) && !empty($gdata[0]['botid'])){$gp .= "g150='{$gdata[0]['botid']}' ";}
- if($this->isAssigned($this->group, 252) && !empty($gdata[0]['redirect'])){$gp .= "g252='{$gdata[0]['redirect']}' ";}
- if($this->isAssigned($this->group, 256)){$gp .= "g256=\"{'rnk':'2','dt':65,'rt':15,'rc':'1','tg':200,'v':1}\" ";}
- if($this->isAssigned($this->group, 278) && !empty($gdata[0]['springflix'])){$gp .= $this->flixs(278, $this->group, $gdata[0]['springflix']);}
- if($this->isAssigned($this->group, 297) && !empty($gdata[0]['summerflix'])){$gp .= $this->flixs(297, $this->group, $gdata[0]['summerflix']);}
- $gp .= "/>";
- var_dump($gp);
- return $gp;
- }
- public function sendRoom($packet, $passme = false, $exclude = 0) {
- foreach ($this->parent->users as $user) {
- if (
- $user->chat == $this->chat &&
- $user->id != $exclude &&
- (
- isset($user->pool) &&
- isset($this->pool) &&
- $user->pool == $this->pool
- )
- ) {
- if ($user->id != $this->id || $passme == false) {
- $user->sendPacket($packet);
- }
- }
- }
- }
- public function noToRank($rank)
- {
- if ($rank >= 14)
- {
- return 'o';
- };
- if ($rank >= 10)
- {
- return 'M';
- };
- if ($rank >= 7)
- {
- return 'm';
- };
- if ($rank >= 3)
- {
- return 'e';
- };
- return 'r';
- }
- public function getDays($days)
- {
- return floor(($days - time()) / (24 * 3600) + 0.3) >= 1 ? floor(($days - time()) / (24 * 3600) + 0.3) : 0;
- }
- }
- class database
- {
- public $link, $host, $user, $pass, $name, $pdo;
- public $doe = true;
- public function __construct($host = null, $user = null, $pass = null, $name = null)
- {
- if ($name != null)
- {
- $this->host = $host;
- $this->user = $user;
- $this->pass = $pass;
- $this->name = $name;
- }
- if (!$this->connected())
- {
- $this->link = @mysqli_connect($this->host, $this->user, $this->pass, $this->name);
- $this->pdo = new PDO("mysql:host={$this->host};dbname={$this->name}", "{$this->user}", "{$this->pass}");
- if (!$this->connected())
- {
- $this->error("Failed to connect to `{$this->host}`.`{$this->name}` using password [" . (empty($this->pass) ? "NO" : 'YES') . "]");
- }
- }
- return true; // Cause I can put it there if I want to
- }
- public function connected()
- {
- return @mysqli_ping($this->link) ? true : false;
- }
- public function error($error)
- {
- print $error . chr(10);
- if ($this->doe == true)
- {
- exit('line:' . __LINE__);
- }
- }
- public function query($query = "")
- {
- if (!is_string($query))
- {
- return false;
- }
- $this->__construct();
- $return = $this->pdo->prepare($query);
- $return->execute();
- #$return = mysqli_query($this->link, $query);
- return $return ? $return : false;
- }
- public function fetch_array($query, $return = array())
- {
- $this->__construct();
- if (!is_string($query) || !($res = $this->query($query)))
- {
- return array();
- }
- while ($data = $res->fetch(\PDO::FETCH_ASSOC))
- {
- $return[] = $data;
- }
- return !empty($return) ? $return : array();
- }
- public function sanatize($data)
- {
- if (is_array($data))
- {
- return array_map(array($this, 'sanatize'), $data);
- }
- if (function_exists("mb_convert_encoding"))
- {
- $data = mb_convert_encoding($data, "UTF-8", 'auto');
- }
- return $this->link->real_escape_string($data);
- }
- public function rand($length = 32, $low = true, $upp = true, $num = true, $indent = false)
- {
- $chars = array_merge($low ? range('a', 'z') : array(), $upp ? range('A', 'Z') : array(), $num ? range('0', '9') : array());
- for ($rand = "";strlen($rand) < $length;$rand .= $chars[array_rand($chars) ]);
- if ($indent != false)
- {
- $rand = implode('-', str_split($rand, $indent));
- }
- return $rand;
- }
- static function urs($x, $y)
- {
- return ($x >> $y) & (2147483647 >> ($y - 1));
- }
- public function hash($str, $rawsalt = '', $hash = 'sha512')
- {
- if ($rawsalt == '')
- {
- $rawsalt = $this->rand(((strlen($str) % 3) + 1) * 5);
- }
- $loc = array(hash('sha1', $rawsalt), hash('sha1', $str), '');
- foreach (str_split($loc[0], 1) as $index => $character)
- {
- $loc[2] .= $character . $loc[1][$index];
- }
- $hash = hash($hash, $loc[2]);
- return substr_replace($hash, $rawsalt, (strlen($str) << 2) % strlen($hash), 0);
- }
- public function validate($str, $hash, $engine = 'sha512')
- {
- $salt = substr($hash, (strlen($str) << 2) % strlen(hash($engine, 1)), ((strlen($str) % 3) + 1) * 5);
- return $this->hash($str, $salt, $engine) === $hash ? true : false;
- }
- public function hashPass($pass, $salt = null, $hashtype = 'sha512', $hash = "")
- {
- return $this->hash($pass, $salt, $hashtype);
- }
- public function checkPass($input, $real, $hash = 'sha512')
- {
- return $this->validate($input, $real, $hash);
- }
- }
Add Comment
Please, Sign In to add comment