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

if($REQUEST_METHOD == "POST"){
	
	if($mode == "update"){
		
		if (is_array($POSTed_data)) {
			foreach ($POSTed_data as $k=>$v) {

				db_query("UPDATE $sql_tbl[sx] SET sxname='$v[sxname]', sxsex='$v[sxsex]', sxage='$v[sxage]', hxgd='$v[hxgd]', sxaddress='$v[sxaddress]' WHERE sxid = '$k'");
			}
		}		
		showmsg("更新成功","lf_sx.php?page=$page");
		
	}elseif ($mode == "delete") {
	
		if (is_array($to_delete)) {
			foreach ($to_delete as $k=>$v) {
				db_query("DELETE FROM $sql_tbl[sx] WHERE sxid='$k'");
			}
			$to_delete = "";

			showmsg("删除成功","lf_sx.php?page=$page");
    	}
	}
}

$txturl = '';
$txtsou = "WHERE 1=1";

$sxname = addslashes($sxname);
$sxname && $txturl .= "&sxname=$sxname";
$sxname && $txtsou .= " AND $sql_tbl[sx].sxname='$sxname'";

$lfuid = intval($lfuid);
$lfuid && $txturl .= "&lfuid=$lfuid";
$lfuid && $txtsou .= " AND $sql_tbl[sx].uid='$lfuid'";

$total_items = ng_query_first_cell("SELECT COUNT($sql_tbl[sx].sxid) FROM $sql_tbl[sx] $txtsou");

if ($total_items > 0) {
	
	$pageurl = "lf_sx.php?".$txturl;
	$objects_per_page = 50;
		
	$total_nav_pages = ceil($total_items/$objects_per_page);
	if($page > $total_nav_pages)
		$page = $total_nav_pages;
	$netgou["max_nav_pages"] = 10;
	include_once ng_dir."/include/navigation.php";

	$sx_lists = ng_query("SELECT $sql_tbl[sx].sxid, $sql_tbl[sx].username, $sql_tbl[sx].sxname, $sql_tbl[sx].sxsex, $sql_tbl[sx].sxage, $sql_tbl[sx].sxaddress, $sql_tbl[sx].hxgd, $sql_tbl[sx].sxshijian, $sql_tbl[sx].sxfoimg, $sql_tbl[sx].sxgp, $sql_tbl[sx].sxip FROM $sql_tbl[sx] $txtsou ORDER BY $sql_tbl[sx].sxid DESC LIMIT $first_page, $objects_per_page");

	$first_item = $first_page+1;
	$last_item =  min($first_page+$objects_per_page, $total_items);
}

$ng_obstart && function_exists('ob_gzhandler') ? ob_start('ob_gzhandler') : ob_start();
$ng_obstart ? $ng_gzip="Gzip enabled":$ng_gzip="Gzip disabled";

require_once PrintTemp('lf_sx');
require_once "./footer.php";

$output=str_replace(array('<!--<!--<!---->','<!--<!---->','<!---->'),array('','',''),ob_get_contents());
ob_end_clean();
echo $output;
flush;
exit;
?>