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

if ($REQUEST_METHOD=="POST" and $action=="addmsg") {

	$username=addslashes(htmlspecialchars($username));
	$email=addslashes(htmlspecialchars($email));
	$content=addslashes(htmlspecialchars($content));
	$msnqq=addslashes(htmlspecialchars($msnqq));
	$tel=addslashes(htmlspecialchars($tel));
	$userip=$REMOTE_ADDR;
	$systime=time();
	
	if(!empty($content) and !empty($username) and !empty($email)){
		$ifshow="";
		
		/*
		if(!empty($content)){//还原空格和回车
			$content=str_replace("　","",$content);
			$content=ereg_replace("\n","<br>　　",ereg_replace(" ","&nbsp;",$content));
		}//还原结束
		*/
		if($netgou["guestbook_audit"]=='Y'){
			$ifshow='N';
		}else{
			$ifshow='N';
		}
		
		db_query("INSERT INTO $sql_tbl[guestbook](login, email, content, userip, systime, ifshow, msnqq, tel) VALUES ('$username', '$email', '$content', '$userip', '$systime', '$ifshow', '$msnqq', '$tel')");

	}else{
	
		ng_header_location("help.php?action=msgerror");
		
	}
}

if ($action=="contactus") {

	$count_guest_book = ng_query_first_cell("SELECT COUNT(id) FROM $sql_tbl[guestbook] where ifshow = 'Y'");
	
	if ($count_guest_book > 0) {
					
		$objects_per_page = 10;
		$total_items = $count_guest_book;
		$total_nav_pages = ceil($total_items/$objects_per_page);
		if($page > $total_nav_pages)
			$page = $total_nav_pages;
		$pageurl = "help.php?action=contactus&";
		include_once ng_dir."/include/navigation.php";
					
		$guest_book = ng_query("SELECT $sql_tbl[guestbook].* FROM $sql_tbl[guestbook] where ifshow = 'Y' ORDER BY id 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('header');
require_once PrintTemp('help');
require_once PrintTemp('footer');

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