<?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/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";

require_once"../template/isset.php";   
    
$text = file("../local/profil/$log.prof"); 
if ($text!=""){
$udata = explode(":||:",$text[0]);
$provlog=trim($udata[0]);
$provpar=trim($udata[1]);
$my_mail=trim($udata[4]);}

echo '<img src="../images/img/mails.gif" alt=""> <b>Письмо Администратору</b><br><br>';

if ($action=="go"){
if(!empty($name)){
if(!empty($body)){
if(eregi("^[a-z0-9\._-]+@[a-z0-9\._-]+\.[a-z]{2,4}\$", $umail)){
if($_SESSION['mail_kod']==$provkod){	
  
$_SESSION['mail_kod'] ="";

if($trans=="y"){$body=transliter($body);}

$now= date("d-m-Y");
$curr=date("H:i:s", time());

$subject = 'Письмо с сайта '.$config_title;
$mail = "Ip: $ip \r\nБраузер: $brow \r\nОтправлено: $now ($curr)\r\n\r\nСообщение: ";
$subject = utf_to_win($subject);
$body = utf_to_win($body);
$body=substr($body,0,3000);
$name = utf_to_win($name);
$mail = utf_to_win($mail);
$mail=substr($mail,0,3000);

$name=check($name);
$body=check($body);


$body = "$mail \r\n$body";
$name = convert_cyr_string($name, 'w','k');
$subject = convert_cyr_string($subject, 'w','k');
$body = convert_cyr_string($body, 'w','k');

$subject = '=?KOI8-R?B?'.base64_encode($subject).'?=';

$adds = "From: \"".$name."\" <".$umail.">\r\n"; 
$adds .= "X-sender: \"".$name."\" <".$umail.">\r\n";
$adds .= "Content-Type: text/plain; charset=koi8-r\r\n";   
$adds .= "MIME-Version: 1.0\r\n";
$adds .= "Content-Transfer-Encoding: 8bit\r\n";
$adds .= "X-Mailer: PHP v.".phpversion();


mail($config_emails,$subject,$body,$adds);

header ("Location: ../index.php?isset=mail&".SID);

}else{header ("Location: index.php?isset=noprovkod&".SID);}
}else{header ("Location: index.php?isset=noemail&".SID);}
}else{header ("Location: index.php?isset=nobody&".SID);}
}else{header ("Location: index.php?isset=noname&".SID);}
}



//------------------------ Главная страница --------------------------//
if(!isset($action)){

if(empty($_SESSION['mail_kod'])){
$mail_kod=rand(1000,9999);
$_SESSION['mail_kod'] = $mail_kod;}

if($config_themes!="wml"){
echo '<form method="post" action="index.php?action=go&amp;'.SID.'">';

if ($_SESSION['log']=="" || md5($_SESSION['par'])=="" || md5($_SESSION['par'])!=$provpar || $_SESSION['log']!=$provlog ) {	
echo 'Ваше имя:<br><input name="name" maxlength="20" /><br>';
echo 'Ваш email:<br><input name="umail" maxlength="50" /><br>'; 

} else {
	
echo '<input name="name" type="hidden" value="'.$log.'" />';
echo '<input name="umail" type="hidden" value="'.$my_mail.'" />'; 
}


echo 'Сообщение:<br><textarea cols="25" rows="3" name="body"></textarea><br>';

if($config_translit=="1"){
echo 'Транслит: <input name="trans" type="checkbox" value="y" /><br>';}

echo 'Проверочный код: <b>'.$mail_kod.'</b><br><input name="provkod" maxlength="6" /><br><br>';
	
	
echo '<input value="Отправить" name="go" type="submit" /></form><hr>';

} else {
	
if ($_SESSION['log']=="" || md5($_SESSION['par'])=="" || md5($_SESSION['par'])!=$provpar || $_SESSION['log']!=$provlog ) {		
echo '<br>Ваше имя:<br><input name="name" maxlength="20"/><br>';	
echo 'Ваш email:<br><input name="umail"/><br>';}

echo 'Сообщение:<br><input name="body" maxlength="5000"/><br>';	
if($config_translit=="1"){
echo 'Транслит: <select name="trans"><option value="0">Нет</option>';
echo '<option value="y">Да</option></select><br>';}
echo 'Проверочный код: <b>'.$mail_kod.'</b><br><input name="provkod" maxlength="6"/><br>';


echo '<anchor>Написать';
echo '<go href="index.php?action=go&amp;'.SID.'" method="post">';

if ($_SESSION['log']=="" || md5($_SESSION['par'])=="" || md5($_SESSION['par'])!=$provpar || $_SESSION['log']!=$provlog ) {
echo '<postfield name="name" value="$(name)"/>';
echo '<postfield name="umail" value="$(umail)"/>';
}else{
echo '<postfield name="name" value="'.$log.'"/>';
echo '<postfield name="umail" value="'.$my_mail.'"/>';	
}
echo '<postfield name="body" value="$(body)"/>';
echo '<postfield name="trans" value="$(trans)"/>';
echo '<postfield name="provkod" value="$(provkod)"/>';
echo '<postfield name="go" value="go"/>';
echo '</go></anchor><br>--------------------<br>';
}}


echo'<br><img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a><br>';
include_once "../themes/$config_themes/foot.php";
?>