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

if($REQUEST_METHOD == "POST"){
	
	if($mode == "add"){
		
		if ($title == ''){
			echo "<script language=\"JavaScript\">\r\n"; 
			echo " alert(\"名称为空，请输入名称\");\r\n"; 
			echo " history.go(-1);\r\n";echo "</script>"; 
			exit; 
		}elseif ($intro == ''){
			echo "<script language=\"JavaScript\">\r\n"; 
			echo " alert(\"链接地址为空，请输入链接地址\");\r\n"; 
			echo " history.go(-1);\r\n";echo "</script>"; 
			exit; 
		}
		
		db_query("INSERT INTO $sql_tbl[bottom] (orderby,title,intro,newwin,status) VALUES ('$orderby','$title', '$intro','$newwin','$status')");
		showmsg("操作成功","ng_bottom.php");
		
	}elseif($mode == "update"){
		
		if (is_array($POSTed_data)) {
			foreach ($POSTed_data as $k=>$v) {

				$status = ($v["status"] ? "Y" : "N");
				db_query("UPDATE $sql_tbl[bottom] SET orderby='$v[orderby]',title='$v[title]',intro='$v[intro]',newwin='$v[newwin]', status='$status' WHERE tid = '$k'");
			}
		}		
		showmsg("操作成功","ng_bottom.php");
		
	}
}

if($mode == "del"){
		
	db_query("DELETE FROM $sql_tbl[bottom] WHERE tid='$tid'");
	showmsg("操作成功","ng_bottom.php");
		
}
	
$ng_bottom = ng_query("select * from $sql_tbl[bottom] order by orderby");

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

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