<?php
// форматирование
$_POST['mess'] = substr($_POST['mess'],0,150);
$_POST['mess'] = htmlspecialchars($_POST['mess']);
$_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>",
'\"'=>'"',
'\"'=>'"',
"\\'"=>"'",
"|","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>",
));
$fp = fopen ("mod/forum/tem/".$t_t_t."count.txt", "r");
if ($_POST['mess'] != "")
{
//count
$count = fread($fp,filesize("mod/forum/tem/".$t_t_t."count.txt"));
fclose ($fp);
$count++;
$fp = fopen ("mod/forum/tem/".$t_t_t."count.txt", "w");
fwrite ($fp, $count);
fclose ($fp);
//text
$fp = fopen ("mod/forum/tem/".$t_t_t."post.txt", "a");
fwrite ($fp, "$_POST[name]|$_POST[date]|$_POST[mess]\r\n");
fclose ($fp);
echo 'Сохранено';
echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=/?pg='.$pg.'&t_t_t='.$t_t_t.'&in_tem=1&p='.$p.'">';
}
else
{
echo 'Неверная длина сообщения.';
};
?>