Administração

Administração

   Novas Urls      Retornar ao inicio do sistema
Procurar por: ">
<% 'Dimension variables Dim adoCon 'Database Connection Variable Dim adoRec 'database Recordset Variable Dim strCon 'Holds the Database driver and the path and name of the database 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 saryInputSearchKeywords 'Array to hold the keywords input by the user to be searched Dim intDatabaseRecordNumber 'Holds the database record number 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 '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 = '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")), " ") '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 'Else the word length is more than the miniumum word length so set the blnWordLegthOK to True Else blnSearchWordLenthOK = True End If Next 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT * FROM tblWebsites " '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 '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 we are showing a page of the latest URL's indexed If 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 & "
The " & intRecordsPerPage & " latest URL's Indexed. Searched the database for " & Request.QueryString("search") & ".    One of the words searched is to short. Searched the database for " & Request.QueryString("search") & ".    Sorry, no records found. Searched the database for " & Request.QueryString("search") & ".    Displaying Records " & 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 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 & " Your Search - " & Request.QueryString("search") & " - 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 & " Sua busca- " & Request.QueryString("search") & " - resultou em muitos resultados." Response.Write vbCrLf & "

" Response.Write vbCrLf & " Sugestões" Response.Write vbCrLf & "
" Response.Write vbCrLf & "
  • Refaça a busca com menos palavras.
  • tente palavras diferentes
  • tente especificar mais o tema.
  • tente urls.
" 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 strTitle = adoRec("Title") strURL = adoRec("URL") intDatabaseRecordNumber = adoRec("SiteIDNo") strDescription = adoRec("Description") 'Display the details of the URLs found Response.Write vbCrLf & " Check box to delete entry" Response.Write vbCrLf & "
" Response.Write vbCrLf & " " & strTitle & "" Response.Write vbCrLf & "
" Response.Write vbCrLf & " " & strDescription Response.Write vbCrLf & "
" Response.Write vbCrLf & " " & strURL & "" 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, or not under min word length If NOT Request.QueryString("mode") = "new" 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 'If there are records displayed then display a delete button at the bottom of the page If intTotalRecordsFound > 0 Then Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & " " Response.Write vbCrLf & "
Check Box to delete entries" Response.Write vbCrLf & " " Response.Write vbCrLf & "
" End If 'Close Server Objects Set adoCon = Nothing Set adoCmd = Nothing %>
   Novas Urls      Voltar a pagina inicial do sistema