<%
'===================================================================================================================
'软件名称：云网影视管理系统
'Copyright (C) 2002-2007 ywnt.net  All rights reserved.
'产品咨询QQ：489234,2813712
'程序版权：云网互动科技有限公司
'程序开发：云网互动科技有限公司
'官方网站：http://www.ywnt.net 
'郑重声明:
'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
'    2、任何个人或组织不得在授权允许的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    3、云网互动科技有限公司保留此软件的法律追究权利
'===================================================================================================================

call IsIPlock()

Function GetDomain()
	   GetDomain = GetConfig("WebUrl") & GetConfig("WebiInstallDir")&"Editor/"
End Function

Function GetConfig(ByVal ConfigField)
Dim ConfigRS
Set ConfigRS = Server.CreateObject(YWNT_TMS_RS)
ConfigRS.Open ("Select "&ConfigField&" From YWNT_TMS_Config"), Conn, 1, 1
GetConfig = ConfigRS(ConfigField)
ConfigRS.Close
Set ConfigRS = Nothing
End Function 

Function GetUsersSystem(ByVal UsersField)
Dim UsersRS
Set UsersRS = Server.CreateObject(YWNT_TMS_RS)
UsersRS.Open ("Select "&UsersField&" From YWNT_TMS_UsersSystem"), Conn, 1, 1
GetUsersSystem = UsersRS(UsersField)
UsersRS.Close
Set UsersRS = Nothing
End Function

Function GetSysPlay(ByVal ConfigField)
Dim GetSysPlayRS
Set GetSysPlayRS = Server.CreateObject(YWNT_TMS_RS)
GetSysPlayRS.Open ("Select "&ConfigField&" From YWNT_TMS_Sysplay"), Conn, 1, 1
GetSysPlay = GetSysPlayRS(ConfigField)
GetSysPlayRS.Close
Set GetSysPlayRS = Nothing
End Function 

Function IsPicTF(Str)
	If Str = "" Then
		IsPicTF = False
	End If
	If Instr(Str,"/") > 0 Or Left(Str,1) = "/" Or Left(Lcase(Str),7) = "http://" And Right(Lcase(Str),4) = ".jpg" Or Right(Lcase(Str),4) = ".gif" Or Right(Lcase(Str),4) = ".png" Then
		IsPicTF = True
	Else
		IsPicTF = False
	End if	
End Function

Function timedate(AddDate)
timedate=Year(AddDate) & "-" & Month(AddDate) & "-" & Day(AddDate)
End Function
		
Function zf(Str,strlen,intPadDotAmount)
If Str = "" Then zf = "":Exit Function
Dim l, T, c, I, strTemp
l = Len(Str)
T = 0
strTemp = Str
For I = 1 To l
	c = Abs(Asc(Mid(Str, I, 1)))
	If c > 255 Then
		T = T + 2
	Else
		T = T + 1
	End If
	If T >= strlen Then
		strTemp = Left(Str, I)
		Exit For
	End If
Next
If strTemp <> Str Then	strTemp = strTemp
zf = strTemp&intPadDotAmount
End Function

