Buscar na internet

Busca

  Adicionar Url       Novas Urls         Escolher Urls aleatoriamente
Busca na web   Página de busca:
">
Procurar por: Todas as palavras Qualquer uma das palavras
<% 'Dimension variables Dim adoCon 'Database Connection Variable Dim adoRec 'database Recordset Variable Dim strAccessDB 'Holds the Access Database Name Dim strSQL 'Database query sring Dim intRecordPositionPageNum 'Holds the record position Dim intRecordLoopCounter 'Loop counter for displaying the database records Dim intTotalRecordsFound 'Holds the total number of records in the database Dim intTotalNumPages 'holds the total number of pages in the database Dim intLinkPageNum 'Holds the page number to be linked to Dim strSearchKeywords 'Holds the keywords input by the user to be searched for Dim strTitle 'Holds the URL Title Dim strURL 'Holds the URL Dim strDescription 'Holds the description of the URL Dim sarySearchWord 'Holds the keywords for the URL 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 intRecordDisplayTo 'Holds the number of the search result that the page is displayed to Dim intRandomRecordNumber 'Holds a random number used to display a random URL 'Declare constants ' Change the following line to the number of entries you wish to have on each page and miniumum word length Const intRecordsPerPage = 10 'Change this number to the amount of entries to be displayed on each page Const intMinuiumSesrchWordLength = 2 'Change this to the minimum word length to be searched on 'Error handler On error resume next '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 the search words to be searched sarySearchWord = Split(Trim(Request.QueryString("search")), " ") 'Read in all the search words into one variable strSearchKeywords = Trim(Request.QueryString("search")) 'Replace any less than or greater than signs with the HTML equivalent (stops people entering HTML tags) strSearchKeywords = Replace(strSearchKeywords, "<", "<") 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 <= intMinuiumSesrchWordLength Then blnSearchWordLenthOK = False End If Next 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT * FROM tblWebsites " 'If the user has selected to search any words then intalise the strSQL statement to search for any words in the database If Request.QueryString("mode") = "anywords" The '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) & "%'" Nex End If 'If the user has selected to search for all words then intalise the strSQL statement to search for entries containing all the search words If Request.QueryString("mode") = "allwords" Then '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 End If 'If the user has selected to see newly enetred URL's then order the search results by date decending If Request.QueryString("mode") = "new" Then 'Order the search results by the date entered into the database decending strSQL = strSQL & " ORDER By Date_Entered DESC" 'Else order the serch results by the number of click through hits decending Else 'Order the search results by the number of click through hits decending (most popular sites first) strSQL = strSQL & " ORDER By Hits DESC" End If 'Initialise the strAccessDB variable with the name of the Access Database strAccessDB = "search_engine" 'Create a connection odject Set adoCon = Server.CreateObject("ADODB.Connection") Set adoRec = Server.CreateObject("ADODB.Recordset") 'Open connection to the database driver strCon = "DRIVER={Microsoft Access Driver (*.mdb)};" 'Open Connection to database strCon = strCon & "DBQ=" & server.mappath(strAccessDB) 'Query the database with the strSQL statement adoRec.Open strSQL, strCon, 3 'Set the number of records to display on each page by the constant set at the top of the script adoRec.PageSize = intRecordsPerPage 'Get the page number record poistion to display from adoRec.AbsolutePage = intRecordPositionPageNum 'Count the number of records found intTotalRecordsFound = CInt(adoRec.RecordCount) 'Count the number of pages the search results will be displayed on calculated by the PageSize attribute set above intTotalNumPages = CInt(adoRec.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 > intTotalRecordsFound Then intRecordDisplayedTo = intTotalRecordsFound 'Display the HTML table with the results status of the search or what type of search it is Response.Write vbCrLf & " " Response.Write vbCrLf & " " 'Display that the URL is randomly generated If Request.QueryString("mode") = "random" Then Response.Write vbCrLf & " " 'Display that we are showing a page of the latest URL's indexed ElseIf Request.QueryString("mode") = "new" Then Response.Write vbCrLf & " " 'Display that one of the words entered was to short ElseIf blnSearchWordLenthOK = False Then Response.Write vbCrLf & " " 'Display that there where no matching records found ElseIf adoRec.EOF Then Response.Write vbCrLf & " " 'Else Search went OK so display how many records found Else Response.Write vbCrLf & " " End If 'Close the HTML table with the search status Response.Write vbCrLf & " " Response.Write vbCrLf & "
Random URL. The " & intRecordsPerPage & " latest URL's Indexed. Searched the web for " & strSearchKeywords & ".    One of the words searched is to short. Searched the web for " & strSearchKeywords & ".    Sorry, no results found. Searched the web for " & strSearchKeywords & ".    Displaying Results " & intRecordDisplayFrom & " - " & intRecordDisplayedTo & " of " & intTotalRecordsFound & ".
" 'Display the various results 'HTML table to display the search results or an error if there are no results Response.Write vbCrLf & "
" & vbCrLf Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & "
" 'Display a random URL If Request.QueryString("mode") = "random" Then 'Randomise system timer Randomize Timer 'Get a random number between 0 and highest number of records in database intRandomRecordNumber = Int(RND * intTotalRecordsFound) 'Move to the choosen random record in the database adoRec.Move intRandomRecordNumber 'Read in the values form the database intSiteIDNo = CInt(adoRec("SiteIDNo")) strTitle = adoRec("Title") strURL = adoRec("URL") strDescription = adoRec("Description") intSiteHits = CInt(adoRec("Hits")) 'Display the randon URL details Response.Write vbCrLf & " " & strTitle & "" Response.Write vbCrLf & "
" Response.Write vbCrLf & " " & strDescription Response.Write vbCrLf & "
" Response.Write vbCrLf & " " & strURL & "  -  Hits " & intSiteHits & "" Response.Write vbCrLf & "

