<?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['dbanaliz'];

  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();}

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

?>
<table align="center" class="table" border="0" cellpadding="0" cellspacing="0" width="80%">
<tr><td>
<fieldset>
<legend align="left" title="<?php echo $TEXT['analiz-tit2']; ?>"><?php echo $TEXT['analiz-text']; ?></legend>
<table align="center" class="table" border="1" cellpadding="0" cellspacing="0" width="100%">
<?php
  $query = "ANALYZE TABLE $all_tbls ";
     $result = mysqli_query($dbcnx,$query);
      if(!$result) {puterror($result2['skin'],$TEXT['error-analiz']); require_once "../utils/bottom_adm.php"; exit();}
?>
           <thead>
           <tr class='tableheadercat'>
             <td width="40%"><?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>
           </tr>
           </thead>
           <tbody id='tab'>
<?php
       while($result_analiz = mysqli_fetch_array($result,MYSQLI_ASSOC))
         {
              $result_analiz1 = $result_analiz['Table'];
              $result_analiz2 = $result_analiz['Op'];
              $result_analiz3 = $result_analiz['Msg_type'];
              $result_analiz4 = $result_analiz['Msg_text'];
            ?>
           <tr>
              <td><?php echo $result_analiz1; ?></td>
              <td><?php echo $result_analiz2; ?></td>
              <td><?php echo $result_analiz3; ?></td>
              <td><?php echo $result_analiz4; ?></td>
           </tr>
           <?php
           }
            //*************************************
            //Информация для лога
            $ip = $_SERVER['REMOTE_ADDR'];
            $doing = $TEXT['log-analiz1'];
            $what = $TEXT['log-analiz2'];
            $who = $result2['familiya']." ".$result2['name'];
            //*************************************
            $query2 = "INSERT INTO tbl_logs ( `log_id` , `data` , `ip` , `who` , `doing` , `what` ) VALUES ( NULL , NOW() , '$ip' , '$who' , '$doing' , '$what')";
            if(mysqli_query($dbcnx,$query2))
            {
            // Автоматически осуществляем переход на главную страницу администрирования
            //echo "<HTML><HEAD>
            //      <META HTTP-EQUIV='Refresh' CONTENT='0; URL=../main.php'>
            //            </HEAD>";
            }
            else {puterror($result2['skin'],$TEXT['error-log']); require_once "../utils/bottom_adm.php"; exit();}

?>
</tbody>
</table>
</fieldset>
</td></tr>
</table>
<?php
  require_once "../utils/bottom_adm.php";
?>