<?php
require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
if ((!isset($_SESSION['id'])) or (!isset($_SESSION['nick'])))  {
  ?>
<!--1390114136-->
  <script type="text/javascript">
  document.location.href = "login.php";
  </script>
  <?php
  exit();
}
$page_title = 'Мод-панель';
require_once('conf/head.php');
$user_id=abs(intval($_SESSION['id']));
$usst=$dbc->query("SELECT * FROM `users` WHERE`id`='$user_id' LIMIT 1")->fetch_assoc();
if($usst['admin']<='0'){header('location: /');}
$user_id = abs(intval($_GET['id']));
if ((isset($_SESSION['id'])) and (isset($_SESSION['nick'])))  {
  /////////////////////////////////

require_once('conf/top.php');

$query = "Select * from users where id = '$user_id' limit 1";
$result = mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД');
$row = mysqli_fetch_array($result);
if ($row == 0) {
require_once('conf/nouser.php');
}
else {

$ip=$row['uip'];
?>

    <div id="main">
    <div class="stats">
    
	

<center> <p class="profile" style="border-top:1px solid #000000; background-color:#000000;"> <span class="net"><?php
if ($row['gruppa'] == 'svoboda') {if ($razn_last_act < 300 ) {?><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/svoboda.png" width="12" height="12" alt="н"/><?php }}
if ($row['gruppa'] == 'dolg') {if ($razn_last_act < 300 ) {?><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/dolg.png" width="12" height="12" alt="н"/><?php }}
if ($row['gruppa'] == 'naemniki') {if ($razn_last_act < 300 ) {?><img src="img/ico/odinochkion.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/odinochki.png" width="12" height="12" alt="н"/><?php }}
$ip=$row['uip'];
echo ' ' . $row['nick'];?> </span></a><span class="bonus">Id:
<?php echo ' ' . $row['id']; ?></span></p></center> </div>
  <?php
if ($row['gruppa'] <> 'mytants' and $row['gruppa'] <> 'bandits' and $row['gruppa'] <> 'monolits' and $row['gruppa'] <> 'zombie') {
?>
<div id="main">

<?php
$id = abs(intval($_SESSION['id']));
$query = "Select admin, id, gruppa from users where id = '$id' limit 1";
$result = mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД');
$row2 = mysqli_fetch_array($result);
$ip=$row['uip'];

if ((isset($_SESSION['id'])) and (isset($_SESSION['nick'])))  {
$query_num = "Select id from users where ban= '0' and uip = '$ip' and 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); 
echo'<center><span class="yellow">Персонажи </span><span class="white">('.$total.')</span> <span class="darkkhaki">(Ip='.$row['uip'].'): </span></p>';
/////////////////////////////////
   ////////////////////////////////

	  $query_us = "Select nick ,id,gruppa,lvl,avatar, last_active  from users where ban= '0' and uip = '$ip' and gruppa <> 'mytants' and gruppa <>'bandits' and gruppa <> 'zombie' and gruppa <> 'monolits' order by  uip = '$ip' and  last_active > NOW()-(300*5) DESC ";
	  }
      $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)) {
	    $lvl = $row_us['lvl'];
$ip=$row_us['uip'];
            $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);
	    ?>
	    <center>
		<?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 }}
	  ?> [<?php echo "$lvl";?>ур]
         <a style="text-decoration:none;"  href="profile.php?id=<?php echo "$id_us"; ?>"><?php echo "$nick";?></a></p></b></center>
	   <span class="white">
	  <?php

	  ?></span>

	  </b>
	  
<?php
}
?>
</center>

<?php if ($row2['admin'] == 1) {?>
<div style="background-color: #1E1E1E;">
<p style="border-top:1px solid #444e4f;"></p>
<center><b>Выдать бан:</b></center>
<p style="border-top:1px solid #444e4f;"></p>
</div>
<div class="stats">
<div class="r6">
<b><a style="text-decoration:none;" href="us_ban.php?usid=<?php echo "$user_id"; ?>&type=4""><img src="img/ico/mail.png"  alt=""width="12" height="12"/>На Почту</a></b></p>
<b>  <a style="text-decoration:none;" href="us_ban.php?usid=<?php echo "$user_id"; ?>&type=1""><img src="img/ico/ban_chat.png"  alt=""width="12" height="12"/><span class="red">На чат</span></a></b></p>
<a style="text-decoration:none;" href="us_ban.php?usid=<?php echo "$user_id"; ?>&type=2""><img src="img/ico/forum.png"  alt=""width="12" height="12"/><span class="blue">На форум</a></span></p> <?php if ($row['ban'] == 0) {?>[
<a style="text-decoration:none;" href="moderator.php?profile=<?php echo "$user_id"; ?>&type=8">На игру</a><?php } else {?>[<span class="red">Забанен</span><?php }?>][
<a style="text-decoration:none;" href="us_ban.php?usid=<?php echo "$user_id"; ?>&type=3"">Забанить на IP</a>]</p></div><?php }
	  ?>
<?php if ($row2['admin'] == 2 or $row2['admin'] == 3) {?>
<div style="background-color: #1E1E1E;">
<p style="border-top:1px solid #444e4f;"></p>
<center><b>Выдать бан:</b></center>
<p style="border-top:1px solid #444e4f;"></p>
</div>
<div class="stats">
<div class="r6">
<b><a class="menu" style="text-decoration:none;" href="us_ban.php?usid=<?php echo "$user_id"; ?>&type=4""><img src="img/ico/mail.png"  alt=""width="12" height="12"/>На Почту</a></b></p>
<b><a class="menu" style="text-decoration:none;" href="us_ban.php?usid=<?php echo "$user_id"; ?>&type=1""><img src="img/ico/ban_chat.png"  alt=""width="12" height="12"/>На чат</a</b></p>
<b><a class="menu" style="text-decoration:none;" href="us_ban.php?usid=<?php echo "$user_id"; ?>&type=2""><img src="img/ico/forum.png"  alt=""width="12" height="12"/>На форум</a></p></b> </b></div><?php }
 
}
}	

}

	?>
 
  <?php
    ///ecли не мутанты
  require_once('conf/navig.php');
  
    require_once('conf/foot.php');
	mysqli_close($dbc);
  ?>
</body>
</html>