" 'Display error message if one of the words is to short ElseIf blnSearchWordLenthOK = False And NOT Request.QueryString("mode") = "new" Then 'Write HTML displaying the error Response.Write vbCrLf & " Your Search - " & strSearchKeywords & " - Contained a word with " & intMinuiumSesrchWordLength & " letters or less, this is to short to search." Response.Write vbCrLf & "

" Response.Write vbCrLf & " Suggestions:" Response.Write vbCrLf & "
" Response.Write vbCrLf & "
  • Try longer keywords.
  • Make sure all words are spelled correctly.
  • Try different keywords.
  • Try more general keywords.
" 'If no search results found then show an error message ElseIf adoRec.EOF Then 'Write HTML displaying the error Response.Write vbCrLf & " Your Search - " & strSearchKeywords & " - did not match any documents." Response.Write vbCrLf & "

" Response.Write vbCrLf & " Suggestions:" Response.Write vbCrLf & "
" Response.Write vbCrLf & "
  • Make sure all words are spelled correctly.
  • Try different keywords.
  • Try more general keywords.
  • Try fewer keywords.
" 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 adoRec.EOF Then Exit For 'Read in the values form the database intSiteIDNo = CInt(adoRec("SiteIDNo")) strTitle = adoRec("Title") strURL = adoRec("URL") strDescription = adoRec("Description") intSiteHits = CInt(adoRec("Hits")) 'Display the details of the URLs found Response.Write vbCrLf & " " & strTitle & "" Response.Write vbCrLf & "
" Response.Write vbCrLf & " " & strDescription Response.Write vbCrLf & "
" Response.Write vbCrLf & " " & strURL & "  -  Hits " & intSiteHits & "" Response.Write vbCrLf & "

" 'Move to the next record in the database adoRec.MoveNext 'Loop back round Next End If 'Close the HTML table displaying the results Response.Write vbCrLf & "
" 'Display an HTML table with links to the other search results if not showing latest 10, a random URL, or not under min word length If NOT Request.QueryString("mode") = "new" And NOT Request.QueryString("mode") = "random" And blnSearchWordLenthOK = True Then 'Display an HTML table with links to the other search results Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & "
" Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & "
" 'If there are more pages to display then add a title to the other pages If intRecordPositionPageNum > 1 or NOT adoRec.EOF Then Response.Write vbCrLf & " Results Page:  " End If 'If the page number is higher than page 1 then display a back link If intRecordPositionPageNum > 1 Then Response.Write vbCrLf & " << Prev  " End If 'If there are more pages to display then display links to all the search results pages If intRecordPositionPageNum > 1 or NOT adoRec.EOF Then 'Loop to diplay a hyper-link to each page in the search results For intLinkPageNum = 1 to intTotalNumPages '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 & "  " & intLinkPageNum & "  " End If Next End If 'If it is Not the End of the search results than display a next link If NOT adoRec.EOF then Response.Write vbCrLf & "  Next >>" End If 'Finsh HTML the table Response.Write vbCrLf & "
" Response.Write vbCrLf & "
" Response.Write vbCrLf & "
" End If 'Close Server Objects Set adoCon = Nothing Set adoCmd = Nothing %>
  Adicionar URL       Novas Urls         Procurar aleatoriamente