Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 8th, 2006, 04:27 AM
chris9902 chris9902 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 2 chris9902 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 58 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old March 20th, 2006, 05:01 AM
chris9902 chris9902 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 2 chris9902 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 58 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old March 20th, 2006, 06:43 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,783 sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 10 h 52 m 17 sec
Reputation Power: 1142
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Search index


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT