View file news/adm/red_news.php

File size: 2.51Kb
<?php
Defined('ADMIN_S_S') or die ('Доступ запрещен!!!');

      $fp = fopen ("news/log/count.txt", "r");
      $a = fread($fp, filesize('news/log/count.txt'));
      fclose ($fp);
       $a = str_replace(')','',$a);
       $a = str_replace('(','',$a);
       $a = trim($a);
      if ($a != 0)
      {
        while (is_file("news/nov$a.txt"))
       {
         include ("news/nov$a.txt");
         echo "Дата:<br>&nbsp;$data<br>";
         echo "Заголовок:<br>&nbsp;&nbsp;$titla<br>";
         echo"
         <form name='redakt' action='' method='post'>
         <input name='id' type='hidden' value='red_news'>
         <input name='incl' type='hidden' value='news/nov$a.txt'>
         <input type='submit' value='Редактировать'>
         </form>
         ";
          --$a;
         echo '<hr>';
       };
      }
      else
      {
       echo 'Новостей еще нет.';
      };
      if ($_POST[incl] == "") $_POST[incl] = 'news/nov1.txt';







   if   ($_POST[pokas] != 1)
  {
             include($_POST[incl]);
             $_SESSION[fil] = $_POST[incl];
  ?>
  <a name="red"></a>
   <hr>
   <form name="red_news" action="<?php echo $_SERVER[self]?>" method="post">
   Заголовок:<br />
   <input name="titla" type="text" value="<?php echo $titla ?>"><br />
   Новость:<br />
   <textarea name="news" rows=8 cols=40><?php echo $news?></textarea> <br />
   <input name="id" type="hidden" value="red_news">
   <input name="pokas" type="hidden" value="1">
   <input type="submit" value="Изменить">
   </form>

<?php
 }
 else
 {
      $_POST[news] = str_replace("'","&nbsp;",$_POST[news]);
      $_POST[news] = str_replace("\"","&quot;",$_POST[news]);
      $_POST[news] = str_replace("\\","",$_POST[news]);
      $_POST[news] = str_replace("<","_",$_POST[news]);
      $_POST[news] = str_replace(">","_",$_POST[news]);
      $_POST[news] = str_replace("Java","_",$_POST[news]);
      $_POST[news] = str_replace("java","_",$_POST[news]);
      $_POST[news] = str_replace("Script","_",$_POST[news]);
      $_POST[news] = str_replace("script","_",$_POST[news]);
      $_POST[news] = str_replace("\n","<br>",$_POST[news]);


 $fp = fopen ("$_SESSION[fil]", "w+");
     fwrite ($fp, "<?php \r\n");
     fwrite ($fp, "\$titla = '$_POST[titla]';\r\n");
     fwrite ($fp, "\$news = '$_POST[news]';\r\n");
     fwrite ($fp, "\$data = '$data';\r\n");
     fwrite ($fp, "\r\n?>");
     fclose ($fp);
     echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/admin.php?int=news/adm/ind.php">';
};



?>