Avatar billede borupborup Nybegynder
25. oktober 2002 - 23:58 Der er 8 kommentarer og
1 løsning

Er der noget der har mod på denne her?

Jeg har fundet en ganske fin søge maskine til egen site på nettet. Den virker fint. Men jeg ville grne have at den ikke viser sites som ikke har nogen beskrivelse eller titel.

Er nogen der har mod på denne her?

/Thomas


Here goes:

<% 'Option Explicit %>
<%

Response.Buffer = True

Dim fsoObject           
Dim fldObject               
Dim sarySearchWord       
Dim strSearchWords       
Dim blnIsRoot           
Dim strFileURL   
Dim strServerPath       
Dim intNumFilesShown       
Dim intTotalFilesSearched   
Dim intTotalFilesFound       
Dim intFileNum       
Dim intPageLinkLoopCounter   
Dim sarySearchResults(1000,2)
Dim intDisplayResultsLoopCounter
Dim intResultsArrayPosition   
Dim blnSearchResultsFound   
Dim strFilesTypesToSearch   
Dim strBarredFolders       
Dim strBarredFiles
Dim blnEnglishLanguage       


Const intRecordsPerPage = 8 'change this to the number of results to show on each page

strFilesTypesToSearch = "htm,html,asp,shtml,aspx"

strBarredFolders = "cgi_bin,_bin" 'cgi_bin and _bin have been put in here as examples, but you can put any folders in here

strBarredFiles = "adminstation.htm,no_allowed.asp,admin.asp" 'adminstration.htm and not_allowed.asp have been put in as an examples

blnEnglishLanguage = True 'True = HTML Encode best for English sites \ False = no Emcoding best for non English sites

intTotalFilesSearched = 0

%>
<html>
<head>
</style>
</head>
<body bgcolor="#FFFFFF">
<form method="get" name="frmSiteSearch" action="search.asp">
  <table cellpadding="0" cellspacing="0" width="90%" align="center">
    <tr>
      <td class="normal" height="2" width="571">
        <b><font size="1">Søg på min site:  </font></b>
        <input name="search" maxlength="50" size="36" value="<% =Request.QueryString("search") %>" class="box" style="font-family: Verdana; font-size: 10px; font-weight:bold">
        <input type="submit" value="Find" name="submit" class="box">
      </td>
    </tr>
    <tr>
      <td class="normal" height="34" width="571" valign="top"><font size="1">Specifik
        s&oslash;gning </font>:
        <input type="radio" name="mode" value="anywords" CHECKED></font><font size="1">Nogle af ordene
        <input type="radio" name="mode" value="allwords">
        Alle ord
        <input type="radio" name="mode" value="phrase">
        S&aelig;tningen </font></td>
    </tr>
  </table>
</form>


<%


strSearchWords = Trim(Request.QueryString("search"))


If blnEnglishLanguage = True Then
    strSearchWords = Server.HTMLEncode(strSearchWords)

Else
    'Just replace the script tag <> with HTML encoded &lt; and &gt;
    strSearchWords = Replace(strSearchWords, "<", "&lt;", 1, -1, 1)
    strSearchWords = Replace(strSearchWords, ">", "&gt;", 1, -1, 1)
End If

sarySearchWord = Split(Trim(strSearchWords), " ")



intFileNum = CInt(Request.QueryString("FileNumPosition"))

intNumFilesShown = intFileNum

Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")

If NOT strSearchWords = "" Then

    Set fldObject = fsoObject.GetFolder(Server.MapPath("./"))
   
    strServerPath = fldObject.Path & "\"
   
    blnIsRoot = True
       
    Call SearchFile(fldObject)           
   
    Set fsoObject = Nothing
    Set fldObject = Nothing   
   
   
    Call SortResultsByNumMatches(sarySearchResults, intTotalFilesFound)
       
   
    Response.Write vbCrLf & "    <table width=""98%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"" bgcolor=""#e7e3db"">"
    Response.Write vbCrLf & "       <tr>"
   
    If blnSearchResultsFound = False Then
        Response.Write vbCrLf & "         <td>&nbsp;Søgte på sider efter <b>" & strSearchWords & "</b>. &nbsp;&nbsp;&nbsp;Desvære der var ingen resultater.</font></td>" 
   
    Else   
        Response.Write vbCrLf & "         <td>&nbsp;Søgte på sider efter <b>" & strSearchWords & "</b>. &nbsp;&nbsp;&nbsp;Viser resultater " & intFileNum + 1 & " - " & intNumFilesShown & " af " & intTotalFilesFound & ".</font></td>"       
    End If
   
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"
       
   
    Response.Write vbCrLf & "    <table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"">"
    Response.Write vbCrLf & "    <tr>"
    Response.Write vbCrLf & "      <td>" 
   
    If blnSearchResultsFound = False Then
   
        Response.Write vbCrLf & "      <br>"
        Response.Write vbCrLf & "      <a>Dit søgeord var - <b>" & strSearchWords & "</b> - Der var desvære ingen resultat/resultater af søgningen.</font>"
          Response.Write vbCrLf & "      <br><br>"
          Response.Write vbCrLf & "      <a><b>Muligheder:</b></font>"
          Response.Write vbCrLf & "      <br>"
          Response.Write vbCrLf & "      <a><ul><li>Har du stavet det rigtigt?<li>Prøv uden special tegn.<li>Prøv med et andet keyword.<li>Prøv med fære keywords.</ul></font>"
   
    Else
       
        For intDisplayResultsLoopCounter = (intFileNum + 1) to intNumFilesShown
       
            Response.Write vbCrLf & "        <br>"
            Response.Write vbCrLf & "        " & sarySearchResults(intDisplayResultsLoopCounter,1)
            Response.Write vbCrLf & "        <br>"
        Next
    End If
   
    Response.Write vbCrLf & "        </td>"
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"

End If


If intTotalFilesFound > intRecordsPerPage then
    Response.Write vbCrLf & "    <br>"
    Response.Write vbCrLf & "    <table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">"
    Response.Write vbCrLf & "       <tr>"
    Response.Write vbCrLf & "         <td>"
    Response.Write vbCrLf & "        <table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
    Response.Write vbCrLf & "          <tr>"
    Response.Write vbCrLf & "            <td width=""50%"" align=""center"">"
    Response.Write vbCrLf & "        <a>Antal sider med valgte søgning:&nbsp;&nbsp;</font>"
    If intNumFilesShown > intRecordsPerPage Then
        Response.Write vbCrLf & "        <a><a href=""search.asp?FileNumPosition=" &  intFileNum - intRecordsPerPage  & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self""><b>&lt;&lt; Sidste</b></a></font> "             
    End If       
    If intTotalFilesFound > intRecordsPerPage Then
        For intPageLinkLoopCounter = 1 to CInt((intTotalFilesFound / intRecordsPerPage) + 0.5)
            If intFileNum = (intPageLinkLoopCounter * intRecordsPerPage) - intRecordsPerPage Then
                Response.Write vbCrLf & "            <font size=1 color=#CC3300><b>" & intPageLinkLoopCounter & "</b></font>"
            Else
                Response.Write vbCrLf & "            &nbsp;<font size=1><a href=""search.asp?FileNumPosition=" &  (intPageLinkLoopCounter * intRecordsPerPage) - intRecordsPerPage & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self"">" & intPageLinkLoopCounter & "</a></font>&nbsp; "           
            End If
        Next
    End If
    If intTotalFilesFound > intNumFilesShown then     
        Response.Write vbCrLf & "        &nbsp;<a><a href=""search.asp?FileNumPosition=" &  intNumFilesShown  & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self""><b>Næste &gt;&gt;</b></a></font>"         
    End If         
   
    Response.Write vbCrLf & "            </td>"         
    Response.Write vbCrLf & "          </tr>"
    Response.Write vbCrLf & "        </table>"       
    Response.Write vbCrLf & "        </td>"
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"
   

End If

%>
<br>
<div align="center"> 
  <table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
    <tr>
       
      <td width="47%" height="18">&nbsp;</td>
        <td width="53%" align="right" height="18"><br>
      </td>
      </tr>
    </table>

</div>
</body>
</html>
<%



Public Sub SearchFile(fldObject)

    Dim objRegExp               
    Dim objMatches   
    Dim filObject
    Dim tsObject               
    Dim subFldObject           
    Dim strFileContents       
    Dim strPageTitle           
    Dim strPageDescription       
    Dim strPageKeywords           
    Dim intSearchLoopCounter       
    Dim intNumMatches           
    Dim blnSearchFound               
   
    On Error Resume Next
   
    Err.Number = 0
                 
    Set objRegExp = New RegExp
                 
    If Err.Number <> 0 Then
        Response.Write("<br>FEJL! Serveren understøtter ikke extension<br>")
                   
        Err.Number = 0
    End If
       
    For Each filObject in fldObject.Files
       
               
        If InStr(1, strFilesTypesToSearch, fsoObject.GetExtensionName(filObject.Name), vbTextCompare) > 0 Then
   
              If NOT InStr(1, strBarredFiles, filObject.Name, vbTextCompare) > 0 Then             
             
              blnSearchFound = False
                 
                  intNumMatches = 0             
                 
                      objRegExp.Global = True
                 
                  objRegExp.IgnoreCase = True
                 
                                   
             
                  Set tsObject = filObject.OpenAsTextStream
           
                strFileContents = tsObject.ReadAll       
       
                strPageTitle = GetFileMetaTag("<title>", "</title>", strFileContents)
                       
                strPageDescription = GetFileMetaTag("<meta name=""description"" content=""", """>", strFileContents)
               
                strPageKeywords = GetFileMetaTag("<meta name=""keywords"" content=""", """>", strFileContents)
                           
               
               
                objRegExp.Pattern = "<[^>]*>"
               
                strFileContents = objRegExp.Replace(strFileContents,"")
                   
                strFileContents = strFileContents & " " & strPageTitle & " " & strPageDescription & " " & strPageKeywords
               
           
                               
                If Request.QueryString("mode") = "phrase" Then
                   
                    objRegExp.Pattern = "\b" & strSearchWords & "\b"
                   
                    Set objMatches = objRegExp.Execute(strFileContents)
                   
                    If objMatches.Count > 0 Then
                   
                        intNumMatches = objMatches.Count
                   
                        blnSearchFound = True
                    End If
               
               
                Else
                           
                    If Request.QueryString("mode") = "allwords" then blnSearchFound = True
                   
                   
                    For intSearchLoopCounter = 0 to UBound(sarySearchWord)
                   
                        objRegExp.Pattern = "\b" & sarySearchWord(intSearchLoopCounter) & "\b"
                       
                        Set objMatches = objRegExp.Execute(strFileContents)
                               
                            If objMatches.Count > 0 Then
                           
                                    intNumMatches = intNumMatches + objMatches.Count
                       
                                If Request.QueryString("mode") = "anywords" then blnSearchFound = True
                               
                            Else
                                If Request.QueryString("mode") = "allwords" then blnSearchFound = False
                               
                            End If
                        Next
                    End If
                                       
                   
                intTotalFilesSearched = intTotalFilesSearched + 1
           
           
                   
                If strPageTitle = "" Then strPageTitle = "<b>Siden har ingen titel!</b>"
                   
                If strPageDescription = "" Then strPageDescription = "Der er ikke lavet en beskrivelse af denne side.</font>"
                   
                If blnSearchFound = True Then
                                   
                                                       
                    intTotalFilesFound = intTotalFilesFound + 1
                                       
                    If  intNumFilesShown < (intRecordsPerPage + intFileNum) and intTotalFilesFound > intNumFilesShown Then
   
                        intNumFilesShown = intNumFilesShown + 1
                       
                    End If   
                             
                      intResultsArrayPosition = intResultsArrayPosition + 1
                               
                      blnSearchResultsFound = True
                                                       
                    If blnIsRoot = True Then
                       
                        sarySearchResults(intResultsArrayPosition,1) = "<a href=""./" &  filObject.Name & """ target=""_self"">" & "<b>" & strPageTitle &  "</b></a>"
                                                                         
                              Else
                              sarySearchResults(intResultsArrayPosition,1) = "<a href=""./" & strFileURL  & fldObject.Name & "/" & filObject.Name & """ target=""_self"">" & "<b>" & strPageTitle & "</b></a>"                                                           
                       
                    End If
                   
                       
                   
                    sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & "        <font size=1><br>" & strPageDescription & "</font>"
                    sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & "        <font size=""1"" color=""#808080""><br>Søgningen machede " & intNumMatches & " &nbsp;-&nbsp; Sidst opdateret " & FormatDateTime(filObject.DateLastModified, VbLongDate) & " &nbsp;-&nbsp; Side størelse " & CInt(filObject.Size / 1024) & "kb</font><font size=1 color=#000000>"
                   
                    sarySearchResults(intResultsArrayPosition,2) = intNumMatches
                                   
                      End If
                           
                    tsObject.Close
            End If
        End If
    Next
   
    Set objRegExp = Nothing
    For Each subFldObject In FldObject.SubFolders
   
    If NOT InStr(1, strBarredFolders, subFldObject.Name, vbTextCompare) > 0 Then
            blnIsRoot = False
            strFileURL = fldObject.Path & "\"
            strFileURL = Replace(strFileURL, strServerPath, "")
            strFileURL = Replace(strFileURL, "\", "/")
            strFileURL = Server.URLEncode(strFileURL)
            strFileURL = Replace(strFileURL, "%2F", "/")
            Call SearchFile(subFldObject)
        End If
    Next

    Set filObject = Nothing
    Set tsObject = Nothing
    Set subFldObject = Nothing
End Sub

Private Sub SortResultsByNumMatches(ByRef sarySearchResults, ByRef intTotalFilesFound)

    Dim intArrayGap         'Holds the part of the array being sorted
    Dim intIndexPosition        'Holds the Array index position being sorted
    Dim intTempResultsHold        'Temperary hold for the results if they need swapping array positions       
    Dim intTempNumMatchesHold    'Temperary hold for the number of matches for the result if they need swapping array positions
    Dim intPassNumber        'Holds the pass number for the sort
   
    For intPassNumber = 1 To intTotalFilesFound
   
        For intIndexPosition = 1 To (intTotalFilesFound - intPassNumber)
       
            If sarySearchResults(intIndexPosition,2) < sarySearchResults((intIndexPosition+1),2) Then
               
                intTempResultsHold = sarySearchResults(intIndexPosition,1)
                intTempNumMatchesHold = sarySearchResults(intIndexPosition,2)
                sarySearchResults(intIndexPosition,1) = sarySearchResults((intIndexPosition+1),1)
                sarySearchResults(intIndexPosition,2) = sarySearchResults((intIndexPosition+1),2)
                sarySearchResults((intIndexPosition+1),1) = intTempResultsHold
                sarySearchResults((intIndexPosition+1),2) = intTempNumMatchesHold           
            End If
        Next           
    Next                   
End Sub

Private Function GetFileMetaTag(ByRef strStartValue, ByRef strEndValue, ByVal strFileContents)

    Dim intStartPositionInFile    'Holds the start position in the file
    Dim intEndPositionInFile    'Holds the end position in the file
   
   
    intStartPositionInFile = InStr(1, LCase(strFileContents), strStartValue, 1)
   
   
    If intStartPositionInFile = 0 And InStr(strStartValue, "name=") Then
       
        strStartValue = Replace(strStartValue, "name=", "http-equiv=")
       
        intStartPositionInFile = InStr(1, LCase(strFileContents), strStartValue, 1)       
    End If
   
                       
    If NOT intStartPositionInFile = 0 Then
                   
        intStartPositionInFile = intStartPositionInFile + Len(strStartValue)
                       
        intEndPositionInFile = InStr(intStartPositionInFile, LCase(strFileContents), strEndValue, 1)
   
        GetFileMetaTag = Trim(Mid(strFileContents, intStartPositionInFile, (intEndPositionInFile - intStartPositionInFile)))
                   
    Else
        GetFileMetaTag = ""
                     
    End If

End Function
%>
Avatar billede doctor6000 Nybegynder
26. oktober 2002 - 00:07 #1
føj den er lang nej tak
Avatar billede borupborup Nybegynder
26. oktober 2002 - 00:10 #2
JA, jeg ved det godt. Men prøv scriptet engang. det faktsik ret smart lavet.

Det er bare lidt belastende at den finde filer som man måske ikke ønsker fundet.

Scriptet sortere filer uden titel og beskrivelse (meta), jeg kan bare ikke se hvordan jeg gør så den ikke viser dem.
Avatar billede learnie Nybegynder
26. oktober 2002 - 10:52 #3
Hvorfor angiver du ikke bare de filer/mapper der ikke må vises i variablerne strBarredFiles/strBarredFolders?
Avatar billede larsen Nybegynder
26. oktober 2002 - 14:13 #4
Prøv lige denne :

<% 'Option Explicit %>
<%

Response.Buffer = True

Dim fsoObject           
Dim fldObject               
Dim sarySearchWord       
Dim strSearchWords       
Dim blnIsRoot           
Dim strFileURL   
Dim strServerPath       
Dim intNumFilesShown       
Dim intTotalFilesSearched   
Dim intTotalFilesFound       
Dim intFileNum       
Dim intPageLinkLoopCounter   
Dim sarySearchResults(1000,2)
Dim intDisplayResultsLoopCounter
Dim intResultsArrayPosition   
Dim blnSearchResultsFound   
Dim strFilesTypesToSearch   
Dim strBarredFolders       
Dim strBarredFiles
Dim blnEnglishLanguage       


Const intRecordsPerPage = 8 'change this to the number of results to show on each page

strFilesTypesToSearch = "htm,html,asp,shtml,aspx"

strBarredFolders = "cgi_bin,_bin" 'cgi_bin and _bin have been put in here as examples, but you can put any folders in here

strBarredFiles = "adminstation.htm,no_allowed.asp,admin.asp" 'adminstration.htm and not_allowed.asp have been put in as an examples

blnEnglishLanguage = True 'True = HTML Encode best for English sites \ False = no Emcoding best for non English sites

intTotalFilesSearched = 0

%>
<html>
<head>
</style>
<META NAME="Generator" CONTENT="Stone's WebWriter 3.5">
</head>
<body bgcolor="#FFFFFF">
<form method="get" name="frmSiteSearch" action="Sog2.asp">
  <table cellpadding="0" cellspacing="0" width="90%" align="center">
    <tr>
      <td class="normal" height="2" width="571">
        <b><font size="1">Søg på min site:  </font></b>
        <input name="search" maxlength="50" size="36" value="<% =Request.QueryString("search") %>" class="box" style="font-family: Verdana; font-size: 10px; font-weight:bold">
        <input type="submit" value="Find" name="submit" class="box">
      </td>
    </tr>
    <tr>
      <td class="normal" height="34" width="571" valign="top"><font size="1">Specifik
        s&oslash;gning </font>:
        <input type="radio" name="mode" value="anywords" CHECKED></font><font size="1">Nogle af ordene
        <input type="radio" name="mode" value="allwords">
        Alle ord
        <input type="radio" name="mode" value="phrase">
        S&aelig;tningen </font></td>
    </tr>
  </table>
</form>


<%


strSearchWords = Trim(Request.QueryString("search"))


If blnEnglishLanguage = True Then
    strSearchWords = Server.HTMLEncode(strSearchWords)

Else
    'Just replace the script tag <> with HTML encoded &lt; and &gt;
    strSearchWords = Replace(strSearchWords, "<", "&lt;", 1, -1, 1)
    strSearchWords = Replace(strSearchWords, ">", "&gt;", 1, -1, 1)
End If

sarySearchWord = Split(Trim(strSearchWords), " ")



intFileNum = CInt(Request.QueryString("FileNumPosition"))

intNumFilesShown = intFileNum

Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")

If NOT strSearchWords = "" Then

    Set fldObject = fsoObject.GetFolder(Server.MapPath("./"))
   
    strServerPath = fldObject.Path & "\"
   
    blnIsRoot = True
       
    Call SearchFile(fldObject)           
   
    Set fsoObject = Nothing
    Set fldObject = Nothing   
   
   
    Call SortResultsByNumMatches(sarySearchResults, intTotalFilesFound)
       
   
    Response.Write vbCrLf & "    <table width=""98%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"" bgcolor=""#e7e3db"">"
    Response.Write vbCrLf & "      <tr>"
   
    If blnSearchResultsFound = False Then
        Response.Write vbCrLf & "        <td>&nbsp;Søgte på sider efter <b>" & strSearchWords & "</b>. &nbsp;&nbsp;&nbsp;Desvære der var ingen resultater.</font></td>" 
   
    Else   
        Response.Write vbCrLf & "        <td>&nbsp;Søgte på sider efter <b>" & strSearchWords & "</b>. &nbsp;&nbsp;&nbsp;Viser resultater " & intFileNum + 1 & " - " & intNumFilesShown & " af " & intTotalFilesFound & ".</font></td>"       
    End If
   
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"
       
   
    Response.Write vbCrLf & "    <table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"">"
    Response.Write vbCrLf & "    <tr>"
    Response.Write vbCrLf & "      <td>" 
   
    If blnSearchResultsFound = False Then
   
        Response.Write vbCrLf & "      <br>"
        Response.Write vbCrLf & "      <a>Dit søgeord var - <b>" & strSearchWords & "</b> - Der var desvære ingen resultat/resultater af søgningen.</font>"
          Response.Write vbCrLf & "      <br><br>"
          Response.Write vbCrLf & "      <a><b>Muligheder:</b></font>"
          Response.Write vbCrLf & "      <br>"
          Response.Write vbCrLf & "      <a><ul><li>Har du stavet det rigtigt?<li>Prøv uden special tegn.<li>Prøv med et andet keyword.<li>Prøv med fære keywords.</ul></font>"
   
    Else
       
        For intDisplayResultsLoopCounter = (intFileNum + 1) to intNumFilesShown
       
            Response.Write vbCrLf & "        <br>"
            Response.Write vbCrLf & "        " & sarySearchResults(intDisplayResultsLoopCounter,1)
            Response.Write vbCrLf & "        <br>"
        Next
    End If
   
    Response.Write vbCrLf & "        </td>"
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"

End If


If intTotalFilesFound > intRecordsPerPage then
    Response.Write vbCrLf & "    <br>"
    Response.Write vbCrLf & "    <table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">"
    Response.Write vbCrLf & "      <tr>"
    Response.Write vbCrLf & "        <td>"
    Response.Write vbCrLf & "        <table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
    Response.Write vbCrLf & "          <tr>"
    Response.Write vbCrLf & "            <td width=""50%"" align=""center"">"
    Response.Write vbCrLf & "        <a>Antal sider med valgte søgning:&nbsp;&nbsp;</font>"
    If intNumFilesShown > intRecordsPerPage Then
        Response.Write vbCrLf & "        <a><a href=""search.asp?FileNumPosition=" &  intFileNum - intRecordsPerPage  & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=" & Request.QueryString("mode") & " target=""_self""><b>&lt;&lt; Sidste</b></a></font> "             
    End If       
    If intTotalFilesFound > intRecordsPerPage Then
        For intPageLinkLoopCounter = 1 to CInt((intTotalFilesFound / intRecordsPerPage) + 0.5)
            If intFileNum = (intPageLinkLoopCounter * intRecordsPerPage) - intRecordsPerPage Then
                Response.Write vbCrLf & "            <font size=1 color=#CC3300><b>" & intPageLinkLoopCounter & "</b></font>"
            Else
                Response.Write vbCrLf & "            &nbsp;<font size=1><a href=""search.asp?FileNumPosition=" &  (intPageLinkLoopCounter * intRecordsPerPage) - intRecordsPerPage & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=" & Request.QueryString("mode") & " target=""_self"">" & intPageLinkLoopCounter & "</a></font>&nbsp; "           
            End If
        Next
    End If
    If intTotalFilesFound > intNumFilesShown then     
        Response.Write vbCrLf & "        &nbsp;<a><a href=""search.asp?FileNumPosition=" &  intNumFilesShown  & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=" & Request.QueryString("mode") & " target=""_self""><b>Næste &gt;&gt;</b></a></font>"         
    End If         
   
    Response.Write vbCrLf & "            </td>"         
    Response.Write vbCrLf & "          </tr>"
    Response.Write vbCrLf & "        </table>"       
    Response.Write vbCrLf & "        </td>"
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"
   

End If

%>
<br>
<div align="center"> 
  <table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
    <tr>
       
      <td width="47%" height="18">&nbsp;</td>
        <td width="53%" align="right" height="18"><br>
      </td>
      </tr>
    </table>

</div>
</body>
</html>
<%



Public Sub SearchFile(fldObject)

    Dim objRegExp               
    Dim objMatches   
    Dim filObject
    Dim tsObject               
    Dim subFldObject           
    Dim strFileContents       
    Dim strPageTitle           
    Dim strPageDescription       
    Dim strPageKeywords           
    Dim intSearchLoopCounter       
    Dim intNumMatches           
    Dim blnSearchFound               
   
    On Error Resume Next
   
    Err.Number = 0
                 
    Set objRegExp = New RegExp
                 
    If Err.Number <> 0 Then
        Response.Write("<br>FEJL! Serveren understøtter ikke extension<br>")
                   
        Err.Number = 0
    End If
       
    For Each filObject in fldObject.Files
       
               
        If InStr(1, strFilesTypesToSearch, fsoObject.GetExtensionName(filObject.Name), vbTextCompare) > 0 Then
   
              If NOT InStr(1, strBarredFiles, filObject.Name, vbTextCompare) > 0 Then             
             
              blnSearchFound = False
                 
                  intNumMatches = 0             
                 
                      objRegExp.Global = True
                 
                  objRegExp.IgnoreCase = True
                 
                                   
             
                  Set tsObject = filObject.OpenAsTextStream
           
                strFileContents = tsObject.ReadAll       
       
                strPageTitle = GetFileMetaTag("<title>", "</title>", strFileContents)
                       
                strPageDescription = GetFileMetaTag("<meta name=""description"" content=""", """>", strFileContents)
'----- Egen linie
                If strPageTitle<>"" or strPageDescription<>"" then
'----- Slut egen linie
                strPageKeywords = GetFileMetaTag("<meta name=""keywords"" content=""", """>", strFileContents)
                           
               
               
                objRegExp.Pattern = "<[^>]*>"
               
                strFileContents = objRegExp.Replace(strFileContents,"")
                   
                strFileContents = strFileContents & " " & strPageTitle & " " & strPageDescription & " " & strPageKeywords
               
           
                               
                If Request.QueryString("mode") = "phrase" Then
                   
                    objRegExp.Pattern = "\b" & strSearchWords & "\b"
                   
                    Set objMatches = objRegExp.Execute(strFileContents)
                   
                    If objMatches.Count > 0 Then
                   
                        intNumMatches = objMatches.Count
                   
                        blnSearchFound = True
                    End If
               
               
                Else
                           
                    If Request.QueryString("mode") = "allwords" then blnSearchFound = True
                   
                   
                    For intSearchLoopCounter = 0 to UBound(sarySearchWord)
                   
                        objRegExp.Pattern = "\b" & sarySearchWord(intSearchLoopCounter) & "\b"
                       
                        Set objMatches = objRegExp.Execute(strFileContents)
                               
                            If objMatches.Count > 0 Then
                           
                                    intNumMatches = intNumMatches + objMatches.Count
                       
                                If Request.QueryString("mode") = "anywords" then blnSearchFound = True
                               
                            Else
                                If Request.QueryString("mode") = "allwords" then blnSearchFound = False
                               
                            End If
                        Next
                    End If
                                       
                   
                intTotalFilesSearched = intTotalFilesSearched + 1
           
           
                   
                If strPageTitle = "" Then strPageTitle = "<b>Siden har ingen titel!</b>"
                   
                If strPageDescription = "" Then strPageDescription = "Der er ikke lavet en beskrivelse af denne side.</font>"
                   
                If blnSearchFound = True Then
                                   
                                                       
                    intTotalFilesFound = intTotalFilesFound + 1
                                       
                    If  intNumFilesShown < (intRecordsPerPage + intFileNum) and intTotalFilesFound > intNumFilesShown Then
   
                        intNumFilesShown = intNumFilesShown + 1
                       
                    End If   
                             
                      intResultsArrayPosition = intResultsArrayPosition + 1
                               
                      blnSearchResultsFound = True
                                                       
                    If blnIsRoot = True Then
                       
                        sarySearchResults(intResultsArrayPosition,1) = "<a href=""./" &  filObject.Name & " target=""_self"">" & "<b>" & strPageTitle &  "</b></a>"
                                                                         
                              Else
                              sarySearchResults(intResultsArrayPosition,1) = "<a href=""./" & strFileURL  & fldObject.Name & "/" & filObject.Name & " target=""_self"">" & "<b>" & strPageTitle & "</b></a>"                                                           
                       
                    End If
                   
                       
                   
                    sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & "        <font size=1><br>" & strPageDescription & "</font>"
                    sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & "        <font size=""1"" color=""#808080""><br>Søgningen machede " & intNumMatches & " &nbsp;-&nbsp; Sidst opdateret " & FormatDateTime(filObject.DateLastModified, VbLongDate) & " &nbsp;-&nbsp; Side størelse " & CInt(filObject.Size / 1024) & "kb</font><font size=1 color=#000000>"
                   
                    sarySearchResults(intResultsArrayPosition,2) = intNumMatches
                                   
                      End If
                           
                    tsObject.Close
            End If
'----- Egen linie
End If
'----- Slut egen linie
        End If
    Next
   
    Set objRegExp = Nothing
    For Each subFldObject In FldObject.SubFolders
   
    If NOT InStr(1, strBarredFolders, subFldObject.Name, vbTextCompare) > 0 Then
            blnIsRoot = False
            strFileURL = fldObject.Path & "\"
            strFileURL = Replace(strFileURL, strServerPath, "")
            strFileURL = Replace(strFileURL, "\", "/")
            strFileURL = Server.URLEncode(strFileURL)
            strFileURL = Replace(strFileURL, "%2F", "/")
            Call SearchFile(subFldObject)
        End If
    Next

    Set filObject = Nothing
    Set tsObject = Nothing
    Set subFldObject = Nothing
End Sub

Private Sub SortResultsByNumMatches(ByRef sarySearchResults, ByRef intTotalFilesFound)

    Dim intArrayGap        'Holds the part of the array being sorted
    Dim intIndexPosition        'Holds the Array index position being sorted
    Dim intTempResultsHold        'Temperary hold for the results if they need swapping array positions       
    Dim intTempNumMatchesHold    'Temperary hold for the number of matches for the result if they need swapping array positions
    Dim intPassNumber        'Holds the pass number for the sort
   
    For intPassNumber = 1 To intTotalFilesFound
   
        For intIndexPosition = 1 To (intTotalFilesFound - intPassNumber)
       
            If sarySearchResults(intIndexPosition,2) < sarySearchResults((intIndexPosition+1),2) Then
               
                intTempResultsHold = sarySearchResults(intIndexPosition,1)
                intTempNumMatchesHold = sarySearchResults(intIndexPosition,2)
                sarySearchResults(intIndexPosition,1) = sarySearchResults((intIndexPosition+1),1)
                sarySearchResults(intIndexPosition,2) = sarySearchResults((intIndexPosition+1),2)
                sarySearchResults((intIndexPosition+1),1) = intTempResultsHold
                sarySearchResults((intIndexPosition+1),2) = intTempNumMatchesHold           
            End If
        Next           
    Next                   
End Sub

Private Function GetFileMetaTag(ByRef strStartValue, ByRef strEndValue, ByVal strFileContents)

    Dim intStartPositionInFile    'Holds the start position in the file
    Dim intEndPositionInFile    'Holds the end position in the file
   
   
    intStartPositionInFile = InStr(1, LCase(strFileContents), strStartValue, 1)
   
   
    If intStartPositionInFile = 0 And InStr(strStartValue, "name=") Then
       
        strStartValue = Replace(strStartValue, "name=", "http-equiv=")
       
        intStartPositionInFile = InStr(1, LCase(strFileContents), strStartValue, 1)       
    End If
   
                       
    If NOT intStartPositionInFile = 0 Then
                   
        intStartPositionInFile = intStartPositionInFile + Len(strStartValue)
                       
        intEndPositionInFile = InStr(intStartPositionInFile, LCase(strFileContents), strEndValue, 1)
   
        GetFileMetaTag = Trim(Mid(strFileContents, intStartPositionInFile, (intEndPositionInFile - intStartPositionInFile)))
                   
    Else
        GetFileMetaTag = ""
                     
    End If

End Function
%>
Avatar billede larsen Nybegynder
26. oktober 2002 - 14:14 #5
Den udskriver kun de filer der har en titel ELLER en beskrivelse
Avatar billede jsc Nybegynder
26. oktober 2002 - 16:47 #6
kunne man få lov til at få et link på den søgemaskine???

/jsc
Avatar billede borupborup Nybegynder
26. oktober 2002 - 19:04 #7
Genialt.
Der er godt nok et lille problem med linket på de fundne sider. når man trykker på det, finder den ikke siden, men det retter jeg selv.

Tusind tak for hjælpen.

Link: http://activedeveloper.dk/download/default.asp?mode=showdownload&id=457
Avatar billede larsen Nybegynder
26. oktober 2002 - 20:35 #8
Det var så lidt :-)
Avatar billede jsc Nybegynder
26. oktober 2002 - 23:26 #9
tak for det .. :D
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester



Seneste spørgsmål Seneste aktivitet
I går 23:37 Poe strøm Af lurup i LAN/WAN
I går 14:46 GIF-EDITOR Af snestrup2000 i Billedbehandling
I går 14:03 Logge ind Af Bob i PC
I går 12:12 2 skærme - 1 virker - den anden siger No signal Af eksmojo i Skærme
I går 10:33 openvpn projekt Af dcedata1977 i Windows