|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Search index
Hi, I have never used VBS before but my site is in a whole heep now.
We have a script that indexs all the files on the server and stores them in a database. I recently changed the way the site works with a simple template system and now nothing gets indexed. this is part of the basic script as it stands right now, not working. Code:
For Each ItemFile In objFolder.Files
If Right(ItemFile.Name, 4) = ".asp" Then
Set objFile = objFso.OpenTextFile(ItemFile.Path, 1)
strAll = objFile.ReadAll
objFile.Close
Set objFile = Nothing
If Left(strAll, 13) = "<!--INDEX-->" Then
intPageNameStart = Instr(strAll, "<title>") + 7
intPageNameEnd = Instr(strAll, "</title>")
strPageName = Mid(strAll, intPageNameStart, intPageNameEnd - intPageNameStart)
strPageURL = Replace(ItemFile.Path, strWebsiteRoot, "")
strPageURL = Replace(strPageURL, "\", "/")
strPageBody = strAll
objConn.Execute "INSERT INTO tbl_WebsiteIndex (PageName,PageURL,PageBody) VALUES ('" & strPageName & "','" & strPageURL & "','" & Replace(strPageBody, "'", "''") & "')"
End If
End If
Next
I'm not 100% sure what this does as i don't know vb and the guy before me never explained it. I do know that it first looks at every .asp file on the D:\ drive (the server) and if it finds "<!--INDEX-->" it then tries to get the content. This worked fine on the old site but fails on the new. the new site template works like this Code:
<%@ Language="VBScript" %> <% Option Explicit %> <% Dim strPageTitle, strPageSize, strPageMenu strPageTitle = "Page Title" strPageSize = "m" strPageMenu = "search" %> <!-- #include virtual ="/inc/tpl/head.asp" --> CONTENT HERE <!-- #include virtual ="/inc/tpl/foot.asp" --> The problem is the script does not phase the asp files so it does not look for <!--INDEX--> in the included header file. Google, Yahoo and MSN find the files ok but my own search dies. Now what I was thinking is if I put a ASP comment around the content like this Code:
<!-- #include virtual ="/inc/tpl/head.asp" --> <%'startIndex%> CONTENT HERE <%'endIndex%> <!-- #include virtual ="/inc/tpl/foot.asp" --> so it only indexs what's between startIndex and endIndex but I have no idea how to code this. also my title is defined in Code:
strPageTitle = "Page Title" so the part of my script that look for <title> would need to be changed but again, no idea. Code:
intPageNameStart = Instr(strAll, "<title>") + 7 intPageNameEnd = Instr(strAll, "</title>") I know it's a big problem and sorry about the long post but it's so important for me so any help would be very very much appreciated. |
|
#2
|
|||
|
|||
|
ok, no replys after a week?
anyway maybe someone who cares could still help. this part of the code: Code:
intPageNameStart = Instr(strAll, "<title>") + 7 intPageNameEnd = Instr(strAll, "</title>") strPageName = Mid(strAll, intPageNameStart, intPageNameEnd - intPageNameStart) gets all the content between <title></title> so is there a way instead of title I could make it look between Code:
<!-- #include virtual ="/inc/tpl/head.asp" --> and <!-- #include virtual ="/inc/tpl/foot.asp" --> I just don't know how to code it |
|
#3
|
||||
|
||||
|
Hi Chris,
In response to your query, this bit of code: Code:
intPageNameStart = Instr(strAll, "<title>") + 7 intPageNameEnd = Instr(strAll, "</title>") strPageName = Mid(strAll, intPageNameStart, intPageNameEnd - intPageNameStart) just finds the position at which the search string starts. intPageNameStart is a variable which will store the start position, InStr is a VB function which identifies the starting position of a specified string, strAll is the string to be searched, "<title>" is the search criteria. The + 7 is necessary because the instr function returns the starting position of the string which is 7 chars long so we must point at the end of the string. To change this code you just have to change the search criteria: Code:
'find end of first string intPageNameStart = Instr(strAll, "<!-- #include virtual ="/inc/tpl/head.asp" -->") + 45 'this 45 may be wrong, count the no of characters in the string 'find beginning of second string intPageNameEnd = Instr(strAll, "<!-- #include virtual ="/inc/tpl/foot.asp" -->") 'everything in-between these points is what you need so it is saved in the variable called strPageName strPageName = Mid(strAll, intPageNameStart, intPageNameEnd - intPageNameStart) Hope this makes sense, Regards Bob |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Search index |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|