<?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['menu-btn19-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 alt="<?php echo $TEXT['add-new']; ?>" align="bottom"  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 = "SELECT * FROM `tbl_ondisk`";
     $result = mysqli_query($dbcnx,$query);
     if(!$result) {puterror($result2['skin'],$TEXT['error-tbl9']); require_once "../utils/bottom_adm.php"; exit();}
       if(mysqli_num_rows($result)>0)
         {
           echo "<thead><tr class='tableheadercat'>
            <td>".$TEXT['ondisk_fs']."</td>
            <td>".$TEXT['ondisk_all']."</td>
            <td>".$TEXT['ondisk_use']."</td>
            <td>".$TEXT['ondisk_dost']."</td>
            <td>".$TEXT['ondisk_usepr']."</td>
            <td>".$TEXT['ondisk_tm']."</td>
            <td colspan=2>".$TEXT['tbl-action']."</td>
                 </tr></thead><tbody id='tab'>";
             while($result_tables = mysqli_fetch_array($result,MYSQLI_ASSOC))
               {
              $delete_pic = "<img alt='picture' src='../skins/".$result2['skin']."/delete.png' />";
              $edit_pic = "<img alt='picture' src='../skins/".$result2['skin']."/edit.png' />";
              $edit = $edit_pic."&nbsp;<a href=editform.php?ond_id=".$result_tables['ond_id']." title='".$TEXT['edit-tit']."'>".$TEXT['edit-new']."</a>";
              $delete = $delete_pic."&nbsp;<a href=delete.php?ond_id=".$result_tables['ond_id']." title='".$TEXT['delete-tit']."'>".$TEXT['delete-new']."</a>";

              $total = disk_total_space($result_tables['mp']);
              $free = disk_free_space($result_tables['mp']);
              $isp = $total-$free;
              $proc1 = $total/100;
              $proc2 = round($isp/$proc1);
              $procent = round($total/100,1);

              if($total > 1024)
              {
              $total = (float)($total/1024);
              if($total > 1024)
                {
                 $total = (float)($total/1024);
                 if($total > 1024)
                 {
                     $total = (float)($total/1024);
                     $total = round($total, 1);
                     $total = $total.$TEXT['size-gb'];
                 } else
                    {
                       $total = (float)($total);
                       $total = round($total, 1);
                       $total = $total.$TEXT['size-mb'];
                    }
                }
                 else
                  {
                  $total = round($total, 1);
                  $total = $total.$TEXT['size-kb'];
                  }
              }
              else {$total = $total.$TEXT['size-b'];}

              if($free > 1024)
              {
              $free = (float)($free/1024);
              if($free > 1024)
                {
                 $free = (float)($free/1024);
                 if($free > 1024)
                 {
                     $free = (float)($free/1024);
                     $free = round($free, 1);
                     $free = $free.$TEXT['size-gb'];
                 } else
                    {
                       $free = (float)($free);
                       $free = round($free, 1);
                       $free = $free.$TEXT['size-mb'];
                    }
                }
                 else
                  {
                  $free = round($free, 1);
                  $free = $free.$TEXT['size-kb'];
                  }
              }
              else {$free = $free.$TEXT['size-b'];}

              if($isp > 1024)
              {
              $isp = (float)($isp/1024);
              if($isp > 1024)
                {
                 $isp = (float)($isp/1024);
                 if($isp > 1024)
                 {
                     $isp = (float)($isp/1024);
                     $isp = round($isp, 1);
                     $isp = $isp.$TEXT['size-gb'];
                 } else
                    {
                       $isp = (float)($isp);
                       $isp = round($isp, 1);
                       $isp = $isp.$TEXT['size-mb'];
                    }
                }
                 else
                  {
                  $isp = round($isp, 1);
                  $isp = $isp.$TEXT['size-kb'];
                  }
              }
              else {$isp = $isp.$TEXT['size-b'];}

           ?>
             <tr>
              <td><?php echo $result_tables['disk_name']; ?></td>
              <td><?php echo $total; ?></td>
              <td><?php echo $isp; ?></td>
              <td><?php echo $free; ?></td>
              <td><?php echo $proc2; ?>&#037;</td>
              <td><?php echo $result_tables['mp']; ?></td>
              <td align="center"><?php echo $edit; ?></td>
              <td align="center"><?php echo $delete; ?></td>
             </tr>
           <?php
               }
         }
?>
</tbody>
</table>
<?php
  require_once "../utils/bottom_adm.php";
?>