%
If Len(Request.Cookies("admin_loggedin" & strSUnique)) = 0 Then Response.Redirect "default.asp"
showTempl = Request("id")
searchCid = Request("cidx")
strSQL = "SELECT * FROM tblHelp ORDER BY cid, sid;"
Set rs = objConn.Execute(strSQL)
x=0
If not rs.EOF then
Do while Not rs.EOF
template = CStr(rs("ID"))
subject = rs("topic")
cid = CLng(rs("cid"))
sid = CLng(rs("sid"))
isExpand = CBool(rs("isexpand"))
If CStr(cid) = CStr(searchCid) then
isExpand = True
If showTempl = template then
strSQL = "UPDATE tblHelp SET isexpand = 1 WHERE cid = " & cid & ";"
objConn.Execute(strSQL)
End If
End If
If sid > 0 then
indent = " "
separator = " style='font-size: 8pt;' "
block = ""
endblock = ""
imgExpand = ""
Else
If x > 0 then endblock = ""
If isExpand then
isHide = ""
imgExpand = "
"
Else
isHide = "display: none; "
imgExpand = "
"
End If
block = "
"
indent = ""
separator = " style='margin-top: 4px; margin-bottom: 4px; background-color: #E0E8EB;' "
End If
Select Case showTempl
Case ""
showCid = 1
showSid = 0
showTitle = subject
showTempl = template
body = rs("body")
strTemplate = endblock & "
" & block & vbcrLf
Case else
If showTempl = template then
showCid = cid
showSid = sid
showTitle = subject
body = rs("body")
strTemplate = strTemplate & endblock & "
" & block & vbcrLf
Else: strTemplate = strTemplate & endblock & "
" & block & vbcrLf
End If
End Select
x = x + 1
rs.MoveNext
Loop
rs.close
strTemplate = strTemplate & "
"
End If
If lcase(Request.ServerVariables("REQUEST_METHOD")) = "post" then
isSearch = True
commonWordsArray = Split("the for and where who that this then that from does will yes")
as_keys = Trim(lCase(CStr(Request("T1"))))
as_keysformat = CLng(Request("D1"))
as_keys = Replace(as_keys, "'", "")
as_keys = Replace(as_keys, "&", "")
as_keys = Replace(as_keys, "<", "")
as_keys = Replace(as_keys, ">", "")
If Len(as_keys) < 3 then
haltSearch = true
Elseif Len(as_keys) > 2 Then
as_queryKeys = formatKeywords(as_keys, as_keysformat)
If Len(as_queryKeys) = 0 then haltSearch = true
End If
If not haltSearch then
strSQL = "SELECT * FROM tblHelp WHERE " & as_queryKeys & " ORDER BY cid, sid;"
Set rs = objConn.Execute(strSQL)
If not rs.EOF then
Set re = new RegExp
re.global=true
re.ignoreCase=true
re.multiLine=true
re.Pattern = "(<[^>]*>)|(\s{1,})"
Set rek = new RegExp
rek.global = False
rek.ignoreCase = true
searchResult = ""
searchResult = searchResult & "
Search result for [" & as_keys & "]:
"
Do While not rs.EOF
ID = CStr(rs("ID"))
subject = rs("topic")
cid = CLng(rs("cid"))
sid = CLng(rs("sid"))
sbody = rs("body")
sbody = Replace(sbody, "
", " ")
sbody = Replace(sbody, vbcrLf, " ")
sbody = Replace(sbody, " ", " ")
If re.test(sbody) then sbody = re.replace(sbody, " ")
If as_keysformat = 3 then
re_key = as_keys
Else
re_key = Split(as_keys, " ")(0)
End If
rek.Pattern = "\b.{0,80}(" & re_key & ").{0,80}\b"
searchResult = searchResult & "
" & cid & "." & sid & " " & subject & ""
If rek.test(sbody) Then
Set kmatch = rek.execute(sbody)
strKeyBody = kmatch(0)
'strKeyBody = Server.HTMLEncode(strKeyBody)
strKeyBody = Replace(strKeyBody, re_key, "
" & re_key & "",1,1,1)
searchResult = searchResult & "
..." & strKeyBody & "...
"
End If
rs.moveNext
Loop
searchResult = searchResult & "
"
Set re = Nothing
Set rek = Nothing
Else
searchResult = "