Function Actor(content,m,OpenS)
Actor=""
ActorName = split(content,"|")
if m="" then
m=Ubound(ActorName)
else
if m>Ubound(ActorName) then
m=Ubound(ActorName)
else
m=m
end if
end if
For n = 0 To m 
Actor=Actor&"<a href="""&GetConfig("WebiInstallDir")&"search.asp?searchtype=2&Keyword="&ActorName(n)&""" "&OpenS&">"&ActorName(n)&"</a> "
Next
End Function

Function ClassName(Id,classurl,OpenS)
Str_Sql = "Select ID,ClassName from YWNT_TMS_MovieClass where ID="&Id&" order by ClassWith asc,id asc"
Set Rs_Class = Conn.Execute(Str_Sql)
if not Rs_Class.Eof then
Str_ClassInfo=Rs_Class("ClassName")
end if
Rs_Class.close
Set RS_class = Nothing
ClassName="<a href="""&classurl&""" "&OpenS&">"&Str_ClassInfo&"</a>"
End Function

Function RegionName(Id,OpenS)
Str_Sql = "Select ID,RegionName from YWNT_TMS_MovieRegion where ID="&Id&" order by RegionWith asc,id asc"
Set RS_Region = Conn.Execute(Str_Sql)
if not RS_Region.Eof then
Str_Region=RS_Region("RegionName")
end if
Rs_Region.close
Set RS_Region = Nothing
RegionName="<a href="""&GetConfig("WebiInstallDir")&"search.asp?searchtype=4&Keyword="&Id&""" "&OpenS&">"&Str_Region&"</a>"
End Function

Function ClassNameE(Id)
Str_Sql = "Select ClassNameE from YWNT_TMS_MovieClass where ID="&Id&" order by ClassWith asc,id asc"
Set Rs_Class = Conn.Execute(Str_Sql)
if not Rs_Class.Eof then
Str_ClassInfo=Rs_Class("ClassNameE")
end if
Rs_Class.close
Set RS_class = Nothing
ClassNameE=Str_ClassInfo
End Function

Function GetCode()
	GetCode= "<input type=""text"" name=""codestr"" size=""6"" /><img src="""&GetConfig("WebiInstallDir")&"Function/Code.asp"" id=""codeImg"" onclick=""codeImg.src='"&GetConfig("WebiInstallDir")&"Function/Code.asp'"" align=""absmiddle""/>"
End Function
	
Function ShowErr(ErrMsg,ErrorUrl,ErrType)
Select Case ErrType
Case 0
ErrTitle="操作失败"
ErrLeft="×"
Case 1
ErrTitle="操作成功"
ErrLeft="√"
End Select
Response.Write"<table width=""100%"" height=""60%"" border=0 align=""center"" cellpadding=1 cellspacing=0>" &vbcrlf
Response.Write"<tr>" &vbcrlf 
Response.Write"<td>" &vbcrlf
Response.Write"<TABLE cellSpacing=1 cellPadding=3 width=""60%"" align=center border=0>" &vbcrlf
Response.Write"<TBODY>" &vbcrlf
Response.Write"<TR>" &vbcrlf
Response.Write"<TD colSpan=3 colspan=2>"&ErrTitle&"</TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"<TR>" &vbcrlf
Response.Write"<TD width=""15%"" height=""10"" align=""center""><font style=""font-size:30px;color: #FF0000;""><strong>"&ErrLeft&"</strong></font></TD>" &vbcrlf
Response.Write"<TD align=""left"" height=""100"">"&ErrMsg&"<li><a href="&ErrorUrl&">返回上一级</a></li></TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"<TR>" &vbcrlf
Response.Write"<TD colSpan=3 height=""25"" colspan=2></TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"</TBODY>" &vbcrlf
Response.Write"</TABLE>" &vbcrlf
Response.Write"</td>" &vbcrlf
Response.Write"</tr>" &vbcrlf
Response.Write"</table>"
response.end
End Function

Function Admin_ShowErr(ErrMsg,ErrorUrl,ErrType)
Select Case ErrType
Case 0
ErrTitle="操作失败"
ErrLeft="×"
Case 1
ErrTitle="操作成功"
ErrLeft="√"
End Select
Response.Write"<table width=""100%"" height=""60%"" border=0 align=""center"" cellpadding=1 cellspacing=0>" &vbcrlf
Response.Write"<tr>" &vbcrlf 
Response.Write"<td>" &vbcrlf
Response.Write"<TABLE class=table cellSpacing=1 cellPadding=3 width=""60%"" align=center border=0>" &vbcrlf
Response.Write"<TBODY>" &vbcrlf
Response.Write"<TR>" &vbcrlf
Response.Write"<TD class=xingmu colSpan=3 colspan=2>"&ErrTitle&"</TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"<TR>" &vbcrlf
Response.Write"<TD class=""hback"" width=""15%"" height=""10"" align=""center""><font style=""font-size:30px;color: #FF0000;""><strong>"&ErrLeft&"</strong></font></TD>" &vbcrlf
Response.Write"<TD class=""hback"" align=""left"" height=""100"">"&ErrMsg&"<li><a href="&ErrorUrl&">返回上一级</a></li></TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"<TR>" &vbcrlf
Response.Write"<TD class=xingmu colSpan=3 height=""25"" colspan=2></TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"</TBODY>" &vbcrlf
Response.Write"</TABLE>" &vbcrlf
Response.Write"</td>" &vbcrlf
Response.Write"</tr>" &vbcrlf
Response.Write"</table>"
response.end
End Function

