Размер файла: 1.17Kb
<?php
$t=microtime();
session_name('sid');
session_start();
include('db.php');
$enter=@$_SESSION['enter'];
if ($enter=='yes')
{$sess_id=session_id();
include('upline.php');
$room=htmlspecialchars($room); $room==substr($room,0,25);
if(preg_match("/[^\da-zA-Z_1-9]+/",$room))
header("Location: privat.php?sid=$sess_id");
else{
if (!$_POST['mess'])
header("Location: privat.php?sid=$sess_id&room=$room");
else{
if (!file_exists("privat/$room.dat"))
{
$fopen=fopen("privat/$room.dat",'w+');
chmod("privat/$room.dat",0777);
fclose($fopen);
}
$file=file ("privat/$room.dat");
$who=$_SESSION['id'];
$mess=htmlspecialchars($_POST['mess']);
$mess=substr($mess,0,350);
$mess=str_replace("|","",$mess);
$mess=str_replace("\n","",$mess);
$time=time();
$messege="$who||$time||$mess\n";
if (count ($file)<85)
{
$zapis=$messege.file_get_contents("privat/$room.dat");
}
else{
$zapis=$messege;
for ($i=0; $i<84; $i++)
{
$zapis=$zapis.$file[$i];
}
}
$fp=fopen("privat/$room.dat",'w+');
flock($fp,LOCK_EX);
fputs ($fp,$zapis);
flock($fp,LOCK_UN);
fclose ($fp);
header("Location: privat.php?sid=$sess_id&room=$room");
}}
}
?>