<?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');
}
?>
<br/>
    <div class="stats">
<p class="bonus">*занятость - количество отправленных вопросов, на которые еще не дан ответ.</p>
<center><p class="name2">Модераторы:</span></p></center>
      
   <?php
    
	  $query_us = "Select * from users where admin <> '0' and admin <> '1'  order by last_active  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'];
            $nick = $row_us['nick'];
	    $id_us = $row_us['id'];
             $opit_us = $row_us['opit'];
		$gruppa = $row_us['gruppa'];
         $message = $row_us['message'];
            $admin = $row_us['admin'];
		$last_active = $row_us['last_active'];
        $last_active = strtotime("$last_active");
        $razn_last_act = ($now - $last_active);
$mes = $pdo->query("SELECT COUNT(id) FROM `messages` WHERE `komy` = '".$id_us."' and `readlen` = '0'")->fetchColumn();
   echo'<p>';
  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/naemniki.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php }}
		  if ($gruppa == 'chistoenebo') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php }}
	  if ($gruppa == 'renegat') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.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> <span class="red">(занятость: <?php echo "$mes";?>) </span>[<a style="text-decoration:none;" href="mes.php?act=dialog&id=<?php echo "$id_us"?>"><img src="img/ico/letter.png" width="12" height="12"/>написать</a>]</p> 
	   <?php  
}

	  ?></span></b>
<center><p class="name2">Администраторы:</span></p></center>
<?php
    
	  $query_us = "Select * from users where admin <> '2' and admin <> '0' and admin <> '3' order by last_active 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'];
            $nick = $row_us['nick'];
	    $id_us = $row_us['id'];
		$gruppa = $row_us['gruppa'];
         $message = $row_us['message'];
            $admin = $row_us['admin'];
		$last_active = $row_us['last_active'];
        $last_active = strtotime("$last_active");
        $razn_last_act = ($now - $last_active);
$mes = $pdo->query("SELECT COUNT(id) FROM `messages` WHERE `komy` = '".$id_us."' and `readlen` = '0'")->fetchColumn();

      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/naemniki.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php }}
		  if ($gruppa == 'chistoenebo') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php }}
	  if ($gruppa == 'renegat') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.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> <span class="red">(занятость: <?php echo "$mes";?>) </span>[<a style="text-decoration:none;" href="mes.php?act=dialog&id=<?php echo "$id_us"?>"><img src="img/ico/letter.png" width="12" height="12"/>написать</a>]</p>
	   <?php
}

require_once('conf/navig.php');
require_once('conf/foot.php');
mysqli_close($dbc);

?>
</body>
</html>