File size: 1Kb
<?php
include "config.php";
include "smileandtegs.php";
$rand=$_POST['rand'];
$browser=$_SERVER['HTTP_USER_AGENT'];
$ip=$_SERVER['REMOTE_ADDR'];
$name = htmlspecialchars($_POST['name']);
$msg=htmlspecialchars($_POST['msg']);
if ($rand!==$_SESSION['myrand'] and strlen($msg)<=500 and strlen($msg)>=4 and strlen($name)>=2 and strlen($name)<=50)
{
$_SESSION['myrand']=$rand;
$_SESSION['name']=$name;
$msg=smile($msg);
$msg=tegs($msg);
if ($linkoff=='Да' or empty($linkoff))
{
$msg=preg_replace("!(http://[\S]+)([\s]|$)!i","<a href=\"\\1\">\\1</a> ",$msg);
}
$msg=str_replace("\r\n","<br/>",$msg);
$msg=str_replace("||","ll",$msg);
if (file_exists("./msg/$id.dat"))
{
$back=file_get_contents("./msg/$id.dat");
}
$file = fopen("./msg/$id.dat","w");
flock ($file,LOCK_EX);
fputs($file,"$name||$browser||$ip||".time()."||$msg||||"."\r\n"."$back");
flock ($file,LOCK_UN);
fclose($file);
}
$site='http://'.$_SERVER['HTTP_HOST'].''.str_replace('send.php','index.php',$_SERVER['PHP_SELF']).'?id='.$id;
header ("Location: $site");
?>