<?
@session_start();

$title="Связь с администрацией сайта";

$bp="../";
$base_path="../";

require_once($base_path.'connect/connect.php');
include_once($base_path.'lib/lib.php');
include_once($base_path.'connect/_svod_rec.php');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?=$title?></title>
<link rel="shortcut icon" href="<?=$bp?>icon/favicon.ico" type="image/x-icon">
<meta name="Author" content="aikuvshinov@mail.ru, http://script-ks.narod.ru" />
<link rel="stylesheet" type="text/css" href="<?=$base_path?>style/style.css" />
<link rel="stylesheet" type="text/css" href="<?=$bp?>style/jquery.fancybox.css" media="screen" />

<script type="text/javascript" charset="utf-8" src="<?=$base_path.'js/'?>jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?=$bp.'js/'?>jquery.easing.1.3.js"></script>
<script type="text/javascript" src="<?=$bp.'js/'?>jquery.fancybox-1.2.1.pack.js"></script>
<script type="text/javascript" src="<?=$bp.'js/'?>fancy.js"></script>

<![if !IE]>
<?
if($rru['round'])
{
?>
<script type="text/javascript" src="<?=$base_path.'js/'?>jquery.corner.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".imground").corner("round");
$(".submit").corner("round");
$(".str").corner("round");
});
</script>
<?
}
?>
<![endif]>


</head>
<BODY 
style="MARGIN: 0px auto; POSITION: inherit; width: 1000px">

<?
include_once($base_path."blok/top_form.php"); 
?>


<table class="table" width="100%">
	
	<tr>
		<td valign="top">
		<?
		if($_POST['Submit'])
			{
			if(!$_SESSION['ID_Glob'] && !$_SESSION['ID_P'])
				{
				$cap_a = trim($_POST['cap']);
				if(!$cap_a)
				$err .= 'Не указан защитный код<br>';
				else
					{
					if($_SESSION['real_code'] != $cap_a)
					$err .= 'Неверно указан защитный код<br>';
					else
						{
						$cap_a = number_format($cap_a,0,"",",");
						$cap_b = $_POST['ip_address'];
						if($cap_a!=$cap_b) $err .= 'Неверно указан защитный код<br>';
						}
					}
				if(isset($_SESSION['real_code'])) unset($_SESSION['real_code']);
				}
	
	
			$send_email=trim($_POST['send_email']);
			if(!$send_email)
			$err .= "Не указан e-mail<br>";
			elseif (! _email($send_email))
			$err .= "Некорректный e-mail<br>";

			$them1=_pre2($_POST['them']);
			$them=$them1[1];
			if(!$them)
			$err .= "Не указана тема сообщения<br>";
			
			$message1=_pre2($_POST['message']);
			$message=$message1[1];
			if(!$message)
			$err .= "Не указан текст сообщения<br>";
	
			if(!$err)
				{
				if (@mail_utf8($rru['email'], $them, $message, $send_email)) 
				$otpr='<font color=green>Ваше сообщение успешно отправлено</font> ';
				else
				$otpr='<font color=red>Не удалось отправить Ваше сообщение<br>Попробуйте повторить позже</font> ';
				}
			}

	if($err)
	echo '<p><font color=red>'.$err.'</font></p>';
	elseif($otpr) echo '<p>'.$otpr.'</p>';

	
	
	if($otpr)
		{
		$send_email='';
		$them='';
		$message='';
		}

	?>
	<form name="form1" method="post" action="">
	<font size=+1 color=red>*</font> Ваш e-mail
	<br>
	<input size="30" type="text" name="send_email" value="<?=$send_email?>">
	<br>
	<font size=+1 color=red>*</font> Тема письма
	<br>
	<input size="30" type="text" name="them" value="<?=$them?>">
	<br>
	<font size=+1 color=red>*</font> Текст письма
	<br>
	<textarea name="message" cols="50" rows="9"><?=$message?></textarea>
	<br>
	<? 
	if(!$_SESSION['ID_Glob'] && !$_SESSION['ID_P'])
		{
		//$font_name[] = array(18, "../blok/new1.ttf"); 
		$font_name[] = array(18, "../blok/new2.ttf"); 
		//$font_name[] = array(20, "../blok/new3.ttf"); 
		//$font_name[] = array(22, "../blok/new4.ttf"); 
		shuffle($font_name);
	
		$m_rand1=1005;
		$m_rand2=9991;
		$cap_img='../tmp_capcha/'.ip2long($_SERVER['REMOTE_ADDR']).'.jpg';
		@mt_srand(time());
		
			$cap_int=mt_rand($m_rand1,$m_rand2);
			$_SESSION['real_code']=$cap_int;
			if($typ_captcha && function_exists('cifr'))
			cifr($cap_int, $cap_img);
			else
				{
				$cap_str=code($cap_int);
				$im=imagecreate(470, 26);
				imagecolorallocate($im,255,255,255);
				$color=imagecolorallocate($im,100,100,100);
				@imagettftext($im, $font_name[0][0], 0, 0, 19, $color, $font_name[0][1], $cap_str);
				imagejpeg($im, $cap_img);
				imagedestroy($im);
				}
		
		echo '<img border="0" src="'.$cap_img.'?id='.time().'">';
		?>
		<br>
		<font size=+1 color=red>*</font> Введите защитный код цифрами 
		<input type="text" size=10 name="cap" id="cap" value="">
		<?
		}
		?>
	<input type="hidden" name="ip_address" id="ip_address" value="<?=$_SERVER['REMOTE_ADDR']?>">
	<br>
	<input class="submit" type="submit" name="Submit" value="Отправить" >
	</form>
	<?

	?>

<script type="text/javascript" charset="utf-8" src="../js/tb.js"></script>
		
		</td>
	</tr>
	
	
	<tr>
		<td>
		<?
		include_once($base_path."blok/bottom_form.php"); 
		?>
		</td>
	</tr>
	
</table>

</body>
</html>