<?php
/*************************************************************\
+-------------------------------------------------------------+
| 通灵佛教网在线烧香程序 System                                 |
| Copyright (c) 2003-2010 Alfred China                        |
| All rights reserved.                                        |
+-------------------------------------------------------------+
\*************************************************************/
require_once('../chk.php');
$temp_dir = "../template/netgou";
$temp_img = "../template/".$tplpath."/images";
$form_dir = "..";

$metawords = $netgou["meta_keywords"];
$metaintro = $netgou["meta_descr"];
$titlename = $netgou["web_name"];

if($mode == "add" && $REQUEST_METHOD == "POST"){
	
	$uid = intval($uid);
	$username = addslashes($username);
	
	$sxgp = addslashes($_POST["sxgp"]);
	$sxfoimg = addslashes($_POST["sxfoimg"]);
	$sxname = addslashes($_POST["sxname"]);
	$sxsex = addslashes($_POST["sxsex"]);
	$sxage = addslashes($_POST["sxage"]);
	$sxaddress = addslashes($_POST["sxaddress"]);
	
	$hxgd = addslashes($_POST["hxgd"]);
	
	if($sxname == ''){
		echo "<script language=\"JavaScript\">\r\n"; 
		echo " alert(\"施主名字不能为空，请填写施主名字！\");\r\n"; 
		echo " history.go(-1);\r\n";echo "</script>"; 
		exit; 
		
	}elseif($sxage == ''){
		echo "<script language=\"JavaScript\">\r\n"; 
		echo " alert(\"施主年龄不能为空，请填写施主年龄！\");\r\n"; 
		echo " history.go(-1);\r\n";echo "</script>"; 
		exit; 
		
	}elseif($sxaddress == ''){
		echo "<script language=\"JavaScript\">\r\n"; 
		echo " alert(\"施主地址不能为空，请填写施主地址！\");\r\n"; 
		echo " history.go(-1);\r\n";echo "</script>"; 
		exit; 
	}
		
	$sxshijian = time();
	$sxstatus = "Y";
	$sxip = $REMOTE_ADDR;
	
	db_query("INSERT INTO $sql_tbl[sx] (username, sxname, sxsex, sxage, sxgp, sxfoimg, sxaddress, hxgd, sxip, sxstatus, sxshijian) VALUES ('$username', '$sxname', '$sxsex', '$sxage', '$sxgp', '$sxfoimg', '$sxaddress', '$hxgd', '$sxip', '$sxstatus', '$sxshijian')");
	
	$gdid=mysql_insert_id();
	if($uid && $userinfo){
		$gdtime  = time();
		$gdip  = $REMOTE_ADDR;
		$gdnum = $netgou["gongde_sx"];
		$oldgd = $userinfo["mygd"];
		$newgd = $userinfo["mygd"]+$netgou["gongde_sx"];
		$gdtxt = $gdid;
		$gdcaozuo = "sys";
		$modetype = "sx";
		
		db_query("UPDATE $sql_tbl[users] SET sxdtm='$gdtime', sxnum = sxnum+1, mygd = '$newgd' WHERE uid='$uid'");
		db_query("INSERT INTO $sql_tbl[gongde] (uid,username,modetype,gdnum,oldgd,newgd,gddtm,gdtxt,gdcaozuo,gdip) VALUES ('$uid','$username','$modetype','$gdnum','$oldgd','$newgd','$gdtime','$gdtxt','$gdcaozuo','$gdip')");
	}
	
	$strmess = urlencode("添加成功");
	ng_header_location("index.php?strmess=$strmess");
			
}

$ng_obstart && function_exists('ob_gzhandler') ? ob_start('ob_gzhandler') : ob_start();
$ng_obstart ? $ng_gzip="Gzip enabled":$ng_gzip="Gzip disabled";
require_once PrintFuTemp('header');
require_once EchoTemp('sxadd');
require_once PrintFuTemp('footer');
$output=str_replace(array('<!--<!--<!---->','<!--<!---->','<!---->'),array('','',''),ob_get_contents());
ob_end_clean();
echo $output;
flush;
exit;
break;
?>