<!--#include file="../Conn.asp" -->
<!--#include file="../Function/Function.asp" -->
<%
if len(Request.Form("CommentsContent"))>800 then  
    response.write"<script>alert('评论内容不能太多,请重新输入！');location.href = 'javascript:history.go(-1)';</script>"
   response.end
end if
IF ChecKWcafesIP(UsersIP())=True Then
CommentsUsers=session("WcafesName")
UsersGroupx=session("WcafesGroup")
Else
IF Request.Cookies("YWNTUserCookie")("UserName")="" Then
Select Case GetUsersSystem("UsersCommentsOn")
Case 0
	response.write"<script>alert('请您登陆后在发表评论！');location.href = 'javascript:history.go(-1)';</script>"
	response.end
Case 1
CommentsUsers="游客"
UsersGroupx="游客"
end Select
Else
Set RS=Server.CreateObject(YWNT_TMS_RS)
SQL="select UsersName,UsersGroup from YWNT_TMS_Users Where UsersName='"&Request.Cookies("YWNTUserCookie")("UserName")&"'"
Rs.open sql,Conn,1,1
If not RS.Eof Then
CommentsUsers=RS("UsersName")
UsersGroupx=RS("UsersGroup")
End If
RS.Close
Set RS = Nothing
End if
End if
if UsersGroupx<>"游客" then
if GetUsersGroup("GroupComments",UsersGroupx)=0 then
	response.write"<script>alert('您所在用户组无权发表评论！');location.href = 'javascript:history.go(-1)';</script>"
	response.end
end if
end if

Set RS=Server.CreateObject(YWNT_TMS_RS)
sql="select * from YWNT_TMS_Comments"
RS.open sql,conn,1,3
RS.addnew
RS("CommentsMovieID")=NoSqlHack(Request.Form("ID"))
RS("CommentsContent")=HTMLEncode(NoSqlHack(Request.Form("CommentsContent")))
RS("CommentsUsers")=CommentsUsers
RS("CommentsDate")=Now()
Select Case GetUsersSystem("UsersCommentsAudit")
Case 0
RS("CommentsAudit")=1
Case 1
RS("CommentsAudit")=0
End Select
RS.update
RS.close
set RS=nothing
Select Case GetUsersSystem("UsersCommentsAudit")
Case 0
response.write"<script>alert('发表评论成功！');location.href = '"&Request.ServerVariables("HTTP_REFERER")&"';</script>"
Case 1
response.write"<script>alert('评论已经加入等待管理员审核通过！');location.href = '"&Request.ServerVariables("HTTP_REFERER")&"';</script>"
End Select
call connclose()
%>
</body>
</html>