Avatar billede goldhammer Nybegynder
03. oktober 2003 - 02:09 Der er 4 kommentarer og
1 løsning

Programmere søgemaskine om

Er der nogen der vil påtage sig opgaven med at lave denne søgemaskine om til PHP+MYSQL, og hvad skal det koste ???

http://www.n-dating.dk/novoseek/default.asp
Avatar billede goldhammer Nybegynder
03. oktober 2003 - 02:10 #1
jeg poster lige default.asp så i kan se hvad det drejer sig om -->>

<% Option Explicit %>
<!--#include file="common.inc" -->
<%
Response.Buffer = True

'Dimension variables
Dim rsSearchResults         'database Recordset Variable
Dim intRecordPositionPageNum     'Holds the record position
Dim intRecordLoopCounter     'Loop counter for displaying the database records
Dim lngTotalRecordsFound     'Holds the total number of records in the database
Dim lngTotalNumPages         'holds the total number of pages in the database
Dim intLinkPageNum         'Holds the page number to be linked to
Dim intLoopCounter        'Holds the loop counter number
Dim sarySearchWord        'Holds the keywords for the URL
Dim strSearchKeywords        'Holds the keywords to be searched
Dim intSQLLoopCounter        'Loop counter for the loop for the sql query
Dim intSearchWordLength        'Holds the length of the word to be searched
Dim blnSearchWordLenthOK    'Boolean set to false if the search word length is not OK
Dim intRecordDisplayFrom    'Holds the number of the search result that the page is displayed from
Dim intRecordDisplayedTo    'Holds the number of the search result that the page is displayed to


'If this is the first time the page is displayed then the page position is set to page 1
If Request.QueryString("PagePosition") = "" Then
    intRecordPositionPageNum = 1

'Else the page has been displayed before so the page postion is set to the Record Position number
Else
    intRecordPositionPageNum = CInt(Request.QueryString("PagePosition"))
End If   


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

'If the use has not entered a value then let the search words variable contain a space (chr10)
If strSearchKeywords = "" Then strSearchKeywords = chr(10)

'Replace any less than or greater than signs with the HTML equivalent (stops people entering HTML tags)
strSearchKeywords = Replace(strSearchKeywords, "<", "&lt;")
strSearchKeywords = Replace(strSearchKeywords, ">", "&gt;")
strSearchKeywords = Replace(strSearchKeywords, "'", "''")

'Read in the search words to be searched
sarySearchWord = Split(Trim(strSearchKeywords), " ")

'Return the tow '' back to one' for displaying on the screen
strSearchKeywords = Replace(strSearchKeywords, "''", "'")


'Initalise the word search length variable
blnSearchWordLenthOK = True

'Loop round to check that each word to be searched has more than the minimum word length to be searched
For intLoopCounter = 0 To UBound(sarySearchWord)
   
    'Initialise the intSearchWordLength variable with the length of the word to be searched
    intSearchWordLength = Len(sarySearchWord(intLoopCounter))
   
    'If the word length to be searched is less than or equal to min word length then set the blnWordLegthOK to false
    If intSearchWordLength <= intMinuiumSearchWordLength Then
        blnSearchWordLenthOK = False       
    End If
Next


'Create a recordset object
Set rsSearchResults = Server.CreateObject("ADODB.Recordset")

   
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblWebsites.* FROM tblWebsites "
       
