inc_functions.asp

来自「一个不错的ASP论坛源码」· ASP 代码 · 共 1,603 行 · 第 1/5 页

ASP
1,603
字号
	bwords = split(strBadWords, "|")
	for i = 0 to ubound(bwords)
  		Set regEx = New RegExp            ' Create regular expression.
  		chrLastLetter = right(bwords(i),1)
		regEx.Pattern = "\b" & left(bwords(i),len(bwords(i))-1) & "(" & chrLastLetter & "|" & chrLastLetter & "s|" & chrLastLetter & "es)" & "\b"            ' Set pattern.
  		regEx.IgnoreCase = FALSE            ' Make case insensitive.
  		str1 = regEx.Replace(fstring, string(len(regEx.Pattern),"*"))
		do until str1 = fstring
			fstring = str1
			str1 = regEx.Replace(fstring, string(len(bwords(i)),"*"))
		loop
		
 	next
	ChkBadWords = str1
	
End Function



function HTMLEncode(fString)

	fString = replace(fString, ">", ">")
	fString = replace(fString, "<", "&lt;")

	HTMLEncode = fString
end function

function HTMLDecode(fString)

	fString = replace(fString, "&gt;", ">")
	fString = replace(fString, "&lt;", "<")

	HTMLDecode = fString
end function


