<!--#include file="top.asp"-->
<!--#include file="Conn.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="w_Content-Type" w_Content="text/html; charset=gb2312" />
<title>文章后台管理</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	SCROLLBAR-FACE-COLOR: #000000;
	MARGIN: 0px; 
	SCROLLBAR-HIGHLIGHT-COLOR: #EEEEEE;
	SCROLLBAR-SHADOW-COLOR: #EEEEEE;
	SCROLLBAR-3DLIGHT-COLOR: #CCCCCC; 
	SCROLLBAR-ARROW-COLOR: #EEEEEE; 
	SCROLLBAR-TRACK-COLOR: #EEEEEE; 
	SCROLLBAR-DARKSHADOW-COLOR: #CCCCCC; 
	TEXT-DECORATION: none
}
td,th {
	font-size: 12px;
	color: #000000;
}
a:link {
	color: #000000;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #000000;
}
a:hover {
	text-decoration: underline;
	color: #FF0000;
}
a:active {
	text-decoration: none;
	color: #FF0000;
}
.cuti_baise {
	font-size: 12px;
	color: #FFFFFF;
	font-weight: bold;
}
.cuti_red {
	font-size: 20px;
	color: #FF0000;
	font-weight: bold;
}
.Heitable {
	border: 1px solid #000000;
}
.heisefont {
	font-size: 12px;
	color: #000000;
}
.baisefont {
	font-size: 12px;
	color: #ffffff;
}
input,select,Textarea{background-color: #FFFFFF; border: 1 solid #000000; color: #000000; font-family:Verdana, Arial,宋体; font-size: 9pt; line-height: 14px;}
-->
</style>
<script langusge="javascript">
function admin_Size(num,objname)
{
	var obj=document.getElementById(objname)
	if (parseInt(obj.rows)+num>=3) {
		obj.rows = parseInt(obj.rows) + num;	
	}
	if (num>0)
	{
		obj.width="90%";
	}
}
</script>
</head>
<body>
<%
Dim ID,Title,Author,w_Content,AddTime,ButtonValue
Sub GetBigClassName(NewsBigClassID)			'定义一个过程,将分类ID转换为名称
	Set RsBigClass=Server.CreateObject("Adodb.RecordSet")
	SqlBigClass="Select * From PPst_BigClass Where BigClassID="&NewsBigClassID
	rsBigClass.open sqlBigClass,conn,1,1
	Response.Write RsBigClass("BigClassName")
	RsBigClass.Close
End Sub



ButtonValue=" 添 加 "		'设定按钮的默认值为"添加",

If Action="Add" and Request("ID")="" then		'如果表单ID为空,表示是添加新的
	If Request("BigClassID")="" Then
		response.Write "<br><br><br><center>你必须添加分类后才能添加信息！！<br><br><a href="&ThisFileName&">》》返回...</a></center><body><html>"
		rs.Close
		Conn.Close
		response.End()
	End If
	
	If Request("Title")="" or Request("w_Content")="" then
		response.Write "<br><br><br><center>新闻标题和内容都不能为空..<br><br><a href="&ThisFileName&">》》返回...</a></center><body><html>"
		Conn.Close
		response.End()
	End If
	
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Sql="Select * From PPst_News"
	rs.open sql,conn,1,3
	rs.AddNew
	rs("Title")=Request("Title")
	rs("Author")=Request("Author")
	rs("BigClassID")=Request("BigClassID")
	rs("w_Content")=Request("w_Content")
	rs("AddTime")=Now()
	rs.update
	rs.close
	response.redirect ThisFileName&"?Result=添加成功！"
End If

If Action="Add" and Request("ID")<>"" then			'如果表单ID不为为空,表示是编辑新闻
	If Request("Title")="" or Request("w_Content")="" then
		response.Write "<br><br><br><center>新闻标题和内容都不能为空..<br><br><a href="&ThisFileName&">》》返回...</a></center><body><html>"
		Conn.Close
		response.End()
	End If

	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Sql="Select * From PPst_News Where ID="&Request("ID")
	rs.open sql,conn,1,3
	rs("Title")=Request("Title")
	rs("Author")=Request("Author")
	rs("BigClassID")=Request("BigClassID")
	rs("w_Content")=Request("w_Content")
	rs.update
	rs.close
	response.redirect ThisFileName&"?Result=编辑成功！"
End If

If Action="Del" then
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Sql="Delete * From PPst_News Where ID="&Request("ID")
	rs.open sql,conn,1,3
	rs.close
	response.redirect ThisFileName&"?Result=删除成功！"
End If

If Action="DelPinglun" then
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Sql="Delete * From PPst_Pinglun Where ID="&Request("PID")
	rs.open sql,conn,1,3
	rs.close
	response.redirect ThisFileName&"?Action=AdminPinglun&ID="&Request("ID")&"&ActionResult=删除成功！"
	'Cstr(Request.ServerVariables("HTTP_REFERER"))
End If

If Action="DelAllPinglun" then
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Sql="Delete * From PPst_Pinglun Where NewsID="&Request("ID")
	rs.open sql,conn,1,3
	rs.close
	response.redirect ThisFileName&"?Action=AdminPinglun&ID="&Request("ID")&"&ActionResult=删除全部成功！"
End If
%>

<%
If Action="View" then
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Sql="Select * From PPst_News Where ID="&Request("ID")
	rs.open sql,conn,1,1
	ID=rs("ID")
	Title=rs("Title")
	Author=rs("Author")
	AddTime=rs("AddTime")
	ReadCishu=rs("ReadCishu")
	w_Content=HtmlCode(rs("w_Content"))
%>
<div align="center">
	<div align="center">

<table border="0" width="600" id="table11" cellspacing="0" cellpadding="0" bgcolor="#99CC00">
	<tr>
		<td>
	<div align="center">

<table width="560" border="0" cellpadding="0" cellspacing="0" height="10" id="table12">
  <tr>
    <td height="10" style="font-size: 12px; color: #000000"></td>
  </tr>
</table>
	</div>
		<div align="center">
<table width="560" border="0" cellpadding="0" cellspacing="1" id="table13">
  <tr>
    <td width="60" height="25" align="center" valign="middle" style="font-size: 12px; color: #000000">
      标题：</td>
    <td width="700" align="left" style="font-size: 12px; color: #000000">&nbsp;[<%Call GetBigClassName(Rs("BigClassID"))%>] <%=Title%></td>
  </tr>
  <tr>
    <td height="25" align="center" valign="middle" style="font-size: 12px; color: #000000">作者：</td>
    <td align="left" valign="middle" style="font-size: 12px; color: #000000">&nbsp;<%=Author%>　　　　　　　　时间：<%=AddTime%>　　　　　　　　阅读 <%=ReadCishu%> 
	次</td>
  </tr>
  <tr>
    <td align="center" valign="Top" height="100" style="font-size: 12px; color: #000000">内容：</td>
    <td align="left" valign="" style="font-size: 12px; color: #000000">&nbsp;<%=Replace(w_Content,VBCrlf,"<br>")%> </td>
  </tr>
  <tr>
    <td height="20" colspan="2" align="center" valign="middle" style="font-size: 12px; color: #000000">
	此处只是提供简单的新闻预览，真实效果请从前台点击查看..</td>
  </tr>
  <tr>
    <td height="20" colspan="2" align="center" valign="middle" style="font-size: 12px; color: #000000"><a href="<%=ThisFileName%>">
	〉〉返回后台</a></td>
  </tr>
</table>
		</div>
		<p>　</td>
	</tr>
</table>
	</div>
</div>
</body>
<!--#include file="foot.asp"-->
</html>
<%
	rs.close
	Conn.Close
	Response.End()
End If

If Action="AdminPinglun" then
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	SQL="Select * From PPst_Pinglun Where NewsID="&Request("ID")&" Order By ID Desc"
	Rs.open sql,conn,1,1
	
	Set Rs_News=Server.CreateObject("Adodb.RecordSet")
	SQL_News="Select * From PPst_News Where ID="&Request("ID")
	Rs_News.open sql_News,conn,1,1
	NewsTitle=Rs_News("Title")
	Rs_News.Close
	
	%>
<%
	Rs.Close
	Conn.Close
	Response.End()
End If

If Action="Edit" then
	'如果Action="Edit"表示是点了编辑按钮,则表单ID不为空,取出该新闻的各种值
	'并赋给参数,如Title=rs("Title"),设定表单各项的默认值等于相应参数
	'如果Action="",则表示不是点了编辑按钮,则不进行一下11行程序
	'所以表单各项的默认值等于空了,如ID
	'然后依次作为区别来判断提交的数据是更改还是添加
	'即使表单的Action的值都是Add
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Sql="Select * From PPst_News Where ID="&Request("ID")
	rs.open sql,conn,1,1
	ID=rs("ID")	
	Title=rs("Title")
	Author=rs("Author")
	BigClassID=rs("BigClassID")
	w_Content=rs("w_Content")
	AddTime=rs("AddTime")
	rs.close
	ButtonValue=" 编 辑 "		'当前是新闻编辑状态,重新设定按钮的值为"编 辑"
End If
%>

<div align="center">

<table border="0" width="600" id="table2" cellspacing="0" cellpadding="0" bgcolor="#99CC00">
	<tr>
		<td>

<div align="center">

<table width="560" border="0" cellpadding="0" cellspacing="0" height="10" id="table3">
  <tr>
    <td height="10" style="font-size: 12px; color: #000000"></td>
  </tr>
</table>
</div>
<div align="center">
<table width="560" border="0" cellpadding="0" cellspacing="0" class="Heitable" id="table4">
  <tr><td height="5" style="font-size: 12px; color: #000000"></td></tr>
  <tr><td style="font-size: 12px; color: #000000">
    		<div align="center">
    		<table width="98%" border="0" cellpadding="0" cellspacing="1" id="table5">
  			<tr><td align="center" height="25" style="font-size: 12px; color: #000000"><%
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Sql="Select * From PPst_BigClass"
	rs.open sql,conn,1,1
	If Rs.RecordCount=0 then
		response.Write "还没有任何分类"
	Else
		Response.Write "<a href="&ThisFileName&">全部</a>"
		For t=1 to Rs.RecordCount
			Response.Write "‖ ‖ ‖("&Rs("BigClassID")&")<a href="&ThisFileName&"?BigClassID="&Rs("BigClassID")&">"&Rs("BigClassName")&"</a>"
		Rs.MoveNext
		Next
	End If
	Rs.Close
			%></td></tr></table>
			</div>
	</td></tr>
  <tr height="5"><td style="font-size: 12px; color: #000000"></td></tr>
  
  <tr><td align="center" style="font-size: 12px; color: #000000">
<%
Set Rs=Server.CreateObject("Adodb.RecordSet")
If Request("BigClassID")="" Then
	Sql="Select * From PPst_News Order By ID Desc"
Else
	Sql="Select * From PPst_News Where BigClassID="&Request("BigClassID")&" Order By ID Desc"
End If
rs.open sql,conn,1,1
if rs.RecordCount=0 then
%>
<div align="center">
<table width="98%" border="0" cellpadding="0" cellspacing="1" id="table6">
  <tr><td align="center" height="25" style="font-size: 12px; color: #000000">没有数据..</td></tr></table>
</div>
<%
Else
	page=request.QueryString("page")
	rs.pagesize=EveryPageNum
	total=rs.recordcount
	if Not IsEmpty(trim(Request("Page"))) then 
		page = CInt(Request("page"))    
    	if page>rs.PageCount then 
			rs.AbsolutePage = rs.PageCount        
		elseif page <= 0 then 
			page = 1 
   		else
   	    	rs.AbsolutePage = page 
    	end if
	End	 if
	page = rs.AbsolutePage
%>
<table width="98%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolorlight="#000000" bordercolordark="#FFFFFF" id="table7">
  <tr>
    <td width="5%" height="25" align="center" style="font-size: 12px; color: #000000"><b>
	ID</b></td>
    <td width="*" align="left" style="font-size: 12px; color: #000000"><b>&nbsp;[类别] 标题(阅读)</b></td>
    <td width="7%" align="center" style="font-size: 12px; color: #000000"><b>编辑</b></td>
    <td width="7%" align="center" style="font-size: 12px; color: #000000"><b>删除</b></td>
	<%If IsPinglun=1 then%>
	<%End If%>
  </tr>
<%
For i=1 to rs.PageSize
	if rs.EOF then
	Exit For 
	end if 
	Set Rs_Pinglun=Server.CreateObject("Adodb.RecordSet")
	SQL_Pinglun="Select * From PPst_Pinglun Where NewsID="&Rs("ID")
	Rs_Pinglun.open sql_Pinglun,conn,1,1
	PinglunNum=Rs_Pinglun.RecordCount
	Rs_Pinglun.Close
%>
  <tr>
    <td height="25" align="center" valign="middle" style="font-size: 12px; color: #000000"><%=rs("ID")%></td>
    <td align="left" style="font-size: 12px; color: #000000">&nbsp;[<a href="<%=ThisFileName%>?BigClassID=<%=rs("BigClassID")%>"><%Call GetBigClassName(Rs("BigClassID"))%></a>]&nbsp;<a href="<%=ThisFileName%>?Action=View&ID=<%=rs("ID")%>"><%=rs("Title")%></A>(<%=rs("ReadCishu")%>) <font color="#666666"><%=rs("AddTime")%></font></td>
    <td align="center" valign="middle" style="font-size: 12px; color: #000000"><a href="newsadd.asp?Action=Edit&ID=<%=rs("ID")%>">
	编辑</a></td>
    <td align="center" valign="middle" style="font-size: 12px; color: #000000"><a href="<%=ThisFileName%>?Action=Del&ID=<%=rs("ID")%>" onClick='return confirm("确定要执行操作吗？\n该操作将删除该新闻下的所有评论\n请慎重！！！！");'>
	删除</a></td>
	<%If IsPinglun=1 then%>
	<%End If%>
  </tr>
 <%
 rs.MoveNext
 Next
 %>
</table>
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="5" id="table8"><tr>
	<td style="font-size: 12px; color: #000000"></td></tr></table>
<table width="98%"  border="0" cellpadding="0" cellspacing="1" id="table9">
   <tr><td height="25" align="center" style="font-size: 12px; color: #000000">
	<%if rs.pagecount<>1 and rs.pagecount<>0 then%>
    	<%if page<rs.pagecount then%>
       		<%if page=1 then %>
        		[首页] [上一页]
       		<%else%>
				[<a href="<%=ThisFileName%>?BigClassID=<%=Request("BigClassID")%>&page=<%=1%>">首页</a>] 
	[<a href="<%=ThisFileName%>?BigClassID=<%=Request("BigClassID")%>&page=<% =page-1 %>">上一页</a>]
			<% end if %>
              [<a href="<%=ThisFileName%>?BigClassID=<%=Request("BigClassID")%>&page=<%=page+1%>">下一页</a>] 
	[<a href="<%=ThisFileName%>?BigClassID=<%=Request("BigClassID")%>&page=<%=rs.PageCount%>">尾页</a>]
		<%else%>
			[<a href="<%=ThisFileName%>?BigClassID=<%=Request("BigClassID")%>&page=<% = 1%>">首页</a>] 
	[<a href="<%=ThisFileName%>?BigClassID=<%=Request("BigClassID")%>&page=<% =page -1 %>">上一页</a>] 
	[下一页] [尾页]
		<%end if %>
	<%else%>
		[首页] [上一页] [下一页] [尾页]
	<%end if%>
	[页次:<font color="red"><b><%=page%></b></font>/<%=rs.PageCount%>] [共<%=rs.RecordCount%>条 <font color="red"><b><%=rs.PageSize%></b></font>条/页]
	</td></tr></table>
<%
rs.Close
End If
Conn.Close
%>
</td></tr><tr><td height="5" style="font-size: 12px; color: #000000"></td></tr></table>

<div align="center">

<table width="560" border="0" cellpadding="0" cellspacing="0" height="10" id="table10">
  <tr>
    <td height="10" style="font-size: 12px; color: #000000"></td>
  </tr>
</table>
</div>
</div>
		</td>
	</tr>
</table>
</div>
</body>

<!--#include file="foot.asp"-->
</html>
