<!--#include file="../../conn/conn_other.asp"-->
<!--#include file="../Incs/SysCode.asp"-->
<%
Response.Charset="Gb2312"
Dim Action
Dim UserName,Content,ClassID
Action=CheckStr(Request("Action"))
PostName=CheckStr(Request("username"))
Content=CheckStr(Request("content"))
VideoID=CheckNum(Request("id"))
Page=CheckNum(Request("Page"))

Select Case Action
	Case "New"
		Call CommentSave()
	Case Else
		Call CommentList(VideoID,Page)
End Select

Function CommentSave()
	Dim Rs,Sql,UserIP
	UserIP=GetIP()
	Sql="Insert Into Dm_Comment(VideoID,PostName,[Content],PostIP,PostTime)values("&VideoID&",'"&PostName&"','"&CheckBadWord(ComBadWord,Content)&"','"&UserIP&"','"&Now()&"')"
	Conn.execute(Sql)
	Call DBUpdate("Dm_Video","ComHits=ComHits+1","VideoID="&VideoID&"")
	Call CommentList(VideoID,Page)
End Function

Function CommentList(VideoID,Page)
	Dim Tag,Table,TagStr,Order,PageSize,PageUrl
	Tag="CommentID"										
	Table="[Dm_Comment]"								
	TagStr="*"	
	Order="CommentID"									
	PageSize=ComListNum							
	PageUrl="Comment.asp"								
	LinkNum=5										
	Dim TotalCount,PageCount
	Dim Rs,Sql,WhereStr
	If VideoID<>0 Then
		WhereStr="Where VideoID="&VideoID&""
		PageUrl=PageUrl&"?id="&VideoID&""
	End If
	TotalCount=GetTotalCount(Tag,Table,WhereStr)
	PageCount=GetPageCount(TotalCount,PageSize)
	Page=GetPageNow(PageCount)
	Sql=GetPageSql(Tag,Table,TagStr,Order,PageSize,WhereStr,Page)
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Rs.Open Sql,Conn,1,1
	If Rs.Bof And Rs.Eof Then
		TempStr=TempStr&"<div class=""comment"">"&vbcrlf
		TempStr=TempStr&"暂无评论~还不赶快抢个沙发！"&vbcrlf
		TempStr=TempStr&"</div>"&vbcrlf
	Else
		Dim I,Content
		I=Int(TotalCount-((Page-1)*PageSize))
		Do While Not Rs.Eof
			Content=Rs("Content")
			For D = 1 To 12
				Content=Replace(Content,"&#091;em"&D&"&#093;","<img src=""/film/Images/Emote/emote"&D&".gif"" style=""margin-right:2px;"">")
			Next
			TempStr=TempStr&"<div class=""comment"" onmouseover=""this.style.backgroundColor='#fff';"" onmouseout=""this.style.backgroundColor='#F8FBFE';"">"&vbcrlf
			TempStr=TempStr&"<ul>"
			TempStr=TempStr&"<li class=""tt""><span>"&I&" 楼  "&FormatTime(Rs("PostTime"),3)&"</span> <b>"&Rs("PostName")&"</b></li>"&vbcrlf
			TempStr=TempStr&"<li class=""cc"">"&Content&"</li>"&vbcrlf
			TempStr=TempStr&"</ul>"&vbCrLf
			TempStr=TempStr&"</div>"&vbcrlf
		I=I-1
		Rs.MoveNext
		Loop
		
		TempStr=TempStr&"<div class=""comp"">"&vbcrlf
		If Page>1 Then
			TempStr=TempStr&"<a href=""javascript:showpage('"&VideoID&"','1');"">首页</a>"&vbcrlf
			TempStr=TempStr&"<a href=""javascript:showpage('"&VideoID&"','"&Page-1&"');"">上一页</a>"&vbcrlf
		End If
		If Page<PageCount Then
			TempStr=TempStr&"<a href=""javascript:showpage('"&VideoID&"','"&Page+1&"');"">下一页</a>"&vbcrlf
			TempStr=TempStr&"<a href=""javascript:showpage('"&VideoID&"','"&PageCount&"');"">尾页</a>"&vbcrlf
		End If
		TempStr=TempStr&"</div>"&vbCrLf
	End If
	Rs.Close
	Set Rs=Nothing
	Rw TempStr
End Function
%>
<%
Call CloseDb()
%>
