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

$newsid = intval($newsid);

if($REQUEST_METHOD == "POST"){
	
	if($subject == ''){
			
		echo "<script language=\"JavaScript\">\r\n"; 
		echo " alert(\"新闻名称为空，请输入新闻名称\");\r\n"; 
		echo " history.go(-1);\r\n";echo "</script>"; 
		exit; 
			
	}elseif($body == ''){
		
		echo "<script language=\"JavaScript\">\r\n"; 
		echo " alert(\"新闻内容为空，请输入新闻内容\");\r\n"; 
		echo " history.go(-1);\r\n";echo "</script>"; 
		exit; 
		
	}
		
	if($newsid != ''){
		
		db_query("UPDATE $sql_tbl[newsletter] SET subject = '$subject', listid = '$listid', avail = '$avail', titleb = '$titleb' WHERE newsid='$newsid'");
		db_query("UPDATE $sql_tbl[newsbody] SET newsbody = '$body' WHERE newsid='$newsid'");
		showmsg("新闻修改成功","news.php");
		
	}elseif($mode == 'add'){

		$send_date = time();
		db_query("INSERT INTO $sql_tbl[newsletter] (subject,send_date,listid,avail,titleb) VALUES ('$subject', '$send_date', '$listid', '$avail', '$titleb')");
		$newsid=mysql_insert_id();
		db_query("INSERT INTO $sql_tbl[newsbody] (newsid,newsbody) VALUES ('$newsid','$body')");
		showmsg("新闻添加成功","addnews.php?listid=$listid");
	}
	
}

if($newsid != ""){
	$news = ng_query_first("SELECT * FROM $sql_tbl[newsletter] WHERE newsid = '$newsid'");
	$news["body"] = ng_query_first_cell("SELECT newsbody FROM $sql_tbl[newsbody] WHERE newsid = '$newsid'");
}
$lists = ng_query("SELECT * FROM $sql_tbl[newslists]");

$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('addnews');
require_once "./footer.php";

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