function ChkString(fString,fField_Type) '## Types - name, password, title, message, url, urlpath, email, number, list
	fString = trim(fString)
	if fString = "" then
		fString = " "
	end if
	if fField_Type = "title" or fField_Type = "preview" then
			fString = Replace(fString, "'", "''")
			if strAllowHTML <> "1" then
						fString = HTMLEncode(fString)
			end if
			ChkBadWords(fString)
			ChkString = fString
			exit function
	end if
	if fField_Type = "decode" then
			fString = HTMLDecode(fString)
			ChkString = fString
			exit function
	end if
	if fField_Type = "urlpath" then
			fString = Server.URLEncode(fString)
			ChkString = fString
			exit function
	end if
	if fField_Type = "SQLString" then
		fString = Replace(fString, "'", "''")
		fString = HTMLEncode(fString)
		ChkString = fString
		exit function
	end if
	if fField_Type = "JSurlpath" then
		fString = Replace(fString, "'", "\'")
		fString = Server.URLEncode(fString)
		ChkString = fString
		exit function
	end if
	if fField_Type = "display" then
		if strAllowHTML <> "1" then
			fString = HTMLEncode(fString)
		end if
		ChkString = fString
		exit function
	elseif fField_Type = "message" then
			if strAllowHTML <> "1" then
				fString = HTMLEncode(fString)
			end if
	elseif fField_Type = "preview" then
			if strAllowHTML <> "1" then
				fString = HTMLEncode(fString)
			end if
	elseif fField_Type = "hidden" then
		fString = HTMLEncode(fString)
	end if
	if strAllowForumCode = "1" and fField_Type <> "signature" then
		fString = doCode(fString, "[b]", "[/b]", "<b>", "</b>")
		fString = doCode(fString, "[s]", "[/s]", "<s>", "</s>")
		fString = doCode(fString, "[strike]", "[/strike]", "<s>", "</s>")
		fString = doCode(fString, "[u]", "[/u]", "<u>", "</u>")
		fString = doCode(fString, "[i]", "[/i]", "<i>", "</i>")
		if fField_Type <> "title" then
			fString = doCode(fString, "[font=Andale Mono]", "[/font=Andale Mono]", "<font face='Andale Mono'>", "</font id='Andale Mono'>")
			fString = doCode(fString, "[font=Arial]", "[/font=Arial]", "<font face='Arial'>", "</font id='Arial'>")
			fString = doCode(fString, "[font=Arial Black]", "[/font=Arial Black]", "<font face='Arial Black'>", "</font id='Arial Black'>")
			fString = doCode(fString, "[font=Book Antiqua]", "[/font=Book Antiqua]", "<font face='Book Antiqua'>", "</font id='Book Antiqua'>")
			fString = doCode(fString, "[font=Century Gothic]", "[/font=Century Gothic]", "<font face='Century Gothic'>", "</font id='Century Gothic'>")
			fString = doCode(fString, "[font=Courier New]", "[/font=Courier New]", "<font face='Courier New'>", "</font id='Courier New'>")
			fString = doCode(fString, "[font=Comic Sans MS]", "[/font=Comic Sans MS]", "<font face='Comic Sans MS'>", "</font id='Comic Sans MS'>")
			fString = doCode(fString, "[font=Georgia]", "[/font=Georgia]", "<font face='Georgia'>", "</font id='Georgia'>")
			fString = doCode(fString, "[font=Impact]", "[/font=Impact]", "<font face='Impact'>", "</font id='Impact'>")
			fString = doCode(fString, "[font=Tahoma]", "[/font=Tahoma]", "<font face='Tahoma'>", "</font id='Tahoma'>")
			fString = doCode(fString, "[font=Times New Roman]", "[/font=Times New Roman]", "<font face='Times New Roman'>", "</font id='Times New Roman'>")
			fString = doCode(fString, "[font=Trebuchet MS]", "[/font=Trebuchet MS]", "<font face='Trebuchet MS'>", "</font id='Trebuchet MS'>")
			fString = doCode(fString, "[font=Script MT Bold]", "[/font=Script MT Bold]", "<font face='Script MT Bold'>", "</font id='Script MT Bold'>")
			fString = doCode(fString, "[font=Stencil]", "[/font=Stencil]", "<font face='Stencil'>", "</font id='Stencil'>")
			fString = doCode(fString, "[font=宋体]", "[/font=宋体]", "<font face='宋体'>", "</font id='宋体'>")
			fString = doCode(fString, "[font=Lucida Console]", "[/font=Lucida Console]", "<font face='Lucida Console'>", "</font id='Lucida Console'>")

			fString = doCode(fString, "[red]", "[/red]", "<font color=red>", "</font id=red>")
			fString = doCode(fString, "[green]", "[/green]", "<font color=green>", "</font id=green>")
			fString = doCode(fString, "[blue]", "[/blue]", "<font color=blue>", "</font id=blue>")
			fString = doCode(fString, "[white]", "[/white]", "<font color=white>", "</font id=white>")
			fString = doCode(fString, "[purple]", "[/purple]", "<font color=purple>", "</font id=purple>")
			fString = doCode(fString, "[yellow]", "[/yellow]", "<font color=yellow>", "</font id=yellow>")
			fString = doCode(fString, "[violet]", "[/violet]", "<font color=violet>", "</font id=violet>")
			fString = doCode(fString, "[brown]", "[/brown]", "<font color=brown>", "</font id=brown>")
			fString = doCode(fString, "[black]", "[/black]", "<font color=black>", "</font id=black>")
			fString = doCode(fString, "[pink]", "[/pink]", "<font color=pink>", "</font id=pink>")
			fString = doCode(fString, "[orange]", "[/orange]", "<font color=orange>", "</font id=orange>")
			fString = doCode(fString, "[gold]", "[/gold]", "<font color=gold>", "</font id=gold>")

			fString = doCode(fString, "[beige]", "[/beige]", "<font color=beige>", "</font id=beige>")
			fString = doCode(fString, "[teal]", "[/teal]", "<font color=teal>", "</font id=teal>")
			fString = doCode(fString, "[navy]", "[/navy]", "<font color=navy>", "</font id=navy>")
			fString = doCode(fString, "[maroon]", "[/maroon]", "<font color=maroon>", "</font id=maroon>")
			fString = doCode(fString, "[limegreen]", "[/limegreen]", "<font color=limegreen>", "</font id=limegreen>")

			fString = doCode(fString, "[h1]", "[/h1]", "<h1>", "</h1>")
			fString = doCode(fString, "[h2]", "[/h2]", "<h2>", "</h2>")
			fString = doCode(fString, "[h3]", "[/h3]", "<h3>", "</h3>")
			fString = doCode(fString, "[h4]", "[/h4]", "<h4>", "</h4>")
			fString = doCode(fString, "[h5]", "[/h5]", "<h5>", "</h5>")
			fString = doCode(fString, "[h6]", "[/h6]", "<h6>", "</h6>")
			fString = doCode(fString, "[size=1]", "[/size=1]", "<font size=1>", "</font id=size1>")
			fString = doCode(fString, "[size=2]", "[/size=2]", "<font size=2>", "</font id=size2>")
			fString = doCode(fString, "[size=3]", "[/size=3]", "<font size=3>", "</font id=size3>")
			fString = doCode(fString, "[size=4]", "[/size=4]", "<font size=4>", "</font id=size4>")
			fString = doCode(fString, "[size=5]", "[/size=5]", "<font size=5>", "</font id=size5>")
			fString = doCode(fString, "[size=6]", "[/size=6]", "<font size=6>", "</font id=size6>")
			fString = doCode(fString, "[list]", "[/list]", "<ul>", "</ul>")
			fString = doCode(fString, "[list=1]", "[/list=1]", "<ol type=1>", "</ol id=1>")
			fString = doCode(fString, "[list=a]", "[/list=a]", "<ol type=a>", "</ol id=a>")
			fString = doCode(fString, "[*]", "[/*]", "<li>", "</li>")
			fString = doCode(fString, "[left]", "[/left]", "<div align=left>", "</div id=left>")
			fString = doCode(fString, "[center]", "[/center]", "<center>", "</center>")
			fString = doCode(fString, "[centre]", "[/centre]", "<center>", "</center>")
			fString = doCode(fString, "[right]", "[/right]", "<div align=right>", "</div id=right>")
			fString = doCode(fString, "[code]", "[/code]", "<pre id=code><font face=courier size=" & strDefaultFontSize & " id=code>", "</font id=code></pre id=code>")
			fString = doCode(fString, "[quote]", "[/quote]", "<BLOCKQUOTE id=quote><font size=" & strFooterFontSize & " face=""" & strDefaultFontFace & """ id=quote>quote:<hr height=1 noshade id=quote>", "<hr height=1 noshade id=quote></font id=quote></BLOCKQUOTE id=quote>")
			fString = doCode(fString, "[url=&quot;", "&quot;]", "[url=""", """]")
			fString = doCode(fString, "[URL=&quot;", "&quot;]", "[url=""", """]")
'			fString = doCode(fString, "[url", "[/url]", "<a>", "</a>")
			fString = replace(fString, "[br]", "<br>", 1, -1, 1)
	if stricons = "1" and _
	fField_Type <> "title" and _
		fField_Type <> "hidden" then
		fString= smile(fString)
	end if
			
			if strIMGInPosts = "1" then
				fString = doCode(fString, "[img]","[/img]","<img src=""",""" border=0>")
				fString = doCode(fString, "[image]","[/image]","<img src=""",""" border=0>")
				fString = doCode(fString, "[img=right]","[/img=right]","<img align=right src=""",""" id=right border=0>")
				fString = doCode(fString, "[image=right]","[/image=right]","<img align=right src=""",""" id=right border=0>")
				fString = doCode(fString, "[img=left]","[/img=left]","<img align=left src=""",""" id=left border=0>")
				fString = doCode(fString, "[image=left]","[/image=left]","<img align=left src=""",""" id=left border=0>")
			end if
		end if
	end if
	if strIcons = "1" and _
	fField_Type <> "title" and _
	fField_Type <> "hidden" then
		fString= smile(fString)
	end if
	if fField_Type <> "hidden" and _
	fField_Type <> "preview" then
		fString = Replace(fString, "'", "''")
	end if
	ChkString = fString
end function

function ChkDateTime(fDateTime)
	if fDateTime = "" then
		exit function
	end if
	if IsDate(fDateTime) then
		select case strDateType
			case "dmy"
				ChkDateTime = Mid(fDateTime,7,2) & "/" & _
				Mid(fDateTime,5,2) & "/" & _
				Mid(fDateTime,1,4)
			case "mdy"
				ChkDateTime = Mid(fDateTime,5,2) & "/" & _
				Mid(fDateTime,7,2) & "/" & _
				Mid(fDateTime,1,4)
			case "ymd"
				ChkDateTime = Mid(fDateTime,1,4) & "/" & _
				Mid(fDateTime,5,2) & "/" & _
				Mid(fDateTime,7,2)
			case "ydm"
				ChkDateTime =Mid(fDateTime,1,4) & "/" & _
				Mid(fDateTime,7,2) & "/" & _
				Mid(fDateTime,5,2)
			case "dmmy"
				ChkDateTime = Mid(fDateTime,7,2) & " " & _
				Monthname(Mid(fDateTime,5,2),1) & " " & _
				Mid(fDateTime,1,4)
			case "mmdy"
				ChkDateTime = Monthname(Mid(fDateTime,5,2),1) & " " & _
				Mid(fDateTime,7,2) & " " & _
				Mid(fDateTime,1,4)
			case "ymmd"
				ChkDateTime = Mid(fDateTime,1,4) & " " & _
				Monthname(Mid(fDateTime,5,2),1) & " " & _
				Mid(fDateTime,7,2)
			case "ydmm"
				ChkDateTime = Mid(fDateTime,1,4) & " " & _
				Mid(fDateTime,7,2) & " " & _
				Monthname(Mid(fDateTime,5,2),1)
			case "dmmmy"
				ChkDateTime = Mid(fDateTime,7,2) & " " & _
				Monthname(Mid(fDateTime,5,2),0) & " " & _
				Mid(fDateTime,1,4)
			case "mmmdy"
				ChkDateTime = Monthname(Mid(fDateTime,5,2),0) & " " & _
				Mid(fDateTime,7,2) & " " & _
				Mid(fDateTime,1,4)
			case "ymmmd"
				ChkDateTime = Mid(fDateTime,1,4) & " " & _
				Monthname(Mid(fDateTime,5,2),0) & " " & _
				Mid(fDateTime,7,2)
			case "ydmmm"
				ChkDateTime = Mid(fDateTime,1,4) & " " & _
				Mid(fDateTime,7,2) & " " & _
				Monthname(Mid(fDateTime,5,2),0)
			case else
				ChkDateTime = doublenum(Mid(fDateTime,5,2)) & "/" & _
				Mid(fDateTime,7,2) & "/" & _
				Mid(fDateTime,1,4)
		end select
		if strTimeType = 12 then
			if cint(Mid(fDateTime, 9,2)) > 12 then
				ChkDateTime = ChkDateTime & " " & _
				(cint(Mid(fDateTime, 9,2)) -12) & ":" & _
				Mid(fDateTime, 11,2) & ":" & _
				Mid(fDateTime, 13,2) & " " & "PM"
			elseif cint(Mid(fDateTime, 9,2)) = 12 then
				ChkDateTime = ChkDateTime & " " & _
				cint(Mid(fDateTime, 9,2)) & ":" & _
				Mid(fDateTime, 11,2) & ":" & _
				Mid(fDateTime, 13,2) & " " & "PM"
			elseif cint(Mid(fDateTime, 9,2)) = 0 then
				ChkDateTime = ChkDateTime & " " & _
				(cint(Mid(fDateTime, 9,2)) +12) & ":" & _
				Mid(fDateTime, 11,2) & ":" & _
				Mid(fDateTime, 13,2) & " " & "AM"
			else
				ChkDateTime = ChkDateTime & " " & _
				Mid(fDateTime, 9,2) & ":" & _
				Mid(fDateTime, 11,2) & ":" & _
				Mid(fDateTime, 13,2) & " " & "AM"
			end if
		else
			ChkDateTime = ChkDateTime & " " & _
			Mid(fDateTime, 9,2) & ":" & _
			Mid(fDateTime, 11,2) & ":" & _
			Mid(fDateTime, 13,2) 
		end if
	end if
end function

function ChkDateFormat(strDateTime)
	ChkDateFormat =  isdate("" & Mid(strDateTime, 5,2) & "/" & Mid(strDateTime, 7,2) & "/" & Mid(strDateTime, 1,4) & " " & Mid(strDateTime, 9,2) & ":" & Mid(strDateTime, 11,2) & ":" & Mid(strDateTime, 13,2) & "")
end function

function StrToDate(strDateTime)
	if ChkDateFormat(strDateTime) then
		StrToDate = cdate("" & Mid(strDateTime, 5,2) & "/" & Mid(strDateTime, 7,2) & "/" & Mid(strDateTime, 1,4) & " " & Mid(strDateTime, 9,2) & ":" & Mid(strDateTime, 11,2) & ":" & Mid(strDateTime, 13,2) & "")
	else
		StrToDate = "" & strForumTimeAdjust
	end if
end function

function DateToStr(dtDateTime)
	DateToStr = year(dtDateTime) & doublenum(Month(dtdateTime)) & doublenum(Day(dtdateTime)) & doublenum(Hour(dtdateTime)) & doublenum(Minute(dtdateTime)) & doublenum(Second(dtdateTime)) & ""
end function

function ReadLastHereDate(UserName)
	dim TempLastHereDate
	dim rs_date

	'## Forum_SQL
	strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.M_LASTHEREDATE "
	strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
	strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS."&Strdbntsqlname&" = '" & UserName & "' "

	
	set rs_date = my_conn.Execute (strSql)

	if (rs_date.BOF and rs_date.EOF) then
		TempLastHereDate = DateAdd("d",-10,strForumTimeAdjust)
	else
		TempLastHereDate = StrToDate(rs_date("M_LASTHEREDATE"))
		if TempLastHereDate = "" or IsNull(TempLastHereDate) then
			TempLastHereDate = DateAdd("d",-10,strForumTimeAdjust)
		end if	
	end if

	rs_date.close	
	set rs_date = nothing

	'## Forum_SQL - Do DB Update
	strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS "
	strSql = strSql & " SET M_LASTHEREDATE = '" & DateToStr(strForumTimeAdjust) & "'"
	strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS." & strDBNTSQLName & " = '" & UserName & "' "

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?