Function CheckCF(FildName,FildValue,Str_LinkStr)
	CheckCF = Conn.execute("select count(*) from YWNT_TMS_Users where "&FildName&"="&Str_LinkStr& FildValue &Str_LinkStr)(0)
End Function

Function UsersGroup(ByVal UsersGroupgField)
Dim GroupRS
Set GroupRS = Server.CreateObject(YWNT_TMS_RS)
GroupRS.Open ("Select GroupName From YWNT_TMS_UsersGroup where ID="&UsersGroupgField), Conn, 1, 1
UsersGroup = GroupRS("GroupName")
GroupRS.Close
Set GroupRS = Nothing
End Function

Function UsersType(UsersTypeField)
Select Case UsersTypeField
Case 0
Response.Write"影币"
Case 1
Response.Write"包月"
End Select
End Function

Function UsersIP()
Dim LoginIP
LoginIP = Trim(Request.ServerVariables("HTTP_X_FORWARDED_FOR"))
If LoginIP = "" Then LoginIP = Request.ServerVariables("REMOTE_ADDR")
UsersIP=LoginIP
End Function

Function UsersLoginSever(UserName,PassWord)
Set RS=Server.CreateObject(YWNT_TMS_RS)
SQL="select UsersState,UsersIP,UsersLogin,UsersGroup from YWNT_TMS_Users Where UsersName='"&UserName&"' And UsersPassword='"&PassWord&"'"
Rs.open sql,Conn,1,3
If RS.Eof And RS.BOf Then
Response.Write("<script>alert('你输入的用户名或密码有误，请重新输入！');history.back();</script>")
response.end
RS.Close:Set RS=Nothing
Exit Function
ElseIf RS("UsersState")=1 Then
Response.Write("<script>alert('您的账号已被管理员锁定，请与管理员联系！');history.back();</script>")
response.end
RS.Close:Set RS=Nothing
Exit Function
Else
RS("UsersIP")=UsersIP()
RS("UsersLogin")=RS("UsersLogin")+1
Rs.Update
UsersGroupOnline=RS("UsersGroup")
RS.Close
Set RS=Nothing
End If
conn.Execute("Delete From YWNT_TMS_UsersOnline where DATEDIFF("&MakeRandomStr&",LoginDate,"&SqlNow&")>40")
conn.Execute("insert into YWNT_TMS_UsersOnline(UsersName,UsersIP,UsersGroup,LoginDate) values('"&UserName&"','"&UsersIP()&"',"&UsersGroupOnline&","&SqlNow&")")
End Function

