www.gusucode.com > 全球营销软件站整站源码4月最新数据 4.0源码程序 > 801wyxqf\adminadmin\sys\admin_announce.asp

    <!--#include file="../../conn.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/const.asp"-->
<!--#include file="../inc/check.asp"-->
<!--#include file="../../inc/ubbcode.asp" -->
<!--#include file="../../inc/cls_editor.asp" -->
<%
Admin_header
'=====================================================================
' 软件名称:801w软件代理系统
' 当前版本:801wAsp 801w cn 801w com
' 文件名称:admin_main.asp
' 更新日期:2010-2-16
' 官方网站:801w代理系统(www.801w.cn www.801w.com) QQ:274667447
'=====================================================================
' Copyright 2003-2010 801w.cn - All Rights Reserved.
' 801wasp is a trademark of 801w.cn
'=====================================================================
%>
<table class="table1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<td class="tableline linetitle" width="100" align="left">系统公告管理</td>
		<td class="tableline" width="*" align="right"><a href="../users/admin_index.asp">管理首页</a>
			 - <a href="admin_announce.asp">公告首页</a>
			 - <a href="?action=add">添加公告</a>
			 - <a href="../users/admin_message.asp">短信管理</a>
			 - <a href="../users/admin_list.asp">用户列表</a>
			 - <a href="../users/admin_group.asp">用户组管理</a>
		</td>
	</tr>
</table>
<%
Dim maxperpage,totalrec,Pcount,pagelinks,showmode,pagenow,count
Dim Action,listArry,SQLQuery,isEdit,TextContent

If Not ChkAdmin("Announce") Then
	Call Transfer_error()
End If
Action = LCase(Request("action"))
Select Case Trim(Action)
Case "save"
	Call SaveAnnounce()
Case "modify"
	Call ModifyAnnounce()
Case "add"
	isEdit = False
	Call EditAnnounce()
Case "edit"
	isEdit = True
	Call EditAnnounce()
Case "view"
	Call ViewAnnounce()
Case "del"
	Call DelAnnounce()
Case Else
	Call showmain()
End Select
If FoundErr=True Then
	ReturnError(ErrMsg)
End If
Admin_footer
SaveLogInfo(AdminName)
NewAsp.PageEnd

Sub showmain()
	Dim i,iCount,lCount
	iCount=1:lCount=2
	maxperpage = 30 '###每页显示数
	count=NewAsp.ChkNumeric(Request("count"))
	pagenow=NewAsp.ChkNumeric(Request("page"))
	If pagenow=0 Then pagenow=1
%>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th>公告标题</th>
	<th>显示位置</th>
	<th>公告类型</th>
	<th>操作选项</th>
	<th>发布时间</th>
</tr>
<tr>
	<td class="tablerow1" colspan="5" align="left" id="showNextPage">&nbsp;</td>
</tr>
<%
	Call showAnnouncelist()
	If IsArray(listArry) Then
		For i=0 To Ubound(listArry,2)
			If Not Response.IsClientConnected Then Response.End
			If (i mod 2) = 0 Then iCount=2:lCount=1 Else iCount=1:lCount=2
%>
<tr align="center">
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap" align="left"><a href="?action=view&AnnounceID=<%=listArry(0,i)%>"><%=listArry(2,i)%></a></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap">
	<%
	Select Case CLng(listArry(1,i))
		Case 0
			Response.Write "首页公告"
		Case 1
			Response.Write "<span class=""style1"">文章频道</span>"
		Case 2
			Response.Write "<span class=""style2"">下载频道</span>"
		Case 3
			Response.Write "<span class=""style3"">商城频道</span>"
		Case 4
			Response.Write "<span class=""style2"">动画频道</span>"
		Case 5
			Response.Write "<span class=""style3"">留言频道</span>"
	Case Else
		Response.Write "<span class=""style1"">所有页面显示</span>"
	End Select
	%>
	</td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap">
	<%
	Select Case CLng(listArry(4,i))
		Case 1
			Response.Write "<span class=""style2"">内容公告</span>"
		Case 2
			Response.Write "<span class=""style1"">弹出公告</span>"
	Case Else
			Response.Write "列表公告"
	End Select
	%>
	</td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><a href="?action=edit&AnnounceID=<%=listArry(0,i)%>">编辑</a> |
	<a href="?action=del&AnnounceID=<%=listArry(0,i)%>" onclick="return confirm('公告删除后将不能恢复,您确定要删除该公告吗?')">删除</a></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><%=showDateTime(listArry(3,i),"yyyy-MM-dd")%></td>
