View file mod/post/save_post.php

File size: 1.82Kb
<?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>",
    '\"'=>'"',
    '\&quot;'=>'"',
    "\\'"=>"'",
    ));

     // Смайлы
      $_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/post/count.txt", "r");

if ($_POST['mess'] != "")
{
//count
$count = fread($fp,filesize("mod/post/count.txt"));
fclose ($fp);
$count++;
$fp = fopen ("mod/post/count.txt", "w");
fwrite ($fp, $count);
fclose ($fp);
//text
$fp = fopen ("mod/post/p/post.txt", "a");
fwrite ($fp, "$_POST[name]|$_POST[date]|$_POST[mess]\r\n");
fclose ($fp);
echo 'Сохранено';
}
else
{
echo 'Неверная длина сообщения.';
};
echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=/?pg='.$pg.'">';








?>