<?php
require 'config.php';
//获取系统信息开始
	$conn = mysql_connect($dbhost, $dbuser, $dbpass);
	mysql_select_db($dbname, $conn);          //选择数据库
	mysql_query("set names gb2312");
	$sql = "SELECT * FROM  `".$qz."setting` LIMIT 1";
	$rs = mysql_query($sql,$conn);
	$sysinfo = mysql_fetch_array($rs);
	$mail = json_decode($sysinfo["mail"],true);
//获取系统信息结束
	
$Filter = require 'filter.php';	//引入键名替换
$turn = array_intersect_key($_POST,$Filter);	//取两个数组里都存在的键名

date_default_timezone_set('PRC');	//调整时差
$ip=$_SERVER["REMOTE_ADDR"];
$from = base64_encode($_SERVER['HTTP_REFERER']);
$data = "";
foreach($turn as $name=>$vaule){	//循环遍历POST过来的信息
    $data .= "【".$Filter[$name]."】：$vaule<br>";
}

$bdata = base64_encode($data);
$sql = "INSERT INTO `$dbname`.`".$qz."order` (`id` ,`content` ,`from` ,`ip` ,`time`)VALUES (NULL ,'".$bdata."' ,'".$from."' ,'".$ip."','".time()."');";
$status = mysql_query($sql);
mysql_close($conn);

//发送邮件开始
if($status && $mail["state"]=="true"){
 	require_once ('class/email.class.php'); 
	$smtp = new smtp($mail["server"],25,true,$mail["account"],$mail["password"]);	//这里面的一个true是表示使用身份验证,否则不使用身份验证. 
	$smtp->debug = false;//是否显示发送的调试信息 
	$mailsubject = "SmSoft单网页系统";//邮件主题 
	$mailbody = $data;//邮件内容 
	$mailtype = "HTML";//邮件格式（HTML/TXT）,TXT为文本邮件 
	@$smtp->sendmail($mail["recaccount"], $mail["account"], $mailsubject, $mailbody, $mailtype);
}
//发送邮件结束

//订单提交完毕之后在下面写代码
if($status){
	echo '<script>alert("订单提交成功");history.go(-1);</script>';
}else{
	echo '信息提交失败,请重试';
}


?>