</tr>
<%
		Next
		listArry=Null
	End If
%>
<tr>
	<td class="tablerow<%=lCount%>" colspan="5" id="NextPageText"><var class="morePage"><%=showlistpage(pagenow,Pcount,maxperpage,totalrec,pagelinks)%></var></td>
</tr>
</table>
<script type="text/javascript">
document.getElementById("showNextPage").innerHTML = document.getElementById("NextPageText").innerHTML;
</script>
<%
End Sub

Sub showAnnouncelist()
	Dim Rs,SQL
	If Trim(Request("ChannelID"))<>"" And Trim(Request("ChannelID"))<>"0" Then
		SQLQuery="WHERE ChannelID="&NewAsp.ChkNumeric(Request("ChannelID"))
	Else
		SQLQuery=""
	End If
	If count=0 Then
		totalrec=NewAsp.Execute("SELECT COUNT(*) FROM [NC_Announce] "&SQLQuery&"")(0)
	Else
		totalrec=count
	End If
	Pcount = CLng(totalrec / maxperpage)
	If Pcount < totalrec / maxperpage Then Pcount = Pcount + 1
	If pagenow>Pcount Then pagenow=1
	pagelinks="?ChannelID="&Request("ChannelID")&"&count="&totalrec&"&"
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	SQL = "SELECT AnnounceID,ChannelID,title,PostTime,AnnounceType FROM [NC_Announce] "&SQLQuery&" ORDER BY PostTime DESC, AnnounceID DESC"
	Rs.Open SQL,Conn,1,1
	If pagenow >1 Then
		Rs.Move (pagenow-1) * maxperpage
	End If
	If Not (Rs.BOF And Rs.EOF) Then
		listArry=Rs.GetRows(maxperpage)
	Else
		listArry=Null
	End If
	Rs.close()
	Set Rs=Nothing
End Sub

Sub EditAnnounce()
	Dim Rs,SQL,oRs,EditTitle
	If isEdit Then
		SQL = "SELECT * FROM NC_Announce WHERE AnnounceID=" & NewAsp.ChkNumeric(Request("AnnounceID"))
		Set Rs = Newasp.Execute(SQL)
		EditTitle = "编辑公告"
	Else
		EditTitle = "添加公告"
	End If
%>
<script language=javascript>
function checkPost(){
	try{
		if (GetContentLength()==0){
			alert("公告内容不能为空!");
			return false
		}
	}
	catch(e){
		if (Trim(document.forms[0].content.value)=="") {
			alert("公告内容不能为空!");
			document.forms[0].content.focus();
			return false
		}
	}
	if (document.forms[0].title.value==""){
		alert("公告标题不能为空!");
		document.forms[0].title.focus();
		return false;
	}
}
</script>