Function UsersLogin()
Response.Write"<SCRIPT>" &_
"function formcheck()" &_
"{" &_
"if (form.userid.value=="""")" &_
"{" &_
"alert('请输入用户名!');" &_
"form.userid.focus();" &_
"return false;" &_
"}" &_
"if (form.password.value=="""")" &_
"{" &_
"alert('请输入密码!');" &_
"form.password.focus();" &_
"return false;" &_
"}" &_
"if (form.codestr.value=="""")" &_
"{" &_
"alert('请输入验证码!');" &_
"form.codestr.focus();" &_
"return false;" &_
"}" &_
"}" &_
"</SCRIPT>" &_
"<table width=""315"" height=""215"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">" &_
"<tr>" &_
"<td bgcolor=""#f7f7f7""><table width=""300"" height=""198"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"" class=""login"">" &_
"<tr>" &_
"<td><table width=""92%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">" &_
"<tr>" &_
"<td width=""246"" colspan=""2""><img src=""images/usercenter_09.gif"" width=""273"" height=""30"" alt="""" /></td>" &_
"</tr>" &_
"<tr>" &_
"<td height=""143"" colspan=""2"">" &_
"<table width=""90%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">" &_
"<form action=""Users_CheckLogin.asp"" method=""post"" name=""form"" id=""form"">" &_
"<tr>" &_
"<td width=""27%""><table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">" &_
"<tr>" &_
"<td width=""25%""><img src=""images/usercenter_13.gif"" width=""4"" height=""10"" alt="""" /></td>" &_
"<td width=""75%"">用户名： </td>" &_
"</tr>" &_
"</table></td>" &_
"<td width=""73%"" height=""30""><input name=""userid"" type=""text"" style=""width:180px"" /></td>" &_
"</tr>" &_
"<tr>" &_
"<td><table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">" &_
"<tr>" &_
"<td width=""25%""><img src=""images/usercenter_13.gif"" width=""4"" height=""10"" alt="""" /></td>" &_
"<td width=""75%"">密　码： </td>" &_
"</tr>" &_
"</table></td>" &_
"<td height=""30""><input name=""password"" type=""password"" style=""width:180px"" /></td>" &_
"</tr>" &_
"<tr>" &_
"<td><table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">" &_
"<tr>" &_
"<td width=""25%""><img src=""images/usercenter_13.gif"" width=""4"" height=""10"" alt="""" /></td>" &_
"<td width=""75%"">验证码： </td>" &_
"</tr>" &_
"</table></td>" &_
"<td height=""30"">"&GetCode&"</td>" &_
"</tr>" &_
"<tr>" &_
"<td><input type=""image"" name=""imageField"" src=""images/usercenter_17.gif"" onClick=""return formcheck();""/></td>" &_
"<td height=""30""><a href=""Users_Index.asp?Url=Users_ForgotPassword.asp"" target=""_blank""><img src=""images/usercenter_18.gif"" width=""190"" border=""0"" height=""23"" alt="""" /></a></td>" &_
"</tr>" &_
"</form>" &_
"</table></td>" &_
"</tr>" &_
"</table></td>" &_
"</tr>" &_
"</table></td>" &_
"</tr>" &_
"</table>"
End Function

	Function MakeRandomChar(Length)
	  Dim I, tempS, v
	  Dim c(65)
	   tempS = ""
	   c(1) = "a": c(2) = "b": c(3) = "c": c(4) = "d": c(5) = "e": c(6) = "f": c(7) = "g"
	   c(8) = "h": c(9) = "i": c(10) = "j": c(11) = "k": c(12) = "l": c(13) = "m": c(14) = "n"
	  c(15) = "o": c(16) = "p": c(17) = "q": c(18) = "r": c(19) = "s": c(20) = "t": c(21) = "u"
	  c(22) = "v": c(23) = "w": c(24) = "x": c(25) = "y": c(26) = "z": c(27) = "1": c(28) = "2"
	   c(29) = "3": c(30) = "4": c(31) = "5": c(32) = "6": c(33) = "7": c(34) = "8": c(35) = "9"
	  c(36) = "-": c(37) = "_": c(38) = "@": c(39) = "!": c(40) = "A": c(41) = "B": c(42) = "C"
	  c(43) = "D": c(44) = "E": c(45) = "F": c(46) = "G": c(47) = "H": c(48) = "I": c(49) = "J": c(50) = "K"
	  c(51) = "L": c(52) = "M": c(53) = "N": c(54) = "O": c(55) = "P": c(56) = "Q": c(57) = "R": c(58) = "S"
	  c(59) = "J": c(60) = "U": c(61) = "V": c(62) = "W": c(63) = "X": c(64) = "Y": c(65) = "Z"
	
	  If IsNumeric(Length) = False Then
		 MakeRandomChar = "":Exit Function
	  End If
	  For I = 1 To Length
		 Randomize
		 v = Int((65 * Rnd) + 1):tempS = tempS & c(v)
		 Next
		MakeRandomChar = tempS
	End Function

Function LookType(MovieType)
Select Case MovieType
Case 1
LookType="在线观看"
Case 2
LookType="下载观看"
Case 3
LookType="bobop2p"
Case 4
LookType="原力p2p"
Case 5
LookType="snsp2p"
Case 6
LookType="snsp2p"
End Select
End Function

Function NoSqlHack(inputStr)
Dim f_NoSqlHack_AllStr,NoSqlHack_Str,NoSqlHack_i,Str_InputStr
Str_InputStr=inputStr
NoSqlHack_AllStr="*|and |exec |insert |select |delete |update |count |master |truncate |declare |and	|exec	|insert	|select	|delete	|update	|count	|master	|truncate	|declare	|char(|mid(|chr(|and[|exec[|insert[|select[|delete[|update[|count[|master[|truncate[|declare[|set[|set |set	|where[|where |where	"
NoSqlHack_Str = Split(NoSqlHack_AllStr,"|")

