<?php
  ///////////////////////////////////////////////////
  //Проверка таблиц базы данных
  ///////////////////////////////////////////////////

  $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=$titlepage = $TEXT['optim-title'];
  $helppage=$TEXT['optim-help'];

  require_once "../config.php";
  require_once "../util/top_layer1.php";

  if($result2['administrator'] == 0) puterror2($TEXT['error-loginform2']);
  $i="";

    $tbls = mysql_query("SHOW TABLES FROM $dbname");
     while($all = mysql_fetch_array($tbls))
      {
      $i .=$all['0'].", ";
      }
     $all_tbls=substr($i, 0,-2);

?>
<table class="table" border="0" cellpadding="0" cellspacing="0" width="80%">
<tr><td>
<fieldset>
<legend align="left" title="<?php echo $TEXT['chec-tit2']; ?>"><?php echo $TEXT['chec_text']; ?></legend>
<table class="table" border="1" cellpadding="0" cellspacing="0" width="100%">
<?php
  $query = "CHECK TABLE $all_tbls MEDIUM";
     $result = mysql_query($query);
      if (!$result) puterror2($TEXT['error-chec']);
?>
           <tr class="tableheadercat">
             <td><?php echo $TEXT['analiz-tab']; ?></td>
             <td><?php echo $TEXT['analiz-op']; ?></td>
             <td><?php echo $TEXT['analiz-msg-type']; ?></td>
             <td><?php echo $TEXT['analiz-msg-text']; ?></td>
             <td><?php echo $TEXT['tbl-action']; ?></td>
           </tr>
<?php
       while($result_analiz = mysql_fetch_array($result))
              {
               //Ссылка на исправление
               $repair = "<a href=repair.php?tbl=".$result_analiz['Table']." title='".$TEXT['rep-tit3']."'>".$TEXT['rep_text2']."</a>";

               $result_analiz1 = $result_analiz['Table'];
               $result_analiz2 = $result_analiz['Op'];
               $result_analiz3 = $result_analiz['Msg_type'];
               $result_analiz4 = $result_analiz['Msg_text'];

               if ($result_analiz['Msg_type'] == "status")
               {
?>
           <tr class="tabledata" onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
              <td><?php echo $result_analiz1; ?></td>
              <td><?php echo $result_analiz2; ?></td>
              <td><?php echo $result_analiz3; ?></td>
              <td><?php echo $result_analiz4; ?></td>
              <td><?php echo $repair; ?></td>
           </tr>
<?php
               }
               if ($result_analiz['Msg_type'] == "warning")
               {
?>
           <tr class="tabledatawarn" onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffff00';">
              <td><?php echo $result_analiz1; ?></td>
              <td><?php echo $result_analiz2; ?></td>
              <td><?php echo $result_analiz3; ?></td>
              <td><?php echo $result_analiz4; ?></td>
              <td><?php echo $repair; ?></td>
           </tr>
<?php
               }
               if ($result_analiz['Msg_type'] == "error")
               {
?>
           <tr class="tabledataerr" onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ff6347';">
              <td><?php echo $result_analiz1; ?></td>
              <td><?php echo $result_analiz2; ?></td>
              <td><?php echo $result_analiz3; ?></td>
              <td><?php echo $result_analiz4; ?></td>
              <td><?php echo $repair; ?></td>
           </tr>
<?php
               }
              }
            //*************************************
            //Информация для лога
            $ip = $_SERVER['REMOTE_ADDR'];
            $doing = $TEXT['log-chec1'];
            $what = $TEXT['log-chec2'];
            $who = $result2['fullname'];
            //*************************************
            $query2 = "INSERT INTO tbl_logs ( `log_id` , `data` , `ip` , `who` , `doing` , `what` ) VALUES ( NULL , NOW() , '$ip' , '$who' , '$doing' , '$what')";
            if(!mysql_query($query2)) puterror2($TEXT['error-log']);
?>
</table>
<table border="0" width="100%">
<tr align="right"><td class="catname"><a href=index.php title="<?php echo $TEXT['global-title6']; ?>"><?php echo $TEXT['btn_back']; ?></a></tr></td>
</table>
</fieldset>
</td></tr>
</table>
<?php
  require_once "../util/bottom.php";
?>
