<?php
#-----------------------------------------------------#
#          ********* WAP-MOTORS *********             #
#             Made by   :  VANTUZ                     #
#               E-mail  :  vsem@pizdec.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); 

$text = file("../local/profil/$log.prof"); 
if ($text!=""){
$udata = explode(":||:",$text[0]);
$provlog=trim($udata[0]);
$provpar=trim($udata[1]);}
if (!$_SESSION[log]=="" && !md5($_SESSION[par])=="" && md5($_SESSION[par])==$provpar && $_SESSION[log]==$provlog) {
		


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, time()."|$ip|$php_self|\r\n");
fflush($flood_file);
flock ($flood_file,LOCK_UN);
fclose($flood_file);   
}


$mess = check($mess);
$log = check($log);
$mess=substr($mess,0,1500);


if($trans=="y"){$mess=str_replace($trans1,$trans2,$mess);};
$mess = antimat($mess);
$mess = smiles($mess); 

$mess=base64_encode($mess);
$tex=$log.'|'.$mess.'|'.$currDate.' / '.$currTime.'|'; 
$tex=preg_replace ("|[\r\n]+|si","",$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);  
chmod ($fp, 0666);
chmod (BASEDIR."local/privat/$uz.$config_priv", 0666);



$tex2=$uz.'|'.$mess.'|'.$currDate.' / '.$currTime.'|'; 
$tex2=preg_replace ("|[\r\n]+|si","",$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: ../index.php?isset=mail&".SID); exit;

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

?>