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

  if(empty($_GET['tbl'])) $_GET['tbl'] = "personal.no_table";
  if(strlen($_GET['tbl'])>30) puterror2($TEXT['error-rep-tbl']);
  $_GET['tbl'] = rep($_GET['tbl']);

  $tbl = substr($_GET['tbl'], 9,30);
  $i="";

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

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

?>
<table 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 class="table" border="1" cellpadding="0" cellspacing="0" width="100%">
<?php
$dis_keys = mysql_query("ALTER TABLE DISABLE KEYS");
  $query = "REPAIR TABLE ".$rep_tbl." EXTENDED";
     $result = mysql_query($query);
      if(!$result) puterror2($TEXT['error-rep']);
?>
           <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>
           </tr>
<?php
       while($result_rep = mysql_fetch_array($result))
              {
               $result_rep1 = $result_rep['Table'];
               $result_rep2 = $result_rep['Op'];
               $result_rep3 = $result_rep['Msg_type'];
               $result_rep4 = $result_rep['Msg_text'];
?>
           <tr class="tabledata" onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
              <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'].$result_rep1;
            $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']);
             }
   $en_keys = mysql_query("ALTER TABLE ENABLE KEYS");
?>
</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";
?>