For NoSqlHack_i=LBound(NoSqlHack_Str) To Ubound(NoSqlHack_Str)
	If Instr(LCase(Str_InputStr),NoSqlHack_Str(NoSqlHack_i))<>0 Then
		If NoSqlHack_Str(NoSqlHack_i)="'" Then NoSqlHack_Str(NoSqlHack_i)=" \' "
		Response.Write "<html><title>警告</title><body bgcolor=""EEEEEE"" leftmargin=""60"" topmargin=""30""><font style=""font-size:16px;font-weight:bolder;color:blue;""><li>您提交的数据有恶意字符</li></font><font style=""font-size:14px;font-weight:bolder;color:red;""><br><li>您的数据已经被记录!</li><br><li>您的IP："&Request.ServerVariables("Remote_Addr")&"</li><br><li>操作日期："&Now&"</li></font></body></html>"
		Response.End
	End if
Next
NoSqlHack = Replace(Str_InputStr,"'","''")
End Function

Function ClassIDIN(TypeID)
		Dim RSclass,TempStr
		Set RSclass = Conn.Execute("Select ID from YWNT_TMS_MovieClass where ClassID="&TypeID&" order by ClassWith asc,id asc" )
		do while Not RSclass.Eof
				ClassIDIN = ClassIDIN&RSclass("ID")&","&ClassIDIN(RSclass("ID")) 
		RSclass.MoveNext
		loop
		RSclass.Close
		Set RSclass = Nothing
End Function
	
