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

Размер файла: 4.9Kb
<?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($cms.'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($cms.'forum/base/'.trim($_POST['kat']).'.txt')) $post = @file($cms.'forum/base/'.trim($_POST['kat']).'.txt'); else echo 'Ошибка';

 $count_post = count($post);

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

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


 echo '

 <table
 style="width: 100%; text-align: left; margin-left: auto; margin-right: auto;"
 border="0" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td style="text-align: left; vertical-align: top;"><span class="mess1">'.file_get_contents($cms.'forum/'.trim($post[$j]).'/namekat.txt').'</span> <span class="mess2">'.file_get_contents($cms.'forum/'.trim($post[$j]).'/opiskat.txt').'</span>   </td>
      <td style="width: 55px; text-align: right; vertical-align: top;">
      <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></td>
    </tr>
  </tbody>
 </table>
      <br />


     ';


 }
			$all = ceil($count_post/$st_r);
			 echo '<table><tr>';
			 for ($i=1;$i<=$all;$i++)
			 {
			     if ($pages==$i) {
			        echo '<td><b class="knopka">'.$i.'</b></td>';
			     }
			     else
			     {
			        echo '<td>
			        <form name="" action="" method="post">
			        <input name="kat" type="hidden" value="'.$_POST['kat'].'">
                    <input type="submit" class="knopka" value="'.$i.'">
                    <input name="fapages" type="hidden" value="'.$i.'">
                    </form>
			        </td>';
			     }
             }
             echo '</tr></table>';
}
elseif ($_POST['step'] == 3)
{
 if (is_file($cms.'forum/base/'.trim($_POST['kat']).'.txt')) $post = @file($cms.'forum/base/'.trim($_POST['kat']).'.txt'); else echo 'Ошибка';
 $ex = $_POST['line'];
 $opis_f = file_get_contents($cms.'forum/'.trim($post[$ex]).'/opiskat.txt');
 $mess1 = $opis_f;
 include($cms.'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($cms.'forum/'.trim($post[$ex]).'/namekat.txt') ?>"><br />
Описание:<br />
<?php
		include($cms.'flud/js/bb.php');
		include($cms.'flud/js/smyle.php');
		$ms_pol = 'opis_f';
		include($cms.'flud/js/smyler.php');
		$ms_pol = 'opis_f';
		include($cms.'flud/js/bber.php');?>
<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($cms.'flud/anti_x.php');
        $o = $mess1;

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

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

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

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



     echo '
     <span class="ramka">
     Успешно!
     </span>
     <META HTTP-EQUIV="Refresh" CONTENT="1;">
     ';

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