'Get the mode to decide how we are going to buid the SQL Query
Select Case Request.QueryString("mode")

    'If the user has selected to search any words then intalise the strSQL statement to search for any words in the database
    Case "anywords"

        'Search for the first search word in the URL titles
        strSQL = strSQL & "WHERE Title LIKE '%" & sarySearchWord(0) & "%'"
   
        'Loop to search for each search word entered by the user
        For intSQLLoopCounter = 0 To UBound(sarySearchWord)
            strSQL = strSQL & " OR Title LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
            strSQL = strSQL & " OR Keywords LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
            strSQL = strSQL & " OR Description LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
        Next
       
        'Order the search results by the number of click through hits decending (most popular sites first)
        strSQL = strSQL & " ORDER By Rating DESC, No_of_ratings DESC, Hits DESC;"


    'If the user has selected to search for all words then intalise the strSQL statement to search for entries containing all the search words
    Case "allwords"
   
        'Search for the first word in the URL titles
        strSQL = strSQL & "WHERE (Title LIKE '%" & sarySearchWord(0) & "%'"
       
        'Loop to search the URL titles for each word to be searched
        For intSQLLoopCounter = 1 To UBound(sarySearchWord)
            strSQL = strSQL & " AND Title LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
        Next
       
        'OR if the search words are in the keywords   
        strSQL = strSQL & ") OR (Keywords LIKE '%" & sarySearchWord(0) & "%'"
       
        'Loop to search the URL keywords for each word to be searched
        For intSQLLoopCounter = 1 To UBound(sarySearchWord)
            strSQL = strSQL & " AND Keywords LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
        Next
       
        'Or if the search words are in the title   
        strSQL = strSQL & ") OR (Description LIKE '%" & sarySearchWord(0) & "%'"
       
        'Loop to search the URL description for each word to be searched
        For intSQLLoopCounter = 1 To UBound(sarySearchWord)
            strSQL = strSQL & " AND Description LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
        Next
       
        'Order the search results by the number of click through hits decending (most popular sites first)
        strSQL = strSQL & ") ORDER By Rating DESC, No_of_ratings DESC, Hits DESC;"


    'If the user has selected to see newly enetred URL's then order the search results by date decending
    Case "new"
        'Initalise the strSQL variable with an SQL statement to query the database
        strSQL = "SELECT TOP " & intRecordsPerPage & " tblWebsites.* FROM tblWebsites"
        strSQL = strSQL & " ORDER By SiteIDNo DESC;"
End Select

'Query the database with the strSQL statement
rsSearchResults.Open strSQL, strCon, 3

'Count the number of records found
lngTotalRecordsFound = CLng(rsSearchResults.RecordCount)   

'If this is a random URL then strip all the other URL's and only leave one remaining URL
If Request.QueryString("submit") = "Random Search" and NOT rsSearchResults.EOF Then
   
    'Randomise system timer
    Randomize Timer
   
    'Move to a random record in the recordset
    rsSearchResults.Move CLng(RND * lngTotalRecordsFound) - 0.5

    'Filter out all the other records
    rsSearchResults.Filter = "SiteIDNo =" & rsSearchResults("SiteIDNO")

Else
    'Set the number of records to display on each page by the constant set at the top of the script
    rsSearchResults.PageSize = intRecordsPerPage
   
    'Get the page number record poistion to display from
    IF NOT rsSearchResults.EOF Then rsSearchResults.AbsolutePage = intRecordPositionPageNum
   
    'Count the number of pages the search results will be displayed on calculated by the PageSize attribute set above
    lngTotalNumPages = CLng(rsSearchResults.PageCount)
   
   
    'Calculate the the record number displayed from and to on the page showing
    intRecordDisplayFrom = (intRecordPositionPageNum - 1) * intRecordsPerPage + 1
    intRecordDisplayedTo = (intRecordPositionPageNum - 1) * intRecordsPerPage + intRecordsPerPage
    If intRecordDisplayedTo > lngTotalRecordsFound Then intRecordDisplayedTo = lngTotalRecordsFound

