<?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";

if(!isset($title)) $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 tooltip4" href="addform.php" ><?php echo $TEXT['add-new']; ?><span><?php echo $TEXT['add-new-tit']; ?><small></small></span></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 = mysql_query($query_body);
     if(!$result_body) {puterror($result2['skin'],$TEXT['error-tbl1']); require_once "../utils/bottom_adm.php"; exit();}
       if(mysql_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 = mysql_fetch_array($result_body,MYSQL_ASSOC))
               {
              $edit = "<a class='tooltip4' href=editform.php?srv_id=".$result_body_srv['srv_id']." >".$TEXT['edit-new']."<span>".$TEXT['edit-tit']."<small></small></span></a>";

              $query_del_srv = mysql_query("SELECT COUNT(ip_id) FROM tbl_ip WHERE srv_id='".$result_body_srv['srv_id']."'");
	            $coun_del_srv = mysql_result($query_del_srv, 0);
                  if($coun_del_srv > 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 class='tooltip4' href=delete.php?srv_id=".$result_body_srv['srv_id']." >".$TEXT['delete-new']."<span>".$TEXT['delete-tit']."<small></small></span></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 class='tooltip4' href=clear.php?srv_id=".$result_body_srv['srv_id']." >".$TEXT['btn_clear']."<span>".$TEXT['btn_clear-tit']."<small></small></span></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 class='tooltip4' href=on.php?srv_id=".$result_body_srv['srv_id']." >".$vkl."<span>".$TEXT['srv-vkluchit']."<small></small></span></a>";
                else $strvisible = "<a class='tooltip4' href=off.php?srv_id=".$result_body_srv['srv_id']." >".$vkl."<span>".$TEXT['srv-vikluchit']."<small></small></span></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";
?>