Det är lite mycket kod:
Nu tog jag heller inte med funktionerna men det har inte så stor betydelse tror jag.
IF Not len(sSearchString) < 3 Then
'Skapa objektet för att kunna läsa och bläddra igenom filer
set objFS = server.createObject("Scripting.FileSystemObject")
set objFolderRoot = objFS.getFolder(application("driver")&application("rootFolder")&"\pages")
set colFiles = objFolderRoot.Files
'Skapa recordsettet som sokresultatet ska läggas in i
set adoRS = Server.CreateObject( "ADODB.Recordset" )
adoRS.CursorLocation = 3
adoRS.Fields.Append "Id", adInteger
adoRS.Fields.Append "titel", adVarChar, 100
adoRS.Fields.Append "beskrivning", adVarChar, 350
adoRS.Fields.Append "antalOrd", adInteger
adoRS.Fields.Append "sokvag", adVarChar, 350
adoRS.Fields.Append "filnamn", adVarChar, 100
adoRS.Open
traffar = 0
raknare = 0
For each objFile in colFiles
raknare = raknare + 1
If pg = 1 Or raknare > start Then
If raknare <=50 Then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(application("driver")&application("rootFolder")&"\pages\"&objFile.name, 1)
strSida = objTextStream.ReadAll
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
strSida = RemoveASP(strSida)
titel = hamtaTitel(strSida, objFile.name)
strSida = RemoveStyle(strSida)
strSida = RemoveJava(strSida)
strSida = RemoveHTML(strSida)
call sok(strSida, sSearchString, sokResultat, antalOrd)
If sokResultat <> "" Then
traffar = traffar + 1
'Lägg in resultatet i recordsetet
adoRS.AddNew
adoRS( "id" ) = traffar
adoRS( "titel" ) = titel
adoRS( "beskrivning" ) = sokResultat
adoRS( "antalOrd" ) = antalOrd
adoRS( "sokvag") = application("httpadress")&"pages/"&objFile.name
adoRS( "filnamn" ) = objFile.name
adoRS.Update
End If
End If
End if
Next
Response.write "<span class=""mallFet"">Sökresultat</span><hr size=1 noshade>"
If traffar = 0 Then
Response.Write "<span class=""vanligtext"">Din sökning - </span><span class=""mallFet"">" & sSearchString & "</span><span class=""vanligtext""> - matchade inte något dokument.</span><br><br>" &_
"<span class=""mallFet"">Tips:</span><br>" &_
"<span class=""vanligtext"">- Kontrollera att alla ord är rättstavade.<br>" &_
"- Försök med andra sökord.<br>" &_
"- Försök med mer allmänna sökord.<br>" &_
"- Försök med färre sökord."
Else
Response.write "<span class=""vanligtext"">Du sökte efter:</span><span class=""vanligtextFarg""> "& sSearchString&"</span>"
If traffar < 50 Then
Response.write "<br><span class=""vanligtext"">Din sökning genererade: "& traffar &" träffar.</span>"
Else
Response.write "<br><span class=""vanligtext"">Eftersom din sökning genrerade mer än 50 träffar så har vi begränsat din sökning till 50 träffar.</span>"
End if
End If
response.write "<br>"
adoRS.Sort = "titel DESC"
'Vilka träffar som visas
Dim startTraff, slutTraff
startTraff = 1
Sluttraff = sidStorlek
If request("pg") = "" Then
pg = 1
Else
pg = cINT(request("pg"))
End If
If pg <> 1 Then
slutTraff = sluttraff * pg
startTraff = slutTraff - sidStorlek +1
End If
If pg = (FIX((adoRS.recordcount / sidStorlek))+1) OR adoRS.recordcount < sidStorlek Then
slutTraff = adoRS.recordcount
End If
Response.write "<br><br>" &_
"<table width=""100%"" cellspacing=""0"" cellpadding=""0"">" &_
"<tr>" &_
"<td bgcolor=""#E8E8E8"" align=""right"" class=""vanligtext"">Visar träffar: "&startTraff&" - "&slutTraff&"</td>" &_
"</tr>" &_
"</table><br>" &vbcrlf &_
"<table width=""100%"" cellspacing=""0"" cellpadding=""0"">"
While Not oRS.EOF AND rowCount < sidStorlek
rowCount = rowCount + 1
response.write "<tr>" &_
"<td valign=""top"" width=""25"" class=""vanligtext"">"
typ = lcase(right(adoRS("filnamn"),3))
select case typ
case "pdf"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_pdf.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "ppt","pps"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_powerpoint.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "psd","eps"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_psd.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "doc"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_word.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "xls"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_excel.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "fla","swf"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_flash.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "wav","wma","mp3","mp2","avi","aIf","mov","mp1","mpa","peg","mpg",".ra"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_ljud.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "zip"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_zip.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "exe","bat"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_exe.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "css"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_css.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "gIf","png","bmp"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_gIf.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "jpg"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_jpg.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "mdb"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_access.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "htm","tml", "asp","asa","xml","hta","htc","stm",".js","xsd","xsl","slt","spx","jsp","jst","scx","cfm","fml","php","hp3","hp4"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_html.gIf' width='16' height='16' alt='' border='0' align='left'>")
case "txt","rtf"
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_text.gIf' width='16' height='16' alt='' border='0' align='left'>")
case Else
response.write("<img src='"&application("httpAdress")&"systembilder/filhanterare/typ_unknown.gIf' width='16' height='16' alt='' border='0' align='left'>")
end select
response.write "</td><td valign=""top"">"
response.write "<a class=""soklank"" href="""& adoRS("sokvag") &""">"&adoRS("titel") &"</a><br>"
Response.write "<span class=""vanligtext"">"& adoRS("beskrivning") &"</span><br>"
response.write "<span class=""sokvag"">"& adoRS("sokvag") &"</span><br><br>"
response.write "</td><tr>"
adoRS.MoveNext
Wend
response.write "</table>"
If sidStorlek > 1 Then
If err.number = 0 Then
Response.write "<br><br>" &_
"<table width=""100%"" cellspacing=""0"" cellpadding=""0"">" &_
"<tr>" &_
"<td bgcolor=""#E8E8E8"" align=""left""><span class=""vanligtext"">Visa sida: </span>"
FOR i = 1 to adoRS.PageCount
If i <> cINT( pg ) Then
response.write "<a href=""http://"&TRIM(request.servervariables("HTTP_HOST") & request.servervariables("SCRIPT_NAME"))&"?sokord="&sSearchString&"&pg="&i&"&slut="&sluttraff&"&start="&starttraff&"&total="&adoRS.recordcount&""">"&i&"</a> "
Else
response.write "<span class=""vanligtext"">"&i&"</span> "
End If
NEXT
Response.write "</td><td bgcolor=""#E8E8E8"" align=""right"" class=""vanligtext"">"
If pg <> 1 Then
response.write "<a href=""http://"&TRIM(request.servervariables("HTTP_HOST") & request.servervariables("SCRIPT_NAME"))&"?sokord="&sSearchString&"&pg="&(pg-1)&"&slut="&sluttraff&"&start="&starttraff&"&total="&adoRS.recordcount&""">Föregående sida</a> I "
Else
response.write "<span class=""vanligtextGra"">Föregående sida</span> | "
End If
If pg <> FIX((adoRS.recordcount / sidStorlek))+1 Then
response.write "<a href=""http://"&TRIM(request.servervariables("HTTP_HOST") & request.servervariables("SCRIPT_NAME"))&"?sokord="&sSearchString&"&pg="&(pg+1)&"&slut="&sluttraff&"&start="&starttraff&"&total="&adoRS.recordcount&""">Nästa sida</a></td>"
Else
response.write "<span class=""vanligtextGra"">Nästa sida</span>"
End If
response.write "</tr>" &_
"</table>"
End If
End If
adoRS.close
set adoRS = Nothing
End if