Файл: stalkerus.tk/activerat.php
Строк: 172
<?php
require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
$page_title = 'Рейтинг';
require_once('conf/head.php');
if ((isset($_SESSION['id'])) and (isset($_SESSION['nick'])))  {
  require_once('conf/top.php');
}
?>
    <div id="main">
    <div class="stats">
    <p class="podmenu">Рейтинг активности</p>
    </div>
    <?php
    $type=$_GET['type'];
    if (empty($type)) {
    $type=1;
    }
    ?>
    <div class="stats">
 <span class="bonus">Рейтинг активности игроков <img src="img/ico/patrul.png" width="16" height="16" alt="н"/></span>
       </div>
   <?php
    
    $query_num = "Select id from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits'" ;
    $result_num = mysqli_query($dbc, $query_num) or die ('Ошибка передачи запроса к БД');
    $total = mysqli_num_rows($result_num); 
    ?>
    <p class="podmenu">Всего игроков <?php echo "[ $total ]"; ?></p>
    <?php
   /////////////////////////////////
   ////////////////////////////////
if (!empty($_GET['page'])) {
  $cur_page = $_GET['page'];
}
else {
  $cur_page = 1;
}
    $result_per_page = 10;
    $skip = (($cur_page - 1) * $result_per_page);
        $num_page = ceil($total / $result_per_page);
    if ($num_page > 0) {
       if ($type==1) {
      $query_us = "Select nick ,id,gruppa, last_active, activ from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by activ DESC limit $skip, $result_per_page";
      }
      if ($type==2) {
      $query_us = "Select nick ,id,gruppa, last_active, bronya from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by bronya DESC limit $skip, $result_per_page";
      }
      if ($type==3) {
      $query_us = "Select nick ,id,gruppa, last_active, razriv_cl from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by razriv_cl DESC limit $skip, $result_per_page";
      }
      if ($type==4) {
      $query_us = "Select nick ,id,gruppa, last_active, yron_p from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by yron_p DESC limit $skip, $result_per_page";
      }
      if ($type==5) {
      $query_us = "Select nick ,id,gruppa, last_active, tochn_p from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by tochn_p DESC limit $skip, $result_per_page";
      }
      if ($type==6) {
      $query_us = "Select nick ,id,gruppa, last_active, safety_p from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by safety_p DESC limit $skip, $result_per_page";
      }
      if ($type==7) {
      $query_us = "Select nick ,id,gruppa, last_active, yron_w from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by yron_w DESC limit $skip, $result_per_page";
      }
      if ($type==8) {
      $query_us = "Select nick ,id,gruppa, last_active, tochn_w from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by tochn_w DESC limit $skip, $result_per_page";
      }
      if ($type==9) {
      $query_us = "Select nick ,id,gruppa, last_active, safety_w from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by safety_w DESC limit $skip, $result_per_page";
      }
      if ($type==10) {
      $query_us = "Select nick ,id,gruppa, max_hp, last_active from users where gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by max_hp DESC limit $skip, $result_per_page";
      }
      $result_us = mysqli_query($dbc, $query_us) or die ('Ошибка передачи запроса к БД');
      $now = (date("Y-m-d H:i:s"));
      $now = strtotime("$now");
      while ($row_us = mysqli_fetch_array($result_us)) {
        $nick = $row_us['nick'];
        $id_us = $row_us['id'];
        $gruppa = $row_us['gruppa'];
        $last_active = $row_us['last_active'];
        $last_active = strtotime("$last_active");
        $razn_last_act = ($now - $last_active);
        ?>
        <div class="zx">
        <?php
      if ($gruppa == 'svoboda') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php }}
      if ($gruppa == 'dolg') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php }}
      if ($gruppa == 'naemniki') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/odinochkion.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/odinochkion.png" width="12" height="12" alt="н"/><?php }}
      ?> <a href="profile.php?id=<?php echo "$id_us"; ?>"><?php echo "$nick";?></a><b>
      <span class="white">(
      <?php
      if ($type==1) { echo $row_us['activ'];}
      if ($type==2) { echo $row_us['bronya'];}
      if ($type==3) { echo $row_us['razriv_cl'];}
      if ($type==4) { echo $row_us['yron_p'];}
      if ($type==5) { echo $row_us['tochn_p'];}
      if ($type==6) { echo $row_us['safety_p'] . '%';}
      if ($type==7) { echo $row_us['yron_w'];}
      if ($type==8) { echo $row_us['tochn_w'];}
      if ($type==9) { echo $row_us['safety_w'] . '%';}
      if ($type==10) { echo $row_us['max_hp'];}
      ?>)</span>
      </b></div>
      
        <?php
      }
      ?>
      <div class="zx">
      <?php
      $phpself= $_SERVER['PHP_SELF'];
      $phpself = htmlentities($phpself, ENT_QUOTES);
      ///////////////////////////////////////
      ////////////////////////////////////////
      if ($cur_page > 1) {
        echo '<a href="' . "$phpself" . '?page=1' . '&type=' . $type . '"><<</a> ';
      }
      else {
        echo '<< ';
      }
      if ($cur_page > 1) {
        echo '<a href="' . "$phpself" . '?page=' . ($cur_page-1) . '&type=' . $type . '"><</a> ';
      }
      else {
        echo '<';
      }
    /////
      if (($cur_page-3)>0) {
     $k = ($cur_page-3);
        ?><a href="<?php echo "$phpself" . '?page=' . ($cur_page-3) . "&type=$type"?>"><?php echo "$k";?></a><?php
      }
     if (($cur_page-2)>0) {
     $k = ($cur_page-2);
        ?> <a href="<?php echo "$phpself" . '?page=' . ($cur_page-2) . "&type=$type"?>"><?php echo "$k";?></a> <?php
      }
     if (($cur_page-1)>0) {
     $k = ($cur_page-1);
        ?> <a href="<?php echo "$phpself" . '?page=' . ($cur_page-1) . "&type=$type"?>"><?php echo "$k";?></a> <?php
      }
    ?> <span class="white"><?php echo " $cur_page ";?></span><?php
     if (($cur_page+1)<=$num_page) {
     $k = ($cur_page+1);
        ?> <a href="<?php echo "$phpself" . '?page=' . ($cur_page+1) . "&type=$type"?>"><?php echo "$k";?></a> <?php
      }
           if (($cur_page+2)<=$num_page) {
     $k = ($cur_page+2);
        ?> <a href="<?php echo "$phpself" . '?page=' . ($cur_page+2) . "&type=$type"?>"><?php echo "$k";?></a> <?php
      }
     if (($cur_page+3)<=$num_page) {
     $k = ($cur_page+3);
        ?> <a href="<?php echo "$phpself" . '?page=' . ($cur_page+3) . "&type=$type"?>"><?php echo "$k";?></a> <?php
      }
    /////
    if ($cur_page < $num_page) {
      echo '<a href="' . "$phpself" . '?page=' . ($cur_page+1) . '&type=' . $type . '">></a> ';
    }
    else {
      echo '>';
    }
    if ($cur_page < $num_page) {
      echo ' <a href="' . "$phpself" .  '?page=' . $num_page . '&type=' . $type . '">>></a> ';
    }
    else {
      echo ' >>';
    }
    ////////////////////////////////
    ///////////////////////////////
    }
    ?>
    </div>
    <?php
   /////////////////////////////////
   //////////////////////////////////
require_once('conf/navig.php');
require_once('conf/foot.php');
mysqli_close($dbc);
?>
</body>
</html>