<?php
 include('cap.php');
 $file=file("db/bl.txt");
 for($n=0;$n<count($file);$n++)$file[$n]=trim($file[$n]);

 //Постраничная навигация
 $topic_count_page=100;
 if(!isset($_GET['page']) || !is_numeric(@$_GET['page']) || @$_GET['page']<1 )$page=1;
 else $page=$_GET['page'];
 if($page > ceil(count($file)/ $topic_count_page))$page=1;
 $start=$page * $topic_count_page-$topic_count_page;
 $pages=ceil(count($file)/ $topic_count_page);
 if(empty($_GET['ind']) || !is_numeric(@$_GET['ind']) || @$_GET['ind']>ceil($pages/10)  || @$_GET['ind']<1)$index=1;
 else $index= $_GET['ind'];


if(isset($_GET['id']))
  {
     $f=fopen("db/bl.txt","w");
     foreach($file as $line) if($line!=$_GET['id'])fwrite($f,"$line\r\n");
     fclose($f);

      echo "<meta http-equiv=refresh content='0; url=admin6.php?page=$page&ind=$index'>";
     exit();
  }

 if(count($file)> $topic_count_page)
    {
      //Постраничная навигаця
         echo "<table CELLPADDING=10 CELLSPACING=0 align=center  width=40%><tr><td>";

          if($index>1)echo "
         <a class='navig_passiv' href=admin6.php?page=".(($index-1)*10)."&ind=".($index-1)." title=назад><<</a>";

         for($i=$index*10-9,$p=1; $i < $pages+1; $i++,$p++)
          {

            if($p>10 )
          	  {
          	  	echo "<a class='navig_passiv'  href=admin6.php?page=".($i)."&ind=".($index+1)." title=далее>>></a>";
          	  	break;
          	  }
          	if($page==$i)
            echo "<a class='navig_activ' href=admin6.php?page=$i&ind=$index>$i</a>";
            else
            echo "<a class='navig_passiv'href=admin6.php?page=$i&ind=$index>$i</a>";
          }


       echo "</td></tr></table><br />";
    }
?>

<table  class=tab1   width=40%>

<?php
 for($x=$start,$y=0; $x<count($file); $x++,$y++)
     {
     	if($y==$topic_count_page)break;
     	echo"<tr><td class=sett1>$file[$x]</td><td class=sett2 align=center><a href=admin6.php?id=$file[$x]&page=$page&ind=$index>удалить</a></td></tr>";

     }
?>
</table>

</div>
</body>
</html>