<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

$lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
if(is_file ("../lang/".$lang."/".$lang.".php")) {include "../lang/".$lang."/".$lang.".php";}
  else {include "../lang/ru/ru.php";}

$title = $TEXT['srv-title'];

require_once "../config_a.php";
require_once "../utils/functions.php";
require_once "../utils/top_adm.php";

if($result2['administrator'] == 0) {puterror($result2['skin'],$TEXT['error-loginform2']); require_once "../utils/bottom_adm.php"; exit();}
?>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%" >
<tr align="right">
    <td><img align="bottom" alt="<?php echo $TEXT['add-new']; ?>" src="../skins/<?php echo $result2['skin']?>/add.png" /><a class="bold_it" href="addform.php" title="<?php echo $TEXT['add-new-tit']; ?>"><?php echo $TEXT['add-new']; ?></a></td>
</tr>
</table>
<table align="center" border="1" cellpadding="3" cellspacing="0" width="90%" >
<?php
     $query_body = "SELECT * FROM `tbl_srv` ORDER BY `name`";
     $result_body = mysqli_query($dbcnx,$query_body);
     if(!$result_body) {puterror($result2['skin'],$TEXT['error-tbl1']); require_once "../utils/bottom_adm.php"; exit();}
       if(mysqli_num_rows($result_body)>0)
         {
           echo "<thead><tr class='tableheadercat'>
            <td>".$TEXT['srv-name']."</td>
            <td>".$TEXT['srv-descr']."</td>
            <td>".$TEXT['srv-autorize']."</td>
            <td>".$TEXT['menu-btn9']."</td>
            <td>".$TEXT['srv-vkl-tit']."</td>
            <td colspan=3>".$TEXT['global-action']."</td>
                 </tr></thead><tbody id='tab'>";
             while($result_body_srv = mysqli_fetch_array($result_body,MYSQLI_ASSOC))
               {
              $edit = "<a href=editform.php?srv_id=".$result_body_srv['srv_id']." title='".$TEXT['edit-tit']."'>".$TEXT['edit-new']."</a>";

              $query_del_srv = mysqli_query($dbcnx,"SELECT COUNT(ip_id) AS c_ip_id FROM tbl_ip WHERE srv_id='".$result_body_srv['srv_id']."'");
	            $coun_del_srv = mysqli_fetch_array($query_del_srv,MYSQLI_ASSOC);
                  if($coun_del_srv['c_ip_id'] > 0)
                     {
                       $delete_pic = "<img alt='nodelete' src='../skins/".$result2['skin']."/nodelete.png' />";
                       $delete =$delete_pic."&nbsp;".$TEXT['delete-new'];
                     }
                      else
                    {
                       $delete_pic = "<img alt='delete' src='../skins/".$result2['skin']."/delete.png' />";
                       $delete = $delete_pic."&nbsp;<a href=delete.php?srv_id=".$result_body_srv['srv_id']." title='".$TEXT['delete-tit']."'>".$TEXT['delete-new']."</a>";
                     }

              $online = "<img alt='online' src='../skins/".$result2['skin']."/online.png' />";
              $offline = "<img alt='offline' src='../skins/".$result2['skin']."/offline.png' />";
              $act = "<img alt='active' src='../skins/".$result2['skin']."/active.png' />";
              $noact = "<img alt='noactive' src='../skins/".$result2['skin']."/no_active.png' />";
              $clr = "<img alt='clear' src='../skins/".$result2['skin']."/clear.png' />";
              $edit_pic = "<img alt='edit' src='../skins/".$result2['skin']."/edit.png' />";

              $clear = $clr."&nbsp;<a href=clear.php?srv_id=".$result_body_srv['srv_id']." title='".$TEXT['btn_clear-tit']."'>".$TEXT['btn_clear']."</a>";

              if($result_body_srv['autorit'] == 1) {$autorize = $act;}
                else {$autorize = $noact;}

              if($result_body_srv['vkl'] == 1) {$vkl = $online;}
                else {$vkl = $offline;}

              if($result_body_srv['ping_ok'] == "yes") {$ping_ok = $act;}
                else {$ping_ok = $noact;}

              if($result_body_srv['vkl'] == '0') {$strvisible = "<a href=on.php?srv_id=".$result_body_srv['srv_id']." title='".$TEXT['srv-vkluchit']."'>".$vkl."</a>";}
                else {$strvisible = "<a href=off.php?srv_id=".$result_body_srv['srv_id']." title='".$TEXT['srv-vikluchit']."'>".$vkl."</a>";}
           ?>
           <tr>
              <td><?php echo $result_body_srv['name']; ?></td>
              <td><?php echo $result_body_srv['descr']; ?></td>
              <td align="center"><?php echo $autorize; ?></td>
              <td align="center"><?php echo $ping_ok; ?></td>
              <td align="center"><?php echo $strvisible; ?></td>
              <td align="center"><?php echo $clear; ?></td>
              <td align="center"><?php echo $edit_pic; ?>&nbsp;<?php echo $edit; ?></td>
              <td align="center"><?php echo $delete; ?></td>
           </tr>
           <?php
               }
         }
?>
</tbody>
</table>
<?php
  require_once "../utils/bottom_adm.php";
?>