<!-- #include file="setup.asp" -->
<!-- #include file="inc/md5.asp" -->

<title>贵州网缘社区 - 公告栏</title>
<%

if Request("menu")="delpassword" then
session("pass")=""
response.redirect "affiche.asp"
end if
top
%>
<table border=0 width=97% align=center cellspacing=1 cellpadding=4 class=a2>
<tr class=a3>
<td height=25>&nbsp;<img src=images/Forum_nav.gif>&nbsp; <%=Clubname%> → 
<a href="affiche.asp">社区公告</a>&nbsp;&nbsp;<%if membercode>4 then %><a href="affiche.asp?menu=admin">[管理公告]<%end if%></a></td>
</tr>
</table><br>
<%
if Request("menu")<>"" then
if Request.Cookies("username")=empty then error("<li>您还未<a href=login.asp>登录</a>社区")
%>
<table cellspacing=1 cellpadding=1 width=97% align=center border=0 class=a2>
  <TR id=TableTitleLink class=a1 height="25">
      <Td align="center"><b><a href="affiche.asp?menu=addaffiche">添加公告</a></b></td>
      <TD align="center"><b><a href="affiche.asp?menu=editaffiche">编辑公告</a></b></td>
      <TD align="center"><b><a href="affiche.asp?menu=delpassword">退出管理</a></b></td>      
      </TR></TABLE>
<br>
<%

if membercode < 5 then error("<li>您没有权限管理公告")
if Request("menu")="loginok" then
session("pass")=md5(""&Request("pass")&"")
if adminpassword<>session("pass") then error2("公告管理密码错误")
if HTMLEncode(Trim(request("addcode")))<>HTMLEncode(Trim(Session("GetCode"))) then error2("验证码错误")
Response.write "<p align=center><font color=ff0000>登录成功，请选择要进行的操作，退出时请点“退出管理”链接(删除缓存里的密码)！</font></p>"
end if

'验证管理密码

if adminpassword=session("pass") then

if Request("menu")="addafficheok" then
sql="select * from [affiche]"
rs.Open sql,Conn,1,3
rs.addnew
rs("title")=""&Request("title")&""
rs("content")=replace(replace(Request("content"),vbCrlf,""),"'","&#39;")
rs("username")=""&Request.Cookies("username")&""
rs("posttime")=date()
rs.update
rs.close
sql="select top 2 * from affiche order by posttime Desc"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
affiche=affiche&"<b>"&rs("title")&"</b> ("&rs("posttime")&")　　　"
RS.MoveNext
loop
Set Rs = Nothing
conn.execute("update [clubconfig] set affichetitle='"&affiche&"'")

%> <p align=center><font color=ff0000>发布成功</font><br><br><a href=affiche.asp>返 回</a></p><%
end if

if Request("menu")="editafficheok" then
id=int(Request("id"))
sql="select * from [affiche] where id="&id&""
rs.Open sql,Conn,1,3
if not rs.eof then
rs("title")=""&Request("title")&""
rs("content")=replace(replace(Request("content"),vbCrlf,""),"'","&#39;")
rs("username")=""&Request.Cookies("username")&""
rs("posttime")=date()
rs.update
rs.close
sql="select top 2 * from affiche order by posttime Desc"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
affiche=affiche&"<b>"&rs("title")&"</b> ("&rs("posttime")&")　　　"
RS.MoveNext
loop
Set Rs = Nothing
conn.execute("update [clubconfig] set affichetitle='"&affiche&"'")

%> <p align=center><font color=ff0000>编辑成功</font><br><br><a href=affiche.asp>返 回</a></p><%
else
%> <p align=center><font color=ff0000>编辑失败，可能该公告刚被其它区长删除了</font><br><br><a href=affiche.asp>返 回</a></p><%
end if
end if