<div onkeydown="CtrlEnter()">
<form method="Post" name="myform" action="admin_announce.asp" onSubmit="return checkPost();">
<%
	If isEdit Then
		Response.Write "<input type=""hidden"" name=""action"" value=""modify"">"
		Response.Write "<input type=""hidden"" name=""AnnounceID"" value="""& NewAsp.ChkNumeric(Request("AnnounceID")) &""">"
	Else
		Response.Write "<input type=""hidden"" name=""action"" value=""save"">"
	End If
%>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  <tr>
    <th colspan="2"><%=EditTitle%></th>
  </tr>
  <tr>
    <td width="20%" align="right" class="tablerow1"><strong>公告标题:</strong></td>
    <td width="80%" class="tablerow1"><input name="title" type="text" id="title" size="50" value='<%If isEdit Then Response.Write Rs("title")%>'> 
      <span class="style1">* </span></td>
  </tr>
  <tr>
    <td align="right" class="tablerow2"><strong>所属频道:</strong></td>
    <td class="tablerow2"><select name="ChannelID" id="ChannelID">
      <option value="0"<%If isEdit Then If Rs("ChannelID") = 0 Then Response.Write " selected"%>>首页公告</option>
<%
	Set oRs = Newasp.Execute("SELECT ChannelID,ChannelName,ChannelType FROM NC_Channel WHERE ChannelType<2  ORDER BY orders")
	Do While Not oRs.EOF
		Response.Write "<option value="""& oRs("ChannelID") &""""
		If isEdit Then
			If oRs("ChannelID") = Rs("ChannelID") Then Response.Write " selected"
		End If
		Response.Write ">"
		Response.Write oRs("ChannelName")
		Response.Write "</option>"
	oRs.movenext
	Loop
	oRs.Close:Set oRs = Nothing
%>
      <option value="999"<%If isEdit Then If Rs("ChannelID") = 999 Then Response.Write " selected"%>>所有频道显示</option>
    </select></td>
  </tr>
  <tr>
    <td align="right" class="tablerow1"><strong>公告类型:</strong></td>
    <td class="tablerow1"><input name="AnnounceType" type="radio" value="0"<%If isEdit Then If Rs("AnnounceType") = 0 Then Response.Write " checked" End If:Else Response.Write " checked" End If%>>
列表公告
<input type="radio" name="AnnounceType" value="1"<%If isEdit Then If Rs("AnnounceType") = 1 Then Response.Write " checked"%>>
内容公告</td>
  </tr>
  <tr>
    <td align="right" class="tablerow2"><strong>公告内容:</strong></td>
    <td class="tablerow2">
<%
	Dim oEditor
	Set oEditor = New Editor_Cls
	oEditor.UserMode	= 0
	oEditor.setEditMode	= 0
	oEditor.ChannelID	= 0
	oEditor.Width		= 590
	oEditor.Height		= 350
	oEditor.BasePath	= "../../editor/"
	oEditor.ToolbarSet	= "AdminMode"'Default,AdminMode,Simple,UserMode,Basic
	If isEdit Then
		oEditor.Value		= Rs("content")
	End If
	oEditor.InstanceName	= "content"
	oEditor.Execute()
	Set oEditor = Nothing
%></td>
  </tr>
  <tr>
    <td align="right" class="tablerow1"><strong>上传文件:</strong></td>
    <td class="tablerow1"><iframe name="image" frameborder="0" width='100%' height="45" scrolling="no" src="../upload.asp?ChannelID=0&stype=image&m=index&inst=content&s=0" allowTransparency="true"></iframe></td>
  </tr>
  <tr>
    <td align="right" class="tablerow2"><strong>发布人:</strong></td>
    <td class="tablerow2"><input name="writer" type="text" id="writer" size="15" value='<%If isEdit Then Response.Write Rs("writer") Else Response.Write AdminName End If%>'> 
      <span class="style1">* </span> 
      <%If isEdit Then%>
      <input name="update" type="checkbox" id="update" value="yes">
更新公告时间 
<%End If%></td>
  </tr>
  <tr>
    <td align="right" class="tablerow1">&nbsp;</td>
    <td align="center" class="tablerow1">
    <input type="button" name="go_button" onclick="javascript:history.go(-1)" value="返回上一页" class="button">
    <input type="submit" name="submit_button" value="保存公告" class="button"></td>
  </tr></form>
  <tr>
    <td colspan="2" class="tablerow2"><strong>说明:</strong><br>
      &nbsp;&nbsp;&nbsp;&nbsp;所属频道 ---- 只有频道首页才显示公告;<br>
      &nbsp;&nbsp;&nbsp;&nbsp;公告类型 ---- 列表显示是指公告以列表的形式显示公告,需要用户点击才可以看到公告内容;内容公告是指公告以内容的方式显示在所在的频道首页,注意只显示最新的一条公告。</td>
  </tr>
</table>
</div>
<%
	If isEdit Then Rs.Close:Set Rs = Nothing
End Sub

Sub checksave()
	Dim i
	If Trim(Request.Form("title")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>公告标题不能为空!</li>"
	End If
	If Trim(Request.Form("ChannelID")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>频道ID不能为空!</li>"
	End If
	If Trim(Request.Form("AnnounceType")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>公告类型不能为空!</li>"
	End If
	If Trim(Request.Form("content")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>公告内容不能为空!</li>"
	End If
	If Trim(Request.Form("writer")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>公告发布人不能为空!</li>"
	End If
	TextContent = ""
	For i = 1 To Request.Form("content").Count
		TextContent = TextContent & Request.Form("content")(i)
	Next
End Sub

Sub SaveAnnounce()
	Call checksave()
	Dim Rs,SQL,AnnounceID
	If Founderr = True Then Exit Sub
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	SQL = "SELECT * FROM NC_Announce WHERE (AnnounceID is null)"
	Rs.Open SQL,Conn,1,3
	Rs.Addnew
		Rs("ChannelID") = NewAsp.ChkNumeric(Request.Form("ChannelID"))
		Rs("title") = Newasp.CheckStr(Request.Form("title"))
		Rs("AnnounceType") = NewAsp.ChkNumeric(Request.Form("AnnounceType"))
		Rs("Content") = TextContent
		Rs("writer") = Newasp.CheckStr(Request.Form("writer"))
		Rs("PostTime") = Now()
		Rs("hits") = 0
	Rs.update
	Rs.Close
	Rs.Open "select top 1 AnnounceID from NC_Announce order by AnnounceID desc", Conn, 1, 1
	AnnounceID = Rs("AnnounceID")
	Rs.Close:Set Rs = Nothing
	Succeed("<li>恭喜您!添加新的公告成功。</li><li><a href=""?action=view&AnnounceID=" & AnnounceID & """>点击此处查看该公告</a></li>")
