<?php

/* FIRESHOP: Advanced Content Market System                         */

/* ============================================                         */

/*                                                                      */

/* Copyright (c) 2012 by Mohamad Porhaji                                */

/* http://Firedesign.ir                                                   */

/*                                                                      */

/* This program is free software.  */

/************************************************************************/

/* $Id: contact.php,v 1.0.0.1 2012/02/18 By Mohamad Porhaji $ */
require_once("mainfile.php");
global $db;

$title_page_over="ارتباط با ما";
$page_title = "ارتباط با ما";

function content()

{global $db;
if(isset($_POST['s_contact'])){

if(empty($_POST['name'])
or empty($_POST['title'])
or empty($_POST['des'])
or empty($_POST['RashCMS']))
{
print('  پركردن همه ي فيلد ها الزامي است  <a href="javascript:history.go(-1)">بازگشت</a>');
}else{
$RashCMS = sql_quote(@$_POST['RashCMS']);
if( @$_SESSION['rash_secimg'] !== $RashCMS) {

        echo"كد امنيتي اشتباه است <a href='javascript:history.go(-1)'>بازگشت</a>";
        }else{
        $randcode =rand(1000,1000000000);
        $_SESSION['rash_secimg'] = $randcode;


$name=$_POST['name'];
$title=$_POST['title'];
$email=$_POST['email'];
$des=$_POST['des'];
$tel=$_POST['tel'];
$ip = @$_SERVER['REMOTE_ADDR'];
$time_stamp= time();
include("includes/jdate.php");
$today = jdate(" d /m /13y");
$dater = $today;


$query = $db->sql_query("INSERT INTO fireshop_contact (`name`, `email`, `tel`, `ip`, `title`, `des`, `date`, `time_stamp`) VALUES ('$name', '$email', '$tel', '$ip', '$title', '$des', '$dater', '$time_stamp')");if($query){
print('<div class="contact_active">پيام شما با موفقيت ارسال گرديد</div>');
$dataq = $db->sql_query("SELECT * FROM fireshop_contact WHERE email='$email' AND ip='$ip' AND date='$dater' AND des='$des' AND time_stamp='$time_stamp' ") or die(mysql_error());
$mdata = $db->sql_fetchrow($dataq);
        $time_stamp                        = $mdata['time_stamp'];
        $id                        = $mdata['id'];
echo"
<div class='warper'><br/><br/>
كد رهگيري زير را يادداشت كنيد و براي پيگيري و دريافت پاسخ از اين كد استفاده كنيد
<br/>
<div align='center' dir='rtl' style='padding:10px'>
<table style='background-color: #333333; font-family: tahoma; font-size: 11px; text-decoration: none; color: #CCCCCC'>
<tr>
<td style='width: 90px;border-left-style: solid; border-left-width: 1px; border-left-color: #cccccc;'>
شماره تماس </td>
<td style='width: 300px;'>&nbsp;  
كد رهگيري </td>
</tr>
</table>
<table style='background-color: #CCCCCC; font-family: tahoma; font-size: 11px; text-decoration: none; color: #333333'>
<tr>
<td style='width:90px;border-left-style: solid; border-left-width: 1px; border-left-color: #ffffff;'>
$id 
</td>
<td style='width:300px;border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>&nbsp;
$time_stamp
</td>
</tr>
</table>

</div>

<br/>
</div>
";


}else{
print('<div class="failed"><div class="MsgBody">'.$lang["Error"].'</div></div>');
}


}
}
}else{

echo"
<form action='contact.php' method='post'>
<div align='right' style='padding:10px'>
<br/><br/>
<div style='float:right;width:110px' for=\"name\">نام و نام خانوادگي : <span style='color: red'>*</span></div>
<div style='float:right;'><input type='text' name=\"name\" size='30' style='height: 20px'/></div><div class='clear'></div><br/>

<div style='float:right;width:110px' for=\"name\">تلفن همراه  : </div>
<div style='float:right;'><input type='text' name='tel' size='30' style='height: 18px'/></div><div class='clear'></div><br/>

<div style='float:right;width:110px' for=\"name\">ايميل  : </div>
<div style='float:right;'><input type='text' name='email' size='30' style='height: 18px'/></div><div class='clear'></div><br/>

<div style='float:right;width:110px' for=\"name\">عنوان پيام  : <span style='color: red'>*</span></div>
<div style='float:right;'><input type='text' name='title' size='30' style='height: 18px'/></div><div class='clear'></div><br/>

<div style='float:right;width:110px' for=\"name\">متن پيام  : <span style='color: red'>*</span></div>
<div style='float:right;'><textarea type='text' name='des'  style='width: 250px; height: 80px'></textarea></div><div class='clear'></div><br/>

<div style='float:right;width:110px' for=\"name\">كد امنيتي  : <span style='color: red'>*</span> </div>
<div style='float:right;'><img id='imagerash' border='0' src='img.php'>  <input type='text' name='RashCMS' size='27' style='height: 18px'/></div><div class='clear'></div><br/><br/>

<input type='submit' name='s_contact' value='ارسال' />
</form><div class='clear'></div>
";
$sql = $db->sql_query("SELECT * FROM fireshop_general where id='1'");
$row = $db->sql_fetchrow($sql);
$site_title=$row['site_title'];
$site_url = $row['site_url'];
$tel  = $row['tel'];
$adress   = $row['adress'];
$mail  = $row['mail'];
echo"<br/><table width='100%'  cellspacing='0' cellpadding='10' id='invoicetoptables'><tr><td id='invoicecontent' valign='top' style='border:1px solid #cccccc'>

<strong>اطلاعات تماس با فروشگاه</strong><br />
آدرس فروشگاه : $adress<br />
تلفن : $tel | 
آدرس اينترنتي : $site_url   <br/>
پست الكترونيك : $mail
</td></tr></table></div>
";


}

}
theme();
?>