<%Response.Buffer = true %>
<!--#include file="../inc/config.asp" -->
<!--#include file="../inc/conn.asp" -->
<!-- #include file="inc/session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'定义变量
dim id,tabname,newsUrl,isoutlink
id=Clng(request.QueryString("id"))
tabname=trim(request.QueryString("table"))
Select Case LCase(tabname)
	Case "news"
		call checkPrevilege(Session("Name"),"p02")
	Case "templet"
		call checkPrevilege(Session("Name"),"p03")
	Case "label"
		call checkPrevilege(Session("Name"),"p04")
	Case "role"
		call checkPrevilege(Session("Name"),"p00")
	Case "admin"
		call checkPrevilege(Session("Name"),"p04")
	Case "vote"
		call checkPrevilege(Session("Name"),"p13")
	Case "ad"
		call checkPrevilege(Session("Name"),"p14")
	Case "commen"
		call checkPrevilege(Session("Name"),"p07")
	Case "friendlink"
		call checkPrevilege(Session("Name"),"p08")
	Case "collect"
		call checkPrevilege(Session("Name"),"p09")
	Case "t_importdb"
		call checkPrevilege(Session("Name"),"p09")
	Case "log"
		call checkPrevilege(Session("Name"),"p12")
	Case "t_task"
		call checkPrevilege(Session("Name"),"p15")
	Case "t_author"
		call checkPrevilege(Session("Name"),"p16")
	Case "t_from"
		call checkPrevilege(Session("Name"),"p16")
	Case "t_special"
		call checkPrevilege(Session("Name"),"p16")
	Case "t_live"
		call checkPrevilege(Session("Name"),"p17")
	Case "t_form"
		call checkPrevilege(Session("Name"),"p18")
	Case "t_download_server"
		call checkPrevilege(Session("Name"),"p19")
End Select
%>
<HTML>
<HEAD>
<TITLE>删除</TITLE>
<meta http-equiv="refresh" content="0;URL=<%=request.ServerVariables("HTTP_REFERER")%>">
<style>
body,td,input,textarea {font-size:9pt}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {font-size: 14pt}
</style>
</HEAD>
<BODY>
<%
if(tabname="news") then
	set rs=server.createobject("adodb.recordset")
	rs.open "select pagepath,isoutlink from news where id="&id,conn,3,1
	if not rs.eof then
		newsUrl=rs(0)
		isoutlink=Cint(rs(1))
	end if
	rs.close
	set rs=nothing 	
	if(newsUrl<>"") then
		newsUrl=replace(newsUrl,"/","\")
	end if
 	if(isoutlink=0) then
 	Set fso = Server.CreateObject("Scripting.FileSystemObject")
 	if not fso.FileExists(server.MapPath("../")&newsUrl) then  
 		Response.Write("<h1>错误:</h1>文件" & server.MapPath("../")&newsUrl&" 不存在<p>") 			
 	else
 		fso.DeleteFile(server.MapPath("../")&newsUrl)
 		Response.Write("<h1>成功删除文件:</h1>" & server.MapPath("../")&newsUrl)
 	end if
	set fso=nothing
 	end if
elseif(tabname="ad") then
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
 	if fso.FileExists(server.MapPath("../ad/js_"&id&".js")) then   		
 		fso.DeleteFile(server.MapPath("../ad/js_"&id&".js"))
 		Response.Write("<h1>成功删除文件:</h1>" & server.MapPath("../ad/js_"&id&".js"))
 	end if
 	set fso=nothing
elseif(tabname="vote") then
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
 	if fso.FileExists(server.MapPath("../vote/js_"&id&".js")) then   		
 		fso.DeleteFile(server.MapPath("../vote/js_"&id&".js"))
 		Response.Write("<h1>成功删除文件:</h1>" & server.MapPath("../vote/js_"&id&".js"))
 	end if
 	set fso=nothing
elseif(tabname="t_module") then
	dim tbl_name
	set rs=server.createobject("adodb.recordset")
	rs.open "select TableName from "&tabname&" where id="&id,conn,3,1
	if not rs.eof then
		tbl_name=rs(0)
	end if
	rs.close
	set rs=nothing
	conn.execute("drop table "&tbl_name)
end if
conn.execute("delete from "&tabname&" where id="&id)
call connclose()
%>
<div align="center">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p class="style1">
  <%response.Write("删除成功!")%></p>
</div>
</BODY>
</HTML>