End Sub

Sub ModifyAnnounce()
	Call checksave()
	Dim Rs,SQL,AnnounceID
	If Founderr = True Then Exit Sub
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	SQL = "SELECT * FROM NC_Announce WHERE AnnounceID=" & NewAsp.ChkNumeric(Request("AnnounceID"))
	Rs.Open SQL,Conn,1,3
		Rs("ChannelID") = NewAsp.ChkNumeric(Request.Form("ChannelID"))
		Rs("title") = Newasp.CheckStr(Request.Form("title"))
		Rs("AnnounceType") = NewAsp.ChkNumeric(Request.Form("AnnounceType"))
		Rs("Content") = TextContent
		Rs("writer") = Newasp.CheckStr(Request.Form("writer"))
		If LCase(Request.Form("Update")) = "yes" Then Rs("PostTime") = Now()
	Rs.update
		AnnounceID = Rs("AnnounceID")
	Rs.Close:Set Rs = Nothing
	Succeed("<li>恭喜您!修改公告成功。</li><li><a href=?action=view&AnnounceID=" & AnnounceID & ">点击此处查看该公告</a></li>")
End Sub

Sub DelAnnounce()
	If Trim(Request("AnnounceID")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>请输入公告ID!</li>"
		Exit Sub
	End If
	Newasp.Execute("DELETE FROM NC_Announce WHERE AnnounceID=" & NewAsp.ChkNumeric(Request("AnnounceID")))
	Succeed("公告删除成功!")
End Sub

Sub ViewAnnounce()
	Dim Rs,SQL
	If Request("AnnounceID") = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>Sorry!您选择了错误的系统参数。</li>"
		Exit Sub
	End If
	Dim n
	n = 1
	Newasp.Execute ("UPDATE NC_Announce SET hits=hits+"&n&" WHERE AnnounceID=" & NewAsp.ChkNumeric(Request("AnnounceID")))
	SQL = "SELECT * FROM NC_Announce WHERE AnnounceID=" & NewAsp.ChkNumeric(Request("AnnounceID"))
	Set Rs = Newasp.Execute(SQL)
	If Rs.BOF And Rs.EOF Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>Sorry!没有找到任何公告。或者您选择了错误的系统参数!</li>"
		Exit Sub
	Else
%>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
	<tr>
		<th colspan="2">查看公告</th>
	</tr>
	<tr>
		<td align="center" class="tablerow2" colspan="2"><a href=?action=edit&AnnounceID=<%=Rs("AnnounceID")%>><font size=4><%=Rs("title")%></font></a></td>
	</tr>
	<tr>
		<td align="center" class="tablerow1"><strong>发布时间:</strong> <%=Rs("PostTime")%> &nbsp;&nbsp;
		<strong>发 布 人:</strong> <%=Rs("writer")%> &nbsp;&nbsp;<strong>浏览次数:</strong> <%=Rs("hits")%></td>
	</tr>
	<tr>
		<td class="tablerow1"><strong>公告内容:</strong><br><%=Replace(ubb.UbbCode(Rs("content")), "[page_break]", "")%></td>
	</tr>
	<tr>
		<td class="tablerow2">上一公告:<%=FrontAnnounce(Rs("AnnounceID"))%>
		<br>下一公告:<%=NextAnnounce(Rs("AnnounceID"))%></td>
	</tr>
	<tr>
		<td align="center" colspan="2" class="tablerow2">
		<input type="button" onclick="javascript:history.go(-1)" value="返回上一页" name="go_button" class="button">&nbsp;&nbsp; 
		<input type="button" name="B1" onclick="javascript:location.href='#'" value="返回顶部" class="button">&nbsp;&nbsp;
		<input type="button" name="B2" onclick="javascript:location.href='?action=edit&AnnounceID=<%=Rs("AnnounceID")%>'" value="编辑公告" class="button"></td>
	</tr>
</table>
<%
	End If
	Rs.Close
	Set Rs = Nothing 
End Sub

Function FrontAnnounce(AnnounceID)
	Dim Rss, SQL
	SQL = "select Top 1 AnnounceID,title from NC_Announce where AnnounceID < " & AnnounceID & " order by AnnounceID desc"
	Set Rss = Newasp.Execute(SQL)
	If Rss.EOF And Rss.BOF Then
		FrontAnnounce = "已经没有了"
	Else
		FrontAnnounce = "<a href=admin_Announce.asp?action=view&AnnounceID=" & Rss("AnnounceID") & ">" & Rss("title") & "</a>"
	End If
	Rss.Close
	Set Rss = Nothing
End Function

Function NextAnnounce(AnnounceID)
	Dim Rss, SQL
	SQL = "SELECT TOP 1 AnnounceID,title FROM NC_Announce WHERE AnnounceID>" & AnnounceID & " ORDER BY AnnounceID ASC"
	Set Rss = Newasp.Execute(SQL)
	If Rss.EOF And Rss.BOF Then
		NextAnnounce = "已经没有了"
	Else
		NextAnnounce = "<a href=admin_Announce.asp?action=view&AnnounceID="& Rss("AnnounceID") &">" & Rss("title") & "</a>"
	End If
	Rss.Close
	Set Rss = Nothing
End Function

Sub CreateAnnounce()
	Dim rsAnnounce,sqlAnnounce
	sqlAnnounce = "SELECT A.AnnounceID,A.title,A.PostTime,A.AnnounceType,C.ChannelDir,C.ChannelUrl,C.BindDomain,C.DomainName FROM [NC_Announce] A INNER JOIN [NC_Channel] C On A.ChannelID=C.ChannelID WHERE A.ChannelID=" & ChannelID & ""
	Set rsAnnounce = Newasp.Execute(sqlAnnounce)
End Sub
%>