View file mod/forum/log/save_tem.php

File size: 2.78Kb
<?php
// форматирование
$_POST['mess'] = substr($_POST['mess'],0,2000/*Длинна сообщения*/);
$_POST['mess'] = htmlspecialchars($_POST['mess']);


$_POST['name_tem'] = substr($_POST['name_tem'],0,20/*Длинна заголовка*/);
$_POST['name_tem'] = htmlspecialchars($_POST['name_tem']);


    $name_tem = md5($_POST['name_tem']);


    if (!is_file("mod/forum/tem/".$name_tem."post.txt"))
    {
     $_POST['mess'] = strtr($_POST['mess'],
     array(
     "[b]"=>"<b>",
     "[/b]"=>"</b>",
     "[s]"=>"<s>",
     "[/s]"=>"</s>",
     "[u]"=>"<u>",
     "[/u]"=>"</u>",
     "[c]"=>"<center>",
     "[/c]"=>"</center>",
     "[i]"=>"<i>",
     "[/i]"=>"</i>",
     "[red]"=>"<span style= color:FF0000>",
     "[green]"=>"<span style= color:00B300>",
     "[/color]"=>"</span>",
     "\r\n"=>"<br>",
     '\"'=>'"',
     '\&quot;'=>'"',
     "\\'"=>"'",
     "|","I",
     ));

     // Смайлы
      $_POST['mess'] = strtr($_POST['mess'],
      array(
      ":)"=>"<img src=/mod/forum/smile/1.gif border=0>",
      ":))"=>"<img src=/mod/forum/smile/2.gif border=0></a>",
      ":P"=>"<img src=/mod/forum/smile/3.gif border=0></a>",
      ":("=>"<img src=/mod/forum/smile/4.gif border=0></a>",
      ":(("=>"<img src=/mod/forum/smile/5.gif border=0></a>",
      ":o"=>"<img src=/mod/forum/smile/6.gif border=0></a>",
      "8o"=>"<img src=/mod/forum/smile/7.gif border=0></a>",
      ":*"=>"<img src=/mod/forum/smile/8.gif border=0></a>",
      ":-0"=>"<img src=/mod/forum/smile/9.gif border=0></a>",
      "):("=>"<img src=/mod/forum/smile/10.gif border=0></a>",
      "8-("=>"<img src=/mod/forum/smile/11.gif border=0></a>",

      ));




         if ($_POST['mess'] != "" and $name_tem != "")
         {
          //count

            $fp = fopen ("mod/forum/tem/".$name_tem."count.txt", "w");
			fwrite ($fp, '1');
			fclose ($fp);

			$fp = fopen ("mod/forum/c_tem.txt", "r");
			$count = fread($fp,filesize("mod/forum/c_tem.txt"));
			fclose ($fp);
			$count++;
			$fp = fopen ("mod/forum/c_tem.txt", "w");
			fwrite ($fp, $count);
			fclose ($fp);

			//text
			$fp = fopen ("mod/forum/tem/".$name_tem."post.txt", "a");
			fwrite ($fp, "$_POST[name]|$_POST[date]|$_POST[mess]\r\n");
			fclose ($fp);

			$fp = @fopen ("mod/forum/rasd/".$t_t_t.".txt", "r");
			$temp_temp = @fread($fp,filesize("mod/forum/rasd/".$t_t_t.".txt"));
			fclose($fp);
			$fp = fopen ("mod/forum/rasd/".$t_t_t.".txt", "w");
			fwrite ($fp, "$_POST[name_tem]|$name_tem|$_SESSION[is_name]\r\n".$temp_temp);
			fclose ($fp);
			echo 'Сохранено';

         }

         else
         echo 'Неверная длина сообщения или заголовка.';

  }
  else
  {
   echo 'Тема уже существует.';
  };
 echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=/?pg='.$pg.'&t_t_t='.$t_t_t.'">';








?>