<?php
include'login.php';
$zag='Гостевая';
include'head.php';
include'functions.php';
include'del_ip.php';
print'<small>';
##########################################
$banusr='no';
$s='ok';
if($id){
$name=$usr[0];
if($usr[4]==2 || $usr[4]==3){
$mail=$usr[2];}
if($usr[4]==1 || $usr[4]==3){
$site=$usr[3];}}
##Во избежание ошибок...
if(empty($mail)){$mail='';}
if(empty($site)){$site='';}
##########################################
if($id){
if(empty($usr[7])){
$banusr='no';
} else {$banusr='yes';}
}
$banlist=banlist($HTTP_USER_AGENT,$REMOTE_ADDR,$bandir);
if(!empty($banlist) && $banusr=='yes'){
if($usr[7]>intval($banlist)){
$banlist=$usr[7];} else {
$usr[7]=$banlist;}}
$a=explode('/',$HTTP_USER_AGENT);
$a=htmlspecialchars(stripslashes($a[0]));
if(!empty($digits)){
if(file_exists('antispam/'.$REMOTE_ADDR.'-'.$a.'.dat')){
if(filesize('antispam/'.$REMOTE_ADDR.'-'.$a.'.dat')!=0){
$file=file('antispam/'.$REMOTE_ADDR.'-'.$a.'.dat');
$file=trim($file[0]);
@unlink('antispam/'.$REMOTE_ADDR.'-'.$a.'.dat');
} else {$file='';}
} else {$file='';}
$digits=intval($digits);
if(md5($digits)==$file){
if(empty($banlist)){
if($banusr=='no'){
if(!empty($name)){
$chk=checkusr($udir,$name);
if(empty($chk) || $id){
if(eregi('^[а-яА-ЯA-Za-z0-9.\-]',$name)){
if(!empty($postmess)){
if(strlen(utf2cyr($name))<=10 && strlen(utf2cyr($postmess))<=200){
##AntiFlood))#############################
$post='';
$ant=opendir($mdir);
while($r=readdir($ant)){
if(is_file($mdir.'/'.$r)){
$prov=file($mdir.'/'.$r);
$prov=explode('#',$prov[0]);
if($prov[0]==$name && $prov[1]==$postmess){
$post='error';
}
}
}
closedir($ant);
##BoDY#################################
if($post!='error'){
if(empty($site) || eregi('^[A-Za-z0-9.\-]{1,26}\.[a-zA-Z0-9]{2,4}$',$site)){
if(empty($mail) || eregi('^[A-Za-z0-9.\-]{1,15}@[A-Za-z0-9.\-]{1,20}\.[a-z]{2,4}$',$mail)){
$postmess=htmlspecialchars(stripslashes($postmess));
$ip=$REMOTE_ADDR;
$agent=htmlspecialchars(stripslashes($HTTP_USER_AGENT));
$agent=str_replace('$','$$',str_replace('#','',$agent));
$postmess=trim(ereg_replace('#(#)*','<br/>',$postmess));
$postmess=str_replace('$','$$',$postmess);
if(!empty($tr)){
$trans1= array("JO","ZH","CH","SH","SCH","JE","JY","JA","jo","zh","ch","sh","sch","je","jy","ja","A","B","V","G","D","E","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","C","Y","a","b","v","g","d","e","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h","c","'","y");
$trans2= array("Ё","Ж","Ч","Ш","Щ","Э","Ю","Я","ё","ж","ч","ш","щ","э","ю","я","А","Б","В","Г","Д","Е","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ы","а","б","в","г","д","е","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ь","ы");
$postmess=str_replace($trans1,$trans2,$postmess);
}
$write="$name#$postmess##$mail#$site#$agent#$ip";
$fp=fopen($mdir.'/'.$time.'.mess','w');
fputs($fp,$write);
fclose($fp);
if($id){
$usr[6]++;
$imp=implode('#',$usr);
$pr=fopen($udir.'/'.$id.'.usr','w');
fputs($pr,$imp);
fclose($pr);
}
print'Сообщение успешно добавлено!';
} else {print htmlspecialchars(stripslashes($name)).', вы неверно ввели E-Mail'; $s='err';}
} else {print htmlspecialchars(stripslashes($name)).', вы неверно ввели свой сайт!'; $s='err';}
} else {print htmlspecialchars(stripslashes($name)).', вы уже писали это сообщение!'; $s='err';}
} else {print 'Ошибка! Ваш ник должен содержать до 10 символов, а сообщение - до 200 символов.'; $s='err';}
} else {print htmlspecialchars(stripslashes($name)).', вы забыли ввести сообщение!'; $s='err';}
} else {print 'Ошибка! Ваш ник содержит плохие символы'; $s='err';}
} else {print 'Для использования этого ника необходимо авторизоваться'; $s='err';}
} else {print 'Вы забыли ввести свой ник!'; $s='err';}
} else {print 'Вы будете разбанены через '.(ceil(($usr[7]-$time)/60)).' минут'; $s='err';}
} else {print 'Вы будете разбанены через '.(ceil((intval($banlist)-$time)/60)).' минут'; $s='err';}
} else {print 'Неверное число с картинки'; $s='err';}
} else {print 'Введите число с картинки!'; $s='err';}
##THE END####################################
print'<br/>-----<br/>';
if($s=='err'){
print'<-<a href="say.php?id='.$id.'&ps='.$ps.'">Назад</a><br/>';}
print'
<--<a href="./?id='.$id.'&ps='.$ps.'">Гостевая</a><br/><---<a href="../">Главная</a>';
print'</small>';
print $endwml;
?>