<?
ob_start("ob_gzhandler");
include("../includes/config.php");
include("../lang/arabic.php");
include("../includes/function.php");
include("../includes/online.php");
include("../includes/easytemplate.php");
include("../includes/inquiry.php");
function cheak ($value){
	$value = trim($value);
	$value = strip_tags($value);
	$value = htmlspecialchars($value);
	return($value) ;
		   }
	$sendername = $_POST[yourname];
	$sendername =  cheak($sendername);
    $sendername = iconv('utf-8','windows-1256',$sendername);


	$sendermail = $_POST[yourmail];
	$sendermail = cheak($sendermail);

 	$message = $_POST[message];
    $message = cheak($message);
    $message = iconv('utf-8','windows-1256',$message);

  	function alpha_numeric($str)
	{
		return ( ! preg_match("/^([-a-z0-9])+$/i", $str)) ? FALSE : TRUE;
	}

	function valid_email($str)
	{
		return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
	}

	if ($sendername=='' || strlen($sendername)<3)
	{
		$errors[] = $lang[shortname];
	}

	if ($message=='' || strlen($message)<20)
	{
		$errors[] = $lang[shortmass];
	}


	if (valid_email($sendermail)==FALSE)
	{
		$errors[] = $lang[rongmail];
	}

	if(is_array($errors))
	{
		echo iconv('windows-1256','utf-8','<p ><b>برجاء مراجعة الاخطاء التالية</b></p>');
		while (list($key,$value) = each($errors))
		{

			echo iconv('windows-1256','utf-8','<span class="error">'.$value.'</span><br />');

		}
	}
	else {

    if(isset($_COOKIE[trcontactus])){
     echo iconv('windows-1256','utf-8','<span class="error">عفوا لقد قمت بارسال رسالة منذ قليل</span><br />');
    }else{


   // بريد الصديق;
	$to = $sitemail;
	//عنوان الرسالة
	$subject = $lang[msub];
    //محتوي الرسالة
    $body = $message;




  # Common Headers

$to= $sitemail;
$subject= $lang[msub];


		$headers = "From: $sendername <$to>\r\nReply-To: $sendermail\r\n";
		$headers .= "X-Sender: <$sendermail>\n";
		$headers .= "X-Mailer: PHP\n";
		$headers .= "Return-Path: <$sendermail>\n";

//الان سنقوم بعملية الإرسال
$mas = mail($to,$subject,$subject,$headers);

	if ($mas){
	@setcookie('trcontactus',$subject,time()+300);
 	echo iconv('windows-1256','utf-8','<p ><b>تم ارسال رسالتكم بنجاح</b></p>');
	}else{
	echo iconv('windows-1256','utf-8','<span class="error"><p ><b>عفوا هناك مشكلة بارسال الرسالة</b></span></p>');
	}

     }




	}
 ob_end_flush();
?>
