<!--#include file="Inc.asp"-->
<!--#include file="Inc/Page_Cls.asp"-->
<%
Dim Action
If Not BBS94KK.Founduser Then BBS94KK.GoToerr(10)
IF SESSION(CacheName& "MyGradeInfo")(37)="0" Then BBS94KK.GoToErr(67)
Action=Lcase(Request.querystring("Action"))
If Len(Action)>10 then BBS94KK.GoToerr(1)
Select Case Action
Case"del"
	DelPlacard
Case Else
	Placard()
End Select
BBS94KK.Footer()
Set BBS94KK=Nothing

Sub DelPlacard()
	Dim ID
	ID=BBS94KK.Checknum(request.querystring("ID"))
	IF BBS94KK.MyAdmin=7 Then
		BBS94KK.execute("Delete From [KK_Placard] where ID="&ID&" and Name='"&BBS94KK.MyName&"'")
	Else
		BBS94KK.execute("Delete From [KK_Placard] where ID="&ID&"")
	End IF
	BBS94KK.Cache.clean("Placard")
	BBS94KK.NetLog "删除公告"
	Response.redirect "Placard.asp"
End Sub

Sub Placard()
	Dim Caption,Content,Temp,TmpBoardID,S,Title,Rs,ID
	If BBS94KK.BoardID>0 Then BBS94KK.CheckBoard()
	IF BBS94KK.MyAdmin=7 And BBS94KK.IsBoardAdmin=False  Then BBS94KK.GoToErr(68)
	ID=BBS94KK.Checknum(request("ID"))
	BBS94KK.Head"发布公告"
	Caption=BBS94KK.Fun.Checkbad(BBS94KK.Fun.GetStr("caption"))
	Content=BBS94KK.Fun.Checkbad(BBS94KK.Fun.GetStr("Content"))
	IF Caption="" And Content="" Then
		Title="发布公告"
		TmpBoardID=BBS94KK.BoardID
		If ID<>0 Then
			Set Rs=BBS94KK.execute("select BoardID,Caption,Content,AddTime,Name,hits from [KK_Placard] where ID="&ID&"")
			IF Not rs.eof Then
				Title="编辑公告"
				TmpBoardID=Rs(0)
				Caption=Rs(1)
				Content=Rs(2)
				If BBS94KK.MyAdmin=7 Then
					If Lcase(BBS94KK.MyName)<>Lcase(Rs(4)) Then BBS94KK.GotoErr(73)
				End If
			Else
				BBS94KK.Gotoerr(69)
			End If
		End If
		S="<form  style='margin:0' action='?action=Placard&BoardID="&BBS94KK.BoardID&"' method='post' name='say'><textarea id='content' name='content' style='display:none'>"&Content&"</textarea>"
		If BBS94KK.MyAdmin=7 Then
			Temp=BBS94KK.BoardName&"<input name='BoardID' value='"&BBS94KK.BoardID&"' type='hidden' />"
		Else
			Temp="<select name='BoardID'><option value='0'>猪婷首页</option>"&BBS94KK.BoardIDList(TmpBoardID,0)&"</select>"
		End If
		S=S&BBS94KK.Row("<b>公告标题：</b>","<input name='ID' type='hidden' value='"&ID&"' /><input type=hidden name='safecode' id='safecode' value='94kk' /><input name='caption' type='text' class='text' id='caption' value='"&caption&"' size='60' />","75%","")
		S=S&BBS94KK.Row("<b>所在版块：</b>",Temp,"75%","")
		If BBS94KK.Info(60)="1" Then Temp="UbbEdit()" Else Temp="HtmlEdit()"
		Temp="<script type=""text/javascript"">"&Temp&"</script>"
		S=S&BBS94KK.Row("<b>公告内容：</b>",Temp,"75%","")
		S=S&"<div style="" padding:5px;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";"" align=""center""><input type='button' class='button' value='提 交' id='sayb' onclick='checkform(16200)' /> <input type='reset' value=' 重 写 ' onclick='Goreset()' class='button' /></div></form>"
		BBS94KK.ShowTable Title,S
		AdminPlacard()
	Else
		TmpBoardID=BBS94KK.Checknum(request("BoardID"))
		IF len(Content)>16200 or Len(Caption)>250 Then BBS94KK.GoToErr(18)
		If BBS94KK.Fun.CheckIsEmpty(Content) Then BBS94KK.GoToErr(50)
		If BBS94KK.Info(60)="1" Then Content=BBS94KK.Fun.Replacehtml(Content)
		Temp=BBS94KK.Fun.UbbString(Content)
		If ID<>0 Then
			Title="编辑公告"
			BBS94KK.Execute("update KK_Placard Set Caption='"&Caption&"',Content='"&Content&"',BoardID="&TmpBoardID&",UbbString='"&Temp&"' where ID="&ID)
		Else
			BBS94KK.execute("insert into[KK_Placard](Caption,Content,AddTime,Name,BoardID,UbbString)values('"&Caption&"','"&Content&"','"&BBS94KK.NowBbsTime&"','"&BBS94KK.MyName&"',"&TmpBoardID&",'"&Temp&"')")
			Title="发布公告"
		End If
		Content="<li>"&Title&"成功!</li><li><a href='Index.asp'>返回首页</a></li>"
		IF TmpBoardID>0 Then Content=Content&"<li><a href=List.asp?BoardID="&BBS94KK.BoardID&">"&BBS94KK.BoardName&"</a>"
		Content="<div style='margin:15px;line-height: 150%'>"&Content&"</div>"
		BBS94KK.Cache.clean("Placard")
		BBS94KK.NetLog Title
		BBS94KK.ShowTable Title,Content
	End If
