<?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 == "update_logo"){
		
		$file_name = "logo";
		$file_type = (strstr($_FILES['title']['type'],"gif")?"gif":(strstr($_FILES['title']['type'],"png")?"png":"jpg"));
							
		$path = "../images/".$file_name.".".$file_type;
		$image_path = "images/".$file_name.".".$file_type;
			
		if (!@move_uploaded_file($_FILES['title']['tmp_name'], $path)) {
			showmsg("上传文件失败，请重新操作","ng_gao.php");
		}
		else {
			db_query("UPDATE $sql_tbl[config] SET value='".addslashes($image_path)."' WHERE name='netgou_logo'");
			@chmod($path, 0666);
			@unlink($image_path);
			showmsg("更新成功","ng_gao.php");
		}
	
	}elseif($mode == "add"){
		
		
		//Upload images begin	
		if ($title){
			
			$file_name = "gao_$title";
			$img_path = "images/gao/";
			$file_type = (strstr($_FILES['title']['type'],"gif")?"gif":(strstr($_FILES['title']['type'],"png")?"png":"jpg"));
						
			//$path = "../".$img_path.$file_name.".".$file_type;
			$image_path = $img_path.$file_name.".".$file_type;
			
			$path = "../images/1.jpg";
			

			if (!@move_uploaded_file($_FILES['title']['tmp_name'], $path)) {
				
				showmsg("上传文件失败，请重新操作","ng_gao.php");
				
			}else{
				$title = $image_path;
				@chmod($path, 0666);
				@unlink($image_path);
			}
				
		}
		//Upload images end	
		
		db_query("INSERT INTO $sql_tbl[gao] (orderby,weizhi,title,intro,newwin,status) VALUES ('$orderby','$weizhi','$title', '$intro','$newwin','$status')");
		showmsg("操作成功","ng_gao.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[gao] SET orderby='$v[orderby]',weizhi='$v[weizhi]',title='$v[title]',intro='$v[intro]',newwin='$v[newwin]', status='$status' WHERE tid = '$k'");
			}
		}		
		showmsg("操作成功","ng_gao.php");
		
	}
}

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

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

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