 |
|
 |
<%
Dim URL 'The URL used to request the page
Dim ID 'The ID from tblMeta that contains the key to open everything, bitch.
Dim Name 'Name of the location from DB
Dim Street 'Street Address
Dim City 'City Address
Dim Zip 'Zip Code
Dim Phone 'Phone Number
Dim Fax 'Fax number
Dim Brief 'Brief description
Dim Rating 'Bender rating
Dim Cost 'Cost code
Dim Conn 'Connection variable to the db
Dim TheSet 'Recordset for the returned goodies
Dim SQL 'SQL Statement
Dim LocSet 'The set used to connect and get location goodies
Dim Count 'Dummy thing used for loops
Dim Path 'Holds the path to the article to display
Dim DB_Art 'Yes if there was something in the DB, no if otherwise.
Dim ArtSetCount 'Recordset used to grab articles for this location
Dim ArtSet
Dim Title 'Holds the title of the article returned
Dim Article 'The filename of the article to pull in
DB_Art = "No"
%>
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub PrintArticle(Article)
Dim fileSys, incFile, line, Path
Set fileSys = Server.CreateObject("Scripting.FileSystemObject")
path = Server.MapPath("/articles") & "\"
Set incFile = fileSys.OpenTextFile(Path & Article, 1, 0)
line = incFile.ReadAll
response.write(line)
incFile.close
Set FileSys = Nothing
End Sub 'Printarticle
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ListArticles (Short) 'Lists the articles for this page. Displays the first available according to ArticleStart
Dim ArtConn
Set ArtConn = Server.CreateObject("ADODB.Connection")
ArtConn.Open "DSN=acnights"
SQL = "SELECT Count(*) AS Count FROM tblArticle WHERE ArticleURL = "&ID&"AND ArticleStart <= Date() AND ArticleExpire >= Date()"
Set ArtSetCount = Server.CreateObject("ADODB.RecordSet")
ArtSetCount.Open SQL, ArtConn
SQL = "SELECT * FROM tblArticle WHERE ArticleURL = " & ID & "AND ArticleStart <= Date() AND ArticleExpire >= Date() ORDER BY ArticleStart ASC"
Set ArtSet = Server.CreateObject("ADODB.RecordSet")
ArtSet.Open SQL, ArtConn
If Lcase(Short) = "no" Then
'''''''''''''''
'the error is in here somewhere dammit!!!
'''''''''''''
If ArtSetCount("Count") = 1 Then 'Show the only article instead of description from tblLocation
If Not (ArtSet.BOF And ArtSet.EOF) Then 'The SQL executed OK
If ArtSet("ArticleName") <> "" Then
Article = ArtSet("ArticleName")
Else
Article = "article_error.htm"
End If
Else 'An error occurred in the SQL statement
article = "article_error.htm"
End If
PrintArticle article
End If 'ArtsetCount = 1
'''''''''' check your if..end if's
If ArtSetCount("Count") > 1 Then 'Multiple articles exist for this location
'Print the first article and link to the rest.
If Not (ArtSet.BOF And ArtSet.EOF) Then 'The SQL executed OK
If ArtSet("ArticleName") <> "" Then
Article = ArtSet("ArticleName")
Else
Article = "article_error.htm"
End If
Else 'An error occurred in the SQL statement
article = "article_error.htm"
End If
PrintArticle article
%>
Related information:
<%
ArtSet.MoveNext
If Not (ArtSet.EOF) Then
Do Until ArtSet.EOF
More = "" & ArtSet("ArticleTitle") & ""
%>
<%=More%>
<%
ArtSet.MoveNext
Loop
End If 'Not ArtSet.EOF
%>
<%
End If 'ArtSetCount > 1
Else 'Just display the titles of the articles and make them links. Short = Yes
If Not (ArtSet.BOF And ArtSet.EOF) Then
Do Until ArtSet.EOF
More = ""
More = More & ArtSet("ArticleTitle") & ""
%>
<%=More%>
<%
ArtSet.MoveNext
Loop
End If
End If 'Check for parameters
End Sub 'ListArticles
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
<%
If Request.QueryString("artID") = "" Then
If Right(Request.ServerVariables("URL"), 1) = "/" Then 'The URL is ending in a backslash (ie, no index was specified)
URL = "http://www.acnights.com" & Lcase(Request.ServerVariables("URL")) & "index.asp"
Else
URL = "http://www.acnights.com" & LCase(Request.ServerVariables("URL"))
End If
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=acnights"
SQL = "SELECT DISTINCTROW ID FROM tblMeta WHERE PageURL LIKE '%" & URL & "%'"
Set TheSet = Server.CreateObject("ADODB.RecordSet")
TheSet.Open SQL, Conn
IF Not (TheSet.BOF And TheSet.EOF) Then 'There's a match in the database!
ID = TheSet("ID")
SQL = "SELECT * FROM tblLocation WHERE LocationURL = " & ID
Set LocSet = Server.CreateObject("ADODB.RecordSet")
LocSet.Open SQL, Conn
If Not (LocSet.BOF And LocSet.EOF) Then 'Woohoo, location write up!
DB_Art = "Yes"
Do Until LocSet.EOF
Name = LocSet("LocationName")
Street = LocSet("LocationStreet")
City = LocSet("LocationCity")
Zip = LocSet("LocationZip")
Phone = LocSet("LocationPhone")
Fax = LocSet("LocationFax")
Brief = LocSet("LocationBrief")
Rating = LocSet("LocationRating")
Cost = LocSet("LocationCost")
Picture = LocSet("LocationPicture")
If Rating <> "" Then
Rating = "http://www.acnights.com/images/"&Rating&"-rate.gif"
End If
If Cost <> "" Then
Cost = "http://www.acnights.com/images/"&Cost&"-cost.gif"
End If
%>
<%
LocSet.MoveNext
Loop
Else 'No match in location table. Search for an article for this place.
ListArticles "no"
End If 'Location writeup
End If 'match in meta db
%>
<%
Set Conn = nothing
Set TheSet = nothing
Set LocSet = nothing
%>
<%
Else 'An article ID was specified in the URL
DB_Art = "Yes"
SQL = "SELECT * FROM tblArticle WHERE ID = " & Request.QueryString("artID")
Set Conn = Server.CreateObject("ADODB.Connection")
Set ArtSet = Server.CreateObject("ADODB.RecordSet")
Conn.Open "acnights"
ArtSet.Open SQL, Conn
If Not (ArtSet.BOF And ArtSet.EOF) Then 'The SQL executed OK
If ArtSet("ArticleName") <> "" Then
Article = ArtSet("ArticleName")
Else
Article = "article_error.htm"
End If
Else 'An error occurred in the SQL statement
article = "article_error.htm"
End If
PrintArticle article
%>
<% End If %>
|
 |
|
 |