inc_functions.asp
来自「一个不错的ASP论坛源码」· ASP 代码 · 共 1,603 行 · 第 1/5 页
ASP
1,603 行
my_conn.Execute (strSql)
ReadLastHereDate = DateToStr(TempLastHereDate)
end function
function getMemberID(fUser_Name)
'## Forum_SQL
strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.MEMBER_ID "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE M_NAME = '" & fUser_Name & "'"
rsGetMemberID = my_Conn.Execute(strSql)
getMemberID = rsGetMemberID("MEMBER_ID")
end function
function ChkDate(fDate)
if fDate = "" or vartype(fDate) = vbNull then
exit function
end if
'if IsDate(fDate) then
select case strDateType
case "dmy"
ChkDate = Mid(fDate,7,2) & "/" & _
Mid(fDate,5,2) & "/" & _
Mid(fDate,1,4)
case "mdy"
ChkDate = Mid(fDate,5,2) & "/" & _
Mid(fDate,7,2) & "/" & _
Mid(fDate,1,4)
case "ymd"
ChkDate = Mid(fDate,1,4) & "/" & _
Mid(fDate,5,2) & "/" & _
Mid(fDate,7,2)
case "ydm"
ChkDate =Mid(fDate,1,4) & "/" & _
Mid(fDate,7,2) & "/" & _
Mid(fDate,5,2)
case "dmmy"
ChkDate = Mid(fDate,7,2) & " " & _
Monthname(Mid(fDate,5,2),1) & " " & _
Mid(fDate,1,4)
case "mmdy"
ChkDate = Monthname(Mid(fDate,5,2),1) & " " & _
Mid(fDate,7,2) & " " & _
Mid(fDate,1,4)
case "ymmd"
ChkDate = Mid(fDate,1,4) & " " & _
Monthname(Mid(fDate,5,2),1) & " " & _
Mid(fDate,7,2)
case "ydmm"
ChkDate = Mid(fDate,1,4) & " " & _
Mid(fDate,7,2) & " " & _
Monthname(Mid(fDate,5,2),1)
case "dmmmy"
ChkDate = Mid(fDate,7,2) & " " & _
Monthname(Mid(fDate,5,2),0) & " " & _
Mid(fDate,1,4)
case "mmmdy"
ChkDate = Monthname(Mid(fDate,5,2),0) & " " & _
Mid(fDate,7,2) & " " & _
Mid(fDate,1,4)
case "ymmmd"
ChkDate = Mid(fDate,1,4) & " " & _
Monthname(Mid(fDate,5,2),0) & " " & _
Mid(fDate,7,2)
case "ydmmm"
ChkDate = Mid(fDate,1,4) & " " & _
Mid(fDate,7,2) & " " & _
Monthname(Mid(fDate,5,2),0)
case else
ChkDate = Mid(fDate,5,2) & "/" & _
Mid(fDate,7,2) & "/" & _
Mid(fDate,1,4)
End Select
'end if
end function
function ChkTime(fTime)
if fTime = "" then
exit function
end if
if strTimeType = 12 then
if cint(Mid(fTime, 9,2)) > 12 then
ChkTime = ChkTime & " " & _
(cint(Mid(fTime, 9,2)) -12) & ":" & _
Mid(fTime, 11,2) & ":" & _
Mid(fTime, 13,2) & " " & "PM"
elseif cint(Mid(fTime, 9,2)) = 12 then
ChkTime = ChkTime & " " & _
cint(Mid(fTime, 9,2)) & ":" & _
Mid(fTime, 11,2) & ":" & _
Mid(fTime, 13,2) & " " & "PM"
elseif cint(Mid(fTime, 9,2)) = 0 then
ChkTime = ChkTime & " " & _
(cint(Mid(fTime, 9,2)) +12) & ":" & _
Mid(fTime, 11,2) & ":" & _
Mid(fTime, 13,2) & " " & "AM"
else
ChkTime = ChkTime & " " & _
Mid(fTime, 9,2) & ":" & _
Mid(fTime, 11,2) & ":" & _
Mid(fTime, 13,2) & " " & "AM"
end if
else
ChkTime = ChkTime & " " & _
Mid(fTime, 9,2) & ":" & _
Mid(fTime, 11,2) & ":" & _
Mid(fTime, 13,2)
end if
end function
function EmailField(fTestString)
TheAt = Instr(2, fTestString, "@")
if TheAt = 0 then
EmailField = 0
else
TheDot = Instr(cint(TheAt) + 2, fTestString, ".")
if TheDot = 0 then
EmailField = 0
else
if cint(TheDot) + 1 > Len(fTestString) then
EmailField = 0
else
EmailField = -1
end if
end if
end if
end function
function ChkIsNew(fDateTime,fType)
if fType = "Topic" then
if strHotTopic = "1" then
if fDateTime > Session(strCookieURL & "last_here_date") then
if rs("T_REPLIES") >= intHotTopicNum then
ChkIsNew = "<img src=" & strImageURL & "icon_folder_new_hot.gif height=15 width=15 alt=热门主题 border=0>"
else
ChkIsNew = "<img src=" & strImageURL & "icon_folder_new.gif height=15 width=15 alt=新主题 border=0>"
end if
else
if rs("T_REPLIES") >= intHotTopicNum then
ChkIsNew = "<img src=" & strImageURL & "icon_folder_hot.gif height=15 width=15 alt=热门主题 border=0>"
else
ChkIsNew = "<img src=" & strImageURL & "icon_folder.gif height=15 width=15 border=0>"
end if
end if
else
if fDateTime > Session(strCookieURL & "last_here_date") then
ChkIsNew = "<img src=" & strImageURL & "icon_folder_new.gif height=15 width=15 alt=新主题 border=0>"
else
ChkIsNew = "<img src=" & strImageURL & "icon_folder.gif height=15 width=15 border=0>"
end if
end if
else
if rsForum("F_STATUS") <> 0 then
if fDateTime > Session(strCookieURL & "last_here_date") then
ChkIsNew = "<IMG src='" & strImageURL & "icon_folder_new.gif' height=15 width=15 border=0 hspace=0 alt='New Posts'>"
Else
ChkIsNew = "<IMG src='" & strImageURL & "icon_folder.gif' height=15 width=15 border=0 hspace=0 alt='Old Posts'>"
end if
else
ChkIsNew = "<IMG src='" & strImageURL & "icon_folder_locked.gif' height=15 width=15 border=0 hspace=0 alt='论坛已被锁定'>"
end if
end if
end function
function ChkQuoteOk(fString)
ChkQuoteOk = not(InStr(1, fString, "'", 0) > 0)
end function
function ChkUser(fName, fPassword)
'## Forum_SQL
strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.MEMBER_ID, " & strMemberTablePrefix & "MEMBERS.M_LEVEL, " & strMemberTablePrefix & "MEMBERS.M_NAME, " & strMemberTablePrefix & "MEMBERS.M_PASSWORD "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS." & strDBNTSQLName & " = '" & fName & "' "
if strAuthType="db" then
strSql = strSql & " AND " & strMemberTablePrefix & "MEMBERS.M_PASSWORD = '" & fPassword &"'"
End IF
strSql = strSql & " AND " & strMemberTablePrefix & "MEMBERS.M_STATUS = " & 1
set rsCheck = my_Conn.Execute (strSql)
if rsCheck.BOF or rsCheck.EOF or not(ChkQuoteOk(fName)) or not(ChkQuoteOk(fPassword)) then
ChkUser = 0
else
if cstr(rsCheck("MEMBER_ID")) = Request.Form("Author") then
ChkUser = 1 '## Author
else
Select case cint(rsCheck("M_LEVEL"))
case 1
ChkUser = 2 '## Normal User
case 2
ChkUser = 3 '## Moderator
case 3
ChkUser = 4 '## Admin
case else
ChkUser = cint(rsCheck("M_LEVEL"))
End Select
end if
end if
rsCheck.close
set rsCheck = nothing
end function
function ChkUser2(fName, fPassword)
'## Forum_SQL
strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.MEMBER_ID, " & strMemberTablePrefix & "MEMBERS.M_LEVEL, " & strMemberTablePrefix & "MEMBERS.M_NAME, " & strMemberTablePrefix & "MEMBERS.M_PASSWORD "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
StrSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS." & strDBNTSQLName & " = '" & fName & "' "
if strAuthType="db" then
strSql = strSql & " AND " & strMemberTablePrefix & "MEMBERS.M_PASSWORD = '" & fPassword &"'"
End If
strSql = strSql & " AND " & strMemberTablePrefix & "MEMBERS.M_STATUS = " & 1
on error resume next
set rsCheck = my_Conn.Execute (strSql)
for counter = 0 to my_Conn.Errors.Count -1
if my_Conn.Errors(counter).Number <> 0 or Err.number > 0 then
ChkUser2 = -1
my_Conn.Errors.Clear
end if
next
if rsCheck.BOF or rsCheck.EOF or not(ChkQuoteOk(fName)) or not(ChkQuoteOk(fPassword)) or ChkUser2 = -1 then
ChkUser2 = 0 '## Invalid Password
else
if cint(rsCheck("MEMBER_ID")) = cint(Request.QueryString("Author")) then
ChkUser2 = 1 '## Author
else
select case cint(rsCheck("M_LEVEL"))
case 1
ChkUser2 = 2 '## Normal User
case 2
ChkUser2 = 3 '## Moderator
case 3
ChkUser2 = 4 '## Admin
case else
ChkUser2 = cint(rsCheck("M_LEVEL"))
end select
end if
end if
rsCheck.close
set rsCheck = nothing
end function
function ChkUser3(fName, fPassword, fReply)
'## Forum_SQL
strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.MEMBER_ID, " & strMemberTablePrefix & "MEMBERS.M_LEVEL, " & strMemberTablePrefix & "MEMBERS.M_NAME, " & strMemberTablePrefix & "MEMBERS.M_PASSWORD, " & strTablePrefix & "REPLY.R_AUTHOR "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS, " & strTablePrefix & "REPLY "
StrSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS." & strDBNTSQLName & " = '" & fName & "' "
if strAuthType="db" then
strSql = strSql & " AND " & strMemberTablePrefix & "MEMBERS.M_PASSWORD = '" & fPassword &"' "
End If
strSql = strSql & " AND " & strTablePrefix & "REPLY.REPLY_ID = " & fReply
strSql = strSql & " AND " & strMemberTablePrefix & "MEMBERS.M_STATUS = " & 1
set rsCheck = my_Conn.Execute (strSql)
if rsCheck.BOF or rsCheck.EOF or not(ChkQuoteOk(fName)) or not(ChkQuoteOk(fPassword)) then
ChkUser3 = 0 '## Invalid Password
else
if cint(rsCheck("MEMBER_ID")) = cint(rsCheck("R_AUTHOR")) then
ChkUser3 = 1 '## Author
else
Select case cint(rsCheck("M_LEVEL"))
case 1
ChkUser3 = 2 '## Normal User
case 2
ChkUser3 = 3 '## Moderator
case 3
ChkUser3 = 4 '## Admin
case else
ChkUser3 = cint(rsCheck("M_LEVEL"))
End Select
end if
end if
rsCheck.close
set rsCheck = nothing
end function
function GetSig(fUser_Name)
'## Forum_SQL
strSql = "SELECT M_SIG "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE M_NAME = '" & Request.Form("UserName") & "'"
set rsSig = my_Conn.Execute (strSql)
if rsSig.EOF or rsSig.BOF then
'## Do Nothing
else
GetSig = rsSig("M_SIG")
end if
rsSig.close
set rsSig = nothing
end function
function DoDropDown(fTableName, fDisplayField, fValueField, fSelectValue, fName)
'## Forum_SQL
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?