File size: 1.03Kb
<?
session_start();
if(isset($_SESSION['chat_name'])){if(trim($_SESSION['chat_name'])!=""){$chat_log=trim(htmlspecialchars($_SESSION['chat_name']));}}
if(isset($_POST['chat_text'])){$chat_text=trim(htmlspecialchars($_POST['chat_text']));}
$chat_xfile = @file("../data/chat_base.dat");
$chat_st=count($chat_xfile) - 1;
$chat_udata = explode("::",$chat_xfile[$chat_st]);
$chat_p=explode("[priv]",$chat_text);
if(isset($chat_p[1])){$chat_t=$chat_p[2];}else{$chat_t=$chat_text;}
if(isset($chat_text))
{
if(strlen($chat_t)<500 and strlen($chat_t)>3)
{
if(isset($chat_log) and ($chat_t != $chat_udata[1]))
{
$chat_data = date("H:i d.m.Y", time()+3600);
$chat_file = fopen("../data/chat_base.dat", "a+");
$chat_str = "$chat_log::$chat_t::$chat_data::$chat_p[1]::\r\n";
flock($chat_file, LOCK_EX);
fwrite($chat_file, $chat_str);
flock($chat_file, LOCK_UN);
fclose($chat_file);
}
}else{echo"Сообщение слишком длинное или короткое!";}
}
?>