if Request("menu")="delaffiche" then
id=int(Request("id"))
conn.execute("delete from [affiche] where id="&id&"")
sql="select top 2 * from affiche order by posttime Desc"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
affiche=affiche&"<b>"&rs("title")&"</b> ("&rs("posttime")&")　　　"
RS.MoveNext
loop
Set Rs = Nothing
conn.execute("update [clubconfig] set affichetitle='"&affiche&"'")
%> <p align=center><font color=ff0000>删除成功</font><br><br><a href=affiche.asp>返 回</a></p><%

end if

if Request("menu")="editaffiche2" then

if Request("id")<>empty then
id=int(Request("id"))
sql="select * from [affiche] where id="&id&""
Set Rs=Conn.Execute(sql)
content=rs("content")
title=rs("title")
end if

%>
<form name="yuziform" method="post" action="?menu=editafficheok" onSubmit="return CheckForm(this);">
<input name="content" type="hidden" value='<%=content%>'>
<input name="id" type="hidden" value='<%=id%>'>

<table cellspacing="1" cellpadding="2" width="97%" border="0" class="a2" align="center">
  <tr height=25>
    <td class=a1 align=middle colspan=2>编辑公告</td>
  </tr>
   <tr height=25>
    <td class=a3 align=middle width="16%">
标题：</td>
    <td class=a3 width="82%">
<input type="text" name="title" size="60" value="<%=title%>"></td></tr>
   <tr height=25>
    <td class=a3 align=middle width="16%">
内容：</td>
    <td class=a3 width="82%" height="250">
    
    <SCRIPT src="inc/post.js"></SCRIPT>

</td></tr>
   <tr height=25>
    <td class=a3 align=middle colspan=2>
<input type="submit" value=" 发 送 " name="submit1">
<input name=preview type="Button" value=" 预 览 " onclick="Gopreview()">
<input type="reset" value=" 重 置 ">
</td></tr></table></form><form name=preview action=preview.asp method=post target=preview_page><input name="content" type="hidden"></form>
<p align=center><a href=affiche.asp>返 回</a></p>
<%


end if


if Request("menu")="addaffiche" then

%>
<form name="yuziform" method="post" action="?menu=addafficheok" onSubmit="return CheckForm(this);">
<input name="content" type="hidden" value='<%=content%>'>
<input name="id" type="hidden" value='<%=id%>'>

<table cellspacing="1" cellpadding="2" width="97%" border="0" class="a2" align="center">
  <tr height=25>
    <td class=a1 align=middle colspan=2>发布新的公告</td>
  </tr>
   <tr height=25>
    <td class=a3 align=middle width="16%">
标题：</td>
    <td class=a3 width="82%">
<input type="text" name="title" size="60" value="<%=title%>"></td></tr>
   <tr height=25>
    <td class=a3 align=middle width="16%">
内容：</td>
    <td class=a3 width="82%" height="250">
    
    <SCRIPT src="inc/post.js"></SCRIPT>

</td></tr>
   <tr height=25>
    <td class=a3 align=middle colspan=2>
<input type="submit" value=" 发 送 " name="submit1">
<input name=preview type="Button" value=" 预 览 " onclick="Gopreview()">
<input type="reset" value=" 重 置 ">
</td></tr></table></form><form name=preview action=preview.asp method=post target=preview_page><input name="content" type="hidden"></form>
<p align=center><a href=affiche.asp>返 回</a></p>
<%
end if
if Request("menu")="editaffiche" then


%>
<br>
<table border="0" cellpadding="5" cellspacing="1" class=a2 width=97%>
<tr>
<td width="5%" align="center" height="25" class=a1>ID</td>
<td width="35%" align="center" height="25" class=a1>标题</td>
<td width="10%" align="center" height="25" class=a1>发布人</td>
<td width="15%" align="center" height="25" class=a1>发布时间</td>
<td width="15%" align="center" height="25" class=a1>管理</td>
</tr>
<%
sql="select * from affiche order by posttime Desc"
rs.Open sql,Conn,1
pagesetup=20 '设定每页的显示数量
rs.pagesize=pagesetup
TotalPage=rs.pagecount  '总页数
PageCount = cint(Request.QueryString("ToPage"))
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
if TotalPage>0 then rs.absolutepage=PageCount '跳转到指定页数
i=0
Do While Not RS.EOF and i<pagesetup
i=i+1%>
<tr>



