<%

Function Mydb(MySqlstr,MyDBType)
	Select Case MyDBType
	Case 0 : Conn.Execute(MySqlstr) : Dataquery = Dataquery + 1
	Case 1 : Set Mydb = Conn.Execute(MySqlstr) : Dataquery = Dataquery + 1
	Case 2 : Set Mydb = Server.CreateObject("Adodb.Recordset") : Mydb.Open MySqlstr,Conn,1,1 : Dataquery = Dataquery + 1
	case 3:
		set db = server.createobject("Adodb.Recordset")
		db.open sqlstr, conn, 1, 3
	End Select
End Function
	
Function CheckStr(str) 
	CheckStr=replace(replace(replace(replace(str,"<","&lt;"),">","&gt;"),chr(13),"")," ","") 
	CheckStr=replace(replace(replace(replace(CheckStr,"'",""),"and",""),"insert",""),"set","") 
	CheckStr=replace(replace(replace(replace(CheckStr,"select",""),"update",""),"delete",""),chr(34),"")
	CheckStr=replace(replace(replace(replace(CheckStr,"*",""),"=",""),"mid",""),"count","")
	CheckStr=replace(replace(replace(replace(CheckStr,"%",""),",",""),"union",""),"where","")
	CheckStr=replace(replace(replace(replace(replace(CheckStr,"(",""),")",""),Chr(0),""),"+",""),";","")
end Function

Function jleRequest(ParaName)
     Dim ParaValue
     ParaValue = trim(ParaName)
	 If ParaValue="" Then Exit Function
        If Not isNumeric(ParaValue) Then
		    Response.Write "<li>  参数类型不合法"
			Response.end
	    Else
           jleRequest = ParaValue
        End If
End Function

Function GetIP() 
	Dim strIPAddr 
	If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" Or InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then 
		strIPAddr = Request.ServerVariables("REMOTE_ADDR") 
	ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then 
		strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1) 
	ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then 
		strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1)
	Else 
		strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
	End If 
	getIP = Checkstr(Trim(Mid(strIPAddr, 1, 30)))
	If getIP="" then getIP="127.0.0.1"
End Function

Function ShowLabel(id)
	if id = "" or isnull(id) then
		ShowLabel = 0
	else
		Sqld = "Select Content from jle_Label where ID = " & id
		Set rsd = conn.execute(Sqld)
		if not rsd.eof then
			ShowLabel = rsd(0)
		else
			ShowLabel = ""
		end if
		rsd.close
	end if
End function

