View file news/adm/add_news.php

File size: 2.12Kb
  <?php
  Defined('ADMIN_S_S') or die ('Доступ запрещен!!!');
    if ($_POST['pokas'] != 1)
    {
?>
<form name="add_news" action="" method="post">
<input name="id" type="hidden" value="add_news">
<input name="pokas" type="hidden" value="1">
<input name="data" type="hidden" value="<?php echo date("d.m.Y");?>">
Дата:&nbsp;&nbsp; <?php echo date("d.m.Y"); ?><br /><br />
Заголовок:<br>
<input name="titla" type="text" value=""> <br /> <br />
Новость:<br />
<textarea name="news" rows=8 cols=60></textarea>
<input type="submit" value="Добавить">
</form>
<?php
}
else
{
     if ($_POST['titla'] != "" and $_POST['news'] != "")
     {
     $f = fopen('news/log/count.txt',"r");
      $vsego = fread($f, filesize('news/log/count.txt'));
      $vsego = str_replace(')','',$vsego);
      $vsego = str_replace('(','',$vsego);
     $vsego++;
     fclose($f);
     $fp = fopen ("news/nov$vsego.txt", "w+");

      $_POST[news] = str_replace("'","&quot;",$_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]);

     fwrite ($fp, "<?php \r\n");
     fwrite ($fp, "\$titla = '$_POST[titla]';\r\n");
     fwrite ($fp, "\$news = '$_POST[news]';\r\n");
     fwrite ($fp, "\$data = '$_POST[data]';\r\n");
     fwrite ($fp, "\r\n?>");
     fclose ($fp);
     $f = fopen('news/log/count.txt',"w");
      fwrite($f,"($vsego)");

     $fp = fopen ("news/log/posl.txt", "w+");
     fwrite ($fp, $_POST['data']);
     fclose ($fp);
      echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/admin.php?int=news/adm/ind.php">';
     }
     else
     {
     echo 'Одно или оба поля не заполнены.';
     };












};









?>