<%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 "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")
End Select
%>
<HTML>
<HEAD>
<TITLE>删除</TITLE>
<meta http-equiv="refresh" content="1;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
 	newsUrl=conn.execute("select pagepath from "&tabname&" where id="&id)(0)
 	isoutlink=Cint(conn.execute("select isoutlink from "&tabname&" where id="&id)(0))
 	if(isoutlink=0) then
 	Set fso = Server.CreateObject("Scripting.FileSystemObject")
 	if not fso.FileExists(server.MapPath("../"&newsUrl)) then  
 		Response.Write("<h1>Error:</h1>" & server.MapPath("../"&newsUrl)&" does not exist<p>")
 		conn.execute("delete from "&tabname&" where id="&id)		
 	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
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("delete success!")%></p>
</div>
</BODY>
</HTML>