Function LoseHtml(ContentStr)
 Dim ClsTempLoseStr,regEx
	ClsTempLoseStr = Cstr(ContentStr)
	Set regEx = New RegExp
	regEx.Pattern = "<(.[^>]*)>"
	regEx.IgnoreCase = True
	regEx.Global = True
	ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
	RegEx.Pattern = "(&.+?;)"
	ClsTempLoseStr = RegEx.Replace(ClsTempLoseStr, "")
	ClsTempLoseStr = Replace(ClsTempLoseStr,VbCrlf,"")
	ClsTempLoseStr = Replace(ClsTempLoseStr,VbCr,"")
	ClsTempLoseStr = Replace(ClsTempLoseStr,VbLf,"")
	ClsTempLoseStr = Replace(ClsTempLoseStr,"  ","")
	ClsTempLoseStr = Replace(ClsTempLoseStr,"","")
	ClsTempLoseStr = Replace(ClsTempLoseStr,"""","'")
	ClsTempLoseStr = Replace(ClsTempLoseStr,"[code]","")
	ClsTempLoseStr = Replace(ClsTempLoseStr,"<!--","")
	ClsTempLoseStr = Trim(ClsTempLoseStr)
 LoseHtml = ClsTempLoseStr
End Function

Function dvHTMLEncode(fString)
if not isnull(fString) then
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")

    fString = Replace(fString, CHR(32), "&nbsp;")
    fString = Replace(fString, CHR(9), "&nbsp;")
    fString = Replace(fString, CHR(34), "&quot;")
    fString = Replace(fString, CHR(39), "&#39;")
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
    fString = Replace(fString, CHR(10), "<BR> ")
    'fString = Replace(fString, "http://static3.photo.sina.com.cn", "photo.asp?url=http://static3.photo.sina.com.cn")

    dvHTMLEncode = fString
end if
end Function

Function HasChinese(str) 
HasChinese = false 
dim i 
for i=1 to Len(str) 
if Asc(Mid(str,i,1)) < 0 then 
HasChinese = true 
exit for 
end if 
next 
end Function

Function replacecolor(Str)
	Dim re,s
	S=Str
	Set re=new RegExp
	re.IgnoreCase =True
	re.Global=True
	re.Pattern="("& KeyWord &")"
	s=re.Replace(s,"<font color='red'>"& KeyWord &"</font>")
	Set Re=Nothing
	replacecolor=s
End Function

Function iparray(ipstr)
 dim t,ipx,ipfb
 if not isnull(ipstr) then
        t = 0
 ipx=""
 ipfb = split(ipstr, ".",4)
  for t = 0 to 2
  ipx = ipx&ipfb(t)&"."
  next
 iparray = ipx&"*"
 end if
end Function

'判断数字奇偶
Function isEven(num)
if not isNumeric(num) then
isEven="这不是一个数字啊"
exit Function
end if
if num mod 2 = 0 then
isEven=0
else
isEven=1
end if
end Function

Function FormatDate(DateAndTime,para)
	On Error Resume Next
	Dim y, m, d, h, mi, s, strDateTime
	FormatDate = DateAndTime
	
	If Not IsNumeric(para) Then Exit Function
	If Not IsDate(DateAndTime) Then Exit Function
	y = Mid(CStr(Year(DateAndTime)),3)
	m = CStr(Month(DateAndTime))
	If Len(m) = 1 Then m = "0" & m
	d = CStr(Day(DateAndTime))
	If Len(d) = 1 Then d = "0" & d
	h = CStr(Hour(DateAndTime))
	If Len(h) = 1 Then h = "0" & h
	mi = CStr(Minute(DateAndTime))
	If Len(mi) = 1 Then mi = "0" & mi
	s = CStr(Second(DateAndTime))
	If Len(s) = 1 Then s = "0" & s
	
	Select Case para
		Case "1"
			strDateTime = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
		Case "2"
			strDateTime = y & "-" & m & "-" & d
		Case "3"
			strDateTime = y & "/" & m & "/" & d
		Case "4"
			strDateTime = y & "年" & m & "月" & d & "日"
		Case "5"
			strDateTime = m & "-" & d
		Case "6"
			strDateTime = m & "/" & d
		Case "7"
			strDateTime = m & "月" & d & "日"
		Case "8"
			strDateTime = y & "年" & m & "月"
		Case "9"
			strDateTime = y & "-" & m
		Case "10"
			strDateTime = y & "/" & m
		Case "11"
			y = CStr(Year(DateAndTime))
			strDateTime = y & "-" & m & "-" & d
		Case "12"
			y = CStr(Year(DateAndTime))
			strDateTime = y & m & d & "_" & h & mi & s			
		Case Else
			strDateTime = DateAndTime
		End Select
		
	'FormatDate = strDateTime
	If datediff("d",DateAndTime,Now())=0 then
	FormatDate = "<font color=#ff0000>"&strDateTime&"</font>"
	else
	FormatDate = ""&strDateTime&""
	End if
End Function

'=================================================
'过程名：BbbImg
'作  用：鼠标滚轮控制图片大小的函数
'参  数：strText
'=================================================
Function BbbImg(strText)
         Dim s,re
         Set re=New RegExp
         re.IgnoreCase = true
         re.Global = true		 
         s=strText
		 
		'去掉图片中的脚本代码
		re.Pattern="<IMG.[^>]*SRC(=| )(.[^>]*)>"
		If mouserimg=1 then
		s=re.replace(s,"<p style=""text-align:center;""><IMG SRC=$2 onload=""javascript:resizeimg(this,575,600)""></p>")
		else
		s=re.replace(s,"<p style=""text-align:center;""><IMG SRC=$2></p>")
		End if
		BbbImg = ChkBadWords(s)
	    Set re=Nothing
End Function

'脏话过滤
Function ChkBadWords(Str)
		If IsNull(Str) Then Exit Function
		On Error Resume Next
		Dim i,rBadWord,BadWord
		BadWord	= BadWord1
		BadWord = Split(BadWord,"|||")
		For i = 0 To Ubound(BadWord)
			rBadWord = Split(BadWord(i),"=")
			Str = Replace(Str,rBadWord(0),rBadWord(1))
		Next
		ChkBadWords = Str
End Function

'用户名检测
Function ChkRegName(str)
	ChkRegName = True
	On Error Resume Next
	For i=0 To Ubound(Split(userWord,","))
		If Instr(Str,Split(userWord,",")(i)) > 0 Then
			ChkRegName = False
			Exit Function
		End If
	Next
End Function

'# IIF
Function IIF(A,B,C)
	If A Then IIF = B Else IIF = C
End Function

Function laoy(block)
	if not isnull(block) then
    block = Replace(block, "{$SitePath}", SitePath)
    laoy = block
	end if
End Function


Sub CreateDir(strPath)
	Dim sTmp,i,Fso,sPath
	sPath = replace(strPath,"/","\")
	sPath=Split(sPath,"\")
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	For I=0 To Ubound(sPath)
		sTmp=Replace(sTmp&sPath(I)&"\","\\","\")
		If Not Fso.FolderExists(server.Mappath(sTmp)) Then
			Fso.CreateFolder server.Mappath(sTmp)				
		End if
	Next
	Set Fso = nothing
End Sub

function createfile(byval content,byval filedir)
	on error resume next
	dim obj : set obj = server.createobject("adodb.Stream")
	obj.type = 2
	obj.open
	obj.charset = "GB2312"
	obj.position = obj.Size
	obj.writeText = content
	obj.savetofile server.mappath(filedir), 2
	obj.close
	if err then err.clear: createfile = false else createfile = true
	set obj = nothing
End function

'显示相关文章
'P_ConID:数值型，当前文章ID
'P_Key:字符型，当前文章关健字
'P_Row:数值型，要显示相关文章的条数
'P_ICO:字符型，标题前图标，可以图片也可为字符
'P_Time:数值型，显示时间，０为不显示，否则为时间格式

Function ShowMutualityArticle(P_ConID,P_Key,P_Row,P_ICO,P_Time)
    dim pRs,pSql
	dim i,TempKeyWord
	
	if P_Row > 0 then
		pSql = "Select TOP "& P_Row
	else
		pSql = "Select "
	end if
	pSql = pSql & " ID,Title,ClassId,DateAndTime From [jle_Article] Where ID <> "& P_ConID &" And "	
	if Instr(P_Key,"|") > 0 then
		P_Key = Split(P_Key,"|")
		TempKeyWord = TempKeyWord &"("
		For i = 0 to Ubound(P_Key)
			TempKeyWord = TempKeyWord &" KeyWord like '%"& P_Key(i) &"%' or KeyWord like '%|"& P_Key(i) &"|%' or KeyWord like '%"& P_Key(i) &"|%' or KeyWord like '%|"& P_Key(i) &"%' "
			if i = Ubound(P_Key) then
				TempKeyWord = TempKeyWord &") And "
			else
				TempKeyWord = TempKeyWord &" Or "
			end if
		Next
	else
		TempKeyWord = TempKeyWord &" KeyWord like '%"& P_Key &"%' And "
	end if
	pSql = pSql & TempKeyWord &" yn = 0 Order By Id Desc"
	'Response.Write pSql
	
    Set pRs = Server.CreateObject("Adodb.recordset")
	pRs.open pSql,conn,1,3
	if not(pRs.bof and pRs.eof) then
		Do While Not pRs.eof
			if pRs(0) <> P_ConID Then
				If html=1 then
				ShowMutualityArticle = ShowMutualityArticle & "<li>"&P_ICO&"<a href="""&SitePath&"NewsList.asp?ID="&pRs(0)&""">"&pRs(1)&"</a>"
				elseif html=2 then
				ShowMutualityArticle = ShowMutualityArticle & "<li>"&P_ICO&"<a href="""&SitePath&"Html/?"&pRs(0)&".html"">"&pRs(1)&"</a>"
				else
				ShowMutualityArticle = ShowMutualityArticle & "<li>"&P_ICO&"<a href="""&SitePath&"Html/"&pRs(0)&".html"">"&pRs(1)&"</a>"
				End if
				If P_Time>0 then
				ShowMutualityArticle = ShowMutualityArticle &"　　"&FormatDate(pRs(3),P_Time)&""
				End if
				ShowMutualityArticle = ShowMutualityArticle &"</li>" & VbCrLf
			end if
			pRs.movenext
		Loop
	else
		ShowMutualityArticle = ShowMutualityArticle & "<li>没有相关文章</li>"
	end if
	pRs.close:set pRs = nothing
End Function

'图片文章调用
'ClassID:数值型，栏目ID
'N:数值型，要显示文章条数
'T:数值型，显示时间，０为不显示，否则为时间格式
'Z:标题字数
'msql:增强条件
'P:排序方式

Sub ShowImgArticle(ClassID,N,Z,msql,P)
	set rs1=server.createobject("ADODB.Recordset")
	SQL1="select Top "&N&" ID,Title,ClassID,DateAndTime,Images, Content,Artdescription from jle_Article where yn = 0 and Images<>''"
	
	If ClassID<>0 then
		If Yao_MyID(ClassID)="0" then
			SQL1=SQL1&" and ClassID="&ClassID&""
		else
			MyID = Replace(""&Yao_MyID(ClassID)&"","|",",")
			SQL1=SQL1&" and ClassID in ("&MyID&")"
		End if
	End if
	
	If msql<>"no" then
			SQL1=SQL1&" and "&msql&""
	End if
	
	SQL1=SQL1&" Order by "&P&""
	
	rs1.open sql1,conn,1,3
	If Not rs1.Eof Then 
	do while not (rs1.eof or err)
	Response.Write("<li><table><tr><td>")
	If Html=1 then
		Response.Write("<a href="""&SitePath&"newsList.asp?ID="&rs1("ID")&""" target=""_blank"">")
	Elseif Html=2 then
		Response.Write("<a href="""&SitePath&"Html/?"&rs1("ID")&".html"" target=""_blank"">")
	Else
		Response.Write("<a href="""&SitePath&"Html/"&rs1("ID")&".html"" target=""_blank"">")
	end if	
    Response.Write("<img src="""&SitePath&""&SiteUp&"/")
	If IsAspJpeg=1 then
	Response.Write("s90/")
	End if
	Response.Write(""&rs1("Images")&""" title="""&rs1("Title")&""" style=""border:1px solid #ccc;padding:2px;width:90px;height:90px;""></a>")
	Response.Write("</td></tr><tr><td>")
	If Html=1 then
		Response.Write("<a href="""&SitePath&"newsList.asp?ID="&rs1("ID")&""" target=""_blank"">")
	elseif html=2 then
		Response.Write("<a href="""&SitePath&"Html/?"&rs1("ID")&".html"" target=""_blank"">")
	Else
		Response.Write("<a href="""&SitePath&"Html/"&rs1("ID")&".html"" target=""_blank"">")
	end if	
	Response.Write(""&left(rs1("Artdescription"),Z)&"</a>")
	Response.Write("</td></tr></table></li>") & VbCrLf
	rs1.movenext
	loop
	'else
	'Response.Write("<li>没有</li>")
	end if
	rs1.close
	set rs1=nothing
End Sub



Sub ShowImgscArticle(ClassID,N,Z,msql,P)
	set rs1=server.createobject("ADODB.Recordset")
	SQL1="select Top "&N&" ID,Title,ClassID,DateAndTime,Images, Content,Artdescription from sc_Article where yn = 0 and Images<>''"
	
	If ClassID<>0 then
		If Yao_MyID(ClassID)="0" then
			SQL1=SQL1&" and ClassID="&ClassID&""
		else
			MyID = Replace(""&Yao_MyID(ClassID)&"","|",",")
			SQL1=SQL1&" and ClassID in ("&MyID&")"
		End if
	End if
	
	If msql<>"no" then
			SQL1=SQL1&" and "&msql&""
	End if
	
	SQL1=SQL1&" Order by "&P&""
	
	rs1.open sql1,conn,1,3
	If Not rs1.Eof Then 
	do while not (rs1.eof or err)
	Response.Write("<li><table><tr><td>")
	If Html=1 then
		Response.Write("<a href="""&SitePath&"newsList.asp?ID="&rs1("ID")&""" target=""_blank"">")
	Elseif Html=2 then
		Response.Write("<a href="""&SitePath&"Html/?"&rs1("ID")&".html"" target=""_blank"">")
	Else
		Response.Write("<a href="""&SitePath&"Html/"&rs1("ID")&".html"" target=""_blank"">")
	end if	
    Response.Write("<img src="""&SitePath&""&SiteUp&"/")
	If IsAspJpeg=1 then
	Response.Write("s90/")
	End if
	Response.Write(""&rs1("Images")&""" title="""&rs1("Title")&""" style=""border:1px solid #ccc;padding:2px;width:90px;height:90px;""></a>")
	Response.Write("</td></tr><tr><td>")
	If Html=1 then
		Response.Write("<a href="""&SitePath&"scList.asp?ID="&rs1("ID")&""" target=""_blank"">")
	elseif html=2 then
		Response.Write("<a href="""&SitePath&"Html/?"&rs1("ID")&".html"" target=""_blank"">")
	Else
		Response.Write("<a href="""&SitePath&"Html/"&rs1("ID")&".html"" target=""_blank"">")
	end if	
	Response.Write(""&left(rs1("Artdescription"),Z)&"</a>")
	Response.Write("</td></tr></table></li>") & VbCrLf
	rs1.movenext
	loop
	'else
	'Response.Write("<li>没有</li>")
	end if
	rs1.close
	set rs1=nothing
End Sub
'文章调用
'ClassID:数值型，栏目ID
'N:数值型，要显示文章条数
'T:数值型，显示时间，０为不显示，否则为时间格式
'ICO:字符型，标题前图标，可以图片也可为字符
'Z:标题字数
'msql:增强条件
'P:排序方式
'ClassName 数值型,1为显示栏目名称,0为不显示
'target 数值型,1为在新窗口打开

Sub ShowArticle(ClassID,N,T,ICO,Z,msql,P,ClassName,target)
	set rs1=server.createobject("ADODB.Recordset")
	SQL1="select Top "&N&" ID,Title,ClassID,DateAndTime,TitleFontColor,IsHot from jle_Article where yn = 0"
	
	If ClassID<>0 then
		If Yao_MyID(ClassID)="0" then
			SQL1=SQL1&" and ClassID="&ClassID&""
		else
			MyID = Replace(""&Yao_MyID(ClassID)&"","|",",")
			SQL1=SQL1&" and ClassID in ("&MyID&")"
		End if
	End if
	
	If msql<>"no" then
			SQL1=SQL1&" and "&msql&""
	End if
	
	SQL1=SQL1&" Order by "&P&""
	
	rs1.open sql1,conn,1,3
	If Not rs1.Eof Then 
	do while not (rs1.eof or err)
	Response.Write("<li>")
	If T<>0 then
	'	Response.Write("<span style=""float:right;"">"&FormatDate(rs1(3),T)&"</span>")
	end if
	If ClassName=1 then
		If Html=3 then
			Response.Write("[<a href="""&SitePath&"Class_"&rs1(2)&".html"">"&Classlist(rs1(2))&"</a>]")
		Else
			Response.Write("[<a href="""&SitePath&"NewsClass.asp?ID="&rs1(2)&""">"&Classlist(rs1(2))&"</a>]")
		End if
	End if
	Response.Write(""&ICO&"<a href=""")
	If Html=1 then
		Response.Write(""&SitePath&"NewsList.asp?ID="&rs1(0)&"""")
	elseif Html=2 then
		Response.Write(""&SitePath&"Html/?"&rs1(0)&".html""")
	elseif Html=3 then
		Response.Write(""&SitePath&"Html/"&rs1(0)&".html""")
	end if
	If target=1 then
	Response.Write(" target=""_blank""")
	End if
	Response.Write(" >")
	If rs1(4)<>"" then
	Response.Write("<font style=""color:"&rs1(4)&""">"&left(rs1(1),Z)&"</font></a>")
	else
	Response.Write(""&left(rs1(1),Z)&"</a>")
	end if
	Response.Write("</li>") & VbCrLf
	rs1.movenext
	loop
	else
	Response.Write("<li>没有</li>")
	end if
	rs1.close
	set rs1=nothing
End Sub


Sub ShowscArticle(ClassID,N,T,ICO,Z,msql,P,ClassName,target)
	set rs1=server.createobject("ADODB.Recordset")
	SQL1="select Top "&N&" ID,Title,ClassID,DateAndTime,TitleFontColor,IsHot from sc_Article where yn = 0"
	
	If ClassID<>0 then
		If Yao_MyID(ClassID)="0" then
			SQL1=SQL1&" and ClassID="&ClassID&""
		else
			MyID = Replace(""&Yao_MyID(ClassID)&"","|",",")
			SQL1=SQL1&" and ClassID in ("&MyID&")"
		End if
	End if
	
	If msql<>"no" then
			SQL1=SQL1&" and "&msql&""
	End if
	
	SQL1=SQL1&" Order by "&P&""
	
	rs1.open sql1,conn,1,3
	If Not rs1.Eof Then 
	do while not (rs1.eof or err)
	Response.Write("<li>")
	If T<>0 then
	'	Response.Write("<span style=""float:right;"">"&FormatDate(rs1(3),T)&"</span>")
	end if
	If ClassName=1 then
		If Html=3 then
			Response.Write("[<a href="""&SitePath&"Class_"&rs1(2)&".html"">"&Classlist(rs1(2))&"</a>]")
		Else
			Response.Write("[<a href="""&SitePath&"scClass.asp?ID="&rs1(2)&""">"&Classlist(rs1(2))&"</a>]")
		End if
	End if
	Response.Write(""&ICO&"<a href=""")
	If Html=1 then
		Response.Write(""&SitePath&"scList.asp?ID="&rs1(0)&"""")
	elseif Html=2 then
		Response.Write(""&SitePath&"Html/?"&rs1(0)&".html""")
	elseif Html=3 then
		Response.Write(""&SitePath&"Html/"&rs1(0)&".html""")
	end if
	If target=1 then
	Response.Write(" target=""_blank""")
	End if
	Response.Write(" >")
	If rs1(4)<>"" then
	Response.Write("<font style=""color:"&rs1(4)&""">"&left(rs1(1),Z)&"</font></a>")
	else
	Response.Write(""&left(rs1(1),Z)&"</a>")
	end if
	Response.Write("</li>") & VbCrLf
	rs1.movenext
	loop
	else
	Response.Write("<li>没有</li>")
	end if
	rs1.close
	set rs1=nothing
End Sub


Function Yao_MyID(a)
Yao_MyID=""
 Dim rs1,sql1
 set rs1=server.createobject("ADODB.Recordset")
 sql1="select ID from jle_Class where TopID = "&a&""
 rs1.open sql1,conn,1,3
 If Not rs1.Eof Then 
 do while not (rs1.eof or err)

If Yao_MyID = "" then
	Yao_MyID = rs1("ID")
else
	Yao_MyID = Yao_MyID &"|"& rs1("ID")
End if
 rs1.movenext
 loop
 else
Yao_MyID = "0"
 end if
 rs1.close
 set rs1=nothing
End Function

Function Classlist(id)
	if id = "" or isnull(id) then
		Classlist = ""
	else
		Sqld = "Select ClassName from jle_Class where ID = " & id
		Set rsd = conn.execute(Sqld)
		if not rsd.eof then
			Classlist = rsd(0)
		else
			Classlist = ""
		end if
		rsd.close
	end if
End Function

Function checkpost(byval back)
	dim server_v1, server_v2
	server_v1 = cstr(request.servervariables("http_referer"))
	server_v2 = cstr(request.servervariables("server_name"))
	if Mid(server_v1, 8, len(server_v2)) <> server_v2 then
		if not back then
			response.write lang_errorpost : response.end
		else
			checkpost = false
		end if
	else
		checkpost = true
	end if
end Function

Function Alert(message,gourl) 
    message = replace(message,"'","\'")
    If gourl="-1" then
        Response.Write ("<script language=javascript>alert('" & message & "');history.go(-1)</script>")
    ElseIf gourl="-2" then
        Response.Write ("<script language=javascript>alert('" & message & "');history.go(-2)</script>")
    ElseIf gourl="Close" then
		Response.Write ("<script language=javascript>alert('" & message & "');window.opener=null;window.close();</script>")
	Else
        Response.Write ("<script language=javascript>alert('" & message & "');location='" & gourl &"'</script>")
    End If
    Response.End()
End Function

Function Info(message)
	Response.Redirect ""&SitePath&""&SiteAdmin&"/Info.asp?Info=" & message & ""
    Response.End()
End Function

Function UserInfo(id,Num)
	if id = "" or isnull(id) Then Exit Function
	Sqld = "Select usergroupid,yn from jle_User where ID = " & id
	Set rsd = conn.execute(Sqld)
	if not rsd.eof then
		UserInfo 	=rsd(Num)
	end if
	rsd.close
	set rsd=nothing
End Function

Function UserInfo2(uname,Num)
	if uname = "" Then Exit Function
	Sqld = "Select UserFace,dengjipic,id,UserMoney from jle_User where UserName = '" & uname & "'"
	Set rsd = conn.execute(Sqld)
	if not rsd.eof then
		UserInfo2 	=rsd(Num)
	end if
	rsd.close
	set rsd=nothing
End Function

'过滤指定html标签

Function lFilterBadHTML(byval strHTML,byval strTAGs)  
  Dim objRegExp,strOutput  
  Dim arrTAG,i
  arrTAG=Split(strTAGs,",")  
  Set objRegExp = New Regexp   
  strOutput=strHTML   
  objRegExp.IgnoreCase = True  
  objRegExp.Global = True  
  For i=0 to UBound(arrTAG)  
    objRegExp.Pattern = "<"&arrTAG(i)&"[\s\S]+</"&arrTAG(i)&"*>"  
    strOutput = objRegExp.Replace(strOutput, "")   
  Next  
  Set objRegExp = Nothing  
  lFilterBadHTML = strOutput   
End Function 

'函数名：EditUserMn
'作用：操作后，给相应用户加分
'参数：str1（被操作的用户名)
'      str2(积分)
'		P_MnType(操作类型，1增加，0减少)
Function EditUserMn(str1,str2,P_MnType)
	dim rs,sql,rs2

	dim EditorTmp,MoneyStr
	sql = "Select UserName From [jle_Article] Where ID = "&str1
	Set rs2 = Conn.Execute(sql)
	if not(rs2.eof And rs2.bof) then
		EditorTmp = rs2(0)

		sql = "Select UserMoney From [jle_User] Where UserName = '"&EditorTmp&"'"
		Set rs = Server.CreateObject("adodb.recordset")
		rs.open sql,connstr,1,3
		if not(rs.bof and rs.eof) then
			If P_MnType = 1 then
				rs(0) = jleRequest(rs(0)) + jleRequest(str2)
			else
				rs(0) = jleRequest(rs(0)) - jleRequest(str2)
			end if
			rs.update
		end if
		rs.close:set rs=nothing
	end if
	
	rs2.close:set rs2=nothing
End Function

'ClassID 链接分类,0为所有
'NUM     调用个数,0为不限
'logo    是否调用logo,1为logo,0为文字
'ClassName是否显示分类名，1为显示

Sub Link(ClassID,Num,logo,ClassName)
	set rs1=server.createobject("ADODB.Recordset")
	SQL1="select"
	If Num<>0 then
		SQL1=SQL1&" top "&Num&""
	End if
	SQL1=SQL1&" ID,Title,ClassID,LinkUrl,LogoUrl,Num from jle_Link where yn <> 0 and "
	If IsSqlDataBase = 1 Then
	SQL1=SQL1&"datediff(dd,GetDate(),AddTime) <= 0 and datediff(dd,GetDate(),LastTime) > 0"
	Else
	SQL1=SQL1&"datediff('d',Now(),AddTime) <= 0 and datediff('d',Now(),LastTime) > 0"
	End if
	If ClassID<>0 then
		SQL1=SQL1&" And ClassID = "&ClassID&""
	End if
	If logo=1 then
		SQL1=SQL1&" And LogoUrl <> ''"
	else
		SQL1=SQL1&" And LogoUrl = ''"
	End if
	SQL1=SQL1&" order by num asc,id asc"	
	rs1.open sql1,conn,1,3
	If Not rs1.Eof Then
	If ClassName=1 then 
		Response.Write("<b>"&linkclassname(rs1("ClassID"))&"：</b>")
	End if
	do while not (rs1.eof or err)
	Response.Write("<a href="""&rs1("LinkUrl")&""" target=""_blank"">")
	If rs1("logourl")<>"" then
		Response.Write("<img src="""&rs1("logourl")&""" width=""88"" height=""31"" alt="""&rs1("Title")&""">")
	Else
		Response.Write(""&rs1("Title")&"")
	End if
	Response.Write("</a>") & VbCrLf
	rs1.movenext
	loop
	end if
	rs1.close
	set rs1=nothing
End Sub

Function linkclassname(id)
	if id = "" or isnull(id) then
		linkclassname = ""
	else
		Sqld = "Select LinkName from jle_LinkClass where ID = " & id
		Set rsd = conn.execute(Sqld)
		if not rsd.eof then
			linkclassname = rsd(0)
		else
			linkclassname = ""
		end if
		rsd.close
		set rsd=nothing
	end if
End Function

Function showFace(Str)
	for i = 1 to PingNum
	Str=replace(Str,"[laoy:"&i&"]","<img src="""&SitePath&"images/faces/"&i&".gif""></img>")
	Next
	showFace=Str
End Function

Function ReplaceshowFace(Str)
	for i = 1 to PingNum
	Str=replace(Str,"[laoy:"&i&"]","")
	Next
	ReplaceshowFace=Str
End Function

Function RndNumber(Min,Max) 
Randomize 
RndNumber=Int((Max - Min + 1) * Rnd() + Min) 
End Function

Function ChkSB(str)
	ChkSB = True
	For i=0 To Ubound(Split(KillWord,","))
		If Instr(Str,Split(KillWord,",")(i)) > 0 Then
			ChkSB = False
			Exit Function
		End If
	Next
End Function

Function IsObjInstalled(strClassString)
	On Error Resume Next
	IsObjInstalled = False
	Err = 0
	Dim xTestObj
	Set xTestObj = Server.CreateObject(strClassString)
	If Err = 0 Then IsObjInstalled = True
	If Err = -2147352567 Then IsObjInstalled = True
	Set xTestObj = Nothing
	Err = 0
End Function

Sub Web_Style()
   Dim Sqlp,Rsp,TempStr
   Sqlp ="Select ID,Title from jle_Css"   
   Set Rsp=server.CreateObject("adodb.recordset")   
   rsp.open sqlp,conn,1,1 
   If Rsp.Eof and Rsp.Bof Then
      Response.Write("<option value="""">请先添加风格</option>")
   Else
      Do while not Rsp.Eof   
         Response.Write("<option value=""" & Rsp("ID") & """")
		 If int(css)=Rsp("ID") then
				Response.Write(" selected" ) 
		 End if
         Response.Write(">" & Rsp("Title") & "</option>") & VbCrLf
      Rsp.Movenext   
      Loop
   End if
   Rsp.Close:Set Rsp=nothing
End Sub
	
Function ReplaceKey(ByVal Str)
		If IsNull(Str) Then Exit Function
		Dim RsKeyword
		sql="Select * From [jle_Key] Order By [Num] Desc"
		Set RsKeyword=Conn.Execute(sql)
		do while not (RsKeyword.eof or err)
		If InStr(Str,RsKeyword("Title")) > 0 Then
			oReplace = RsKeyword("Replace")
			If oReplace=0 then oReplace=-1
			Str = p_replace(Str,RsKeyword("Title"),"<a href="""&RsKeyword("Url")&""" target=""_blank""><font color=blue>"&RsKeyword("Title")&"</font></a>",1,oReplace,1)
		End if	
		RsKeyword.movenext
		loop
		ReplaceKey = Str
		RsKeyword.Close:Set RsKeyword=nothing
End Function

Function p_replace(byval content,byval asp,byval htm,byval aa,byval Rnum,byval bb)
dim Matches,objRegExp,strs,i
strs=content
Set objRegExp = New Regexp
objRegExp.Global = True
objRegExp.IgnoreCase = True
objRegExp.Pattern = "(\<a[^<>]+\>.+?\<\/a\>)|(\<img[^<>]+\>)"'
Set Matches =objRegExp.Execute(strs)
i=0
Dim MyArray()
For Each Match in Matches
ReDim Preserve MyArray(i)
MyArray(i)=Mid(Match.Value,1,len(Match.Value))
strs=replace(strs,Match.Value,"<"&i&">",1,Rnum,1)
i=i+1
Next
if i=0 then
 content=replace(content,asp,htm,1,Rnum,1)
 p_replace=content
 exit Function
end if
strs=replace(strs,asp,htm,1,Rnum,1)
for i=0 to ubound(MyArray)
strs=replace(strs,"<"&i&">",MyArray(i),1,Rnum,1)
next
p_replace=strs
end Function

Function ShowLabel(id)
	if id = "" or isnull(id) then
		ShowLabel = 0
	else
		Sqld = "Select Content from jle_Label where ID = " & id
		Set rsd = conn.execute(Sqld)
		if not rsd.eof then
			ShowLabel = rsd(0)
		else
			ShowLabel = ""
		end if
		rsd.close
	end if
End function

Function RandReg(str)
	if str = "" then
		RandReg = ""
	else
		RReg=split(str,CHR(10))
		for i=0 to ubound(RReg)
			RReg1 = RReg(i)
		next
		RandReg = RReg1
	end if
End function

Function ShowlevelOption(P_GroupID)
	dim oRs
	Set oRs = Conn.Execute("Select UserGroupID,GroupName from jle_UserGroup where usermoney=-1 order by usergroupid")
	If Not(oRs.eof And oRs.bof) Then
		ShowlevelOption = ShowlevelOption &"<option value='0'"
		if Instr(","& P_GroupID &",",",0,") > 0 Then ShowlevelOption = ShowlevelOption &" selected"
		ShowlevelOption = ShowlevelOption &">游客</option>" & vbNewLine
		Do While Not oRs.eof
			ShowlevelOption = ShowlevelOption &"<option value='"&oRs("UserGroupID")&"'"
			if Instr(","& P_GroupID &",",","& oRs("UserGroupID") &",") > 0 Then ShowlevelOption = ShowlevelOption &" selected"
			ShowlevelOption = ShowlevelOption &">" & oRs("GroupName")&"</option>" & vbNewLine
			oRs.movenext
		Loop
	Else
		ShowlevelOption = "用户组数据丢失,须重新建立用户组"
	End If
	oRs.Close:Set oRs = Nothing	
End Function

Function ShowlevelOption2(P_GroupID)
	dim oRs
	Set oRs = Conn.Execute("Select UserGroupID,GroupName from jle_UserGroup where usermoney=-1 order by usergroupid")
	If Not(oRs.eof And oRs.bof) Then
		Do While Not oRs.eof
			if Instr(","& P_GroupID &",",","& oRs("UserGroupID") &",") > 0 Then
			ShowlevelOption2 = ShowlevelOption2 &" " & oRs("GroupName")&" " & vbNewLine
			End if
			oRs.movenext
		Loop
	Else
		ShowlevelOption2 = "用户组数据丢失,须重新建立用户组"
	End If
	oRs.Close:Set oRs = Nothing	
End Function



'广告管理权限


'文章管理权限

%>