<?php
#-----------------------------------------------------#
#          ********* WAP-MOTORS *********             #
#             Made by   :  VANTUZ                     #
#               E-mail  :  visavi.net@mail.ru         #
#                 Site  :  http://pizdec.ru           #
#             WAP-Site  :  http://visavi.net          #
#                  ICQ  :  36-44-66                   #
#  Вы не имеете право вносить изменения в код скрипта #
#-----------------------------------------------------#	
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/gzip.php";
require_once"../template/header.php";

$id=(int)$id;

if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!=""){
 	 
$str=strlen(trim($msg));
if($msg=="" || $str<6){
header ("Location: komm.php?id=$id&isset=posts&".SID); exit;}

 //--------------------- Новый антифлуд -----------------------------//
if($config_floodstime > 0){
if(flooder($ip, $php_self) == TRUE ){header ("Location: komm.php?id=$id&isset=antiflood&".SID); exit;}
$flood_file = fopen(BASEDIR."local/flood.dat", "a+");
flock ($flood_file,LOCK_EX);
fputs ($flood_file,"$sitetime|$ip|$php_self|\r\n");
fflush($flood_file);
flock ($flood_file,LOCK_UN);
fclose($flood_file);   
}

//--------------------- Карантин -----------------------------//

if($config_karantin > 0){
if($udata[6]+$config_karantin>$sitetime){header ("Location: komm.php?id=$id&isset=karantin&".SID); exit;}
}

$brow=check($brow);
$msg=substr($msg,0,1000);
$msg=check($msg);
$msg=preg_replace ("|[\r\n]+|si","<br>",$msg);

if($trans=="y"){$msg=transliter($msg);}
$msg = antimat($msg);
$msg = smiles($msg);


$file = file("../local/datakomm/$id.dat");
$total = count($file);
$total = $total - 1;

$data1 = explode("|",$file[$total]);
$me=$data1[5]+1;

//////////////////////////////////////////////////////////////////////////////////////
$text=$brow.', '.$ip.'|'.$msg.'||'.$sitetime.'|'.$log.'|'.$me.'|';
$text=preg_replace ("|[\r\n]+|si","",$text);

$fp=fopen("../local/datakomm/$id.dat","a+");
flock ($fp,LOCK_EX);
fputs ($fp,"$text\r\n");
flock ($fp,LOCK_UN);
fclose ($fp);
chmod ($fp, 0777);
chmod ("../local/datakomm/$id.dat", 0777);

/////////////////////////////////////
$f = file("../local/local.dat"); 
$u = explode("|",$f[0]);
$u[3]++;
$t=$u[0].'|'.$u[1].'|'.$u[2].'|'.$u[3].'|'.$u[4].'|'.$u[5].'|'.$u[6].'|'.$u[7].'|'.$u[8].'|'.$u[9].'|'.$u[10].'|';

$fp = fopen("../local/local.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
fputs($fp,$t);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
///////////////////////////

$file=file("../local/datakomm/$id.dat"); $i = count($file);
if ($i>=$config_maxpostnews) {
$fp=fopen("../local/datakomm/$id.dat","w");
flock ($fp,LOCK_EX);
unset ($file[0]);
fputs ($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose ($fp);
chmod ($fp, 0777);
chmod ("../local/datakomm/$id.dat", 0777);
}


//------------------------------ Запись в профиль ----------------------------//
$ufile = file(BASEDIR."local/profil/$log.prof"); 
$udata = explode(":||:",$ufile[0]);

$udata[14]=$ip;
$udata[33]++;
$udata[36]++;
$udata[41]++;

for ($u=0; $u<$config_userprofkey; $u++){
$utext.=$udata[$u].':||:';}

if(!empty($udata[0]) && !empty($udata[1])){
$fp=fopen(BASEDIR."local/profil/$log.prof","a+");    
flock($fp,LOCK_EX);           
ftruncate($fp,0);                                                                
fputs($fp,$utext);
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);  
unset($utext); 
} 

header ("Location: komm.php?id=$id&isset=addon&".SID);
}else {
header ("Location: ../index.php?isset=inputoff&".SID); exit;}
?>
