<?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/".$lang."/ru.php";

  $title=$titlepage = $TEXT['menu-btn30'];
  $helppage = $TEXT['menu-btn30-title'];
  require_once "../config.php";
  require_once "../util/top.php";

  if($result2['administrator'] == 0) puterror2($TEXT['error-loginform2']);
?>
<img alt="<?php echo $TEXT['add-new']; ?>" align="bottom"  src="../img/insert.png"  height="15" align="top" /><a class="bold_it" href="addform.php" title="<?php echo $TEXT['add-new-tit']; ?>"><?php echo $TEXT['add-new']; ?></a>
<br />
<br />
<span class="tabledata"><?php echo $TEXT['param_about']; ?></span>
<table align="center" border="1" cellpadding="3" cellspacing="0" width="90%">
<?php
     $query = "SELECT * FROM `tbl_ondisk`";
     $result = mysql_query($query);
     if(!$result) puterror2($TEXT['error-tbl9']);
       if(mysql_num_rows($result)>0);
         {
           echo "<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>";
             while($result_tables = mysql_fetch_array($result,MYSQL_ASSOC))
               {
              $edit = "<a href=editform.php?ond_id=".$result_tables['ond_id']." title='".$TEXT['login-edit-tit']."'>".$TEXT['tbl-edit']."</a>";
              $delete = "<a href=delete.php?ond_id=".$result_tables['ond_id']." title='".$TEXT['login-del-tit']."'>".$TEXT['tbl-delete']."</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 class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
              <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><?php echo $edit; ?></td>
              <td><?php echo $delete; ?></td>
             </tr>
           <?php
               }
         }
?>
</table>
<?php
  require_once "../util/bottom.php";
?>