<td height="25" align="center" bgcolor="FFFFFF"> <%=rs("id")%>
<td height="25" align="center" bgcolor="FFFFFF"><%=rs("title")%>
<td height="25" align="center" bgcolor="FFFFFF"><a target="_blank" href="Profile.asp?username=<%=rs("username")%>"><%=rs("username")%></a>
<td height="25" align="center" bgcolor="FFFFFF"><%=rs("posttime")%>
<td height="25" align="center" bgcolor="FFFFFF"><a href="?menu=editaffiche2&id=<%=rs("id")%>">修改公告</a> <a onclick=checkclick('您确定要删除该公告？') href="?menu=delaffiche&id=<%=rs("id")%>">删除公告</a></td>
</tr>
<%
RS.MoveNext
loop
RS.Close
%>
</table>
[<b>
<script>
ShowPage(<%=TotalPage%>,<%=PageCount%>,"")
</script>
</b>]

<%




end if

'输入管理密码
else
%> <br>
<br>
<br>
<form action="?menu=loginok" method="post">
	<input type="hidden" value="pass" name="menu">
	<table width="333" border="0" cellspacing="1" cellpadding="2" align="center" class="a2">
		<tr>
			<td width="328" class="a1" height="25">
			<div align="center">
				登录管理</div>
			</td>
		</tr>
		<tr>
			<td height="19" width="328" valign="top" class="a3">
			<div align="center">
				请输入管理密码: <input size="15" name="pass" type="password"><br>
				验 证 码: <input size="15" name="addcode" value name="addcode">&nbsp;<%=getcode1()%><br>
				<input type="submit" value=" 登录 " name="Submit1">　<input type="reset" value=" 取消 " name="Submit">
			</div>
			</td>
		</tr>
	</table>
</form>
<%
end if

else




sql="select * from affiche order by posttime Desc"
rs.Open sql,Conn,1
pagesetup=10 '设定每页的显示数量
rs.pagesize=pagesetup
TotalPage=rs.pagecount  '总页数
PageCount = cint(Request.QueryString("ToPage"))
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
if TotalPage>0 then rs.absolutepage=PageCount '跳转到指定页数
i=0
Do While Not RS.EOF and i<pagesetup
i=i+1
%>
<div align="center">
<table border="0" width="97%" cellspacing="1" cellpadding="5" height="64" class="a2">
	<tr>
		<td width="100%" height="20" class="a1">
		<p align="center"><%=rs("title")%></p>
		</td>
	</tr>
	<tr>
		<td width="100%" class="a3"><%=rs("content")%>
		</td>
	</tr>
	<tr>
		<td width="100%" class="a4" height="18">
		<p align="right">发布人 <%=rs("username")%>　发布时间 
		<font style="family:arial; font-size: 7pt"><%=rs("posttime")%></font> </p>
		</td>
	</tr>
</table></div>
<br>
<%
RS.MoveNext
loop
RS.Close
%><center>
[<b>
<script>
ShowPage(<%=TotalPage%>,<%=PageCount%>,"")
</script>
</b>]
<%
end if
htmlend
%>

<%
Function getcode1()
Dim test
On Error Resume Next
Set test=Server.CreateObject("Adodb.Stream")
Set test=Nothing
If Err Then
Dim zNum
Randomize timer
zNum = cint(8999*Rnd+1000)
Session("GetCode") = zNum
getcode1= Session("GetCode") 
Else
getcode1= "<img src=""nccode.asp"">" 
End If
End Function
%>