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

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

  if(empty($_GET['tbl'])) {$_GET['tbl'] = "db_manydhcp.no_table";}
  if(strlen($_GET['tbl'])>30) {puterror($result2['skin'],$TEXT['error-rep-tbl']); require_once "../utils/bottom_adm.php"; exit();}
  $_GET['tbl'] = rep($_GET['tbl']);
  
  $tbl = substr($_GET['tbl'], 12,40);

    $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);

  if($tbl !== "no_table") {$rep_tbl = "`".$tbl."`";}
    else {$rep_tbl = $all_tbls;}

?>
<table align="center" class="table" border="0" cellpadding="0" cellspacing="0" width="80%">
<tr><td>
<fieldset>
<legend align="left" title="<?php echo $TEXT['rep-tit2']; ?>"><?php echo $TEXT['rep_text']; ?></legend>
<table align="center" class="table" border="1" cellpadding="0" cellspacing="0" width="100%">
<?php
$dis_keys = mysqli_query($dbcnx,"ALTER TABLE DISABLE KEYS");
  $query = "REPAIR TABLE ".$rep_tbl." EXTENDED";
     $result = mysqli_query($dbcnx,$query);
      if(!$result) {puterror($result2['skin'],$TEXT['error-rep']); 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_rep = mysqli_fetch_array($result,MYSQLI_ASSOC))
              {
               $result_rep1 = $result_rep['Table'];
               $result_rep2 = $result_rep['Op'];
               $result_rep3 = $result_rep['Msg_type'];
               $result_rep4 = $result_rep['Msg_text'];
?>
           <tr>
              <td><?php echo $result_rep1; ?></td>
              <td><?php echo $result_rep2; ?></td>
              <td><?php echo $result_rep3; ?></td>
              <td><?php echo $result_rep4; ?></td>
           </tr>
<?php
            //*************************************
            $ip = $_SERVER['REMOTE_ADDR'];
            $doing = $TEXT['log-rep1'];
            $what = $TEXT['log-rep2']."&nbsp;&rArr;&nbsp;&laquo;".$result_rep1."&raquo;";
            $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)) {puterror($result2['skin'],$TEXT['error-log']); require_once "../utils/bottom_adm.php"; exit();}
            }
$en_keys = mysqli_query($dbcnx,"ALTER TABLE ENABLE KEYS");
?>
</tbody>
</table>
</fieldset>
</td></tr>
</table>
<?php
  require_once "../utils/bottom_adm.php";
?>