Function HtmlClassID(TypeID,CompatStr)  
		Dim RSclass,TempStr
		Set RSclass = Conn.Execute("Select ID,ClassName,ClassID,ClassWith from YWNT_TMS_MovieClass where ClassID="&TypeID&" order by ClassWith asc,id asc" )
		TempStr =CompatStr & "┄"
		do while Not RSclass.Eof
				HtmlClassID = HtmlClassID & "<option value="""& RSclass("ID") &""">"
				HtmlClassID = HtmlClassID & "├" & TempStr &  RSclass("ClassName")
				HtmlClassID = HtmlClassID & "</option>" & Chr(13) & Chr(10)
				HtmlClassID = HtmlClassID &HtmlClassID(RSclass("ID"),TempStr)
		RSclass.MoveNext
		loop
		RSclass.Close
		Set RSclass = Nothing
End Function

Sub IsIPlock()
    UserTrueIP =UsersIP()
    If session("IPlock") = "" Then
        session("IPlock") = ChecKIPlock(UserTrueIP)
    End If
    If session("IPlock") = True Then
        Response.Write "对不起！您的IP（" & UserTrueIP & "）被系统限定。您可以和站长联系。"
        Response.End
    End If
End Sub

Function EncodeIP(Sip)
    Dim strIP
    strIP = Split(Sip, ".")
    If UBound(strIP) < 3 Then
        EncodeIP = 0
        Exit Function
    End If
    If IsNumeric(strIP(0)) = False Or IsNumeric(strIP(1)) = False Or IsNumeric(strIP(2)) = False Or IsNumeric(strIP(3)) = False Then
        Sip = 0
    Else
        Sip = CSng(strIP(0)) * 256 * 256 * 256 + CLng(strIP(1)) * 256 * 256 + CLng(strIP(2)) * 256 + CLng(strIP(3)) - 1
    End If
    EncodeIP = Sip
End Function

Function ChecKIPlock(ByVal sUserIP)
If sUserIP = "" Or IsNull(sUserIP) Then Exit Function
On Error Resume Next
UserIP=EncodeIP(sUserIP)
Set RS=Server.CreateObject(YWNT_TMS_RS)
SQL="select IPType from YWNT_TMS_IP Where StartIPS<="&UserIP&" And OverIPS>="&UserIP
Rs.open sql,Conn,1,1
If RS.Eof And RS.BOf Then
ChecKIPlock=False
Else
Select Case RS("IPType")
Case 0
ChecKIPlock=False
Case 1
ChecKIPlock=True
End Select
End If
RS.Close
Set RS = Nothing
End Function

Function ChecKWcafesIP(ByVal sUserIP)
If sUserIP = "" Or IsNull(sUserIP) Then Exit Function
On Error Resume Next
UserIP=EncodeIP(sUserIP)
Set RS=Server.CreateObject(YWNT_TMS_RS)
SQL="select WcafesName,WcafesUseDate,WcafesGroup,WcafesAdmin,WcafesRegDate from YWNT_TMS_Wcafes Where WcafesStartIPS<="&UserIP&" And WcafesOverIPS>="&UserIP&" And WcafesAudit=1"
Rs.open sql,Conn,1,1
If RS.Eof And RS.BOf Then
ChecKWcafesIP=False
Else
ChecKWcafesIP=True
session("WcafesName") =RS("WcafesName")
session("WcafesUseDate") =RS("WcafesUseDate")
session("WcafesGroup") =RS("WcafesGroup")
session("WcafesAdmin") =RS("WcafesAdmin")
session("WcafesRegDate") =RS("WcafesRegDate")
End If
RS.Close
Set RS = Nothing
End Function

Function Movielog(MovieName,UserName,MovieType,UsersGroupx,UsersTypex,UsersCoin,UsersCoinDate)
Set Rs = server.CreateObject(YWNT_TMS_RS)
sql="Select * from YWNT_TMS_UsersLog where MovieName='"&MovieName&"' and DateDiff("&MakeRandomStr&",Date,"&SqlNow&")<"&GetUsersSystem("UsersDeductionDate")&" and UsersName='"&UserName&"' Order by ID desc"
Rs.open sql,Conn,1,3
if Rs.eof then
GroupWatched=GetUsersGroup("GroupWatched",UsersGroupx)
IF CheckMovieLog(MovieName,UserName)>GroupWatched Then
Response.Write("<script>alert('您所在用户组每日只能观看"&GroupWatched&"部影片!');</script>")
response.end
End IF
Select Case UsersTypex
Case 0
IF UsersCoin<MovieCoin Then
Response.Write("<script>alert('对不起您的影币不够请您充值后观看此影片!');</script>")
response.end
End IF
Conn.execute("Update YWNT_TMS_Users set UsersCoin=UsersCoin-"&MovieCoin&" where UsersName='"&Request.Cookies("YWNTUserCookie")("UserName")&"'")
Case 1
IF UsersCoinDate<Now() Then
Response.Write("<script>alert('您包月的时间已经到期请您充值后观看!');</script>")
response.end
End IF
Case else
IF session("WcafesUseDate")<Now() Then
Response.Write("<script>alert('您所在网吧的包月时间已经到期请您提醒网吧主充值后观看!');</script>")
response.end
End IF
End Select
IF GetSysPlay("MovieLog")=1 Then
Rs.addnew
RS("MovieName")=MovieName
RS("UsersName")=UserName
RS("MovieType")=MovieType
RS("UsersIP")=UsersIP()
RS("UsersGroup")=UsersGroupx
RS("Date")=Now()
Rs.Update
End if
end if
RS.Close
Set RS = Nothing
End Function

Function CheckMovieLog(MovieName,UserName)
	CheckMovieLog = Conn.execute("select count(*) from YWNT_TMS_UsersLog where DateDiff("&DayStr&",Date,"&SqlNow&")<1 and UsersName='"&UserName&"'")(0)
End Function

Function GetUsersGroup(ByVal ConfigField,ByVal UsersGroup)
Dim ConfigRS
Set ConfigRS = Server.CreateObject(YWNT_TMS_RS)
ConfigRS.Open ("Select "&ConfigField&" From YWNT_TMS_UsersGroup Where ID="&UsersGroup&""), Conn, 1, 1
GetUsersGroup = ConfigRS(ConfigField)
ConfigRS.Close
Set ConfigRS = Nothing
End Function 

Function CollectionMoive(CollectionMoiveField,CollectionMoiveID)
Dim RS
Set RS = Server.CreateObject(YWNT_TMS_RS)
RS.Open ("Select "&CollectionMoiveField&" From YWNT_TMS_Movie Where ID="&CollectionMoiveID&""), Conn, 1, 1
CollectionMoive = RS(CollectionMoiveField)
RS.Close
Set RS = Nothing
End Function

Function CollectionClassName(Id)
Str_Sql = "Select ID,ClassName from YWNT_TMS_MovieClass where ID="&Id&" order by ClassWith asc,id asc"
Set Rs_Class = Conn.Execute(Str_Sql)
Str_ClassInfo=Rs_Class("ClassName")
Rs_Class.close
Set RS_class = Nothing
Response.Write(Str_ClassInfo)
End Function

function UBBCode(strContent)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="\[face(\d*?)\]"
strContent=re.Replace(strContent,"<img src="&GetConfig("WebiInstallDir")&"Function/Faces/$1.gif>")
set re=Nothing
UBBCode=strContent
end function

	Function HTMLEncode(fString)
		If Not IsNull(fString) Then
			fString = replace(fString, ">", "&gt;")
			fString = replace(fString, "<", "&lt;")
			fString = Replace(fString, CHR(32), " ")		
			fString = Replace(fString, CHR(9), " ")			
			fString = Replace(fString, CHR(34), "&quot;")
			fString = Replace(fString, CHR(13), "")
			fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
			fString = Replace(fString, CHR(10), "<BR> ")
			fString=ChkBadWords(fString)
			HTMLEncode = fString
		End If
	End Function

	Function ChkBadWords(Str)
		If IsNull(Str) Then Exit Function
		Dim i
		BadWords=split(GetUsersSystem("UsersCommentsFiltration"),vbCrLf)
		For i = 0 To UBound(BadWords)
			If InStr(Str,BadWords(i))>0 Then
					Str = Replace(Str,BadWords(i),"*")
			End If
		Next
		ChkBadWords = Str
	End Function

	Function Replacehtml(Textstr)
		Dim Str,re
		Str=Textstr
		Set re=new RegExp
			re.IgnoreCase =True
			re.Global=True
			re.Pattern="<(.[^>]*)>"
			Str=re.Replace(Str, "")
			Set Re=Nothing
			Replacehtml=Str
	End Function
	
Function GetLink(ByVal ConfigField)
Dim LinkRS
Set LinkRS = Server.CreateObject(YWNT_TMS_RS)
LinkRS.Open ("Select "&ConfigField&" From YWNT_TMS_LinkSystem"), Conn, 1, 1
GetLink = LinkRS(ConfigField)
LinkRS.Close
Set LinkRS = Nothing
End Function 

Function GetUserGroup(SelectArr)
	   Dim RSObj
	   Set RSObj=Server.CreateObject(YWNT_TMS_RS)
	   RSObj.Open "Select ID,GroupName From YWNT_TMS_UsersGroup",Conn,1,1
	   Do While Not RSObj.Eof
			If Instr(","&SelectArr&",",","&RSObj(0)&",")<>0 Then
			 GetUserGroup=GetUserGroup & RSObj(1) & "&nbsp;&nbsp;"
			End IF
		 	RSObj.MoveNext
	   If RSObj.Eof Then Exit Do
	   Loop
	   RSObj.Close
	   Set RSObj=Nothing
End Function

Function WAdminGroup(FromName,ID)
Set Rs = server.CreateObject(YWNT_TMS_RS)
sql="Select "&FromName&" from YWNT_TMS_AdminGroup Where ID="&ID&" Order by ID desc"
Rs.open sql,Conn,1,1
WAdminGroup=RS(FromName)
RS.close     
set RS=nothing
End Function

Function AddLog(Events,LogType)
Set Rs = server.CreateObject(YWNT_TMS_RS)
sql="Select * from YWNT_TMS_Log"
Rs.open sql,Conn,1,3
Rs.Addnew
RS("Events")=Events
RS("AdminName")=Session("Admin")
RS("Date")=Now()
RS("AdminIP")=UsersIP()
RS("LogType")=LogType
Rs.Update
Rs.close     
set Rs=nothing
End Function

function CheckLogin(GroupName)
IF Session("Admin")<>"" and Session("AdminGroup")<>"" and Session("AdminSession")=true Then
IF Instr(","&Replace(WAdminGroup("Groupbox",Session("AdminGroup"))," ","")&",",","&GroupName&",")=0 Then
	call Admin_ShowErr("<li>您所在管理员组没有操作该内容的权限</li>","javascript:history.go(-1)",0)
End if
Else
	Response.Redirect "Admin_Login.asp"
END IF
End function
%>