Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class parser
- {
- private
- $data = '',
- $pointer = 0;
- public function __construct($data)
- {
- $this->data = $data;
- }
- public function pos()
- {
- return $this->pointer;
- }
- public function size()
- {
- return mb_strlen($this->data);
- }
- public function read($len = 0)
- {
- if ($len == 0)
- {
- $len = $this->size();
- }
- $string = mb_substr($this->data, $this->pointer, $len);
- $this->pointer += $len;
- return $string;
- }
- public function field($type, $len, $chrs = false, $implode = true)
- {
- $data = unpack($type, $this->read($len));
- if ($chrs)
- {
- $data = array_map('chr', $data);
- }
- return $implode ? implode('', $data) : $data;
- }
- /* Parser functions */
- public function parseStr($len = 0)
- {
- if ($len == 0)
- {
- $len = $this->parseUshort();
- if ($len == 0)
- {
- return;
- }
- }
- return $this->field('c*', $len, true);
- }
- public function parseBool()
- {
- return (bool) $this->parseByte();
- }
- public function parseByte()
- {
- return $this->field('C*', 1);
- }
- public function parseBytes($len)
- {
- return $this->field('l*', $len);
- }
- public function parseDouble()
- {
- $data = unpack('d*', strrev($this->read(8)));
- return implode('', $data);
- }
- public function parseFloat()
- {
- $data = unpack('f*', strrev($this->read(4)));
- return implode('', $data);
- }
- public function parseInt()
- {
- return $this->field('l*', 4);
- }
- public function parseShort()
- {
- return $this->field('s*', 2);
- }
- public function parseUint()
- {
- return $this->field('N*', 4);
- }
- public function parseUshort()
- {
- return $this->field('n*', 2);
- }
- /* Dumper functions */
- public function dumpBool()
- {
- return $this->parseByte() ? 'true' : 'false';
- }
- }
- error_reporting(0);
- // Load room list
- $file = new parser(gzuncompress(file_get_contents('http://haxball.com/list3')));
- // Not bothered about these
- $local3 = $file->parseByte();
- $local4 = $file->parseUint();
- $rooms = array();
- while ($file->pos() < $file->size())
- {
- $room = new parser($file->read($file->parseUshort()));
- $ver = $room->parseUshort();
- $id = $room->parseStr();
- $name = $room->parseStr();
- $players = $room->parseByte();
- $max_players = $room->parseByte();
- $password = $room->parseBool();
- $country = $room->parseStr();
- $latitude = $room->parseFloat();
- $longitude = $room->parseFloat();
- $rooms[] = array(
- 'ver' => $ver,
- 'id' => $id,
- 'name' => $name,
- 'players' => $players,
- 'max_players' => $max_players,
- 'password' => $password,
- 'country' => $country,
- 'latitude' => $latitude,
- 'longitude' => $longitude,
- 'distance' => $distance
- );
- }
- //include 'inc/config.php';
- //$dba = new mysqli($config['database']['hostname'], $config['database']['username'], $config['database']['password'], $config['database']['database']);
- $config2['database']['type'] = 'mysql';
- $config2['database']['database'] = 'helloweb4';
- $config2['database']['table_prefix'] = 'mybb_';
- $config2['database']['hostname'] = 'sql.helloweb.home.pl';
- $config2['database']['username'] = 'helloweb4';
- $config2['database']['password'] = '.d9WHC1gQEY';
- $linksb = mysql_connect($config2['database']['hostname'], $config2['database']['username'], $config2['database']['password']);
- mysql_select_db($config2['database']['database'], $linksb);
- $sbrooms = array();
- $hos = array();
- $sqlhos=mysql_query("SELECT `uid`, `usergroup` FROM `mybb_users` WHERE `usergroup` = 20 ORDER BY `uid` DESC");
- while($wynikhos = mysql_fetch_array($sqlhos)) {
- array_push($hos, $wynikhos['uid']);
- }
- $sqlsb=mysql_query("SELECT * FROM `mybb_mysb_shouts` WHERE `shout_msg` LIKE '%http://www.haxball.com/?roomid=%' AND `shout_date` >= (".time()." - 20200) ORDER BY `id` DESC");
- while($wyniksb = mysql_fetch_array($sqlsb)) {
- $uid = $wyniksb['uid'];
- $pattern = '/roomid=[~0-9A-Za-z]*/';
- if(preg_match($pattern, $wyniksb['shout_msg'], $matches)) {
- $roomid = substr($matches[0], -64);
- foreach($rooms as $key=>$val){
- if(preg_match("#$roomid#", $val['id'])){
- foreach($sbrooms as $key2=>$val2){
- if(preg_match("#$roomid#", $val2['id'])){
- $nie = 1;
- }
- }
- if($nie == 0) {
- $sbrooms[] = array(
- 'ver' => $val['ver'],
- 'id' => $val['id'],
- 'name' => $val['name'],
- 'players' => $val['players'],
- 'max_players' => $val['max_players'],
- 'password' => $val['password'],
- 'country' => $val['country'],
- 'latitude' => $val['latitude'],
- 'longitude' => $val['longitude'],
- 'distance' => $val['distance'],
- 'shoutuid' => $wyniksb['uid']
- );
- }
- $nie = 0;
- }
- }
- }
- }
- $roomssb = '<ul class="nav profile-sidenav" id="profile-sidenav" style="width:100%; margin-top:0; text-align: left;">
- <li class="active" style="color: white;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
- background-image: url(../images/ababab.png);margin: 0 0 -1px;
- padding: 8px 14px;
- border: 1px solid #E5E5E5;"><i class="icon-play pull-right" style="margin: 3px 0"></i> Zagraj z nami!</li>';
- foreach($sbrooms as $klucz=>$war) {
- $roomssb .= '<li class="" style="margin: 0 0 -1px;
- padding: 8px 14px;
- border: 1px solid #E5E5E5;"><span class="smalltext">
- ';
- if(in_array($war['shoutuid'], $hos) && (preg_match("#pl-hb#", $war['name']) || preg_match("#PL-HB#", $war['name']))) {
- $roomssb .= '<i class="icon-star pull-right" style="margin: 10px 0px 0 0;" data-rel="tooltip" data-placement="left" title="Oficjalny pokój PL-HB"></i>';
- }
- if($war['password'] == 1) {
- $roomssb .= '<i class="icon-lock pull-right" style="margin: 10px 0px 0 0;" data-rel="tooltip" data-placement="left" title="Pokój chroniony hasłem"></i>
- <div style="margin-top: 3px;float: left;line-height: 15px;"><p class="ellipsis" style="width: 220px;"><a href="http://www.haxball.com/?roomid='.$war['id'].'&pass=1">'.$war['name'].'</a><p>';
- } else {
- $roomssb .= '<div style="margin-top: 3px;float: left;line-height: 15px;"><p class="ellipsis" style="width: 220px;"><a href="http://www.haxball.com/?roomid='.$war['id'].'">'.$war['name'].'</a></p>';
- }
- $roomssb .= '<span style="font-size: 12px;"><span class="muted">Liczba graczy: </span>'.$war['players'].'/'.$war['max_players'].'</span></div><br style="clear:both;"></span></li>
- ';
- }
- if(!$sbrooms) {
- $roomssb .= '<li class="muted" style="margin: 0 0 -1px;
- padding: 8px 14px;
- border: 1px solid #E5E5E5;">
- Teraz nie gramy na żadnym pokoju.
- <i class="icon-info-sign pull-right" style="margin-top:3px; margin-right:-1px;" data-placement="left" data-rel="tooltip" data-original-title="Jeśli chcesz, aby twój pokój pojawił się na tej liście, wyślij na shoutboxie odnośnik do niego. Pąmiętaj, że pokój nie może być ukryty!" data-placement="left"></i>
- </li>
- ';
- }
- $roomssb .= '</ul>';
- // echo'<link href="css/bootstrap.min.css" rel="stylesheet">';
- echo $roomssb;
- if($_GET['hehe']) {
- print_r($sbrooms);
- }
- if($_GET['all']) {
- print_r($rooms);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement