Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15

Discussione: cerca nel sito

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    272

    cerca nel sito

    Ciao a tutti, sto usando uno script in asp scaricato da internet che crea un modulo: Cerca nel sito , dopo aver apportato le dovute modifiche (per lo più di grafica) per le mie necessità, ho notato che avendo usato gli include e un'unica pagina di default che richiama le altre, lo script mi cerca le pagine in maniera corretta, ma le visualizza senza includere la default.asp necessaria per una corretta visualizzazione della pagina.

    Il link a riguardo dovrebbe essere questo:

    http://<div class=""testosmall"">&#91;im... & "</b></div>

    Le pagine del mio sito vengono chiamate nel seguente modo:

    default.asp?sez=azienda (include/azienda.asp)
    default.asp?sez=contatti (include/contatti.asp)

    etc.etc.
    Posso risolvere il problema? Scusate, spero di essermi spiegata chiaramente.

  2. #2
    Scusami ma non ho capito il problema...

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    272
    Hai ragione, rileggendo mi sono accorta di non essere stata chiara.
    Allora, ho creato il sito con un'unica pagina di default e le altre si trovano in un'altra cartella: include.
    Di conseguenza richiamo le pagine così:
    <%
    Dim sez
    sez= Request.QueryString("sez")
    if sez= "azienda" Then%>

    etc.etc.

    il link è: default.asp?sez=azienda

    Se io cerco una parola che si trova nella pagina azienda.asp con lo script scaricato , me la trova correttamente, ma il link va a: include/azienda.asp invece che default.asp?sez=azienda, quindi la pagina si visualizza male.

    Spero di essermi fatta capire

  4. #4
    Perfetto!

    Posta il codice...

  5. #5
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    272
    Avrei voluto scrivere solo la parte riguardante il link, ma non ci capisco un gran chè. Il codice è molto lungo:


    <%

    'Read in all the search words into one variable
    strSearchWords = Trim(Request.QueryString("search"))

    'If the site is in English then use the server HTML encode method
    If blnEnglishLanguage = True Then
    'Replace any HTML tags with the HTML codes for the same characters (stops people entering HTML tags)
    strSearchWords = Server.HTMLEncode(strSearchWords)

    'If the site is not english just change the script tags
    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

    'Slit each word to be searched up and place in an array
    sarySearchWord = Split(Trim(strSearchWords), " ")



    'Read the file number to show from
    intFileNum = CInt(Request.QueryString("FileNumPosition"))

    'Set the number of files shown so far to the file number read in above
    intNumFilesShown = intFileNum


    'Create the file system object
    Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")


    'If there is no words entered by the user to search for then dont carryout the file search routine
    If NOT strSearchWords = "" Then


    'Get the path and the root folder to be searched
    Set fldObject = fsoObject.GetFolder(Server.MapPath("./"))

    'Read in the server path to this ASP script
    strServerPath = fldObject.Path & "\"

    'Set to true as this is searching the root directory
    blnIsRoot = True

    'Call the search sub prcedure
    Call SearchFile(fldObject)

    'Reset server variables
    Set fsoObject = Nothing
    Set fldObject = Nothing


    'Call the Bubble Sort procedure to sort the results into highest matches first
    Call SortResultsByNumMatches(sarySearchResults, intTotalFilesFound)


    'Display the HTML table with the results status of the search or what type of search it is
    Response.Write vbCrLf & " <table width=""98%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"" bgcolor=""#ededed"">"
    Response.Write vbCrLf & " <tr>"

    'Display that there where no matching records found
    If blnSearchResultsFound = False Then
    Response.Write vbCrLf & " <td><div class=""testosmall"">Risultato per: " & strSearchWords & ". Spiacente, nessun risultato trovato.</div></td>"

    'Else Search went OK so display how many records found
    Else
    Response.Write vbCrLf & " <td><div class=""testosmall"">Risultato per: " & strSearchWords & ". Visualizzazione dei risultati " & intFileNum + 1 & " - " & intNumFilesShown & " su " & intTotalFilesFound & ".</div></td>"
    End If

    'Close the HTML table with the search status
    Response.Write vbCrLf & " </tr>"
    Response.Write vbCrLf & " </table>"


    'HTML table to display the search results or an error if there are no results
    Response.Write vbCrLf & " <table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"">"
    Response.Write vbCrLf & " <tr>"
    Response.Write vbCrLf & " <td>"

    'If no results are found then display an error message
    If blnSearchResultsFound = False Then

    'Write HTML displaying the error
    Response.Write vbCrLf & "
    "
    Response.Write vbCrLf & " <div class=""testosmall"">La ricerca - " & strSearchWords & " - non ha trovato alcun risultato."
    Response.Write vbCrLf & "

    "
    Response.Write vbCrLf & " Suggerimenti:"
    Response.Write vbCrLf & "
    "
    Response.Write vbCrLf & " <ul>[*]Assicurarsi che tutte le parole siano scritte correttamente.[*]Fare una nuova ricerca.[/list]</div>"

    'Else display the results
    Else

    'Loop round to display each result within the search results array
    For intDisplayResultsLoopCounter = (intFileNum + 1) to intNumFilesShown

    Response.Write vbCrLf & "
    "
    Response.Write vbCrLf & " " & sarySearchResults(intDisplayResultsLoopCounter,1)
    Response.Write vbCrLf & "
    "
    Next
    End If

    'Close the HTML table displaying the results
    Response.Write vbCrLf & " </td>"
    Response.Write vbCrLf & " </tr>"
    Response.Write vbCrLf & " </table>"

    End If


    'Display an HTML table with links to the other search results
    If intTotalFilesFound > intRecordsPerPage then

    'Display an HTML table with links to the other search results
    Response.Write vbCrLf & "
    "
    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 & " <div class=""testosmall"">Pagine trovate:</div>"


    'If the page number is higher than page 1 then display a back link
    If intNumFilesShown > intRecordsPerPage Then
    Response.Write vbCrLf & " <div class=""testosmall"">&lt;&lt;Indietro</div> "
    End If


    'If there are more pages to display then display links to all the search results pages
    If intTotalFilesFound > intRecordsPerPage Then

    'Loop to diplay a hyper-link to each page in the search results
    For intPageLinkLoopCounter = 1 to CInt((intTotalFilesFound / intRecordsPerPage) + 0.5)

    'If the page to be linked to is the page displayed then don't make it a hyper-link
    If intFileNum = (intPageLinkLoopCounter * intRecordsPerPage) - intRecordsPerPage Then
    Response.Write vbCrLf & " <div class=""testosmall""> " & intPageLinkLoopCounter&"</div>"
    Else

    Response.Write vbCrLf & " http://<div class=""testosmall"">" &...nter & "</div> "
    End If
    Next
    End If


    'If it is Not the last of the search results than display a next link
    If intTotalFilesFound > intNumFilesShown then
    Response.Write vbCrLf & " <div class=""testosmall"">Avanti&gt;&gt;</div>"
    End If


    'Finsh HTML the table
    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

    %>

  6. #6
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    272

  7. #7
    non ho capito dov'è il problema...
    IP-PBX management: http://www.easypbx.it

    Old account: 2126 messages
    Oldest account: 3559 messages

  8. #8
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    272
    Da ieri sto provando a risolvere il problema, non ci sono ancora riuscita, ho cercato di spiegarlo a lukeonweb, ma non è stato facile....

    però potrebbe essermi utile se mi sapessi dire come faccio con la funzione Instr a ricavare la prima parte di una stringa fino al punto.
    (praticamente la stringa è il nome di un file [mezzi.asp], io ho bisogno di ricavare solo mezzi)
    Puoi aiutarmi?

  9. #9
    ma è sempre ".asp" la fine?

    se si basta fare
    codice:
    varPulita=replace(varSporca,".asp","")
    altrimenti
    codice:
    varPulita=left(varSporca,len(varSporca)-instrrev(varSporca,"."))
    se non erro
    IP-PBX management: http://www.easypbx.it

    Old account: 2126 messages
    Oldest account: 3559 messages

  10. #10
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    272
    MMMMMHHHHH......
    sono più confusa di prima.
    Il codice della pagina è il seguente:

    For Each filObject in fldObject.Files


    'Check the file extension to make sure the file is of the extension type to be searched
    If InStr(1, strFilesTypesToSearch, fsoObject.GetExtensionName(filObject.Name), vbTextCompare) > 0 Then

    'Check to make sure the file about to be searched is not a barred file if it is don't search the file
    If NOT InStr(1, strBarredFiles, filObject.Name, vbTextCompare) > 0 Then
    'Initalise the search found variable to flase
    blnSearchFound = True

    'Initalise the number of matches variable
    intNumMatches = 0

    'Set the regular exprsion object to read all cases of the occurance not just the first
    objRegExp.Global = True

    'Set the regular expression object to ignore case
    objRegExp.IgnoreCase = True



    'Open the file for searching
    Set tsObject = filObject.OpenAsTextStream

    'Read in the contents of the file
    strFileContents = tsObject.ReadAll

    'Read in the title of the file
    strPageTitle = GetFileMetaTag("<title>", "</title>", strFileContents)

    'Read in the description meta tag of the file
    strPageDescription = GetFileMetaTag("<meta name=""description"" content=""", """>", strFileContents)

    'Read in the keywords of the file
    strPageKeywords = GetFileMetaTag("<meta name=""keywords"" content=""", """>", strFileContents)



    'Set the pattern using regular expressions to srip any HTML tags
    objRegExp.Pattern = "<[^>]*>"

    'Strip HTML tags from the contects of the file to be searched
    strFileContents = objRegExp.Replace(strFileContents,"")

    'Put the tittle, description and the keywords back into the file to be searched
    strFileContents = strFileContents & " " & strPageTitle & " " & strPageDescription & " " & strPageKeywords



    'If the user has choosen to search by phrase
    If Request.QueryString("mode") = "phrase" Then

    'Set the pattern to search for
    objRegExp.Pattern = "\b" & strSearchWords & "\b"

    'Search the file for the phrase
    Set objMatches = objRegExp.Execute(strFileContents)

    'Check to see if the phrase has been found
    If objMatches.Count > 0 Then

    'Get the number of times the phrase is matched
    intNumMatches = objMatches.Count

    'If the search is found then set the search found variable to true
    blnSearchFound = True
    End If


    'Else the search is either by all or any words
    Else

    'If the search is by all words then initialise the search found variable to true
    If Request.QueryString("mode") = "allwords" then blnSearchFound = True


    'Loop round to search for each word to be searched
    For intSearchLoopCounter = 0 to UBound(sarySearchWord)

    'Set the pattern to search for
    objRegExp.Pattern = "\b" & sarySearchWord(intSearchLoopCounter) & "\b"

    'Search the file for the search words
    Set objMatches = objRegExp.Execute(strFileContents)

    'Check to see if any of the words have been found
    If objMatches.Count > 0 Then

    'Get the number of times the search word is matched
    intNumMatches = intNumMatches + objMatches.Count

    'If the search word is found and the search is for any words then set the search found variable to true
    If Request.QueryString("mode") = "anywords" then blnSearchFound = True

    Else
    'If the search word is not found and the search is for all words then set the search found variable back to false as one of the words has not been found
    If Request.QueryString("mode") = "allwords" then blnSearchFound = False

    End If
    Next
    End If


    'Calculate the total files searched
    intTotalFilesSearched = intTotalFilesSearched + 1



    'If the page contains no title then Page Title variable the appropriate message to display
    If strPageTitle = "" Then strPageTitle = "La pagina trovata non ha titolo. Clicca per il risultato."

    If strPageTitle = "Untitled Document" Then strPageTitle= "La pagina trovata non ha titolo. Clicca per il risultato."

    'If the page contains no title then Page Description variable the appropriate message to display
    If strPageDescription = "" Then strPageDescription = ""



    'If the search found variable is true then display the results
    If blnSearchFound = True Then


    'Calculate the total files found
    intTotalFilesFound = intTotalFilesFound + 1


    'Check that the file shown is between the the files shown so far and the maximum files to show per page
    If intNumFilesShown < (intRecordsPerPage + intFileNum) and intTotalFilesFound > intNumFilesShown Then

    'Calculate the number of results shown
    intNumFilesShown = intNumFilesShown + 1

    End If



    'Place the search results into the saerch results array
    'Calculate the array position of the results array
    intResultsArrayPosition = intResultsArrayPosition + 1


    'Set the search results found boolean to true
    blnSearchResultsFound = True

    'If the file is in the root directory then
    If blnIsRoot = True Then


    'Place the search results into the search results array
    sarySearchResults(intResultsArrayPosition,1) = "http://<div class=""testosmall"">&#91;im... & "</b></div>"


    'Else it is not in the root directiory
    Else
    'Place the search results into the search results array
    sarySearchResults(intResultsArrayPosition,1) = "http://<div class=""testosmall"">&#91;im... & "</b></div>"

    End If

    'Place the rest of the search results in the search results array
    sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & "
    <div class=""testosmall"">" & strPageDescription &"</DIV>"
    sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & " <font family=""Verdana"" size=""1"" color=""#999999"" > Ultima modifica " & FormatDateTime(filObject.DateLastModified, VbLongDate) & " - Peso " & CInt(filObject.Size / 1024) & "kb</font>"



    'Read in the number of search word matches into the second part of the two dimensional array
    sarySearchResults(intResultsArrayPosition,2) = intNumMatches

    End If

    'Close the text stream object
    tsObject.Close
    End If
    End If
    Next


    Il link sottolineato è il link che mi dà il problema, perchè mi restituisce:
    //localhost/miosito/default2.asp?sez=mezzi.asp
    mentre deve restituirmi
    //localhost/miosito/default2.asp?sez=mezzi

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.