End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
Avanceret Meta Tag Generator 2003
Udvikling: webmaster (http://www.move2.dk)
Instructioner: Kopier og indsæt dine koder i mellem <HEAD> og </HEAD> i dit HTML document. God fornøjelse!

<META NAME="Title" CONTENT="Ren dansk søgemaskine, ikke andet - pure danish searchengine, nothing all">
<!-- Novoseek -->
<META NAME="Subject" CONTENT="søgemaskine, searchengine">
<META NAME="Description" CONTENT="Søgemaskine, Searchengine">
<META NAME="Keywords" CONTENT="søgemaskine, søge, amskine, keywords, websites, searchengine, search, engine, keywords, websites">
<META NAME="Language" CONTENT="DA">
<META NAME="Copyright" CONTENT="© Michael Guldhammer">
<META NAME="Designer" CONTENT="Michael Guldhammer">
<META NAME="Publisher" CONTENT="Novoseek">
<META NAME="Revisit-After" CONTENT="7 Days">
<META NAME="Distribution" CONTENT="Global">
<META NAME="Robots" CONTENT="All">

    <TITLE><!-- #include file="include_titel.asp" --></TITLE>
<!-- Check the from is filled in correctly before submitting -->
<SCRIPT  language="JavaScript">
<!-- Hide from older browsers...
//Check the enquiry form is filled in correctly
function CheckForm () {
       
    //If there is aproblem with the form then display an error
    if (document.frmInterSearch.search.value == "") {
        msg = "_________________________________________________________________\n\n";
        msg += "din søgninger ikke blevet foretaget fordi der ikke er blevet udfyldt korrekt\n";
        msg += "vær venlig at skrive et nyt søgeord.\n";
        msg += "_________________________________________________________________\n\n";
        msg += "\n\vær venlig at indtast et søgeord."
       
        alert(msg + "\n\n");
       
        return false;
    }
   
    return true;
}

//Function to open pop up window
function openWin(theURL,winName,features) {
      window.open(theURL,winName,'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=350,height=310');
}
// -->
</script>
<meta name="generator" content="Novoseek.dk - Admin">
</HEAD>
<BODY bgColor=#ffffff text=#000000 link=#000099 vLink=#000099>
<CENTER>
<TABLE cellSpacing=0 cellPadding=0 width=700 border=0>
                <TR>
    <!-- #include file="include_top.asp" -->
      </TR>
            </TABLE><BR>
<form method="get" name="frmInterSearch" action="default.asp" onSubmit="return CheckForm();">
  <table cellpadding="0" cellspacing="0" width="514" align="center" height="85">
    <tr>
      <td height="85" width="95" align="right" rowspan="3">
      </td>
      <td height="85" width="4" align="right" rowspan="3"> </td>
      <td class="text" height="31" width="409" valign="bottom"><font face="verdana" size="1"><b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        Søg:</b></font></td>
    </tr>
    <tr>
      <td class="normal" height="25" width="409">
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input name="search" maxlength="50" size="35" value="<% =Request.QueryString("search") %>"><input type="submit" value="Søg" name="submit">
        </td>
    </tr>
    <tr>
      <td class="text" height="29" width="409" valign="top"><font face="verdana" size="1"> &nbsp;&nbsp;&nbsp;&nbsp;
        Søg på :</font>
        <input type="radio" name="mode" value="allwords" CHECKED><font face="verdana" size="1">Alle ord</font>
        <input type="radio" name="mode" value="anywords"><font face="verdana" size="1">flere ord</font>
</td>
    </tr>
  </table>
<BR>
<TABLE cellSpacing=0 cellPadding=4 width=700 bgColor=#dddddd border=0>
 
  <TR>
        <TD><FONT face=Verdana,Arial,Geneva size=1><B>Velkommen til Novoseek.dk</B></FONT></TD>
      </TR></TABLE><BR>
<table cellSpacing=0 cellPadding=0 width=700 border=0>
 
  <TR>
        <TD valign=top width=100%> <table border=0 width=100% cellpadding=1 cellspacing=1>

<font face=Verdana,Arial,Geneva size=1>
<%
If NOT Request.QueryString("mode") = "" Then
    '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=""0"" cellpadding=""1"" align=""center"" bgcolor=""" & strTableBorderColour & """>"
    Response.Write vbCrLf & "      <tr>"
    Response.Write vbCrLf & "     <td>"
    Response.Write vbCrLf & "    <table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""2"" align=""center"" bgcolor=""" & strTableColour & """>"
    Response.Write vbCrLf & "       <tr>"
   
    'Display that the URL is randomly generated   
    If Request.QueryString("submit") = "Random Search" Then
        Response.Write vbCrLf & "         <td  class=""text""> Random Search for <span class=""bold"">" & strSearchKeywords & "</span>.</td>"
       
    'Display that we are showing a page of the latest URL's indexed
    ElseIf Request.QueryString("mode") = "new" Then
        Response.Write vbCrLf & "         <td class=""text""> De " & intRecordsPerPage & " sidste tilmelde sider...</td>" 
       
    'Display that one of the words entered was to short
    ElseIf    blnSearchWordLenthOK = False Then
        Response.Write vbCrLf & "         <td class=""text""> Du søgte efter <b>" & strSearchKeywords & "</b> &nbsp;et af orderne du søgte på var for korte.</td>" 
   
    'Display that there where no matching records found
    ElseIf rsSearchResults.EOF Then
        Response.Write vbCrLf & "         <td class=""text""> Din søgning på nettet efter <b>" & strSearchKeywords & "</b> fandt desværre intet.</td>" 
   
    'Else Search went OK so display how many records found
    Else   
        Response.Write vbCrLf & " <td class=""text"">Din søgning på nettet efter <b>" & strSearchKeywords & "</b> Viser " & intRecordDisplayFrom & " - " & intRecordDisplayedTo & " af " & lngTotalRecordsFound & " sider.</td>"       
    End If
           
    'Close the HTML table with the search status
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"
    Response.Write vbCrLf & "    </td>"
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"


    'Display the various results
   
    'HTML table to display the search results or an error if there are no results
    Response.Write vbCrLf & "    <br>" & vbCrLf
    Response.Write vbCrLf & "    <table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"">"
    Response.Write vbCrLf & "    <tr>"
    Response.Write vbCrLf & "      <td class=""text"">" 
   
    'Display error message if one of the words is to short
    If blnSearchWordLenthOK = False And NOT Request.QueryString("mode") = "new" Then
   
        'Write HTML displaying the error
        Response.Write vbCrLf & "      Din søgning på - <span class=""bold"">" & strSearchKeywords & "</span> - Indeholder et ord med " & intMinuiumSearchWordLength & " bogstav eller mindre din søgning var for kort."
          Response.Write vbCrLf & "      <br><br>"
          Response.Write vbCrLf & "      Forslag:"
          Response.Write vbCrLf & "      <br>"
          Response.Write vbCrLf & "      <ul><li>Prøv et længere søgeord.<li>Vær sikker på at alle ord er stavet rigtigt.<li>Prøv forskellige søgeord.<li>Prøv mere generelle søgeord.</ul>"
         
    'If no search results found then show an error message
    ElseIf rsSearchResults.EOF Then
   
        'Write HTML displaying the error
        Response.Write vbCrLf & "      Din søgnig på - <b>" & strSearchKeywords & "</b> - machede intet i vores database."
          Response.Write vbCrLf & "      <br><br>"
          Response.Write vbCrLf & "      Forslag:"
          Response.Write vbCrLf & "      <br>"
          Response.Write vbCrLf & "      <ul><li>Vær sikker på at alle ord er stavet rigtigt.<li>Prøv forskellige søgeord.<li>Prøv mere gennerelle søgeord.<li>Prøv med mindre søgeord.</ul>"
         
    Else
        'For....Next Loop to display the results from the database
        For intRecordLoopCounter = 1 to intRecordsPerPage
       
            'If there are no records left to display then exit loop
            If rsSearchResults.EOF Then Exit For                   
                 
                  'Display the details of the URLs found       
              Response.Write vbCrLf & "      <a href=""get_url.asp?SiteID=" & CInt(rsSearchResults("SiteIDNo")) & """ target=""_blank"">" & rsSearchResults("Title") & "</a>"
              Response.Write vbCrLf & "      <br>"
              Response.Write vbCrLf & "      " & rsSearchResults("Description")
              Response.Write vbCrLf & "      <br>"
              Response.Write vbCrLf & "      <span class=""italic""><img src=""images/" & CInt(rsSearchResults("Rating")) & "_star_rating.gif"" width=""66"" height=""14"" alt=""" & CInt(rsSearchResults("Rating")) & " star rating""> Baseret på " & CLng(rsSearchResults("No_of_ratings")) & " stemmer&nbsp;&nbsp;-&nbsp;&nbsp;<a href=""java script:openWin('rate_link.asp?SiteID=" & rsSearchResults("SiteIDNo") & "','rate_site')"" style=""font-size:" & intTextSize-1 & "; font-style: italic;"">Stem på siden</a>&nbsp;&nbsp;-&nbsp;&nbsp;Hits&nbsp;" & CInt(rsSearchResults("Hits")) & "&nbsp;&nbsp;-&nbsp;&nbsp;" & Replace(rsSearchResults("URL"), "http://", "") & "</span>"
              Response.Write vbCrLf & "      <br><br>"
         
            'Move to the next record in the database
            rsSearchResults.MoveNext
       
        'Loop back round     
        Next
    End If
   
    'Close the HTML table displaying the results
    Response.Write vbCrLf & "        </td>"
    Response.Write vbCrLf & "      </tr>"
    Response.Write vbCrLf & "    </table>"
   
   
   
    'If there are more pages to display then add a title to the other pages
    If intRecordPositionPageNum > 1 OR NOT rsSearchResults.EOF AND blnSearchWordLenthOK = True Then
   
        'Display an HTML table with links to the other search results
        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""  class=""text"">"
       
        'If there are more pages to display then add a title to the other pages
        If intRecordPositionPageNum > 1 or NOT rsSearchResults.EOF Then
            Response.Write vbCrLf & "        Results Page:&nbsp;&nbsp;"
        End If
       
        'If the page number is higher than page 1 then display a back link       
        If intRecordPositionPageNum > 1 Then
            Response.Write vbCrLf & "        <a href=""default.asp?PagePosition=" &  intRecordPositionPageNum - 1  & "&search=" & Server.URLEncode(strSearchKeywords) & "&mode=" & Request.QueryString("mode") &""" target=""_self"">&lt;&lt;&nbsp;Prev</a>&nbsp; "             
        End If       
       
       
        'If there are more pages to display then display links to all the search results pages
        If intRecordPositionPageNum > 1 or NOT rsSearchResults.EOF Then
           
            'Loop to diplay a hyper-link to each page in the search results       
            For intLinkPageNum = 1 to lngTotalNumPages       
               
                'If the page to be linked to is the page displayed then don't make it a hyper-link
                If intLinkPageNum = intRecordPositionPageNum Then
                    Response.Write vbCrLf & "            " & intLinkPageNum
                Else
               
                    Response.Write vbCrLf & "            &nbsp;<a href=""default.asp?PagePosition=" &  intLinkPageNum  & "&search=" & Server.URLEncode(strSearchKeywords) & "&mode=" & Request.QueryString("mode") & """ target=""_self"">" & intLinkPageNum & "</a>&nbsp; "           
                End If
            Next
        End If
       
       
        'If it is Not the End of the search results than display a next link       
        If NOT rsSearchResults.EOF then     
            Response.Write vbCrLf & "        &nbsp;<a href=""default.asp?PagePosition=" &  intRecordPositionPageNum + 1  & "&search=" & Server.URLEncode(strSearchKeywords) & "&mode=" & Request.QueryString("mode") & """ target=""_self"">Næste&nbsp;&gt;&gt;</a>"         
        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>"
        Response.Write vbCrLf & "    <br>"
   
    End If
End If


'Close Server Objects
Set rsSearchResults = Nothing
Set strCon = Nothing
Set adoCon = Nothing
%>
</font>

      </TR></TABLE><BR>
<table cellSpacing=0 cellPadding=4 width=700 border=0>
 
  <TR>
  <!-- #include file="include_bund.asp" -->
  </TR>
</TABLE></CENTER>

</BODY>
</HTML>
Avatar billede locturian Nybegynder
03. oktober 2003 - 11:32 #2
Eh, nu taler jeg kun for mig selv her, men er du skudt? 200 point for at oversætte al den kode til et andet sprog? Held og lykke siger jeg bare...
Avatar billede goldhammer Nybegynder
03. oktober 2003 - 12:38 #3
Nej nej, det var bare for at "modtage/kommentere" mit spørgsmål.
Jeg er selvfølgelig villig til at betale for at får det lavet *S*
Sorry, det er min fejl at jeg ikke fik skrevet at jeg ville betale for det *S*
Gi, et bud på en pris *S*
Avatar billede goldhammer Nybegynder
04. oktober 2003 - 17:25 #4
Tak for de dejlige svar *SS*
Avatar billede goldhammer Nybegynder
04. oktober 2003 - 17:26 #5
Lukker
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
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

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