<!--#include file="error.asp"-->
<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Fyblogs网站管理系统</title>
</head>
<body>
<%
action=request("action")

if Request("action")="del" then
delnews="delete * from news where id="&request("id")
conn.execute(delnews)
response.write "<script>alert('文章已删除!');window.location='newslist.asp';</script>"
'--------------------------------------------------------------------
elseif Request("action")="add" then
title=changechr(trim(request("title")))
author=request.form("author")
comefrom=request.form("comefrom")
addtime=request.form("addtime")
hits=request.form("hits")
typeid=request.form("typeid")
bigclassid=request.form("bigclassid")
content=request.form("content")
ispic=request.form("ispic")
picfile=request.form("picfile")
links=request.form("links")
SpecialID=request.form("SpecialID")

call checknull(title,"新闻标题")
call checknull(typeid,"所属栏目")
call checknull(addtime,"添加时间")


if content="" and links="" then
response.write "<script>alert('请至少输入新闻链接和正文中一项！');history.go(-1);</Script>"	 
 Response.End
end if

If hits="" Then
hits="0"
end if

if ispic=1 and picfile="" then
response.write "<script>alert('文章属性选择了图片，但还没有选择图片,请选择！');history.go(-1);</Script>"	 
 Response.End
end if


if bigclassid=0 then
show=Conn.ExeCute("SELECT * FROM type WHERE ID="&typeid&"")("show")
else
show=Conn.ExeCute("SELECT * FROM bigclass WHERE ID="&bigclassid&"")("show")
end if
if show=3 and ispic<>1 then
response.write "<script>alert('文章所属类别的类型是图片列表，文章属性必须是图片新闻,请重新选择！');history.go(-1);</Script>"	 
 Response.End
end if


set rs=server.CreateObject("adodb.recordset")
sql="select * from news"
rs.open sql,conn,1,3
rs.addnew

rs("title")=title
rs("author")=author
rs("comefrom")=comefrom
rs("addtime")=addtime
rs("hits")=hits
rs("bigclassid")=bigclassid
rs("typeid")=typeid
rs("content")=content
rs("ispic")=ispic
rs("picfile")=picfile
rs("links")=links
rs("SpecialID")=SpecialID
rs.update
rs.close

response.write "<script>alert('文章添加成功!');window.location='newslist.asp';</script>"

'--------------------------------------------------------------------
elseif Request("action")="edit" then
title=changechr(trim(request("title")))
author=request.form("author")
comefrom=request.form("comefrom")
addtime=request.form("addtime")
hits=request.form("hits")
typeid=request.form("typeid")
bigclassid=request.form("bigclassid")
content=request.form("content")
ispic=request.form("ispic")
picfile=request.form("picfile")
links=request.form("links")
SpecialID=request.form("SpecialID")

call checknull(title,"新闻标题")
call checknull(typeid,"所属栏目")
call checknull(addtime,"添加时间")

if content="" and links="" then
 response.write "<script>alert('请至少输入新闻链接和正文中一项！');history.go(-1);</Script>"	 
 Response.End
end if

If hits="" Then
hits="0"
end if

if ispic=1 and picfile="" then
response.write "<script>alert('文章属性选择了图片，但还没有选择图片,请选择！');history.go(-1);</Script>"	 
 Response.End
end if

if bigclassid=0 then
show=Conn.ExeCute("SELECT * FROM type WHERE ID="&typeid&"")("show")
else
show=Conn.ExeCute("SELECT * FROM bigclass WHERE ID="&bigclassid&"")("show")
end if
if show=3 and ispic<>1 then
response.write "<script>alert('文章所属类别的类型是图片列表，文章属性必须是图片新闻,请重新选择！');history.go(-1);</Script>"	 
 Response.End
end if

set rs1=server.createobject("adodb.recordset")
id=request("id")
sql1="select * from news where id="&id
rs1.open sql1,conn,1,3

rs1("title")=title
rs1("author")=author
rs1("comefrom")=comefrom
rs1("addtime")=addtime
rs1("hits")=hits
rs1("bigclassid")=bigclassid
rs1("typeid")=typeid
rs1("content")=content
rs1("ispic")=ispic
rs1("picfile")=picfile
rs1("links")=links
rs1("SpecialID")=SpecialID
rs1.update
rs1.close
response.write "<script language=javascript>alert('修改成功！');window.location.href='newslist.asp';</script>"

end if
%>
</body>
</html>
