<?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";

$uz=check($uz); 


if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!=""){
		
if($uz==""){header ("Location: privat.php?action=submit&isset=nouz&uz=$uz&".SID); exit;}
if($uz==$log){header ("Location: privat.php?action=submit&isset=noprivlog&uz=$uz&".SID); exit;}

$str=strlen($mess);
if($mess=="" || $str<6){header ("Location: privat.php?action=submit&isset=nomess&uz=$uz&".SID); exit;}

$proverka = file("../local/profil/$uz.prof"); 
$ster=strlen($uz);
if (empty($proverka) || $ster<1){
{header ("Location: privat.php?action=submit&isset=nouzer&".SID); exit;}	
} else {

$filesize= filesize("../local/privat/$uz.$config_priv");
$filesize=round($filesize/1024,2);
$pers=round($filesize*100/$config_limitsmail);
if($pers>="99"){header ("Location: privat.php?action=submit&isset=fullmail&uz=$uz&".SID); exit;}


$iglines=file("../local/dataignor/$uz.dat");
$igcount=count($iglines);
for ($ign=0; $ign<$igcount; $ign++) { 
list(,$igbase)=explode("|",$iglines[$ign]); 
if ($log == $igbase) {$result="ok"; }}
if($result=="ok"){header ("Location: privat.php?action=submit&isset=ignoring&uz=$uz&".SID); exit;}


 //--------------------- Новый антифлуд -----------------------------//
if($config_floodstime > 0){
if(flooder($ip, $php_self) == TRUE ){header ("Location: privat.php?action=submit&isset=antiflood&uz=$uz&".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);   
}


$mess = check($mess);
$log = check($log);
$mess = utf_substr($mess,0,1000);

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

$mess=base64_encode($mess);
$tex=$log.'|'.$mess.'|'.$sitetime.'|'; 
$tex=no_br($tex);


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

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

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

$fp=fopen(BASEDIR."local/privat/$uz.$config_priv","a+");  
flock ($fp,LOCK_EX);                                                              
fputs($fp,"$tex\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);  


$tex2=$uz.'|'.$mess.'|'.$sitetime.'|'; 
$tex2=no_br($tex2);

$fp=fopen(BASEDIR."local/dataoutput/$log.$config_priv","a+");  
flock ($fp,LOCK_EX);                                                              
fputs($fp,"$tex2\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);  
chmod ($fp, 0666);
chmod (BASEDIR."local/dataoutput/$log.$config_priv", 0666);

$file=file(BASEDIR."local/dataoutput/$log.$config_priv"); 
$i = count($file);
if ($i>=20) {
$fp=fopen(BASEDIR."local/dataoutput/$log.$config_priv","w");
flock ($fp,LOCK_EX);
unset($file[0]);
fputs($fp, implode($file));
flock ($fp,LOCK_UN);
fclose($fp);
}


header ("Location: privat.php?isset=mail&".SID); exit;

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

?>