End Sub

Sub AdminPlacard()
	Dim P,arr_Rs,i,Temp,S,PInfo,Sqlwhere,Title
	If BBS94KK.MyAdmin=7 Then
		Sqlwhere="Name='"&BBS94KK.MyName&"'"
		Title="我发表的公告"
	Else
		Title="公告列表"
	End If
	Set P = New Cls_PageView
	P.strTableName = "[KK_Placard]"
	P.strPageUrl = "?Action="&Action
	P.strFieldsList = "ID,Caption,BoardID,Name,AddTime,hits"
	P.strPrimaryKey ="ID"
	p.strCondiction=Sqlwhere
	P.strOrderList = "BoardID,ID desc"
	P.intPageSize = Request.QueryString("page")
	P.strCookiesName = "Placard_List"
	P.strPageVar = "page"
	P.InitClass
	Arr_Rs = P.arrRecordInfo
	PInfo = P.strPageInfo
	Set P = nothing
	S="<div style='text-align:center;border-bottom:1px solid "&BBS94KK.SkinsPIC(0)&";padding:3px;font-weight:bold;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";'><div style=""float:left;width:32%"">公告标题</div><div style=""float:left;width:18%"">所在版块</div><div style=""float:left;width:12%"">作者</div><div style=""float:left;width:20%"">时间</div><div style=""float:left;"">管理</div><div style=""clear: both;""></div></div>"
	If IsArray(Arr_Rs) Then
		For i = 0 to UBound(Arr_Rs, 2)
		S=S&"<div style='overflow :hidden;text-align:center;border-bottom:1px solid "&BBS94KK.SkinsPIC(0)&";height:22px;line-height:22px'><div style=""float:left;width:32%;text-align:left;""><a href='#this' onclick=""openwin('See.asp?Action=placard&ID="&Arr_Rs(0,i)&"',500,400,'yes')"" >"&Arr_Rs(1,i)&"</a></div><div style=""float:left;width:18%;border-left:1px solid "&BBS94KK.SkinsPIC(0)&";"">"&Replace(BBS94KK.GetBoardName(Arr_Rs(2,i)),"所有版块","猪婷首页")&"</div><div style=""float:left;width:12%;border-left:1px solid "&BBS94KK.SkinsPIC(0)&";""><a href='UserInfo.asp?Name="&Arr_Rs(3,i)&"'>"&Arr_Rs(3,i)&"</a></div><div style=""float:left;width:20%;border-left:1px solid "&BBS94KK.SkinsPIC(0)&";"">"&Arr_Rs(4,i)&"</div><div style=""float:left;border-left:1px solid "&BBS94KK.SkinsPIC(0)&";padding-left:5px;height:22px;""><a href='?Action=Edit&ID="&Arr_Rs(0,i)&"&BoardID="&Arr_Rs(2,i)&"'><img src='Images/Icon/Edit.gif' alt='' border='0'>修改</a> <a href='#this' onclick=""if(confirm('删除这条公告！\n\n您确定要删除吗？'))window.location.href='?action=del&ID="&Arr_Rs(0,i)&"'"" ><img src='Images/Icon/del.gif' alt='' border='0'>删除</a></div><div style=""clear: both;""></div></div>"
		Next
		S=S&"<div style=""BACKGROUND: "&BBS94KK.SkinsPIC(2)&";"">"&PInfo&"</div>"
	End If
	BBS94KK.ShowTable Title,S
End Sub
%>
