Просмотр файла jpmobile/adm/for_red_for.php

Размер файла: 4.1Kb
<?php
Defined('ADMIN_S_S') or die ('Доступ запрещен!!!');
echo
'<span class="ramka">
Редактировать форум.
</span><br>';

if ($_POST['step'] == 1 or $_POST['step'] == '')
{
 echo 'Выберите каталог с форумами.<br>';
         echo '<form name="" action="" method="post">';
         echo '<select size="1" name="kat">
         ';
             $forum_r = @file('forum/base/catalog.txt');
             $forum_c = count($fprum_r);
             $forum_cc = 0;
			 while ($forum_r[$forum_cc] != '')
			 {
			  $exe = explode('|',$forum_r[$forum_cc]);
			  echo '<option value="'.trim($exe[1]).'">'.$exe[0].'</option>';
			  echo '<br><br>';
			  $forum_cc++;
			 }

          echo '</select><br />
          ';
          echo '<input name="step" type="hidden" value="2">';
          echo '<input type="submit" value="Далее">';
          echo '</form>';
}
elseif ($_POST['step'] == 2)
{


   $st_r = 10;
 if (is_file('forum/base/'.trim($_POST['kat']).'.txt')) $post = @file('forum/base/'.trim($_POST['kat']).'.txt'); else echo 'Ошибка';

 $count_post = count($post);

 if (empty($_GET['pages'])) {
    $pages = 1;
 }  else {
    $pages = (int) $_GET['pages'];
 }

 $j = ($count_post-1)-(($pages-1)*$st_r);
 $i = $j-$st_r;
 for(; $i<$j && $j>=0; $j--)
 {


 echo '
 <span class="mess1">'.file_get_contents('forum/'.trim($post[$j]).'/namekat.txt').'</span> <span class="mess2">'.file_get_contents('forum/'.trim($post[$j]).'/opiskat.txt').'</span>

      <form name="" action="" method="post">
      <input name="line" type="hidden" value="'.$j.'">
      <input name="kat" type="hidden" value="'.$_POST['kat'].'">
      <input name="step" type="hidden" value="3">
      <input class="knopka" type="submit" value="Выбрать">
      </form>
      <hr>


     ';


 }
 echo 'Страницы:&nbsp;'."\n";
 $all = ceil($count_post/$st_r);
 for ($i=1;$i<=$all;$i++) {
    if ($pages==$i) {
        echo '<b>'.$i.'</b> ';
    } else {
        echo '<a href="/adminf.php?id=2&pages='.$i.'">'.$i.'</a> '."";
    }

 }
}
elseif ($_POST['step'] == 3)
{
 if (is_file('forum/base/'.trim($_POST['kat']).'.txt')) $post = @file('forum/base/'.trim($_POST['kat']).'.txt'); else echo 'Ошибка';
 $ex = $_POST['line'];
 $opis_f = file_get_contents('forum/'.trim($post[$ex]).'/opiskat.txt');
 $mess1 = $opis_f;
 include('flud/anti_y.php');
 $opis_f = $mess1;

?>
<span class="ramka">
<form name="" action="" method="post">
Заголовок:<br>
<input name="im_f" type="text" value="<?php echo file_get_contents('forum/'.trim($post[$ex]).'/namekat.txt') ?>"><br>
Описание:<br>
<textarea style="width:100%;" name="opis_f" rows=10 cols=50><?php echo $opis_f ?></textarea>
<br>
<input name="step" type="hidden" value="4">
<input name="line" type="hidden" value="<?php echo $_POST['line'] ?>">
<input name="kat" type="hidden" value="<?php echo $_POST['kat'] ?>">

<input class="knopka" type="submit" value="Редактировать">
</form>
</span>
<?php
}
elseif ($_POST['step'] == 4)
{
    if (($_POST['im_f'] != "") and ($_POST['opis_f'] != "") and ($_POST['kat'] != ""))
    {

        $n = htmlspecialchars(substr($_POST['im_f'],0,150));

        $mess1 = $_POST['opis_f'];
        include('flud/anti_x.php');
        $o = $mess1;

         $n=strtr($n,array
          (
          "|"=>"I",
          "\r\n"=>"<br>",
          )
         );

        $not_rep = file('forum/base/'.trim($_POST['kat']).'.txt');
        $not_rep = trim($not_rep[$_POST['line']]);

        $fp = fopen ('forum/'.$not_rep.'/namekat.txt', "w+");
        fwrite ($fp, stripslashes($n));
        fclose ($fp);

        $fp = fopen ('forum/'.$not_rep.'/opiskat.txt', "w+");
        fwrite ($fp, stripslashes($o));
        fclose ($fp);



     echo '
     <span class="ramka">
     Успешно!
     </span>
      <a href="/adminf.php?m='.$_GET['m'].'&id='.$_GET['id'].'">Далее</a>
     ';

    }
      else
      {
       echo 'Ошибка. Поля не заполнены полностью...';
      }
}
?>