<% Option Explicit %> <% '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Main ' ' Purpose: ' ' Directs the action. ' ' Revisions: ' ' [TDB 28.Mar.2002] Made dynamic from flat mock-up. ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub Main() Dim strLatestLink, strArchiveLink Call WriteStandardHeader("Book Reviews - bluebones.net", _ "Book Reviews of fiction, programming and popular science books", _ "book review, favourite books, books for programmers") ' Response.Write "

Book Reviews

" ' strLatestLink = "Latest Book Reviews" strArchiveLink = "" & _ "All Book Reviews" If Request.QueryString("action") = "view_review" Then Response.Write GetReviewByID(Request.QueryString("review_id")) Response.Write "

" & strArchiveLink & "

" ElseIf Request.QueryString("action") = "archive" Then Response.Write GetArchive() Else Response.Write GetArchive() ' Else ' Response.Write GetLatestReviews(5) ' Response.Write "

" & strArchiveLink & "

" End If Call WriteStandardFooter() End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' GetLatestReviews ' ' Purpose: ' ' Gets the HTML of the latest reviews (number as specified). ' ' Parameters: ' ' dtmLatest - No reviews more recent than this date. ' intReviews - The number of reviews to get. ' ' Returns: ' ' String of HTML of reviews. ' ' Revisions: ' ' [TDB 28.Mar.2002] Code written. ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function GetLatestReviews(intReviews) Dim strSQL, objRS, strRev strSQL = "SELECT TOP " & intReviews & _ " review_id, title, author, rating, review_date, " & _ "uk_url, us_url, review " & _ "FROM book_reviews ORDER BY review_date DESC" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open strSQL, BLUEBONES_CONN_STRING_ If (objRS.EOF) Then GetLatestReviews = "

No book reviews

" Exit Function End If Do Until objRS.EOF strRev = strRev & GetReview(objRS("review_id"), _ objRS("title"), objRS("author"), objRS("rating"), _ objRS("review_date"), objRS("uk_url"), objRS("us_url"), _ objRS("review")) objRS.MoveNext Loop GetLatestReviews = strRev End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' GetReview ' ' Purpose: ' ' Gets the HTML of a book review with the specified details. ' ' Parameters: ' ' intReviewID - Review ID number. ' strTitle - Title of book. ' strAuthor - Author(s) of book. ' intRating - Rating for book. ' dtmReview - Date of review. ' strUKURL - Amazon UK URL or Empty for no-display. ' strUSURL - Amazon US URL or Empty for no-display. ' strReview - Text of the review itself. ' ' Returns: ' ' String of HTML of review. ' ' Revisions: ' ' [TDB 28.Mar.2002] Code written. ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function GetReview(intReviewID, strTitle, strAuthor, intRating, _ dtmReview, strUKURL, strUSURL, strReview) Dim strRev strRev = strRev & "

" & strTitle & "

By " & strAuthor & "

" strRev = strRev & "

" strRev = strRev & GetStars(intRating) & "
" strRev = strRev & GetPermanentLink(GetSelfRefURL(True) & _ "?action=view_review&review_id=" & intReviewID, strTitle) & "  " strRev = strRev & FormatDate_ddMMMyyyy(dtmReview, False) & "
" If (strUKURL <> Empty) Or (strUSURL <> Empty) Then strRev = strRev & "
" If (strUKURL <> Empty) Then strRev = strRev & "Amazon UK" End If If (strUKURL <> Empty) And (strUSURL <> Empty) Then strRev = strRev & " | " End If If (strUSURL <> Empty) Then strRev = strRev & "Amazon US" End If End If strRev = strRev & "

" strRev = strRev & "

" & Replace(strReview, vbNewLine, "
") & _ "

" ' strRev = strRev & "

Comments

" & _ ' vbCrLf GetReview = strRev End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' GetReviewByID ' ' Purpose: ' ' Retrieves the HTML of a review from its ID. ' ' Parameters: ' ' intReviewID - Database key for the review to retrieve. ' ' Returns: ' ' String of HTML of the review. ' ' Revisions: ' ' [TDB 29.Mar.2002] Code written. ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function GetReviewByID(intReviewID) Dim strSQL, objRS strSQL = "SELECT title, author, rating, review_date, " & _ "uk_url, us_url, review FROM book_reviews " & _ "WHERE review_id = " & intReviewID Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open strSQL, BLUEBONES_CONN_STRING_ If objRS.EOF Then GetReviewByID = "

Review does not exist. Sorry

" Exit Function End If GetReviewByID = GetReview(intReviewID, objRS("title"), _ objRS("author"), _ objRS("rating"), objRS("review_date"), objRS("uk_url"), _ objRS("us_url"), objRS("review")) End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' GetArchive ' ' Purpose: ' ' List of links to all book reviews ever. ' ' Returns: ' ' String of HTML links. ' ' Revisions: ' ' [TDB 29.Mar.2002] Code written. ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function GetArchive() Dim strSQL, objRS, strArc, strURL, intCurrentMonth, intCurrentYear strSQL = "SELECT review_id, title, author, review_date, rating, review " & _ "FROM book_reviews ORDER BY review_date DESC, review_id DESC" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open strSQL, BLUEBONES_CONN_STRING_ strArc = "

Book Reviews

" strArc = strArc & "

Books with reviews are links.

" Do Until objRS.EOF If DatePart("m", objRS("review_date")) <> intCurrentMonth _ Or DatePart("yyyy", objRS("review_date")) <> intCurrentYear Then intCurrentMonth = DatePart("m", objRS("review_date")) intCurrentYear = DatePart("yyyy", objRS("review_date")) strArc = strArc & "

" & MonthName(intCurrentMonth) & " " & _ intCurrentYear & "

" End If strURL = LCase(GetSelfRefURL(True)) & _ "?action=view_review&review_id=" & objRS("review_id") strArc = strArc & "

" If (objRS("review") <> "") Then strArc = strArc & GetPermanentLink(strURL, objRS("title")) & _ " " End If strArc = strArc & objRS("title") If (objRS("review") <> "") Then strArc = strArc & "" End If strArc = strArc & " - " & objRS("author") & " - " & _ FormatDate_ddMMMyyyy(objRS("review_date"), False) If objRS("rating") <> 0 Then strArc = strArc & " - (" & objRS("rating") & "/5)" End If strArc = strArc & "" & vbCrLf objRS.MoveNext 'If Not objRS.EOF Then strArc = strArc & "

" 'End If Loop objRS.Close Set objRS = Nothing GetArchive = strArc End Function Call Main() %>