Файл: postnewmsg.php
Строк: 35
<?php
include 'config.php';
include 'functions.php';
if (!empty($_SESSION['rand']) and !empty($status))
{
$_SESSION['rand']='';
$_SESSION['text']='';
if (empty($_POST['refresh']))
{
$mes=$_POST['mes'];
$mes=substr($mes,0,1500);
if (empty($mes)) {
include 'head.php';
echo 'Нужно заполнить форму!<br/>'; exit($end); }
$mes=bb_code($mes);
$mes=smile($mes);
$time=time();
$brows=$_SERVER['HTTP_USER_AGENT'];
$ip=$_SERVER['REMOTE_ADDR'];
if (!empty($id)) {
$user=$id; } else {
$user=$nick; }
$mes_id=newmes();
$buff=@file_get_contents("msg.dat");
$fopen=fopen("msg.dat","w");
fputs($fopen,"$mid#/#/#$mes_id#/#/#$user#/#/#$time#/#/#$brows#/#/#$ip#/#/#$mes#/#/#rn"."$buff");
fclose($fopen);
$file=file('users.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($ex[0]==$id)
{
$post=trim($ex[6])+1;
$string=str_replace($ex[0].'#/#/#'.$ex[1].'#/#/#'.$ex[2].'#/#/#'.$ex[3].'#/#/#'.$ex[4].'#/#/#'.$ex[5].'#/#/#'.$ex[6].'#/#/#'.$ex[7].'#/#/#'.$ex[8].'#/#/#'.$ex[9].'#/#/#'.$ex[10].'#/#/#'.$ex[11].'#/#/#'.$ex[12].'#/#/#'.$ex[13].'#/#/#'.$ex[14].'',$ex[0].'#/#/#'.$ex[1].'#/#/#'.$ex[2].'#/#/#'.$ex[3].'#/#/#'.$ex[4].'#/#/#'.$ex[5].'#/#/#'.$post.'#/#/#'.$ex[7].'#/#/#'.$ex[8].'#/#/#'.$ex[9].'#/#/#'.$ex[10].'#/#/#'.$ex[11].'#/#/#'.$ex[12].'#/#/#'.$ex[13].'#/#/#'.$ex[14].'',file_get_contents("users.dat"));
$fopen=fopen("users.dat","w");
fputs($fopen,$string);
fclose($fopen);
}
}
$_SESSION['text'].='Ваше сообщение успешно добавлено!<br/>';
}
}
else
{
$_SESSION['text'].='Сообщение не добавлено!<br/>';
}
header("location:index.php?rand=".rand('1111','9999'));
?>