% Response.Buffer = true
dim results, error, resultsFound, pageOn, pageLength, pageStart, pageEnd
dim quicksearch, look_for
'if (Request.QueryString("listby") = "") and ((Request.QueryString("clearall") = "yes") or (Request.Form("searchfor") = "")) then
'if Request.QueryString("clearall") = "yes" then
' look_for = ""
'end if
'allow for a quick search from the nav bar
if Request.QueryString("quick") <> "" then
quicksearch = true
look_for = Request.QueryString("quick")
end if
'lets them resort the results
if Trim(Request.Form("searchfor")) <> "" then
look_for = Trim(Request.Form("searchfor"))
end if
'find page
pageOn = Request.QueryString("page")
if not isNumeric(pageOn) then
pageOn = 0
end if
'define pageLength
pageLength = 25
'retreive results from DB and make sure not paging past end of results
if Request.QueryString("submitted") = "true" then
call getResults()
end if
%>
|
|
Looking for that certain level? You know you saw it some where, right?
Try a LvL search, its no luck dip search this one, every level looked at by LvL is
listed here:
<%
if resultsFound then
dim tmpOutPut
tmpOutPut = datepart("yyyy",now()) & datepart("m",now()) & datepart("d",now()) & datepart("h",now()) & datepart("n",now()) & datepart("s",now()) & server.URLEncode(trim(request.Form("searchfor")))
if Request.Form("searchOutPut") = "asCSV" then
'render a CSV file of the data and return a link to the file
result2CSV(tmpOutPut)
elseif Request.Form("searchOutPut") = "asXML" then
'render an XML file of the data and return a link to the file
result2XML(tmpOutPut)
else
'return the results to the page
result2Page()
end if
end if
%>
<%if error <> "" Then
%>
<%=error%>
|
<%
end if%>
<%
if Request.Form("searchOutPut") <> "asXML" then
'only display if the search if a 'standard search'
if Request.Form("searchOutPut") <> "asCSV" then
if (resultsFound) then
if pageOn > 0 then 'show previous page nav
%>&quick=<%=server.URLPathEncode(look_for)%>&page=<%=pageOn-1%>"><< Back <%
end if
if ((pageOn + 1) * pageLength) < ubound(results,2) then 'more to show
%>&quick=<%=server.URLPathEncode(look_for)%>&page=<%=pageOn+1%>">Next >><%
end if
end if
end if
end if
%> |
|
search tips: |
|
* Getting no results? try part of a word only (less is more here).
* A 'blank' search will return every level, are you sure you want to do this?
* You can use '_' as a single letter wild card.
* You can search by level name or authors name or authors email or level type, but not
all at once (you will get no results)
* DM will return all levels that are of the DM type.
Just like CTF will return all CTF levels, just like Tourney will .....
* A serach for DM, CTF will return nothing (unless
there is a DM, CTF level, :]).
* Basically you can not search for more than one 'type' of level and you can not search
for more than one combination (ie, 'Tigger-oN DM' will return nothing)
* A serach for the letter 'e' will return every level
with an 'e' in its name (a lot of them)
|
|
|
|
<%
'---------------
' renders an XML file of the search results
function result2XML(fileOutPutName)
' the format of the XML is below;
'
'
'
'
'
'
'
'
'
'
'array position
'id 0, str_title 1, str_filename 2,
'str_type 3, str_author 4, str_author_email 5, nmb_comments 6,
'ranking 7, votes 8, datestamp 9
const ForReading = 1, ForWriting = 2
dim f, fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(current_ROOT & "xml\searchData\"& fileOutPutName &".xml", ForWriting, True)
'start the XML file for this search
f.Writeline ""
for n=0 to ubound(results,2)
f.Writeline " "
f.Writeline " "& server.HTMLEncode(results(1,n)) &""
f.Writeline " "& server.HTMLEncode(results(2,n)) &""
f.Writeline " "& server.HTMLEncode(results(4,n)) &""
f.Writeline " "& server.HTMLEncode(results(3,n)) &""
f.Writeline " "& server.HTMLEncode(results(9,n)) &""
f.Writeline " "& site_url & "comments.asp?id=" & results(0,n) &""
f.Writeline " "
next
f.Writeline ""
Response.Write("An XML file your search results has been created right here. Hold down SHIFT on your keyboard and click here to view the file.
")
end function
'---------------
' renders a CSV file of the search results
function result2CSV(fileOutPutName)
' the format of the CSV is below;
'id, Title, FileName, Author, Type, DateAdded, ReviewPage
'array position
'id 0, str_title 1, str_filename 2,
'str_type 3, str_author 4, str_author_email 5, nmb_comments 6,
'ranking 7, votes 8, datestamp 9
const ForReading = 1, ForWriting = 2
dim f, fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(current_ROOT & "xml\searchData\"& fileOutPutName &".csv", ForWriting, True)
'start the CSV file for this search
f.Writeline """id"", ""Title"", ""FileName"", ""Author"", ""Type"", ""DateAdded"", ""ReviewPage"""
for n=0 to ubound(results,2)
f.Writeline """"& results(0,n) &""","""& replace(results(1,n),"""","""""") &""","""& replace(results(2,n),"""","""""") &""","""& replace(results(4,n),"""","""""") &""","""& replace(results(3,n),"""","""""") &""","""& replace(results(9,n),"""","""""") &""","""& site_url & "comments.asp?id=" & results(0,n) &""""
next
Response.Write("A CSV of your search results has been created right here. Hold down SHIFT on your keyboard and click here to view the file.
")
end function
'--------------------
' displays the result of the search as HTML
function result2Page()
%>
<%
if pageOn > 0 then 'show previous page nav
%>&quick=<%=server.URLPathEncode(look_for)%>&page=<%=pageOn-1%>"><< Back <%
end if
if ((pageOn + 1) * pageLength) < ubound(results,2) then 'show next
%>&quick=<%=server.URLPathEncode(look_for)%>&page=<%=pageOn+1%>">Next >><%
end if
%> |
title |
file |
filesize |
author |
type - d/load |
added |
posts |
rank |
votes |
<%
i = 1
dim t_rk, t_vt, scr, t_fn, t_id
dim p_fs
'determine start and end of page
pageStart = pageOn * pageLength
pageEnd = ((pageOn + 1)* pageLength)- 1
if pageEnd > ubound(results,2) then
pageEnd = ubound(results,2)
end if
'page through array of results returned
for n = pageStart to pageEnd
if i mod 2 then
bgcolor = ""
else
bgcolor = " bgcolor="& bgcolourCustom &""
end if
'fields and array position
'id 0, str_title 1, str_filename 2,
'str_type 3, str_author 4, str_author_email 5, nmb_comments 6,
'ranking 7, votes 8, datestamp 9
t_fn = results(2,n)
t_id = results(0,n)
t_rk = results(7,n)
t_vt = results(8,n)
if not IsNull(t_rk) or not IsNull(t_vt) then
scr = Cint(t_rk) / Cint(t_vt)
else
scr = 0
end if
if (t_vt = "") or (IsNull(t_vt)) then
t_vt = 0
end if
'find out how big the file is in kb
p_fs = FileSize(cdrom_dir & file_dir(t_fn) & "\" & t_fn & ".zip")
%>
><%=results(1,n)%> |
><%=t_fn%> |
><%=p_fs%> |
><%=results(4,n)%> |
><%=results(3,n)%> |
><%=realdateshort(results(9,n))%> |
><%=results(6,n)%> |
><%=Round(scr,2)%> |
><%=t_vt%> |
<%
i = i + 1
if i mod 5 = 0 then
Response.Flush
end if
next
Response.Write("
")
'close off table
end function
function getResults()
dim query, tigCON, tigRS
' set up the query to list the news by date Desc
query = "SELECT id, str_title, str_filename, " &_
"str_type, str_author, str_author_email, nmb_comments, " &_
"ranking, votes, datestamp " &_
"FROM q3a_levels " &_
"WHERE (bit_archived = 0) AND ("
if quicksearch then
'only want to search type of level field
query = query & "(str_type like '%" & SQLSafe(look_for) & "%')) "
else
query = query & "(str_author_email like '%" & SQLSafe(look_for) & "%') or " &_
"(str_author like '%" & SQLSafe(look_for) & "%') or " &_
"(str_type like '%" & SQLSafe(look_for) & "%') or " &_
"(str_filename like '%" & SQLSafe(look_for) & "%') or " &_
"(str_title like '%" & SQLSafe(look_for) & "%'))"
end if
if Request.QueryString("listby") = "filename" then
query = query & "order by str_filename"
elseif Request.QueryString("listby") = "author" then
query = query & "order by str_author"
elseif Request.QueryString("listby") = "type" then
query = query & "order by str_type"
elseif Request.QueryString("listby") = "date" then
query = query & "order by datestamp desc"
elseif Request.QueryString("listby") = "votes" then
query = query & "order by votes desc"
elseif Request.QueryString("listby") = "comments" then
query = query & "order by nmb_comments desc"
elseif Request.QueryString("listby") = "score" then
query = query & "order by (ranking / votes) desc"
else
query = query & "order by str_title"
end if
'Response.Write("Query = [" & query & "]
")
set tigCON = Server.CreateObject("ADODB.Connection")
tigCON.Open(DSN)
set tigRS = tigCON.Execute(query)
' make sure we have see if there is no records
if (tigRS.EOF) Then
error = "Your search for " & look_for & " has returned no results, have a look over the search tips below for some pointers."
else
results = tigRS.getRows
'make sure not paging past end of results
if (pageOn * pageLength) =< ubound(results,2) then
resultsFound = true
else
error = "There are no more results."
end if
end if
tigRS.close
tigCON.close
end function
%>