Guest User

Untitled

a guest
Dec 10th, 2018
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.66 KB | None | 0 0
  1. <?PHP
  2.     $main_content .= '<form method="post" action=""><table>';
  3.     if(count($config['site']['worlds']) > 1)
  4.     {
  5.         if(isset($_POST['world']) and is_numeric($_POST['world']))
  6.         {
  7.             $wid = (int) $_POST['world'];
  8.             $wid = '<option value='.$wid.'>'.$config['site']['worlds'][$wid].'</option>';
  9.         }
  10.         $select_w .= '<tr><td>Select World:</td><td><select name="world" onchange="submit()">'.$wid.'';
  11.         $i=1;
  12.         foreach($config['site']['worlds'] as $id => $world_n)
  13.         {
  14.             if($_POST['world'] != $id)
  15.             {
  16.                 $worlds[$i] .= '<option value="'.$id.'">'.$world_n.'</option>';
  17.             }
  18.             if($id == (int) $_POST['world'])
  19.             {
  20.                 $world_id = $id;
  21.                 $world_name = $world_n;
  22.             }
  23.             $i++;
  24.         }
  25.          
  26.         $main_content .= ''.$select_w.'';
  27.         for($i=0;$i <= count($config['site']['worlds']); $i++)
  28.         {
  29.             $main_content .= ''.$worlds[$i].'';
  30.         }
  31.         $main_content .= '</td></tr></select>';
  32.     }
  33.  
  34.     if(!isset($world_id))
  35.     {
  36.         $world_id = 0;
  37.         $world_name = $config['server']['serverName'];
  38.     }
  39.      
  40.     if(count($towns_list) > 1)
  41.     {
  42.         if(isset($_POST['town']) and is_numeric($_POST['town']))
  43.         {
  44.             $pid = (int) $_POST['town'];
  45.             $pid = '<option value='.$pid.'>'.$towns_list[$world_id][$pid].'</option>';
  46.         }
  47.         else
  48.         {
  49.             $pid = '<option value="all">[ALL]</option>';
  50.             $all=true;
  51.         }
  52.         $select .= '<tr><td>Select City:</td><td><select name="town" onchange="submit()">'.$pid.'';
  53.         $i=1;
  54.         foreach($towns_list[$world_id] as $id => $town_n)
  55.         {
  56.             if($_POST['town'] != $id)
  57.             {
  58.                 $towns[$i] .= '<option value="'.$id.'">'.$town_n.'</option>';
  59.             }
  60.             if($id == (int) $_POST['town'])
  61.             {
  62.                 $town_id = $id;
  63.                 $town_name = $town_n;
  64.             }
  65.             $i++;
  66.         }
  67.  
  68.         $main_content .= ''.$select.'';
  69.         for($i=1;$i <= count($towns_list[$world_id]); $i++)
  70.         {
  71.             $main_content .= ''.$towns[$i].'';
  72.         }
  73.         if(!$all)
  74.             $main_content .= '<option value="all">[ALL]</option>';
  75.              
  76.         $main_content .= '</td></tr></select>';
  77.     }
  78.     if(isset($town_id))
  79.     {
  80.         $a_status = array(1 => "Empty", "Rented", "[ALL]");
  81.          
  82.         if(isset($_POST['status']) and is_numeric($_POST['status']))
  83.         {
  84.             $sid = (int) $_POST['status'];
  85.             $sid = '<option value='.$sid.'>'.$a_status[$sid].'</option>';
  86.             if($_POST['status'] == 1)
  87.                 $s[1] = true;
  88.             elseif($_POST['status'] == 2)
  89.                 $s[2] = true;
  90.             elseif($_POST['status'] == 3)
  91.                 $s[3] = true;
  92.         }
  93.         $main_content .= '<tr><td>Select by status:</td><td><select name="status" onchange="submit()">'.$sid.'';
  94.         if(!$s[3])
  95.             $main_content .= '<option value="3">[ALL]</opyion>';
  96.         if(!$s[2])
  97.             $main_content .= '<option value="2">Rented</option>';
  98.         if(!$s[1])
  99.             $main_content .= '<option value="1">Empty</option>';
  100.         $main_content .= '</td></tr></select>';
  101.          
  102.     }
  103.          
  104.     $main_content .= '</table></form>';
  105.      
  106.     if(isset($_POST['status']))
  107.     {
  108.         if($_POST['status'] == 1)
  109.             $stat = "and `owner` = ''";
  110.         elseif($_POST['status'] == 2)
  111.             $stat = "and `owner` > 0";
  112.     }
  113.      
  114.     if(!isset($town_id))
  115.     {
  116.         $houses_info = $SQL->query("SELECT * FROM `houses` WHERE `world_id` = ".$world_id." ORDER BY `town` , `name`");
  117.         $towns_all = true;
  118.     }
  119.      
  120.     $main_content .= '<h2>Houses on '.$config['site']['worlds'][(int) $_GET['world']].'</h2>';
  121.     $main_content .= '<table>
  122.     <tr bgcolor="'.$config['site']['vdarkborder'].'">
  123.     <td width="40px"><font color="white"><b>#</b></font></td>
  124.     <td width="140px"><font color="white"><b>Address</b></font></td>
  125.     <td><font color="white"><b>Size</b></font></td>
  126.     <td width="70px"><font color="white"><b>Price</b></font></td>
  127.     <td width="70px"><font color="white"><b>inactive</b></font></td>
  128.     <td><font color="white"><b>Status</b></font></td>
  129.    
  130.     </tr>';
  131.     $number_of_rows = 0;
  132.     if(!$towns_all)
  133.         $houses_info = $SQL->query("SELECT * FROM `houses` WHERE `world_id` = ".$world_id." and `town` = ".$town_id." ".$stat." ORDER BY `name`");
  134.     $players_info = $SQL->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername`, `players`.`online` AS `online` , `accounts`.`premdays` AS `premdays` , `accounts`.`lastday` AS `lastlogin` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`");
  135.  
  136.  
  137.     $players = array();
  138.     foreach($players_info->fetchAll() as $player)
  139.         $players[$player['houseid']] = array('name' => $player['ownername'], 'days' => $player['premdays'], 'last' => $player['lastlogin']);
  140.        
  141.    
  142.     foreach($houses_info->fetchAll() as $house)
  143.     {
  144.         $owner = $players[$house['id']];
  145.         if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['lightborder']; } else { $bgcolor = $config['site']['darkborder']; } $number_of_rows++;
  146.        
  147.        
  148.        
  149.  
  150.        
  151.        
  152.         $main_content .= '
  153.         <tr bgcolor="'.$bgcolor.'">
  154.         <td>'.$number_of_rows.' </td>
  155.         <td>'.$house['name'].'</td>
  156.         <td width="50"><center>'.$house['size'].' sqm</center></td>
  157.         <td width="65"><center>'.($house['price'] / 100000).'kk</center></td>';
  158.         $main_content .= '<td>';
  159.         if(!empty($owner['name'])){
  160.         $t = time() - (int)$player['lastlogin'];
  161.                 $i = 0;
  162.  
  163.                 foreach(array(
  164.                                 'year' =>  $t / 86400 / 365,
  165.                                 'month' =>  $t / (28*86400) % 12,
  166.                                 'week' =>  $t / 604800 % 4,
  167.                                 'day' => $t / 86400 % 7,
  168.                                 'hour' => $t / 3600 % 24,
  169.                                 'minute' => $t / 60 % 60,
  170.                                 'second' => $t % 60
  171.                 ) as $k => $v)
  172.                 {
  173.                     if($player['online'] === 1){
  174.                         $main_content .= '<font color="#ff0000">Online</font>';
  175.                          break;
  176.                     }
  177.                     elseif($v = (int)$v) {
  178.                                $main_content .='<b>'.$v.'</b> '.$k.($v === 1 ? '' : 's');
  179.                                 if(++$i === 2)
  180.                                         break;
  181.                         }
  182.                 }
  183.         }
  184.         else{
  185.                 $main_content .= '';
  186.         }
  187.         $main_content .= '</td>';
  188.         //$main_content .= var_dump($player['online']);
  189.         $main_content .= '<td>';       
  190.         if(!empty($owner['name']))
  191.         {    
  192.             if($owner['deleted'] > 0)
  193.                 $status='<font color=red><b>[DELETED]</b></font>';
  194.                  
  195.             if(isPremium($owner['days'], $owner['last']))
  196.             {
  197.                 $main_content .= '<a href="?subtopic=characters&name='.urlencode($owner['name']).'">'.$owner['name'].'</a>'.$status.'';
  198.             }
  199.             else
  200.             {
  201.                 $main_content .= '<a href="?subtopic=characters&name='.urlencode($owner['name']).'">'.$owner['name'].'</a>'.$status.' (FACC)';
  202.             }
  203.         }
  204.         else
  205.         {
  206.             $main_content .= '';
  207.         }
  208.         $main_content .= '</td></tr>';
  209.     }
  210.     $main_content .= '</TABLE>';
  211. ?>
Add Comment
Please, Sign In to add comment